:root {
  color-scheme: light dark;
  --bg: #fff;
  --fg: #1a1a1a;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121212;
    --fg: #f0f0f0;
  }
}
body {
  font-family: -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  max-width: 380px;
  margin: 24px auto 40px;
  padding: 0 16px;
  text-align: center;
  background: var(--bg);
  color: var(--fg);
}
h1 {
  font-size: 1.4rem;
  margin-bottom: 4px;
}
.weather-banner {
  display: inline-block;
  margin: 0 auto 18px;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(105, 200, 242, 0.15);
  color: #4aa8d8;
  font-size: 0.85rem;
  font-weight: 600;
}
.form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
  margin: 24px 0;
}
.form[hidden] {
  display: none;
}
.form label {
  font-size: 0.85rem;
  font-weight: bold;
}
.form input {
  font-size: 1rem;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid #999;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip-group[hidden] {
  display: none;
}
.opt-chip {
  font-size: 0.85rem;
  font-weight: normal;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid #999;
  background: transparent;
  color: inherit;
}
.opt-chip.active {
  background: #333;
  color: #fff;
  border-color: #333;
}
.opt-chip.opt-custom {
  border-style: dashed;
}
.custom-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}
.custom-wrap[hidden] {
  display: none;
}
.custom-wrap input {
  flex: 1;
}
.link-back {
  flex-shrink: 0;
  font-size: 0.8rem;
  font-weight: normal;
  padding: 4px 6px;
  border: none;
  background: none;
  color: #4aa8d8;
  white-space: nowrap;
}

