:root {
  --sky: #b9e9ff;
  --grass: #6fc36c;
  --road: #343942;
  --line: #fff2a8;
  --ink: #17212b;
  --muted: #5f6b75;
  --panel: rgba(255, 255, 255, .92);
  --shadow: rgba(34, 46, 55, .24);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  min-height: 100svh;
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: linear-gradient(#b9e9ff 0 58%, #76c96e 58% 100%);
  overflow: hidden;
}

button {
  font: inherit;
  cursor: pointer;
}

.roadBackdrop {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.roadBackdrop::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -18svh;
  width: min(760px, 105vw);
  height: 62svh;
  background: var(--road);
  clip-path: polygon(43% 0, 57% 0, 100% 100%, 0 100%);
  transform: translateX(-50%);
}

.lane {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 12px;
  height: 56svh;
  transform: translateX(-50%);
  background: repeating-linear-gradient(to bottom, var(--line) 0 34px, transparent 34px 68px);
}

.cloud {
  position: absolute;
  width: 150px;
  height: 48px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .8);
  box-shadow: 42px 8px 0 rgba(255, 255, 255, .8), 78px -6px 0 rgba(255, 255, 255, .8);
}

.cloudOne {
  top: 7svh;
  left: 8vw;
}

.cloudTwo {
  top: 15svh;
  right: 18vw;
  transform: scale(.8);
}

main {
  position: relative;
  z-index: 1;
  min-height: 100svh;
  padding: env(safe-area-inset-top) 14px env(safe-area-inset-bottom);
}

.hidden {
  display: none !important;
}

.setupScreen {
  min-height: 100svh;
  display: grid;
  place-items: center;
}

.setupPanel {
  width: min(760px, 100%);
  display: grid;
  grid-template-columns: minmax(240px, .9fr) 1fr;
  gap: 20px;
  align-items: center;
  padding: 18px;
  border: 3px solid rgba(255, 255, 255, .72);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 22px 60px var(--shadow);
}

.brandScene {
  position: relative;
  min-height: 320px;
  border-radius: 8px;
  background: linear-gradient(#9ddfff 0 55%, #75bf67 55% 100%);
  overflow: hidden;
}

.brandScene::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -95px;
  width: 280px;
  height: 320px;
  background: #353a42;
  clip-path: polygon(42% 0, 58% 0, 100% 100%, 0 100%);
  transform: translateX(-50%);
}

.sun {
  position: absolute;
  right: 28px;
  top: 24px;
  width: 54px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #ffd94a;
  box-shadow: 0 0 0 12px rgba(255, 217, 74, .28);
}

.roadLine {
  position: absolute;
  left: 50%;
  bottom: 0;
  z-index: 2;
  width: 10px;
  height: 185px;
  transform: translateX(-50%);
  background: repeating-linear-gradient(to bottom, #fff4a3 0 28px, transparent 28px 56px);
}

.car {
  position: absolute;
  left: 50%;
  bottom: 66px;
  z-index: 3;
  width: 168px;
  height: 94px;
  transform: translateX(-50%);
}

.carTop {
  position: absolute;
  left: 38px;
  top: 0;
  width: 90px;
  height: 50px;
  border-radius: 22px 22px 4px 4px;
  background: #2477d4;
}

.carTop::before,
.carTop::after {
  content: "";
  position: absolute;
  top: 10px;
  width: 28px;
  height: 22px;
  border-radius: 4px;
  background: #d9f6ff;
}

.carTop::before {
  left: 14px;
}

.carTop::after {
  right: 14px;
}

.carBody {
  position: absolute;
  left: 0;
  bottom: 18px;
  width: 168px;
  height: 52px;
  border-radius: 22px 28px 14px 14px;
  background: #e23b3b;
  box-shadow: inset 0 -8px 0 rgba(0, 0, 0, .16);
}

.wheel {
  position: absolute;
  bottom: 0;
  width: 34px;
  aspect-ratio: 1;
  border: 7px solid #171b20;
  border-radius: 50%;
  background: #cdd4dc;
}

.wheel.left {
  left: 24px;
}

.wheel.right {
  right: 24px;
}

.setupCopy,
.colorPickers {
  display: grid;
  gap: 12px;
}

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

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(42px, 8vw, 76px);
  line-height: .88;
}

