:root {
  --cream: #f3eadc;
  --cream-deep: #e7d8c0;
  --ink: #1b2430;
  --ink-soft: #3c4654;
  --red: #c43b3b;
  --red-deep: #9c2c2c;
  --snow: #fffaf3;
  --pine: #2c4638;
  --gold: #c9a227;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bot: env(safe-area-inset-bottom, 0px);
}

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

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #1b2430;
  color: var(--ink);
  font-family: "Avenir Next", "Segoe UI", "Trebuchet MS", system-ui, sans-serif;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  overscroll-behavior: none;
}

#stage {
  position: relative;
  width: min(100vw, 430px);
  height: 100dvh;
  max-height: 932px;
  margin: 0 auto;
  overflow: hidden;
  background: var(--cream);
  box-shadow: 0 0 0 1px rgba(27, 36, 48, 0.12);
}

canvas#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.screen {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  padding: calc(18px + var(--safe-top)) 20px calc(18px + var(--safe-bot));
}

.screen.hidden,
#hud.hidden {
  display: none;
}

#boot {
  align-items: center;
  justify-content: center;
  text-align: center;
  background: var(--cream);
  z-index: 6;
}

.boot-logo {
  width: min(72vw, 260px);
  margin: 12px 0 0;
}

.boot-sub {
  margin: 8px 0 0;
  color: var(--ink-soft);
}

#title {
  justify-content: flex-start;
  gap: 8px;
  padding-top: calc(10px + var(--safe-top));
  padding-bottom: calc(10px + var(--safe-bot));
  background: linear-gradient(
    180deg,
    rgba(243, 234, 220, 0.96) 0%,
    rgba(243, 234, 220, 0.88) 42%,
    rgba(243, 234, 220, 0.9) 100%
  );
}

.title-top {
  flex: 0 0 auto;
  text-align: center;
  padding-top: 2px;
}

.eyebrow {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.edition {
  display: block;
  width: max-content;
  margin: 6px auto 0;
  padding: 3px 10px;
  border-radius: 99px;
  background: #c9a227;
  color: #1a1a1a;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  border: 2px solid #1a1a1a;
}

.flag-bar {
  width: 72px;
  height: 8px;
  margin: 6px auto 8px;
  border-radius: 99px;
  background: linear-gradient(#c43b3b 0 33%, #fffaf3 33% 66%, #c43b3b 66%);
  box-shadow: 0 1px 0 rgba(27, 36, 48, 0.08);
}

h1.wordmark {
  margin: 0;
  line-height: 0;
}

.wordmark-logo {
  display: block;
  width: min(100%, 280px);
  max-width: 100%;
  height: auto;
  margin: 0 auto;
}

#title .wordmark-logo {
  width: min(68%, 216px);
}

.wordmark-ski {
  margin: 4px 0 0;
  font-size: clamp(22px, 6vw, 30px);
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--red);
}

.tag {
  margin: 6px 0 0;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.3;
}

.cast-wrap {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  min-height: 0;
  overflow: visible;
}

.cast-label {
  flex: 0 0 auto;
  margin: 0 0 8px;
  text-align: center;
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.cast {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  justify-items: center;
  align-content: start;
  gap: 6px 8px;
  width: min(100%, 268px);
  margin: 0 auto;
}

.cast-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  width: 100%;
  max-width: 80px;
  min-width: 0;
  padding: 2px 2px 4px;
  border: 2px solid transparent;
  border-radius: 18px;
  cursor: pointer;
  background: transparent;
}

.cast-card.picked {
  border-color: var(--red);
  background: rgba(196, 59, 59, 0.1);
}

.cast-card.picked .cast-name {
  color: var(--red);
  font-weight: 700;
}

.cast-bust-wrap {
  position: relative;
  width: 100%;
  max-width: 68px;
}

