:root {
  --ink: #102a43;
  --ink-soft: #486581;
  --cream: #fff9ee;
  --paper: #fffdf8;
  --coral: #ff6b5f;
  --coral-dark: #e34f45;
  --yellow: #ffd166;
  --teal: #20a39e;
  --line: rgba(16, 42, 67, 0.12);
  --shadow: 0 16px 40px rgba(36, 57, 76, 0.13);
  --radius: 22px;
  font-family: ui-rounded, "SF Pro Rounded", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ink);
  background: var(--cream);
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--cream);
}

body {
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  background:
    radial-gradient(circle at 8% 5%, rgba(255, 209, 102, 0.34), transparent 24rem),
    radial-gradient(circle at 94% 18%, rgba(32, 163, 158, 0.13), transparent 23rem),
    var(--cream);
}

button,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  width: min(100%, 760px);
  margin: 0 auto;
  padding: max(22px, env(safe-area-inset-top)) 16px max(28px, env(safe-area-inset-bottom));
}

.hero {
  position: relative;
  overflow: hidden;
  padding: clamp(22px, 6vw, 38px);
  color: white;
  border-radius: 28px;
  background:
    radial-gradient(circle at 84% 0%, rgba(255, 209, 102, 0.33), transparent 28%),
    linear-gradient(135deg, #102a43 0%, #153d5b 58%, #176b75 100%);
  box-shadow: var(--shadow);
}

.hero::after {
  content: "";
  position: absolute;
  right: -34px;
  top: -35px;
  width: 130px;
  aspect-ratio: 1;
  border: 18px solid rgba(255, 255, 255, 0.06);
  border-radius: 50%;
}

.hero__eyebrow {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 12px;
  color: #cfeff1;
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.11em;
}

.hero__eyebrow span {
  color: var(--yellow);
}

.hero__title-row {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

h1 {
  margin: 0;
  font-size: clamp(32px, 9vw, 58px);
  line-height: 0.98;
  letter-spacing: -0.06em;
}

h1 span {
  color: var(--yellow);
}

.hero p {
  margin: 12px 0 0;
  color: rgba(255, 255, 255, 0.76);
  font-size: 14px;
  line-height: 1.6;
}

.hero__badge {
  display: grid;
  flex: 0 0 auto;
  width: 60px;
  aspect-ratio: 1;
  place-items: center;
  color: var(--ink);
  border: 3px solid rgba(255, 255, 255, 0.7);
  border-radius: 18px 18px 18px 5px;
  background: var(--yellow);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.2);
  font-size: 18px;
  font-weight: 900;
  transform: rotate(4deg);
}

.progress-panel {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "copy count"
    "track track";
  gap: 10px 16px;
  align-items: center;
  margin-top: 24px;
  padding: 14px 15px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 17px;
  background: rgba(255, 255, 255, 0.09);
  backdrop-filter: blur(12px);
}

.progress-panel__copy {
  grid-area: copy;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.progress-panel__copy strong {
  font-size: 14px;
}

.progress-panel__copy span {
  color: rgba(255, 255, 255, 0.65);
  font-size: 11px;
}

.progress-panel__count {
  grid-area: count;
  color: var(--yellow);
  font-weight: 850;
  font-variant-numeric: tabular-nums;
}

.progress-panel__track {
  grid-area: track;
  height: 5px;
  overflow: hidden;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.12);
}

.progress-panel__track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--yellow), #ff9f68);
  transition: width 350ms cubic-bezier(0.22, 1, 0.36, 1);
}

.progress-panel.has-bingo {
  border-color: rgba(255, 209, 102, 0.72);
  background:
    radial-gradient(circle at 85% 20%, rgba(255, 209, 102, 0.22), transparent 32%),
    rgba(255, 255, 255, 0.12);
  box-shadow: inset 0 0 0 1px rgba(255, 209, 102, 0.12), 0 8px 24px rgba(0, 0, 0, 0.12);
  animation: bingo-arrival 680ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.progress-panel.has-bingo .progress-panel__copy strong {
  color: var(--yellow);
  font-size: clamp(24px, 7vw, 34px);
  line-height: 1;
  letter-spacing: -0.04em;
}

.progress-panel.has-bingo .progress-panel__copy span {
  margin-top: 5px;
  color: white;
  font-size: 12px;
  font-weight: 750;
}

.progress-panel.has-bingo .progress-panel__count {
  align-self: start;
  padding: 5px 8px;
  color: var(--ink);
  border-radius: 999px;
  background: var(--yellow);
  font-size: 12px;
}

@keyframes bingo-arrival {
  from { opacity: 0.55; transform: scale(0.96); }
}

.board-section {
  margin-top: 30px;
}

.board-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0 2px 12px;
}

.board-heading h2 {
  margin: 0;
  font-size: 17px;
  letter-spacing: -0.02em;
}

