:root {
  color-scheme: dark;
  --bg: #08111f;
  --panel: rgba(16, 30, 50, 0.88);
  --panel-strong: #14243a;
  --line: rgba(148, 163, 184, 0.22);
  --text: #f8fafc;
  --muted: #91a4bc;
  --cyan: #51e5d4;
  --cyan-dark: #0f766e;
  --amber: #ffcb69;
  --coral: #ff6b6b;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.38);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", "Noto Sans JP", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100dvh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 16% 12%, rgba(81, 229, 212, 0.13), transparent 34%),
    radial-gradient(circle at 88% 76%, rgba(255, 107, 107, 0.1), transparent 30%),
    linear-gradient(155deg, #08111f 0%, #0c1727 52%, #07101d 100%);
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  content: "";
  opacity: 0.28;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: linear-gradient(to bottom, black, transparent 80%);
}

button {
  min-height: 44px;
  border: 0;
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
}

button:focus-visible {
  outline: 3px solid var(--amber);
  outline-offset: 3px;
}

button:disabled {
  cursor: not-allowed;
  filter: grayscale(0.7);
  opacity: 0.52;
}

[hidden] {
  display: none !important;
}

.app-shell {
  display: grid;
  min-height: 100dvh;
  place-items: center;
  padding: clamp(16px, 4vw, 40px);
}

.screen {
  width: min(100%, 760px);
}

.title-screen {
  position: relative;
  overflow: hidden;
  padding: clamp(34px, 8vw, 72px) clamp(24px, 7vw, 72px);
  border: 1px solid var(--line);
  border-radius: 32px;
  text-align: center;
  background: linear-gradient(145deg, rgba(20, 36, 58, 0.94), rgba(9, 19, 34, 0.95));
  box-shadow: var(--shadow);
}

.title-screen::after {
  position: absolute;
  top: -110px;
  right: -80px;
  width: 280px;
  height: 280px;
  border: 44px solid rgba(81, 229, 212, 0.08);
  border-radius: 50%;
  content: "";
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--cyan);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.18em;
}

h1 {
  position: relative;
  z-index: 1;
  margin: 0;
  font-size: clamp(3.8rem, 14vw, 7.6rem);
  font-weight: 950;
  letter-spacing: -0.075em;
  line-height: 0.76;
}

h1 span {
  color: transparent;
  -webkit-text-stroke: 2px var(--cyan);
}

.title-copy {
  margin: clamp(30px, 6vw, 48px) 0 22px;
  color: #d9e4f0;
  font-size: clamp(1rem, 3vw, 1.25rem);
  line-height: 1.75;
}

.rule-card {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 0 auto 28px;
  flex-wrap: wrap;
}