.setupCopy p:not(.eyebrow),
.winPanel p:not(.eyebrow) {
  color: var(--muted);
  font-size: 18px;
  line-height: 1.4;
}

.playerSetup {
  display: grid;
  gap: 8px;
}

.playerSetup strong {
  font-size: 18px;
}

.swatches {
  display: grid;
  grid-template-columns: repeat(6, 42px);
  gap: 8px;
}

.swatch {
  width: 42px;
  aspect-ratio: 1;
  border: 3px solid #fff;
  border-radius: 50%;
  background: var(--swatch);
  box-shadow: 0 5px 0 rgba(23, 33, 43, .2);
}

.swatch.selected {
  outline: 4px solid #17212b;
  outline-offset: 2px;
}

#startBtn,
.winActions button {
  width: 100%;
  border: 0;
  border-radius: 8px;
  padding: 16px 18px;
  color: #261300;
  background: #ffd94a;
  box-shadow: 0 7px 0 #c28c00;
  font-weight: 950;
}

#startBtn:active,
.winActions button:active,
.smallBtn:active,
.tile:active {
  transform: translateY(3px);
}

.gameScreen {
  min-height: 100svh;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 10px;
  padding: 10px 0;
}

.gameTop {
  display: grid;
  grid-template-columns: 118px 1fr 118px;
  gap: 10px;
  align-items: center;
}

.gameTitle {
  min-width: 0;
  display: grid;
  justify-items: center;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, .88);
  text-align: center;
  box-shadow: 0 8px 24px rgba(34, 46, 55, .13);
}

.gameTitle span {
  font-size: 13px;
  color: #f27622;
  font-weight: 950;
  text-transform: uppercase;
}