.text-button {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 0;
  color: var(--ink-soft);
  border: 0;
  background: none;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.text-button span {
  display: grid;
  width: 19px;
  aspect-ratio: 1;
  place-items: center;
  border: 1.5px solid currentColor;
  border-radius: 50%;
  font-size: 11px;
}

.bingo-board {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(5px, 1.8vw, 11px);
}

.bingo-lines {
  position: absolute;
  z-index: 5;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.bingo-line {
  position: absolute;
  height: clamp(5px, 1.7vw, 8px);
  border-radius: 999px;
  background: linear-gradient(90deg, #fff0a6, var(--yellow), #ffac5e);
  box-shadow:
    0 0 0 2px rgba(16, 42, 67, 0.82),
    0 2px 12px rgba(255, 179, 66, 0.9);
  transform-origin: left center;
  animation: draw-line 620ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.bingo-line::before,
.bingo-line::after {
  content: "";
  position: absolute;
  top: 50%;
  width: clamp(10px, 3.3vw, 16px);
  aspect-ratio: 1;
  border: 2px solid rgba(16, 42, 67, 0.82);
  border-radius: 50%;
  background: var(--yellow);
  transform: translateY(-50%);
  box-shadow: 0 2px 8px rgba(255, 179, 66, 0.7);
}

.bingo-line::before {
  left: 0;
  transform: translate(-25%, -50%);
}

.bingo-line::after {
  right: 0;
  transform: translate(25%, -50%);
}

@keyframes draw-line {
  from { opacity: 0; scale: 0 1; }
}

.bingo-card {
  --card-radius: clamp(11px, 3.5vw, 19px);
  position: relative;
  isolation: isolate;
  display: flex;
  min-width: 0;
  aspect-ratio: 0.82;
  align-items: stretch;
  overflow: hidden;
  padding: 0;
  color: white;
  border: 0;
  border-radius: var(--card-radius);
  background: #214f69;
  box-shadow: 0 7px 18px rgba(28, 52, 70, 0.13);
  text-align: left;
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.bingo-card:active {
  transform: scale(0.97);
}

.bingo-card:focus-visible,
.text-button:focus-visible,
.reset-button:focus-visible,
.primary-button:focus-visible,
.danger-button:focus-visible,
.sheet__close:focus-visible {
  outline: 3px solid var(--yellow);
  outline-offset: 3px;
}

.bingo-card__art {
  position: absolute;
  z-index: -2;
  inset: 0;
  background-image: url("assets/bingo-illustrations.png");
  background-repeat: no-repeat;
  background-position: calc(var(--col) * 33.3333%) calc(var(--row) * 33.3333%);
  background-size: 400% 400%;
  transition: transform 300ms ease, filter 300ms ease;
}

.bingo-card::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0;
  background: linear-gradient(180deg, rgba(5, 21, 34, 0.28) 0%, rgba(5, 21, 34, 0.08) 34%, rgba(5, 21, 34, 0.83) 100%);
}

.bingo-card__content {
  display: flex;
  width: 100%;
  min-width: 0;
  flex-direction: column;
  justify-content: space-between;
  padding: clamp(8px, 2.4vw, 14px);
}

.bingo-card__prompt {
  max-width: 9em;
  font-size: clamp(10px, 2.8vw, 15px);
  font-weight: 850;
  line-height: 1.25;
  letter-spacing: -0.025em;
  text-shadow: 0 1px 7px rgba(0, 0, 0, 0.62);
}

.bingo-card__sign {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 4px;
  color: rgba(255, 255, 255, 0.84);
  font-size: clamp(9px, 2.35vw, 12px);
  font-weight: 750;
}

.bingo-card__sign span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bingo-card__plus {
  display: grid;
  flex: 0 0 auto;
  width: clamp(18px, 5.2vw, 25px);
  aspect-ratio: 1;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  font-size: 15px;
  line-height: 1;
  backdrop-filter: blur(7px);
}

.bingo-card.is-filled {
  box-shadow: 0 8px 19px rgba(32, 163, 158, 0.2);
}

.bingo-card.is-filled .bingo-card__art {
  filter: saturate(0.9) brightness(0.83);
}

.bingo-card.is-filled .bingo-card__sign {
  width: 100%;
  padding: 5px 7px;
  color: var(--ink);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.91);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.15);
}

.bingo-card.is-filled .bingo-card__plus {
  color: white;
  border: 0;
  background: var(--teal);
  font-size: 0;
}

.bingo-card.is-filled .bingo-card__plus::after {
  content: "✓";
  font-size: 13px;
  font-weight: 900;
}

.bingo-card.is-bingo {
  box-shadow: 0 0 0 3px var(--yellow), 0 10px 22px rgba(255, 160, 40, 0.28);
  animation: bingo-pulse 700ms ease both;
}

@keyframes bingo-pulse {
  50% { transform: translateY(-4px) rotate(-1deg); }
}

.page-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 22px 3px 0;
}

.save-note {
  display: flex;
  align-items: center;
  gap: 7px;
  color: #718096;
  font-size: 11px;
  line-height: 1.5;
}

.save-note__dot {
  flex: 0 0 auto;
  width: 7px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 0 0 4px rgba(32, 163, 158, 0.12);
}

.reset-button {
  flex: 0 0 auto;
  padding: 7px 0;
  color: #8c6470;
  border: 0;
  background: none;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.sheet {
  width: min(calc(100% - 28px), 430px);
  max-height: calc(100dvh - 30px);
  overflow-y: auto;
  padding: 0;
  color: var(--ink);
  border: 0;
  border-radius: 26px;
  background: var(--paper);
  box-shadow: 0 28px 80px rgba(10, 30, 44, 0.32);
}

.sheet::backdrop {
  background: rgba(7, 25, 39, 0.66);
  backdrop-filter: blur(7px);
}

.sheet form,
.rules-sheet > div {
  position: relative;
  padding: 22px;
}

.sheet__close {
  position: absolute;
  z-index: 2;
  top: 13px;
  right: 13px;
  display: grid;
  width: 34px;
  aspect-ratio: 1;
  place-items: center;
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 50%;
  background: rgba(16, 42, 67, 0.35);
  font-size: 23px;
  line-height: 1;
  cursor: pointer;
  backdrop-filter: blur(10px);
}

.sheet__art {
  height: 176px;
  margin: -22px -22px 20px;
  border-radius: 26px 26px 16px 16px;
  background-image:
    linear-gradient(180deg, transparent 45%, rgba(16, 42, 67, 0.4)),
    url("assets/bingo-illustrations.png");
  background-repeat: no-repeat;
  background-position: center, calc(var(--col) * 33.3333%) calc(var(--row) * 33.3333%);
  background-size: 100% 100%, 400% 400%;
}

.sheet__label {
  margin: 0 0 5px;
  color: var(--coral-dark);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.sheet h2 {
  margin: 0 40px 22px 0;
  font-size: 25px;
  line-height: 1.25;
  letter-spacing: -0.035em;
}

.sheet label {
  display: block;
  margin-bottom: 7px;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 750;
}

.sheet input {
  width: 100%;
  min-height: 51px;
  padding: 0 15px;
  color: var(--ink);
  border: 1.5px solid #cbd5df;
  border-radius: 14px;
  background: white;
  outline: none;
  font-size: 16px;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.sheet input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 4px rgba(32, 163, 158, 0.13);
}

.sheet input[aria-invalid="true"] {
  border-color: var(--coral);
}

.field-error {
  min-height: 18px;
  margin: 6px 2px 7px;
  color: #c73b34;
  font-size: 12px;
}

.primary-button,
.danger-button {
  width: 100%;
  min-height: 50px;
  border-radius: 14px;
  font-weight: 850;
  cursor: pointer;
}

.primary-button {
  color: white;
  border: 0;
  background: var(--coral);
  box-shadow: 0 9px 20px rgba(227, 79, 69, 0.2);
}

.primary-button:active {
  background: var(--coral-dark);
}

.danger-button {
  min-height: 42px;
  margin-top: 7px;
  color: #95616c;
  border: 0;
  background: transparent;
  font-size: 13px;
}

.danger-button[hidden] {
  display: none;
}

.rules-sheet .sheet__close {
  color: var(--ink);
  border-color: var(--line);
  background: rgba(16, 42, 67, 0.06);
}

.rules-sheet h2 {
  margin-bottom: 22px;
}

.rules-sheet ol {
  display: grid;
  gap: 14px;
  margin: 0 0 18px;
  padding: 0;
  list-style: none;
}

.rules-sheet li {
  display: grid;
  grid-template-columns: 37px 1fr;
  gap: 12px;
  align-items: center;
}

.rules-sheet li strong {
  display: grid;
  width: 37px;
  aspect-ratio: 1;
  place-items: center;
  color: white;
  border-radius: 12px;
  background: var(--teal);
}

.rules-sheet li span {
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.55;
}

.rules-sheet__tip {
  margin: 0 0 20px;
  padding: 13px 14px;
  color: #6f5520;
  border: 1px solid rgba(224, 166, 40, 0.24);
  border-radius: 13px;
  background: #fff6d8;
  font-size: 12px;
  line-height: 1.65;
}

.toast {
  position: fixed;
  z-index: 20;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  max-width: calc(100% - 32px);
  padding: 10px 15px;
  color: white;
  border-radius: 999px;
  background: rgba(16, 42, 67, 0.94);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.22);
  font-size: 13px;
  font-weight: 750;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 16px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (hover: hover) {
  .bingo-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 13px 25px rgba(28, 52, 70, 0.2);
  }

  .bingo-card:hover .bingo-card__art {
    transform: scale(1.04);
  }
}

@media (max-width: 390px) {
  .app-shell {
    padding-right: 11px;
    padding-left: 11px;
  }

  .hero {
    padding: 20px 18px;
    border-radius: 24px;
  }

  .hero p {
    margin-top: 8px;
    font-size: 12px;
  }

  .hero__badge {
    width: 53px;
  }

  .progress-panel {
    margin-top: 18px;
    padding: 12px 13px;
  }

  .board-section {
    margin-top: 22px;
  }

  .bingo-card__content {
    padding: 8px 7px;
  }

  .bingo-card__plus {
    width: 19px;
  }
}

@media (min-width: 640px) {
  .bingo-card {
    aspect-ratio: 0.93;
  }

  .bingo-card__prompt {
    font-size: 15px;
  }
}

@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;
  }
}
