:root {
  color-scheme: light;
  --ink: #123f46;
  --ink-soft: #4b696d;
  --paper: #fff9e8;
  --cream: #fff1c8;
  --sky: #83dfe2;
  --mint: #aee5d3;
  --yellow: #f9d96f;
  --coral: #ffb39f;
  --blue: #b8d5f5;
  --white: #fffef8;
  --shadow: 0 7px 0 rgba(18, 63, 70, 0.14);
  --soft-shadow: 0 12px 34px rgba(18, 63, 70, 0.13);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--paper);
  -webkit-text-size-adjust: 100%;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 94%, rgba(249, 217, 111, 0.32), transparent 26rem),
    var(--paper);
  font-family: ui-rounded, "Arial Rounded MT Bold", "Trebuchet MS", system-ui, sans-serif;
  font-weight: 700;
  overscroll-behavior-y: none;
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
  font: inherit;
  touch-action: manipulation;
}

button:focus-visible {
  outline: 5px solid #fff;
  outline-offset: 3px;
  box-shadow: 0 0 0 9px var(--ink);
}

.page {
  min-height: 100vh;
}

.hero {
  position: relative;
  min-height: 178px;
  padding: max(18px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) 20px max(24px, env(safe-area-inset-left));
  overflow: hidden;
  color: #fff;
  background: linear-gradient(115deg, #0f5960, #19767c);
  border-bottom: 5px solid var(--ink);
}

.hero::after {
  position: absolute;
  inset: auto 0 0;
  height: 18px;
  content: "";
  background: linear-gradient(90deg, #e2d598 0 45%, #d6c37e 45% 55%, #e2d598 55%);
  opacity: 0.8;
}

.hero-content {
  position: relative;
  z-index: 2;
  width: min(1220px, 100%);
  margin: 0 auto;
}

.route-badge {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  gap: 8px;
  margin-bottom: 13px;
  padding: 5px 12px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.9);
  border: 2px solid rgba(255, 255, 255, 0.7);
  border-radius: 999px;
  box-shadow: 0 5px 0 rgba(7, 46, 51, 0.18);
  backdrop-filter: blur(8px);
}

.flag,
.route-car {
  font-size: 21px;
  line-height: 1;
}

.route-car {
  transform: scaleX(-1);
}

.route-dots {
  width: clamp(16px, 4vw, 46px);
  border-top: 3px dotted #6f8e91;
}

.title-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
}

.eyebrow {
  margin: 0 0 5px;
  color: #c9f1e6;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1 {
  max-width: 800px;
  margin: 0;
  font-size: clamp(32px, 5vw, 58px);
  font-weight: 900;
  letter-spacing: -0.035em;
  line-height: 0.94;
  text-wrap: balance;
}

h1 .game-name {
  color: var(--yellow);
}

.player-title {
  font-size: 0.62em;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.hero-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 3px;
}

.icon-button,
.new-card-button {
  border: 0;
  box-shadow: 0 6px 0 rgba(5, 43, 47, 0.28);
}

.icon-button {
  width: 54px;
  height: 54px;
  flex: 0 0 54px;
  padding: 0;
  font-size: 25px;
  background: #fff;
  border-radius: 50%;
}

.icon-button:active,
.new-card-button:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 rgba(5, 43, 47, 0.28);
}

.new-card-button {
  display: inline-flex;
  align-items: center;
  min-height: 54px;
  gap: 8px;
  padding: 0 20px;
  color: var(--ink);
  background: var(--yellow);
  border-radius: 999px;
  white-space: nowrap;
}

.new-card-button > span:first-child {
  font-size: 24px;
}

.scenery {
  position: absolute;
  inset: 0;
  opacity: 0.5;
  pointer-events: none;
}

.sun {
  position: absolute;
  top: 22px;
  right: 23%;
  width: 64px;
  height: 64px;
  background: var(--yellow);
  border-radius: 50%;
  box-shadow: 0 0 0 12px rgba(249, 217, 111, 0.12);
}

.cloud {
  position: absolute;
  width: 90px;
  height: 25px;
  background: rgba(255, 255, 255, 0.58);
  border-radius: 99px;
}

.cloud::before,
.cloud::after {
  position: absolute;
  bottom: 0;
  content: "";
  background: inherit;
  border-radius: 50%;
}

.cloud::before {
  left: 13px;
  width: 40px;
  height: 40px;
}

.cloud::after {
  right: 12px;
  width: 50px;
  height: 50px;
}

.cloud-one {
  top: 50px;
  left: 55%;
}

.cloud-two {
  top: 31px;
  right: 4%;
  transform: scale(0.72);
}

.mountain {
  position: absolute;
  bottom: -58px;
  width: 190px;
  height: 190px;
  background: #9ec9b1;
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}