.gameTitle strong {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.smallBtn {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: #17212b;
  box-shadow: 0 5px 0 rgba(0, 0, 0, .28);
  font-weight: 850;
}

.boards {
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.boardPanel {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 8px;
  padding: 10px;
  border: 4px solid var(--player);
  border-radius: 8px;
  background: rgba(255, 255, 255, .9);
  box-shadow: 0 12px 30px rgba(34, 46, 55, .18);
}

.boardHeader {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 6px;
  color: var(--player-ink);
  background: var(--player-soft);
}

.boardHeader span,
.boardHeader strong {
  font-weight: 950;
}

.bingoGrid {
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  grid-template-rows: repeat(5, minmax(0, 1fr));
  gap: 6px;
}

.tile {
  min-width: 0;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 5px;
  border: 2px solid rgba(23, 33, 43, .12);
  border-radius: 7px;
  color: #17212b;
  background: #ffffff;
  box-shadow: inset 0 -5px 0 rgba(23, 33, 43, .08);
  text-align: center;
}

.tile span {
  display: block;
  max-width: 100%;
  overflow-wrap: anywhere;
  font-size: 15px;
  font-weight: 850;
  line-height: 1.05;
}

.tile.marked {
  color: var(--player-ink);
  border-color: var(--player);
  background: var(--player-soft);
  box-shadow: inset 0 0 0 999px rgba(255, 255, 255, .02);
}

.tile.marked span::before {
  content: "✓ ";
  color: var(--player);
  font-weight: 1000;
}

.tile.winning {
  color: #fff;
  border-color: #17212b;
  background: var(--player);
  animation: pulseWin .7s ease-in-out infinite alternate;
}

.tile.winning span::before {
  color: #fff;
}

.tile:disabled {
  cursor: default;
}

.winOverlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(18, 27, 36, .52);
}

.winPanel {
  position: relative;
  z-index: 2;
  width: min(420px, 100%);
  display: grid;
  gap: 12px;
  padding: 22px;
  border: 4px solid #fff;
  border-radius: 8px;
  background: #fffef7;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .34);
  text-align: center;
}

.winPanel h2 {
  font-size: clamp(34px, 9vw, 58px);
  line-height: .95;
}

.winActions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.winActions .secondary {
  color: #fff;
  background: #17212b;
  box-shadow: 0 7px 0 rgba(0, 0, 0, .34);
}

.confetti {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.confetti i {
  position: absolute;
  top: -18px;
  width: 10px;
  height: 18px;
  border-radius: 2px;
  animation: confettiFall 2s linear both;
}

@keyframes confettiFall {
  0% {
    opacity: 1;
    translate: 0 0;
  }
  100% {
    opacity: 0;
    translate: 22px 108svh;
    rotate: 520deg;
  }
}

@keyframes pulseWin {
  from {
    transform: scale(1);
  }
  to {
    transform: scale(.96);
  }
}

@media (max-width: 760px) {
  body {
    overflow: auto;
  }

  .setupPanel {
    grid-template-columns: 1fr;
  }

  .brandScene {
    min-height: 220px;
  }

  .gameScreen {
    min-height: 100svh;
  }

  .gameTop {
    grid-template-columns: 86px 1fr 86px;
  }

  .smallBtn {
    font-size: 13px;
  }

  .boards {
    grid-template-columns: 1fr;
  }

  .boardPanel {
    min-height: 540px;
  }
}

@media (orientation: landscape) and (max-height: 540px) {
  body {
    overflow: hidden;
  }

  main {
    height: 100svh;
    min-height: 0;
    padding: env(safe-area-inset-top) 8px env(safe-area-inset-bottom);
  }

  .gameScreen {
    height: 100%;
    min-height: 0;
    gap: 6px;
    padding: 6px 0;
  }

  .setupScreen {
    height: 100%;
    min-height: 0;
  }

  .setupPanel {
    width: min(900px, 100%);
    max-height: calc(100svh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 12px);
    grid-template-columns: minmax(180px, .55fr) 1fr;
    gap: 10px;
    padding: 10px;
    overflow: hidden;
  }

  .brandScene {
    min-height: 0;
    height: 100%;
    max-height: 260px;
  }

  .brandScene::after {
    bottom: -72px;
    width: 210px;
    height: 245px;
  }

  .sun {
    right: 18px;
    top: 18px;
    width: 38px;
    box-shadow: 0 0 0 8px rgba(255, 217, 74, .28);
  }

  .roadLine {
    height: 135px;
  }

  .car {
    bottom: 42px;
    width: 126px;
    height: 70px;
  }

  .carTop {
    left: 29px;
    width: 68px;
    height: 38px;
    border-radius: 16px 16px 4px 4px;
  }

  .carTop::before,
  .carTop::after {
    top: 8px;
    width: 20px;
    height: 16px;
  }

  .carTop::before {
    left: 10px;
  }

  .carTop::after {
    right: 10px;
  }

  .carBody {
    bottom: 13px;
    width: 126px;
    height: 40px;
    border-radius: 16px 20px 11px 11px;
  }

  .wheel {
    width: 26px;
    border-width: 5px;
  }

  .wheel.left {
    left: 18px;
  }

  .wheel.right {
    right: 18px;
  }

  .setupCopy,
  .colorPickers {
    gap: 7px;
  }

  .setupCopy p:not(.eyebrow) {
    font-size: 13px;
    line-height: 1.25;
  }

  h1 {
    font-size: clamp(32px, 8vw, 48px);
  }

  .playerSetup {
    gap: 5px;
  }

  .playerSetup strong {
    font-size: 14px;
  }

  .swatches {
    grid-template-columns: repeat(6, 30px);
    gap: 6px;
  }

  .swatch {
    width: 30px;
    border-width: 2px;
    box-shadow: 0 3px 0 rgba(23, 33, 43, .2);
  }

  .swatch.selected {
    outline-width: 3px;
  }

  #startBtn {
    padding: 10px 14px;
    box-shadow: 0 4px 0 #c28c00;
  }

  .gameTop {
    grid-template-columns: 94px 1fr 94px;
    gap: 6px;
  }

  .smallBtn {
    min-height: 38px;
    font-size: 12px;
  }

  .gameTitle {
    padding: 5px 8px;
  }

  .gameTitle span {
    display: none;
  }

  .gameTitle strong {
    font-size: 13px;
  }

  .boards {
    min-height: 0;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 6px;
  }

  .boardPanel {
    min-height: 0;
    padding: 6px;
    gap: 5px;
    border-width: 3px;
  }

  .boardHeader {
    padding: 5px 8px;
    font-size: 13px;
  }

  .bingoGrid {
    gap: 4px;
  }

  .tile {
    padding: 3px;
    border-width: 1px;
    box-shadow: none;
  }

  .tile span {
    font-size: 12px;
    line-height: 1;
  }
}