.cast-bust {
  width: 100%;
  aspect-ratio: 1;
  max-width: 68px;
  border-radius: 16px;
  background: var(--snow);
  box-shadow: 0 8px 18px rgba(27, 36, 48, 0.08);
  object-fit: contain;
  padding: 2px;
  display: block;
}

.cast-card.locked {
  opacity: 1;
}

.cast-card.locked .cast-bust {
  filter: grayscale(1) brightness(0.82) contrast(0.92);
  opacity: 0.78;
}

.cast-card.locked .cast-bust-wrap::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 18px;
  background: rgba(227, 232, 236, 0.38);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
  pointer-events: none;
}

.lock-badge {
  position: absolute;
  right: 2px;
  bottom: 2px;
  z-index: 1;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #1b2430;
  color: #f3eadc;
  font-size: 10px;
  display: grid;
  place-items: center;
  box-shadow: 0 2px 0 rgba(27, 36, 48, 0.25);
}

.cast-name {
  font-size: 8px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.cast-soon {
  font-size: 7px;
  letter-spacing: 0.08em;
  line-height: 1.15;
  text-transform: uppercase;
  color: #7b8490;
  margin-top: 0;
  text-align: center;
  max-width: 100%;
}

.toast {
  position: absolute;
  left: 18px;
  right: 18px;
  top: 46%;
  z-index: 12;
  margin: 0 auto;
  max-width: 340px;
  padding: 14px 18px;
  border-radius: 18px;
  background: #1b2430;
  color: #fffaf3;
  text-align: center;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.01em;
  line-height: 1.3;
  pointer-events: none;
  box-shadow: 0 14px 32px rgba(27, 36, 48, 0.4), 0 0 0 3px #c9a227;
  animation: toast-pop 0.22s ease-out;
}

.toast.hidden {
  display: none;
}

@keyframes toast-pop {
  from {
    transform: scale(0.92);
    opacity: 0;
  }
  to {
    transform: none;
    opacity: 1;
  }
}

.kult {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(18px + var(--safe-top));
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
  animation: kult-pop 0.45s ease-out;
}

.kult.hidden {
  display: none;
}

.kult img {
  width: min(72%, 280px);
  height: auto;
  filter: drop-shadow(0 8px 18px rgba(27, 36, 48, 0.35));
}

.kult p {
  margin: 6px 0 0;
  font-size: clamp(28px, 9vw, 42px);
  font-weight: 900;
  letter-spacing: 0.12em;
  color: #fffaf3;
  text-shadow: 0 3px 0 #9c2c2c, 0 8px 18px rgba(27, 36, 48, 0.35);
}

@keyframes kult-pop {
  from {
    transform: translateY(-12px) scale(0.92);
    opacity: 0;
  }
  to {
    transform: none;
    opacity: 1;
  }
}

#end.cold {
  background: linear-gradient(
    180deg,
    rgba(36, 58, 78, 0.78) 0%,
    rgba(210, 222, 230, 0.88) 100%
  );
}

#end.cold h2,
#end.cold .end-name,
#end.cold .one-liner {
  color: #1b2430;
}

.title-bottom {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  padding-top: 4px;
  padding-bottom: 2px;
}

#btn-surprise {
  width: min(100%, 320px);
  height: 44px;
  font-size: 14px;
}

.btn-main,
.btn-ghost,
.btn-text {
  font: inherit;
  border: 0;
  cursor: pointer;
}

.btn-main {
  width: min(100%, 320px);
  height: 56px;
  border-radius: 999px;
  background: var(--red);
  color: var(--snow);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  box-shadow: 0 10px 0 var(--red-deep);
  transform: translateY(-2px);
}

.btn-main:active {
  transform: translateY(4px);
  box-shadow: 0 4px 0 var(--red-deep);
}

.btn-ghost {
  width: min(100%, 320px);
  height: 44px;
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 2px solid rgba(27, 36, 48, 0.18);
}

.btn-text {
  background: none;
  color: var(--ink-soft);
  font-size: 13px;
  padding: 8px;
}