.mountain::after {
  position: absolute;
  top: 0;
  left: 50%;
  width: 80px;
  height: 60px;
  content: "";
  background: rgba(255, 255, 255, 0.86);
  clip-path: polygon(50% 0, 100% 100%, 70% 79%, 53% 100%, 37% 78%, 0 100%);
  transform: translateX(-50%);
}

.mountain-one {
  right: 12%;
}

.mountain-two {
  right: -2%;
  bottom: -83px;
  transform: scale(1.25);
}

.road {
  position: absolute;
  right: 0;
  bottom: -68px;
  width: 42%;
  height: 140px;
  background: #405258;
  transform: skewX(-25deg);
}

.road::after {
  position: absolute;
  top: 50%;
  left: 8%;
  right: 8%;
  content: "";
  border-top: 5px dashed rgba(255, 255, 255, 0.8);
}

.car {
  position: absolute;
  right: 14%;
  bottom: 10px;
  z-index: 1;
  font-size: 42px;
  transform: scaleX(-1);
}

.game {
  width: min(1240px, 100%);
  margin: 0 auto;
  padding: 18px max(24px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
}

.game-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 26px;
  margin-bottom: 16px;
}

.progress-copy {
  width: min(500px, 50%);
}

.progress-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 8px;
  font-size: 16px;
}

.bingo-count {
  color: var(--ink-soft);
  font-size: 14px;
  white-space: nowrap;
}

.progress-track {
  height: 14px;
  overflow: hidden;
  background: #e1dbc8;
  border: 2px solid var(--ink);
  border-radius: 99px;
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, #f2c948, #ff916f);
  border-radius: inherit;
  transition: width 350ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.instruction {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin: 0;
  padding: 11px 17px;
  color: var(--ink);
  background: #fff;
  border: 2px solid #e6dfca;
  border-radius: 999px;
  box-shadow: 0 4px 0 #e5ddc7;
  font-size: clamp(14px, 2vw, 17px);
}

.instruction span {
  font-size: 22px;
}

.board {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(8px, 1.4vw, 16px);
}

.card {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: clamp(105px, 13vh, 148px);
  place-items: center;
  padding: clamp(8px, 1.4vw, 15px) 8px 10px;
  overflow: hidden;
  background: var(--white);
  border: 3px solid var(--ink);
  border-radius: clamp(18px, 2.5vw, 28px);
  box-shadow: var(--shadow);
  cursor: pointer;
  isolation: isolate;
  user-select: none;
  -webkit-user-select: none;
  transition: transform 140ms ease, box-shadow 140ms ease, filter 180ms ease;
}

.card::before {
  position: absolute;
  inset: 0 0 auto;
  z-index: -1;
  height: 38%;
  content: "";
  background: rgba(255, 255, 255, 0.28);
}

.card.tone-coral {
  background: var(--coral);
}

.card.tone-mint {
  background: var(--mint);
}

.card.tone-yellow {
  background: var(--yellow);
}

.card.tone-blue {
  background: var(--blue);
}

.card:not(.found):hover {
  transform: translateY(-2px);
  box-shadow: 0 9px 0 rgba(18, 63, 70, 0.14);
}

.card:active {
  transform: translateY(5px) scale(0.985);
  box-shadow: 0 2px 0 rgba(18, 63, 70, 0.18);
}

.card-icon {
  display: block;
  align-self: end;
  font-family: "Apple Color Emoji", "Segoe UI Emoji", sans-serif;
  font-size: clamp(42px, 6.6vw, 73px);
  font-weight: 400;
  filter: drop-shadow(0 4px 0 rgba(18, 63, 70, 0.1));
  line-height: 1;
  transform-origin: center;
}

.card-label {
  display: block;
  align-self: start;
  max-width: 100%;
  margin-top: 7px;
  overflow: hidden;
  font-size: clamp(13px, 1.9vw, 19px);
  font-weight: 900;
  letter-spacing: -0.02em;
  line-height: 1.05;
  text-align: center;
  text-overflow: ellipsis;
}

.check-sticker {
  position: absolute;
  top: 7px;
  right: 7px;
  display: grid;
  width: clamp(33px, 4vw, 44px);
  height: clamp(33px, 4vw, 44px);
  place-items: center;
  color: #fff;
  background: var(--ink);
  border: 3px solid #fff;
  border-radius: 50%;
  box-shadow: 0 4px 0 rgba(18, 63, 70, 0.2);
  font-size: 22px;
  opacity: 0;
  transform: rotate(-18deg) scale(0.4);
  transition: opacity 180ms ease, transform 280ms cubic-bezier(0.2, 1.4, 0.3, 1);
}

.card.found {
  box-shadow: inset 0 0 0 6px rgba(255, 255, 255, 0.74), 0 4px 0 rgba(18, 63, 70, 0.12);
  filter: saturate(0.73);
  transform: translateY(3px);
}

.card.found .card-icon {
  animation: found-bounce 420ms cubic-bezier(0.2, 1.4, 0.3, 1);
}

.card.found .check-sticker {
  opacity: 1;
  transform: rotate(-8deg) scale(1);
}

.game-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 18px 4px 0;
  color: var(--ink-soft);
  font-size: 13px;
  text-align: center;
}

