:root {
  color-scheme: dark;
  --night: #0c1927;
  --ink: #131e2c;
  --snow: #fff3db;
  --gold: #f6ca78;
  --muted: #c2cbd2;
  --green: #214c40;
  --red: #682a39;
  font:
    16px system-ui,
    sans-serif;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: radial-gradient(ellipse at 50% 20%, #193446, var(--night) 65%);
  color: var(--snow);
  min-height: 100vh;
}
[hidden] {
  display: none !important;
}
button {
  font: inherit;
  color: inherit;
  background: #162b3a;
  border: 1px solid #e9c78058;
  border-radius: 0.75rem;
  min-height: 44px;
  padding: 0.5rem 0.9rem;
  cursor: pointer;
  touch-action: manipulation;
}
button:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 4px;
}
button:disabled {
  opacity: 0.45;
  cursor: default;
}
.top,
main {
  width: min(1120px, 100% - 2rem);
  margin: auto;
}
.top {
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}
.brand {
  font-family: Georgia, serif;
  font-size: clamp(1rem, 4vw, 1.22rem);
  font-weight: bold;
}
.brand b,
.eyebrow,
.crystals span {
  color: var(--gold);
}
.hero {
  position: relative;
  min-height: 350px;
  display: grid;
  align-items: center;
  overflow: hidden;
  border-radius: 1.5rem;
  border: 1px solid #e9c78060;
  background:
    linear-gradient(90deg, #0a1629f0 0%, #0a1629b0 32%, #0a162918 75%),
    url('./art/winter-village.webp') 63% 49% / cover,
    #142e41;
  box-shadow: 0 14px 42px #030b1580;
}
.hero-copy {
  padding: clamp(1.5rem, 5vw, 4rem);
  max-width: 510px;
  position: relative;
}
.eyebrow {
  letter-spacing: 0.16em;
  font-size: 0.82rem;
  font-weight: 750;
  margin: 0 0 1rem;
}
h1,
h2 {
  font-family: Georgia, serif;
  margin: 0;
}
.hero h1 {
  font-size: clamp(3.1rem, 8vw, 6rem);
  line-height: 0.95;
  letter-spacing: -0.045em;
  text-shadow: 0 4px 20px #060d1a;
}
.hero em {
  color: var(--gold);
  font-weight: normal;
}
.hero-copy > p:last-child {
  max-width: 29ch;
  line-height: 1.5;
  margin: 1.2rem 0 0;
  text-shadow: 0 1px 8px #000;
}
.doors-section {
  padding: 2rem 0 3rem;
}
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.section-heading h2 {
  font-size: clamp(1.5rem, 4vw, 2.1rem);
}
.section-heading p {
  color: var(--muted);
  margin: 0.4rem 0 0;
}
.crystals {
  border: 1px solid #e9c78058;
  border-radius: 99px;
  padding: 0.55rem 0.85rem;
  background: #102433;
}
.doors {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: clamp(0.55rem, 1.6vw, 1rem);
}
.door {
  container-type: inline-size;
  position: relative;
  isolation: isolate;
  perspective: 650px;
  display: block;
  min-width: 0;
  min-height: 110px;
  aspect-ratio: 1/0.95;
  padding: 0;
  background: #0b1522;
  box-shadow: 0 6px 10px #050a1570;
  border-radius: 1rem;
}
.door-face {
  position: absolute;
  inset: 0;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 0.24rem;
  border-radius: inherit;
  background:
    radial-gradient(ellipse at top, #ffffff21, transparent 76%),
    var(--door-color, #274553);
  transform-origin: left;
  transition: transform 0.48s ease;
  border: 1px solid #ffda8a44;
  backface-visibility: hidden;
}
.door-face::before {
  content: '';
  position: absolute;
  inset: 0.35rem;
  border: 1px solid #ffda8a45;
  border-radius: 0.72rem;
  pointer-events: none;
}
.door.opening .door-face {
  transform: rotateY(-102deg);
}
.door-inside {
  color: var(--gold);
  font-size: 2.2rem;
}
.door.available {
  border-color: var(--gold);
}
.door.available .door-face {
  --door-color: #245749;
}
.door.locked {
  cursor: default;
}
.door:nth-child(3n + 2) {
  --door-color: #552b3b;
}
.door:nth-child(3n + 3) {
  --door-color: #1e443e;
}
.door-number {
  font:
    700 clamp(2rem, 39cqw, 3.4rem) / 1 Georgia,
    serif;
}
.door-label {
  font-size: clamp(0.68rem, 11cqw, 0.9rem);
  font-weight: 700;
}
.door-mark {
  color: var(--gold);
  font-size: 0.85rem;
  line-height: 1;
}
.door.christmas {
  grid-column: 1/-1;
  aspect-ratio: auto;
  min-height: 125px;
  border-color: #e2a64c;
}
.christmas .door-face {
  background: radial-gradient(ellipse at top, #fff0b9, #e5ae51 74%, #b6762e);
  color: #36241c;
}
.christmas .door-mark,
.door-status {
  color: #5e3b20;
}
.door-status {
  font-size: 0.78rem;
  font-weight: 650;
}
.snow {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 4;
}
.snow i {
  position: absolute;
  top: -18px;
  left: var(--x);
  width: var(--s);
  height: var(--s);
  border-radius: 50%;
  background: white;
  opacity: 0.54;
  animation: fall var(--d) linear var(--delay) infinite;
}
@keyframes fall {
  to {
    transform: translate(35px, 105vh);
  }
}
dialog {
  max-width: min(430px, calc(100% - 2rem));
  border: 1px solid #efca7e80;
  border-radius: 1.25rem;
  background: #132a39;
  color: var(--snow);
  text-align: center;
  padding: 1.7rem;
}
dialog::backdrop {
  background: #050c19ba;
}
.primary {
  background: var(--gold);
  color: #292019;
  font-weight: 800;
}
#game {
  padding-bottom: 1rem;
  max-width: 900px;
  margin: auto;
}
.game-head {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 0 0 0.65rem;
}
.game-head h1 {
  font-size: clamp(1.8rem, 5vw, 2.7rem);
}
.game-layout {
  display: grid;
  gap: 0.65rem;
  max-width: 545px;
  margin: auto;
}
.playfield {
  position: relative;
  overflow: hidden;
  border: 1px solid #e9c78070;
  border-radius: 1rem;
  background: #243d65;
}
canvas {
  display: block;
  width: 100%;
  height: min(52vh, 570px);
  height: min(52svh, 570px);
  object-fit: contain;
}
.game-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 0.8rem;
  text-align: center;
  background: #081322ab;
}
.game-overlay > div {
  border: 1px solid #e9c78080;
  background: #132b3bef;
  border-radius: 1rem;
  padding: clamp(0.75rem, 3vw, 1.4rem);
  width: min(100%, 360px);
}
.game-overlay h2 {
  color: var(--gold);
}
.game-overlay p {
  margin: 0.5rem 0 0.8rem;
  line-height: 1.35;
}
.game-panel {
  display: grid;
  gap: 0.5rem;
}
.stats {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  text-align: center;
  gap: 0.35rem;
}
.stats div {
  padding: 0.35rem;
  border: 1px solid #e9c78050;
  border-radius: 0.65rem;
  background: #152c3c;
}
.stats dt {
  font-size: 0.85rem;
  color: var(--muted);
}
.stats dd {
  margin: 0;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.steering,
.game-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}
.steering button {
  background: #235143;
  font-size: 1.55rem;
  min-height: 54px;
  user-select: none;
}
.steering button:active {
  background: #407464;
}
@media (max-width: 720px) {
  .doors {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .door {
    min-height: 84px;
  }
}
@media (max-width: 380px) {
  .doors {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
@media (orientation: landscape) and (min-width: 620px) {
  .game-layout {
    max-width: none;
    grid-template-columns: minmax(0, 1fr) minmax(210px, 30%);
    align-items: center;
  }
  .stats {
    grid-template-columns: 1fr 1fr;
  }
  canvas {
    height: min(calc(100svh - 145px), 605px);
    min-height: 215px;
  }
}
@media (orientation: landscape) and (max-height: 500px) {
  body:has(#calendar[hidden]) .top {
    min-height: 49px;
  }
  .game-head {
    margin-bottom: 0.35rem;
  }
  .game-head h1 {
    font-size: 1.6rem;
  }
  canvas {
    height: calc(100svh - 110px);
    min-height: 200px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .snow {
    display: none;
  }
  .door-face {
    transition: none;
  }
}

/* Suppress in-page touch gestures only on the driving screen. */
body:has(#game:not([hidden])) {
  overscroll-behavior: none;
}

.game-layout {
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.drive-powers {
  position: absolute;
  top: 0.35rem;
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 0.7rem);
  pointer-events: none;
  margin: 0;
  padding: 0.4rem 0.6rem;
  border: 1px solid #77eeff80;
  border-radius: 0.65rem;
  background: #132b3b;
  color: #d0faff;
  font-size: 0.85rem;
  text-align: center;
}

.drive-feedback {
  position: absolute;
  top: 12%;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--feedback-color);
  border-radius: 1rem;
  background: #121a35ed;
  color: var(--feedback-color);
  font-weight: 800;
  white-space: nowrap;
  pointer-events: none;
  animation: drive-pop 200ms ease-out;
}

@keyframes drive-pop {
  from {
    opacity: 0.5;
    transform: translate(-50%, 8px) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateX(-50%);
  }
}

@media (prefers-reduced-motion: reduce) {
  .drive-feedback {
    animation: none;
  }
}