.hint {
  margin: 0;
  text-align: center;
  font-size: 12px;
  color: var(--ink-soft);
}

@media (max-height: 760px) {
  #title .wordmark-logo {
    width: min(58%, 176px);
  }

  .wordmark-ski {
    font-size: 20px;
    margin-top: 2px;
  }

  .edition {
    margin-top: 4px;
    font-size: 9px;
    padding: 2px 8px;
  }

  .tag {
    font-size: 12px;
    margin-top: 4px;
  }

  .cast {
    width: min(100%, 240px);
    gap: 4px 6px;
  }

  .cast-bust-wrap,
  .cast-bust {
    max-width: 58px;
  }

  .btn-main {
    height: 50px;
  }
}

#reveal {
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
  background: rgba(243, 234, 220, 0.88);
}

.reveal-card {
  width: min(72vw, 260px);
  aspect-ratio: 1;
  border-radius: 36px;
  background: var(--snow);
  box-shadow: 0 18px 40px rgba(27, 36, 48, 0.12);
  display: grid;
  place-items: center;
  overflow: hidden;
}

#reveal-img {
  width: 92%;
  height: 92%;
  object-fit: contain;
}

#reveal h2,
#end h2 {
  margin: 4px 0 0;
  font-size: 36px;
  letter-spacing: -0.03em;
}

.one-liner {
  margin: 0;
  max-width: 280px;
  color: var(--ink-soft);
  font-size: 15px;
}

#hud {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  padding: calc(10px + var(--safe-top)) 14px 0;
}

.hud-bar {
  height: 6px;
  border-radius: 99px;
  background: rgba(27, 36, 48, 0.12);
  overflow: hidden;
}

#progress {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--gold), var(--red));
}

.piste-badge {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
  padding: 7px 12px;
  border-radius: 14px;
  background: rgba(27, 36, 48, 0.86);
  color: #fffaf3;
  box-shadow: 0 8px 18px rgba(27, 36, 48, 0.18);
}

.piste-badge strong {
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1.2;
}

.piste-badge span {
  flex: 0 0 auto;
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #e8b84a;
}

.piste-card {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  background: rgba(27, 36, 48, 0.32);
  animation: kult-pop 0.35s ease-out;
  padding: 24px;
  text-align: center;
}

.piste-card.hidden {
  display: none;
}

.piste-card-kicker {
  margin: 0 0 8px;
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: #e8b84a;
}

.piste-card h2 {
  margin: 0;
  font-size: clamp(28px, 8vw, 40px);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #fffaf3;
  text-shadow: 0 3px 0 #9c2c2c, 0 10px 22px rgba(27, 36, 48, 0.4);
}

.piste-card-tag {
  margin: 10px 0 0;
  font-size: 16px;
  color: #fffaf3;
}

.hud-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
}

.hud-k {
  display: block;
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.hud-score strong {
  font-size: 28px;
  line-height: 1;
}

.hud-peep {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 250, 243, 0.78);
  border-radius: 999px;
  padding: 4px 10px 4px 4px;
}

#hud-bust {
  width: 36px;
  height: 36px;
  object-fit: contain;
  background: var(--snow);
  border-radius: 50%;
}

#hud-name {
  font-size: 12px;
  font-weight: 700;
}

.hud-chips {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  min-height: 28px;
}

.hud-chip {
  display: none;
  align-items: center;
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
  box-shadow: 0 2px 0 rgba(27, 36, 48, 0.12);
}

.hud-chip.on {
  display: inline-flex;
}

.hud-chip.pils {
  background: #e8b84a;
  color: #3a2408;
}

.hud-chip.boost {
  background: #7ee0f2;
  color: #08303a;
}

.hud-chip.float {
  background: #9fd0ea;
  color: #16324a;
}

.hud-chip.buzz {
  background: #e07a3a;
  color: #3a1408;
}

.hud-chip.jump {
  background: #7cde6a;
  color: #14320c;
}

.hud-chip.slow {
  background: #b59bff;
  color: #1e1040;
}