.game-footer p {
  margin: 0;
}

.game-footer span {
  margin-right: 4px;
  color: #26816f;
}

.connection-status {
  color: #765f25;
}

.modal {
  width: min(500px, calc(100% - 32px));
  padding: 30px;
  color: var(--ink);
  background: var(--white);
  border: 4px solid var(--ink);
  border-radius: 32px;
  box-shadow: 0 16px 0 rgba(18, 63, 70, 0.18), 0 30px 80px rgba(6, 42, 46, 0.25);
  text-align: center;
}

.modal::backdrop {
  background: rgba(8, 41, 45, 0.65);
  backdrop-filter: blur(6px);
}

.modal[open] {
  animation: modal-pop 280ms cubic-bezier(0.2, 1.25, 0.3, 1);
}

.modal-art,
.celebration-art {
  display: grid;
  width: 102px;
  height: 102px;
  place-items: center;
  margin: -7px auto 15px;
  background: var(--yellow);
  border: 4px solid var(--ink);
  border-radius: 30px;
  box-shadow: 0 7px 0 rgba(18, 63, 70, 0.14);
  font-size: 58px;
  transform: rotate(-4deg);
}

.modal h2 {
  margin: 0 0 10px;
  font-size: clamp(30px, 6vw, 44px);
  letter-spacing: -0.04em;
  line-height: 1;
}

.modal p {
  margin: 0 auto 24px;
  color: var(--ink-soft);
  font-family: ui-rounded, "Arial Rounded MT Bold", "Trebuchet MS", system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.45;
}

.name-fields {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  margin: 2px 0 18px;
  text-align: left;
}

.name-fields label {
  font-size: 15px;
}

.name-fields input {
  width: 100%;
  min-height: 52px;
  padding: 10px 14px;
  color: var(--ink);
  background: #fff;
  border: 3px solid #cad7d5;
  border-radius: 16px;
  font: inherit;
  font-size: 18px;
}

.name-fields input:focus {
  outline: 4px solid var(--yellow);
  border-color: var(--ink);
}

.modal .form-error {
  margin: -4px auto 17px;
  padding: 9px 12px;
  color: #8f2f20;
  background: #ffe0d8;
  border-radius: 12px;
  font-size: 14px;
}

.modal-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
}

.button-primary,
.button-secondary {
  min-height: 54px;
  padding: 0 20px;
  border: 3px solid var(--ink);
  border-radius: 999px;
  box-shadow: 0 5px 0 rgba(18, 63, 70, 0.18);
}

.button-primary {
  color: #fff;
  background: var(--ink);
}

.button-secondary {
  background: var(--cream);
}

.button-primary:active,
.button-secondary:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 rgba(18, 63, 70, 0.18);
}

.celebration-modal {
  overflow: visible;
  background:
    radial-gradient(circle at 10% 12%, var(--yellow) 0 5px, transparent 6px),
    radial-gradient(circle at 88% 19%, var(--coral) 0 7px, transparent 8px),
    radial-gradient(circle at 19% 84%, var(--mint) 0 7px, transparent 8px),
    radial-gradient(circle at 82% 83%, var(--blue) 0 6px, transparent 7px),
    var(--white);
  background-size: 68px 68px, 78px 78px, 84px 84px, 72px 72px;
}