.mixer {
  position: relative;
  height: 210px;
  margin: 20px auto 6px;
  max-width: 340px;
  perspective: 700px;
}
.mixer[hidden] {
  display: none;
}
.chip {
  position: absolute;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 1.2rem;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  opacity: 0;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: inset -3px -4px 6px rgba(0, 0, 0, 0.25), 0 6px 10px rgba(0, 0, 0, 0.3);
}
.chip-weather { left: 0; top: 4px; background: radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0) 50%), #69c8f2; }
.chip-mood { right: 0; top: 4px; background: radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0) 50%), #ff7272; }
.chip-situation { left: 0; bottom: 6px; background: radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0) 50%), #b0d840; }
.chip-spell { right: 0; bottom: 6px; background: radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0) 50%), #c084fc; }
.stage-caption {
  position: absolute;
  left: 0;
  right: 0;
  top: 66%;
  font-size: 1.05rem;
  font-weight: 800;
  min-height: 1.4em;
  padding: 0 8px;
}
.stage-caption span {
  background: linear-gradient(90deg, #ffd66b, #ff9d3d);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.core {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 26px;
  height: 26px;
  margin: -13px 0 0 -13px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff8e1, #ffd66b 40%, #ff7272 85%);
  box-shadow: inset -4px -5px 8px rgba(153, 40, 0, 0.35), inset 3px 3px 6px rgba(255, 255, 255, 0.5), 0 0 18px rgba(255, 140, 0, 0.55);
}
.spark {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: radial-gradient(circle, #fff6d0, #ff9d3d 60%, transparent 100%);
  box-shadow: 0 0 8px rgba(255, 160, 40, 0.9);
  pointer-events: none;
}
.shockwave {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid rgba(255, 200, 90, 0.9);
  pointer-events: none;
}

.balls {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 20px 0;
  flex-wrap: wrap;
  min-height: 44px;
}
.ball {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 0.95rem;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6), 0 0 2px rgba(0, 0, 0, 0.5);
  background:
    radial-gradient(circle at 32% 26%, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0) 45%),
    var(--ball-color, #ccc);
  box-shadow: inset -4px -5px 9px rgba(0, 0, 0, 0.3), 0 4px 7px rgba(0, 0, 0, 0.35);
}
.ball.settled {
  animation: pop 0.4s cubic-bezier(.3, 1.6, .4, 1);
}
@keyframes pop {
  0% { transform: scale(1.3) rotateX(15deg); }
  55% { transform: scale(0.9) rotateX(-6deg); }
  100% { transform: scale(1) rotateX(0deg); }
}
.c-yellow { --ball-color: #fbc400; }
.c-blue   { --ball-color: #69c8f2; }
.c-red    { --ball-color: #ff7272; }
.c-gray   { --ball-color: #aaaaaa; }
.c-green  { --ball-color: #b0d840; }

button {
  font-size: 1rem;
  padding: 10px 20px;
  border-radius: 8px;
  border: none;
  background: #333;
  color: #fff;
  cursor: pointer;
}
button:disabled {
  opacity: 0.5;
  cursor: default;
}
.reason {
  margin-top: 8px;
  margin-bottom: 4px;
  font-size: 1.15rem;
  font-weight: 800;
  line-height: 1.4;
  min-height: 1.6em;
}
.reason span {
  background: linear-gradient(90deg, #ff7272, #fbc400);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.reason.flash {
  animation: flashPulse 0.6s ease-out;
}
@keyframes flashPulse {
  0% { filter: drop-shadow(0 0 0 rgba(255, 140, 0, 0)); }
  35% { filter: drop-shadow(0 0 14px rgba(255, 140, 0, 0.85)); }
  100% { filter: drop-shadow(0 0 0 rgba(255, 140, 0, 0)); }
}
.error {
  margin-top: 16px;
  font-size: 0.9rem;
  color: #d33;
  min-height: 1.2em;
}
.disclaimer {
  margin-top: 32px;
  font-size: 0.8rem;
  color: #888;
}
.nav-link {
  text-align: center;
  font-size: 0.85rem;
}
.nav-link a {
  color: #4aa8d8;
  text-decoration: none;
}
.nav-link a:hover {
  text-decoration: underline;
}
.nav-link strong {
  font-weight: 700;
}
.subtitle {
  font-size: 0.85rem;
  color: #888;
  margin-top: -4px;
}
.card {
  background: rgba(130, 130, 130, 0.08);
  border-radius: 14px;
  padding: 18px 16px;
  margin: 18px 0;
  text-align: left;
}
.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}
.tab-btn {
  flex: 1;
  background: transparent;
  border: 1px solid #999;
  color: inherit;
  padding: 8px 0;
  border-radius: 999px;
  font-size: 0.9rem;
}
.tab-btn.active {
  background: #333;
  color: #fff;
  border-color: #333;
}
.field-hint {
  font-size: 0.75rem;
  color: #888;
}
.welcome-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  font-size: 0.95rem;
}
.logout-btn {
  background: transparent;
  border: 1px solid rgba(150, 150, 150, 0.6);
  border-radius: 999px;
  color: inherit;
  font-size: 0.78rem;
  padding: 3px 12px;
}
.empty-hint {
  font-size: 0.85rem;
  color: #888;
}
.ticket-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ticket-card {
  background: rgba(130, 130, 130, 0.08);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ticket-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  font-weight: 700;
}
.ticket-balls {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.ball.small {
  width: 30px;
  height: 30px;
  font-size: 0.72rem;
}
.status-badge {
  font-size: 0.75rem;
  padding: 3px 10px;
  border-radius: 999px;
  font-weight: 700;
}
.status-pending {
  background: rgba(150, 150, 150, 0.2);
  color: #888;
}
.status-win {
  background: rgba(176, 216, 64, 0.25);
  color: #6a8f18;
}
.status-lose {
  background: rgba(255, 114, 114, 0.15);
  color: #c0392b;
}
.form-actions {
  display: flex;
  gap: 8px;
}
.ticket-card-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.ticket-action-btn {
  background: transparent;
  border: 1px solid rgba(150, 150, 150, 0.5);
  color: inherit;
  font-size: 0.78rem;
  padding: 3px 12px;
  border-radius: 999px;
}
.ticket-delete-btn {
  border-color: rgba(255, 114, 114, 0.6);
  color: #c0392b;
}
.ticket-list-actions {
  display: flex;
  justify-content: flex-end;
  min-height: 1.6em;
}
.ticket-select-checkbox {
  width: 16px;
  height: 16px;
  margin-right: 4px;
}
.bonus-plus {
  display: flex;
  align-items: center;
  font-weight: 700;
  font-size: 1.1rem;
  color: #888;
}
.bonus-ball {
  outline: 2px dashed rgba(150, 150, 150, 0.6);
  outline-offset: 2px;
}
.section-title {
  font-size: 0.85rem;
  font-weight: bold;
  margin: 18px 0 8px;
}
.scan-btn {
  width: 100%;
  margin-bottom: 12px;
  background: transparent;
  border: 1px dashed #999;
  color: inherit;
  border-radius: 10px;
}
#scanner-video {
  width: 100%;
  border-radius: 12px;
  background: #000;
}
.scanner-actions {
  display: flex;
  justify-content: center;
  margin-top: 10px;
}
.scan-game-option {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}
.scan-game-option input[type="checkbox"] {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
}