.hud-chip.sauna {
  background: #f4a27a;
  color: #4a1c10;
}

.hud-chip.water {
  background: #8ec8e8;
  color: #123046;
}

.buzz-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.buzz-wrap.hidden {
  display: none;
}

.buzz-track {
  flex: 1;
  height: 7px;
  border-radius: 99px;
  background: rgba(27, 36, 48, 0.12);
  overflow: hidden;
}

#buzz-bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #e8b84a, #e07a3a, #c43b3b);
}

#hud.wobbly {
  filter: blur(0.6px) contrast(1.05);
}

#hud.wobbly-hard {
  filter: blur(1.4px) saturate(1.25);
}

#slot {
  align-items: center;
  justify-content: center;
  gap: 0;
  text-align: center;
  background: #f5ede0;
  padding: calc(10px + var(--safe-top)) 12px calc(12px + var(--safe-bot));
}

.slot-from.hidden {
  display: none;
}

.slot-machine {
  position: relative;
  width: min(100%, 348px);
  margin: 0 22px 0 0;
  padding: 10px 10px 12px;
  border-radius: 12px;
  background:
    radial-gradient(circle at 11px 8px, #f2c4b4 3.4px, #d94a4a 4.1px, #1a1a1a 4.7px, transparent 5px),
    repeating-linear-gradient(
      180deg,
      #e15454 0px,
      #c43b3b 13px,
      #9c2c2c 14px,
      #9c2c2c 16px
    );
  background-size: 22px 16px, 100% 100%;
  border: 4px solid #1a1a1a;
  outline: 5px solid #c9a227;
  outline-offset: 0;
  box-shadow:
    0 0 0 8px #1a1a1a,
    0 10px 0 #7a1e1e,
    0 18px 24px rgba(26, 26, 26, 0.28);
}

.slot-studs {
  height: 14px;
  margin: 0 2px 8px;
  background-image: radial-gradient(
    circle at 50% 42%,
    #f6d0c0 0 3.6px,
    #c43b3b 4.2px 5.6px,
    #1a1a1a 6.1px 6.7px,
    transparent 6.9px
  );
  background-size: 20px 14px;
  background-repeat: repeat-x;
  background-position: 4px 0;
}

.slot-studs-bot {
  margin: 10px 2px 0;
}

.slot-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 4px 8px;
}

.slot-bust {
  width: 54px;
  height: 54px;
  flex: 0 0 54px;
  object-fit: contain;
  background: #f5ede0;
  border: 3px solid #1a1a1a;
  border-radius: 10px;
  box-shadow: 3px 3px 0 #1a1a1a;
}

.slot-head-copy {
  flex: 1;
  min-width: 0;
}