.celebration-kicker {
  margin-bottom: 8px !important;
  color: #d75939 !important;
  font-size: 13px !important;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.celebration-art {
  background: var(--coral);
  animation: trophy-wiggle 700ms ease-in-out 200ms both;
}

.confetti {
  position: fixed;
  inset: 0;
  z-index: 20;
  overflow: hidden;
  pointer-events: none;
}

.confetti-piece {
  position: absolute;
  top: -30px;
  width: 13px;
  height: 21px;
  background: var(--piece-color);
  border-radius: 3px;
  animation: confetti-fall var(--fall-time) linear forwards;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: max(20px, env(safe-area-inset-bottom));
  z-index: 30;
  max-width: calc(100% - 32px);
  padding: 12px 18px;
  color: #fff;
  background: var(--ink);
  border-radius: 999px;
  box-shadow: var(--soft-shadow);
  opacity: 0;
  pointer-events: none;
  text-align: center;
  transform: translate(-50%, 16px);
  transition: opacity 180ms ease, transform 180ms ease;
}

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

noscript {
  position: fixed;
  inset: 20px;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 30px;
  color: #fff;
  background: var(--ink);
  border-radius: 30px;
  text-align: center;
}

@keyframes found-bounce {
  0% { transform: scale(1); }
  45% { transform: scale(1.2) rotate(-5deg); }
  100% { transform: scale(1); }
}

@keyframes modal-pop {
  from { opacity: 0; transform: scale(0.8) translateY(30px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes trophy-wiggle {
  0% { transform: rotate(-4deg) scale(0.5); }
  45% { transform: rotate(8deg) scale(1.14); }
  70% { transform: rotate(-8deg) scale(1); }
  100% { transform: rotate(-4deg) scale(1); }
}

@keyframes confetti-fall {
  0% { transform: translate3d(0, -10vh, 0) rotate(0); }
  100% { transform: translate3d(var(--drift), 112vh, 0) rotate(var(--spin)); }
}

@media (max-width: 760px) {
  .hero {
    min-height: 168px;
    padding-inline: 16px;
  }

  .title-row {
    align-items: flex-end;
    gap: 12px;
  }

  .eyebrow {
    font-size: 10px;
  }

  h1 {
    font-size: clamp(30px, 8vw, 45px);
  }

  .new-card-button {
    width: 54px;
    padding: 0;
    justify-content: center;
  }

  .new-card-button > span:last-child {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
  }

  .game {
    padding: 14px 12px max(20px, env(safe-area-inset-bottom));
  }

  .game-toolbar {
    align-items: stretch;
    gap: 10px;
    margin-bottom: 12px;
  }

  .progress-copy {
    width: 56%;
  }

  .progress-heading {
    gap: 5px;
    font-size: 13px;
  }

  .bingo-count {
    font-size: 11px;
  }

  .instruction {
    justify-content: center;
    padding: 8px 11px;
    font-size: 12px;
    text-align: center;
  }

  .board {
    gap: 7px;
  }

  .card {
    min-height: clamp(94px, 12.5vh, 124px);
    border-width: 2px;
    border-radius: 18px;
    box-shadow: 0 5px 0 rgba(18, 63, 70, 0.14);
  }

  .card-icon {
    font-size: clamp(35px, 10vw, 58px);
  }

  .card-label {
    margin-top: 5px;
    font-size: clamp(10px, 2.8vw, 15px);
  }

  .check-sticker {
    top: 3px;
    right: 3px;
    width: 31px;
    height: 31px;
    border-width: 2px;
    font-size: 16px;
  }

  .game-footer {
    flex-direction: column;
    gap: 4px;
    padding-top: 13px;
  }
}

@media (max-height: 820px) and (min-width: 800px) {
  .hero {
    min-height: 148px;
    padding-top: 13px;
    padding-bottom: 14px;
  }

  .route-badge {
    min-height: 32px;
    margin-bottom: 8px;
    padding-block: 3px;
  }

  .flag,
  .route-car {
    font-size: 17px;
  }

  .eyebrow {
    margin-bottom: 2px;
    font-size: 11px;
  }

  h1 {
    font-size: 45px;
  }

  .icon-button {
    width: 48px;
    height: 48px;
    flex-basis: 48px;
  }

  .new-card-button {
    min-height: 48px;
  }

  .game {
    padding-top: 11px;
  }

  .game-toolbar {
    margin-bottom: 10px;
  }

  .progress-heading {
    margin-bottom: 5px;
  }

  .instruction {
    padding-block: 8px;
  }

  .board {
    gap: 9px 14px;
  }

  .card {
    min-height: 0;
    height: 109px;
    padding: 7px 7px 8px;
    border-radius: 22px;
  }

  .card-icon {
    font-size: 52px;
  }

  .card-label {
    margin-top: 4px;
    font-size: 16px;
  }

  .game-footer {
    padding-top: 11px;
  }
}

@media (max-width: 480px) {
  .hero-actions {
    gap: 7px;
  }

  .icon-button,
  .new-card-button {
    width: 46px;
    height: 46px;
    min-height: 46px;
    flex-basis: 46px;
  }

  .route-badge {
    min-height: 32px;
    margin-bottom: 10px;
  }

  .flag,
  .route-car {
    font-size: 17px;
  }

  .game-toolbar {
    display: block;
  }

  .progress-copy {
    width: 100%;
    margin-bottom: 9px;
  }

  .instruction {
    width: 100%;
  }

  .modal {
    padding: 25px 18px;
    border-radius: 26px;
  }

  .modal-actions {
    flex-direction: column;
  }

  .name-fields {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .name-fields label:not(:first-child) {
    margin-top: 7px;
  }

  .button-primary,
  .button-secondary {
    width: 100%;
  }
}

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