.rule-card span {
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.035);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.primary-button {
  position: relative;
  z-index: 1;
  width: min(100%, 330px);
  min-height: 58px;
  padding: 14px 24px;
  border-radius: 18px;
  color: #061614;
  background: linear-gradient(135deg, #7df7e9, var(--cyan));
  box-shadow: 0 12px 28px rgba(81, 229, 212, 0.24);
  font-size: 1rem;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.primary-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 15px 34px rgba(81, 229, 212, 0.32);
}

.phase-note {
  margin: 20px 0 0;
  color: #536b84;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.16em;
}

.game-screen {
  padding: clamp(16px, 4vw, 28px);
  border: 1px solid var(--line);
  border-radius: clamp(22px, 5vw, 32px);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.game-header,
.status-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.game-header {
  gap: 16px;
  margin-bottom: 16px;
}

.game-header .eyebrow {
  margin-bottom: 4px;
}

.seed-label {
  max-width: 56vw;
  margin: 0;
  overflow: hidden;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.68rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.text-button {
  flex: 0 0 auto;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.035);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.status-strip {
  padding: 12px clamp(12px, 3vw, 22px);
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(3, 10, 20, 0.46);
}

.status-item {
  display: grid;
  min-width: 72px;
  gap: 4px;
  text-align: center;
}

.status-item span {
  color: var(--muted);
  font-size: clamp(0.64rem, 2.6vw, 0.76rem);
}

.status-item strong {
  font-size: clamp(1.35rem, 5vw, 1.9rem);
  line-height: 1;
}

.ball-wrap {
  display: grid;
  width: clamp(72px, 21vw, 104px);
  aspect-ratio: 1;
  place-items: center;
  margin: -24px 8px -16px;
  border-radius: 50%;
  background: linear-gradient(145deg, #fff7e7, var(--amber));
  box-shadow: 0 12px 34px rgba(255, 203, 105, 0.28);
}

.draw-ball {
  color: #202638;
  font-size: clamp(2rem, 9vw, 3.2rem);
  font-weight: 950;
  letter-spacing: -0.05em;
}

.draw-ball.is-drawing {
  animation: ball-pop 340ms ease-out;
}

.card-panel {
  width: min(100%, 560px);
  margin: clamp(24px, 6vw, 38px) auto 0;
}

.column-labels,
.bingo-card {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
}

.column-labels {
  gap: clamp(4px, 1.5vw, 8px);
  margin-bottom: 8px;
}

.column-labels span {
  color: var(--cyan);
  text-align: center;
  font-size: clamp(0.86rem, 3.5vw, 1.1rem);
  font-weight: 950;
  letter-spacing: 0.12em;
}

.bingo-card {
  overflow: hidden;
  gap: clamp(3px, 1vw, 7px);
  padding: clamp(6px, 1.5vw, 10px);
  border: 1px solid rgba(81, 229, 212, 0.22);
  border-radius: clamp(18px, 4vw, 26px);
  background: rgba(81, 229, 212, 0.055);
}

.bingo-cell {
  position: relative;
  display: grid;
  min-width: 0;
  aspect-ratio: 1;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: clamp(10px, 2.6vw, 16px);
  color: #d8e3ee;
  background: var(--panel-strong);
  font-size: clamp(1rem, 5.4vw, 1.75rem);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.04);
}

.bingo-cell::after {
  position: absolute;
  inset: 15%;
  border: 2px solid transparent;
  border-radius: 50%;
  content: "";
  transform: scale(0.25);
  transition: 180ms ease-out;
}

.bingo-cell.is-marked {
  color: #071a19;
  background: linear-gradient(145deg, #83f5e7, var(--cyan));
  border-color: rgba(255, 255, 255, 0.24);
}

.bingo-cell.is-marked::after {
  border-color: rgba(7, 26, 25, 0.24);
  transform: scale(1);
}

.bingo-cell.is-free {
  color: #271f0d;
  background: linear-gradient(145deg, #ffe3a9, var(--amber));
  font-size: clamp(0.72rem, 3.3vw, 1.05rem);
  letter-spacing: 0.03em;
}

.bingo-cell.is-hit {
  z-index: 1;
  animation: cell-hit 480ms ease-out;
}

.bingo-cell.is-new-line {
  box-shadow: 0 0 0 2px var(--amber), 0 0 26px rgba(255, 203, 105, 0.55);
}

.announcement {
  min-height: 26px;
  margin: 18px 0 10px;
  color: var(--muted);
  text-align: center;
  font-size: clamp(0.82rem, 3vw, 0.95rem);
  font-weight: 800;
}

.announcement.is-bingo {
  color: var(--amber);
}

.game-actions {
  display: flex;
  justify-content: center;
}

.draw-button {
  display: grid;
  width: min(100%, 390px);
  min-height: 72px;
  place-items: center;
  padding: 10px 24px;
  border-radius: 22px;
  color: #081516;
  background: linear-gradient(135deg, #7df7e9, var(--cyan));
  box-shadow: 0 14px 36px rgba(81, 229, 212, 0.26);
}

.draw-button span {
  font-size: 1.45rem;
  font-weight: 950;
  letter-spacing: 0.14em;
  line-height: 1;
}

.draw-button small {
  opacity: 0.58;
  font-size: 0.6rem;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.complete-panel {
  margin-top: 22px;
  padding: 24px;
  border: 1px solid rgba(255, 203, 105, 0.35);
  border-radius: 22px;
  text-align: center;
  background: rgba(255, 203, 105, 0.07);
}

.complete-panel h2 {
  margin: 0 0 8px;
  font-size: clamp(1.5rem, 6vw, 2.1rem);
}

.complete-panel > p:not(.eyebrow) {
  margin: 0 0 20px;
  color: var(--muted);
}

noscript {
  display: block;
  padding: 16px;
  color: white;
  background: #7f1d1d;
  text-align: center;
}

@keyframes ball-pop {
  0% {
    opacity: 0.4;
    transform: scale(0.5) rotate(-12deg);
  }
  70% {
    transform: scale(1.12) rotate(2deg);
  }
  100% {
    opacity: 1;
    transform: scale(1) rotate(0);
  }
}

@keyframes cell-hit {
  0% {
    transform: scale(0.82);
  }
  55% {
    transform: scale(1.08);
  }
  100% {
    transform: scale(1);
  }
}

@media (max-width: 480px) {
  .app-shell {
    align-items: start;
    padding: 10px;
  }

  .title-screen,
  .game-screen {
    border-radius: 22px;
  }

  .title-screen {
    margin-top: max(8px, env(safe-area-inset-top));
  }

  .game-screen {
    padding: 14px 12px calc(16px + env(safe-area-inset-bottom));
  }

  .game-header {
    margin-bottom: 12px;
  }

  .status-strip {
    border-radius: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