.slot-logo {
  display: block;
  width: min(100%, 168px);
  height: auto;
  margin: 0 auto;
  filter: drop-shadow(0 2px 0 #1a1a1a);
}

.slot-kicker {
  display: inline-block;
  margin: 6px 0 0;
  padding: 3px 10px;
  border-radius: 6px;
  background: #c9a227;
  color: #1a1a1a;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  border: 2px solid #1a1a1a;
}

.slot-windows {
  display: flex;
  gap: 5px;
  padding: 8px;
  border-radius: 10px;
  background: linear-gradient(180deg, #e8c85a 0%, #c9a227 55%, #8a6a12 100%);
  border: 4px solid #1a1a1a;
  box-shadow:
    inset 0 0 0 2px #f5ede0,
    0 4px 0 #8a6a12;
}

.slot-reel {
  flex: 1;
  width: 0;
  height: 86px;
  display: block;
  background: #f5ede0;
  border-radius: 8px;
  border: 3px solid #1a1a1a;
}

.slot-arm {
  position: absolute;
  right: -28px;
  top: 86px;
  width: 48px;
  height: 150px;
  padding: 0;
  border: 0;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.arm-shaft {
  width: 12px;
  height: 78px;
  border-radius: 6px;
  background: linear-gradient(90deg, #e8c85a, #c9a227 55%, #8a6a12);
  border: 2px solid #1a1a1a;
  transform-origin: 50% 8px;
  transition: transform 0.18s ease;
}

.arm-knob {
  width: 30px;
  height: 30px;
  margin-top: -8px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #e85d5d, #c43b3b 55%, #9c2c2c);
  border: 3px solid #1a1a1a;
  box-shadow: 0 3px 0 #1a1a1a;
}

.arm-label {
  margin-top: 8px;
  width: 28px;
  padding: 6px 0;
  border-radius: 6px;
  background: #c43b3b;
  color: #f5ede0;
  border: 2px solid #1a1a1a;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.04em;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
}

.slot-arm.pulled .arm-shaft {
  transform: rotate(28deg) scaleY(0.72);
}

.slot-arm.pulled .arm-knob {
  transform: translate(10px, 8px);
}

.slot-arm:disabled {
  opacity: 0.9;
}

.slot-plaque {
  margin: 8px 6px 0;
  padding: 6px 8px;
  min-height: 0;
  border-radius: 8px;
  background: #2a2218;
  color: #f5ede0;
  border: 3px solid #c9a227;
  box-shadow: 3px 3px 0 #1a1a1a;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.01em;
  line-height: 1.22;
}

.slot-quotes {
  margin: 2px 0 0;
}

.slot-plaque-b {
  background: #3a2c1c;
  border-color: #e8c85a;
  margin-top: 6px;
}

.slot-award {
  margin: 6px 8px 0;
  min-height: 16px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #f5ede0;
  text-shadow: 0 1px 0 #1a1a1a;
}

.slot-dropin {
  width: calc(100% - 20px);
  height: 48px;
  margin: 8px 10px 2px;
  border-radius: 8px;
  background: #c43b3b;
  color: #f5ede0;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border: 3px solid #1a1a1a;
  box-shadow: 0 5px 0 #1a1a1a;
}

.slot-dropin:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #1a1a1a;
}

.slot-dropin.hidden {
  display: none;
}

@media (max-height: 760px) {
  .slot-machine {
    padding: 6px 8px 8px;
  }

  .slot-bust {
    width: 44px;
    height: 44px;
    flex-basis: 44px;
  }

  .slot-reel {
    height: 62px;
  }

  .slot-arm {
    height: 118px;
    top: 64px;
  }

  .arm-shaft {
    height: 52px;
  }

  .slot-plaque {
    font-size: 10px;
    margin-top: 6px;
    padding: 5px 7px;
  }

  .slot-plaque-b {
    margin-top: 5px;
  }

  .slot-dropin {
    height: 40px;
    margin-top: 6px;
  }
}

.hud-msg {
  position: absolute;
  left: 0;
  right: 0;
  top: 46%;
  margin: 0;
  text-align: center;
  font-size: 18px;
  font-weight: 800;
  color: var(--ink);
  text-shadow: 0 1px 0 #fffaf3;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.hud-msg.show {
  opacity: 1;
}

#end {
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  background: rgba(243, 234, 220, 0.92);
}

.end-bust {
  width: 120px;
  height: 120px;
  object-fit: contain;
  background: var(--snow);
  border-radius: 28px;
}

.end-name {
  margin: 0;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 12px;
}

.end-score {
  margin: 8px 0 0;
  font-size: 16px;
}

.end-score strong {
  font-size: 40px;
  display: block;
  line-height: 1;
}

.end-stats {
  margin: 0 0 8px;
  color: var(--ink-soft);
  font-size: 13px;
}

.end-actions {
  width: min(100%, 320px);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.end-actions .btn-main.hidden,
.end-actions .btn-ghost.hidden {
  display: none;
}

@media (min-width: 500px) {
  body {
    display: grid;
    place-items: center;
  }

  #stage {
    height: min(100dvh, 844px);
    border-radius: 28px;
  }
}
