@font-face {
  font-family: "Press Start 2P";
  src: url("../fonts/PressStart2P-Regular.ttf") format("truetype");
  font-display: swap;
}
@font-face {
  font-family: "VT323";
  src: url("../fonts/VT323-Regular.ttf") format("truetype");
  font-display: swap;
}

:root {
  --sky: #0b1a4a;
  --sky-2: #071028;
  --ice: #9ad4ee;
  --ice-2: #d7f3ff;
  --teal: #2ee0c0;
  --teal-dk: #148f86;
  --gold: #ffd23c;
  --orange: #ff8a1a;
  --ink: #071018;
  --panel: #101820;
  --wood: #6a3e1e;
  --wood-2: #3e2210;
  --wood-hi: #a86a36;
  --text: #f3f7fb;
  --muted: #d5e0ea;
  --body: "VT323", "Lucida Console", ui-monospace, monospace;
  --display: "Press Start 2P", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  background: #080c12;
  color: var(--text);
  font-family: var(--body);
  font-size: 18px;
  line-height: 1.4;
}
h1, h2,
.play-cta,
.hud-label,
.hud-value,
.vote-tag,
.board-banner,
.title-wording,
.end-score,
.cta-main,
.coin-label {
  font-family: var(--display);
}
button {
  font-family: inherit;
  cursor: pointer;
  border: 0;
}
img { image-rendering: pixelated; image-rendering: crisp-edges; user-select: none; -webkit-user-drag: none; }
.hidden { display: none !important; }
.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.screen { display: none; min-height: 100dvh; }
.screen.active { display: flex; flex-direction: column; align-items: center; }

/* ----- CRT chrome ----- */
.crt-wrap {
  width: min(960px, 100%);
  padding: 16px 12px 8px;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.crt-bezel {
  width: 100%;
  background:
    linear-gradient(180deg, #8a5a30 0%, var(--wood) 18%, var(--wood-2) 70%, #2a1608 100%);
  border-radius: 28px;
  padding: 22px 22px 28px;
  box-shadow:
    inset 0 2px 0 #c9945a,
    inset 0 -4px 0 #1a0c04,
    0 18px 40px rgba(0,0,0,.55);
}
.crt-screen {
  position: relative;
  background: var(--sky-2);
  border-radius: 16px;
  overflow: hidden;
  min-height: 420px;
  box-shadow:
    inset 0 0 0 6px #1a0e08,
    inset 0 0 40px rgba(0,0,0,.45);
}
.scanlines {
  pointer-events: none;
  position: absolute;
  inset: 0;
  z-index: 8;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0,0,0,.18) 0 1px,
    transparent 1px 3px
  );
  mix-blend-mode: multiply;
}
.scanlines.thin { background: repeating-linear-gradient(to bottom, rgba(0,0,0,.12) 0 1px, transparent 1px 3px); }

.title-sky {
  position: relative;
  min-height: 520px;
  background:
    radial-gradient(ellipse at 50% 0%, #16306a 0%, var(--sky) 45%, var(--sky-2) 100%);
  padding: 22px 16px 0;
  text-align: center;
  display: flex;
  flex-direction: column;
}
.stars {
  position: absolute; inset: 0;
  background-image:
    radial-gradient(circle, #fff 0 1px, transparent 1.5px),
    radial-gradient(circle, #d0e8ff 0 1px, transparent 1.5px),
    radial-gradient(circle, #fff 0 1.2px, transparent 1.8px);
  background-size: 90px 80px, 130px 110px, 70px 140px;
  background-position: 10px 12px, 40px 30px, 20px 60px;
  opacity: .7;
}
.title-wording {
  position: relative;
  z-index: 2;
  margin: 8px 0 0;
  font-size: clamp(22px, 6vw, 44px);
  line-height: 1.15;
  letter-spacing: 1px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.title-logo { display: none; }
.t-orange {
  color: var(--orange);
  text-shadow: 4px 4px 0 #7a2d00, 0 0 18px rgba(255,138,26,.35);
}
.t-yellow {
  color: var(--gold);
  text-shadow: 4px 4px 0 #7a4d00, 0 0 18px rgba(255,210,60,.35);
}
.mountains {
  position: absolute;
  left: 0; right: 0;
  top: -72px;
  bottom: auto;
  display: flex;
  justify-content: space-between;
  padding: 0 4%;
  pointer-events: none;
  z-index: 1;
}
.mountains img { height: 90px; width: auto; opacity: .95; }
.mountains img:last-child { transform: scaleX(-1) scale(1.25); }
.ice-floor {
  display: none;
}
.title-bottom {
  position: relative;
  z-index: 4;
  margin-top: auto;
  width: 100%;
  padding: 44px 16px 18px;
  background:
    linear-gradient(180deg, #8eccea 0%, #c5eefc 40%, #b8e6f6 100%);
  overflow: visible;
}
.title-bottom::before {
  content: "";
  position: absolute;
  left: 0; right: 0; top: 0;
  height: 14px;
  background: linear-gradient(180deg, #eaf8ff 0%, #c5eefc 100%);
  box-shadow: 0 -2px 0 #6eacc8;
  pointer-events: none;
}
.title-bottom .play-cta { margin-top: 0; }

.title-cast {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: clamp(8px, 3vw, 28px);
  margin-top: 80px;
  margin-bottom: -48px;
  min-height: 200px;
  padding: 0 24px;
}
.cast { position: relative; }
.cast img { display: block; }
.cast.newcomer img { height: 150px; width: auto; }
.cast.chest img { height: 92px; width: auto; margin-bottom: 8px; }
.cast.sponsor { display: flex; align-items: flex-end; gap: 0; }
.cast.sponsor .sponsor-body { height: 160px; width: auto; }
.cast.sponsor .sponsor-sign { height: 88px; width: auto; margin: 0 0 70px -8px; transform: rotate(8deg); }
.cast.newcomer { padding: 0 10px 6px; }
.coin-label {
  position: absolute;
  left: 50%;
  top: auto;
  bottom: 0;
  transform: translateX(-50%);
  color: var(--gold);
  background: var(--ink);
  font-size: 8px;
  letter-spacing: 0.5px;
  text-shadow: none;
  white-space: nowrap;
  padding: 4px 6px 3px;
  border-radius: 4px;
  border: 2px solid #5a3e08;
  z-index: 6;
}

.play-cta {
  position: relative;
  z-index: 4;
  margin-top: 10px;
  background: var(--teal);
  color: #042028;
  padding: 14px 18px;
  border-radius: 10px;
  font-size: 14px;
  box-shadow: 0 4px 0 var(--teal-dk), 0 8px 16px rgba(0,0,0,.35);
  letter-spacing: 0.5px;
}
.title-cta {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 14px 28px;
  min-width: min(340px, 92%);
}
.cta-main {
  font-size: clamp(11px, 2.6vw, 14px);
  letter-spacing: 1px;
  color: #042028;
  line-height: 1.2;
  white-space: nowrap;
}
.cta-sub {
  font-family: var(--body);
  font-size: clamp(18px, 3.4vw, 22px);
  letter-spacing: 0.4px;
  color: #042028;
  line-height: 1;
  white-space: nowrap;
}
.play-cta:hover, .play-cta:focus-visible { filter: brightness(1.08); outline: none; }
.play-cta:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--teal-dk); }
.play-cta:disabled { opacity: .55; cursor: wait; transform: none; }

.lab-status {
  position: relative;
  z-index: 4;
  margin: 10px auto 0;
  max-width: 360px;
  width: min(360px, 94%);
  background: #071018;
  color: #eef4f8;
  border: 2px solid #1e3c46;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 17px;
  line-height: 1.35;
  text-align: center;
}
.title-sub {
  position: relative;
  z-index: 4;
  margin: 10px auto 0;
  max-width: 28em;
  color: var(--ink);
  font-size: 20px;
  line-height: 1.35;
  text-shadow: none;
}
.footer-line {
  color: #dce6ee;
  font-size: 16px;
  text-align: center;
  padding: 8px 12px 16px;
}

/* loading */
.load-inner {
  position: relative;
  z-index: 2;
  padding: 48px 20px 36px;
  text-align: center;
  min-height: 480px;
}
.load-penguins { display: flex; justify-content: center; gap: 24px; }
.load-penguins img { height: 120px; width: auto; }
.bob { animation: bob 1.1s ease-in-out infinite; }
.bob.delay { animation-delay: .25s; }
@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-12px); }
}
.load-inner h2 {
  color: var(--teal);
  font-size: 16px;
  margin: 18px 0 8px;
}
.load-copy { color: #eef4f8; font-size: 20px; max-width: 28em; margin: 0 auto 24px; line-height: 1.4; }
.load-steps {
  list-style: none;
  padding: 0;
  margin: 0 auto;
  max-width: 460px;
  text-align: left;
  font-size: 18px;
}
.load-steps li {
  padding: 10px 12px 10px 36px;
  margin: 8px 0;
  background: rgba(0,0,0,.25);
  border: 2px solid #1c2a38;
  border-radius: 8px;
  position: relative;
  color: #d5e0ea;
}
.load-steps li::before {
  content: "";
  position: absolute;
  left: 10px; top: 11px;
  width: 12px; height: 12px;
  border: 2px solid #4a6070;
  border-radius: 50%;
}
.load-steps li.running { color: #fff; }
.load-steps li.running::before {
  border-color: var(--teal);
  box-shadow: 0 0 8px var(--teal);
  animation: pulse 1s infinite;
}
.load-steps li.done { color: #d8fff6; }
.load-steps li.done::before {
  content: "✓";
  border: 0;
  color: var(--teal);
  font-size: 12px;
  top: 8px;
  left: 12px;
  width: auto; height: auto;
}
.load-steps li.fail { color: #ffb0b0; }
.load-error { color: #ffb0b0; font-size: 18px; margin-top: 16px; }
@keyframes pulse { 50% { opacity: .4; } }

/* ----- Game layout ----- */
#screen-game {
  background: #0a1018;
  padding: 0 16px 8px;
}
.game-header {
  width: min(1100px, 100%);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  padding: 16px 0 12px;
}
.game-header h1 {
  margin: 0;
  font-size: 14px;
  justify-self: start;
}
.vote-tag {
  justify-self: center;
  background: #1a1204;
  color: var(--gold);
  border: 2px solid #7a5a10;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 8px;
  line-height: 1.4;
  white-space: nowrap;
}
.brand { justify-self: end; color: #dce6ee; font-size: 16px; }

.game-layout {
  width: min(1100px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(260px, .8fr);
  gap: 24px;
  align-items: start;
  flex: 1;
}
.board-col { display: flex; flex-direction: column; align-items: center; }
.board-crt {
  position: relative;
  width: 100%;
  background:
    radial-gradient(ellipse at 50% 0%, #1b3a6c 0%, #123058 30%, #0c2438 100%);
  border: 6px solid #1a0e08;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: inset 0 0 40px rgba(0,0,0,.35), 0 10px 24px rgba(0,0,0,.4);
  padding: 12px 12px 8px;
}
.board-crt::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 58%;
  background:
    linear-gradient(180deg, rgba(126,200,232,0) 0%, #6eb8d8 12%, #c5eefc 80%);
  z-index: 0;
  pointer-events: none;
}
.hud {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  padding: 4px 8px 8px;
}
.hud-label { display: block; font-size: 8px; color: var(--gold); }
.hud-value { font-size: 14px; }
.hud-value.gold { color: var(--gold); text-shadow: 2px 2px 0 #000; }
.hud-value.green { color: #7cff4a; text-shadow: 2px 2px 0 #000; }
.hud-block:last-child { text-align: right; }
.hud-block:nth-child(2) { text-align: center; }

.hole-grid {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px 10px;
  padding: 4px 8px 12px;
  aspect-ratio: 1.15 / 1;
}
.hole {
  position: relative;
  overflow: hidden;
  background:
    url("../assets/hole.png") center bottom / 100% auto no-repeat;
  min-height: 90px;
  cursor: pointer;
  touch-action: manipulation;
}
.penguin {
  position: absolute;
  left: 50%;
  bottom: 14%;
  width: 68%;
  height: auto;
  transform: translate(-50%, 120%);
  transition: transform 300ms cubic-bezier(.22, .7, .28, 1);
  pointer-events: none;
  z-index: 1;
}
.hole.up .penguin { transform: translate(-50%, 20%); }
.hole.bonked .penguin { transform: translate(-50%, 28%) rotate(-8deg); }
.spark {
  position: absolute;
  left: 50%;
  top: 20%;
  width: 40%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  opacity: 0;
  z-index: 3;
}
.hole.bonked .spark { animation: spark 280ms ease-out; }
@keyframes spark {
  0% { opacity: 1; transform: translate(-50%, -40%) scale(.6); }
  100% { opacity: 0; transform: translate(-50%, -80%) scale(1.3); }
}

.board-banner {
  position: relative;
  z-index: 2;
  margin: 0 auto 8px;
  background: #0a0a0a;
  color: var(--gold);
  font-size: 8px;
  padding: 6px 10px;
  border-radius: 6px;
  display: inline-block;
  width: auto;
  text-align: center;
}
.board-crt .board-banner { display: block; width: max-content; margin: 0 auto 8px; }
.board-play { margin-top: 16px; min-width: 180px; font-size: 16px; padding: 14px 36px; }
.round-hint { color: #e4edf4; font-size: 18px; line-height: 1.4; text-align: center; max-width: 28em; margin: 10px 0 0; }

.receipts-panel {
  background: #0c141c;
  border: 2px solid #1c2a38;
  border-radius: 12px;
  padding: 18px 16px;
  min-height: 320px;
}
.receipts-panel h2 {
  margin: 0 0 14px;
  color: var(--teal);
  font-size: 12px;
}
.receipt-list { list-style: none; padding: 0; margin: 0; }
.receipt-list li {
  display: grid;
  grid-template-columns: 18px 1fr auto;
  gap: 8px;
  align-items: start;
  padding: 10px 0;
  border-bottom: 1px solid #1c2a38;
  font-size: 17px;
  line-height: 1.35;
  color: #eef4f8;
}
.receipt-list li .mark { color: var(--teal); font-size: 12px; line-height: 1; }
.receipt-list li.pending .mark { color: var(--gold); animation: pulse 1s infinite; }
.receipt-list li.fail .mark { color: #ff8080; }
.receipt-list a { color: var(--teal); text-decoration: none; }
.receipt-list a:hover { text-decoration: underline; }
.balance-pill {
  margin-top: 18px;
  background: #0b1c22;
  border: 2px solid var(--teal-dk);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 17px;
  color: #e4f4f2;
}
.balance-pill strong { color: var(--teal); }

/* end card */
.end-card {
  position: fixed;
  inset: 0;
  background: rgba(4, 8, 14, .72);
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.end-inner {
  background: #101820;
  border: 3px solid var(--teal-dk);
  border-radius: 14px;
  padding: 28px 22px 22px;
  max-width: 520px;
  width: 100%;
  text-align: center;
  box-shadow: 0 16px 40px rgba(0,0,0,.5);
}
.end-inner h2 { color: var(--teal); font-size: 14px; margin: 0 0 14px; }
.end-inner p { font-size: 20px; color: #eef4f8; line-height: 1.45; max-width: 32em; margin: 0 auto 10px; }
.end-score { color: var(--gold) !important; font-size: 12px !important; margin: 16px 0; }
.end-vote { color: var(--gold) !important; }
.end-actions { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-top: 18px; }
.text-btn { background: none; color: #dce6ee; font-family: var(--body); font-size: 18px; text-decoration: underline; }

/* mallet follower */
.mallet {
  position: fixed;
  width: 72px;
  height: 72px;
  background: url("../assets/mallet.png") center / contain no-repeat;
  pointer-events: none;
  z-index: 30;
  transform: translate(-20%, -80%) rotate(-20deg);
  display: none;
}
body.show-mallet .mallet { display: block; }
body:has(#end-card:not(.hidden)) .mallet { display: none !important; }
body.swing .mallet { background-image: url("../assets/mallet-hit.png"); }


/* ----- Title cost / sponsor receipt ----- */
.cost-card {
  position: relative;
  z-index: 4;
  margin: 12px auto 0;
  max-width: 360px;
  width: min(360px, 94%);
  background: #071018;
  color: #eef4f8;
  border: 2px solid #1e3c46;
  border-radius: 8px;
  padding: 12px 14px 10px;
  text-align: left;
  box-shadow: 4px 4px 0 rgba(0,0,0,.28), inset 0 0 0 1px #143038;
  overflow: visible;
}
.cost-heading {
  font-family: var(--display);
  font-size: 8px;
  color: var(--gold);
  margin: 0 0 8px;
  letter-spacing: 0.4px;
  line-height: 1.35;
}
.cost-lines {
  list-style: none;
  margin: 0;
  padding: 0;
}
.cost-lines li,
.cost-you-pay {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 0;
  font-size: 17px;
  line-height: 1.4;
  color: #eef4f8;
}
.cost-you-pay {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 2px dashed #2a4450;
  font-size: 18px;
}
.cost-dots {
  flex: 1 1 auto;
  border-bottom: 2px dotted #5a7380;
  min-width: 10px;
  transform: translateY(-5px);
}
.cost-amt {
  flex: 0 0 auto;
  text-decoration: line-through;
  text-decoration-thickness: 2px;
  text-decoration-color: #8aa0b0;
  color: #dce6ee;
}
.cost-zero {
  flex: 0 0 auto;
  color: var(--teal);
}
.cost-note {
  margin: 8px 0 0;
  font-size: 14px;
  line-height: 1.3;
  color: #c5d4de;
}
.sponsored-stamp {
  position: absolute;
  left: 50%;
  top: 46%;
  transform: translate(-50%, -50%) rotate(-14deg);
  font-family: var(--display);
  font-size: 13px;
  color: var(--teal);
  border: 3px solid var(--teal);
  border-radius: 6px;
  padding: 6px 8px 4px;
  letter-spacing: 1px;
  background: rgba(7, 16, 24, .12);
  box-shadow: 0 0 0 1px rgba(46, 224, 192, .4);
  pointer-events: none;
  animation: stamp-in 500ms cubic-bezier(.15, 1.35, .4, 1) 450ms both;
}
@keyframes stamp-in {
  0% { opacity: 0; transform: translate(-50%, -72%) rotate(-28deg) scale(1.55); }
  72% { opacity: 1; transform: translate(-50%, -46%) rotate(-12deg) scale(0.96); }
  100% { opacity: 1; transform: translate(-50%, -50%) rotate(-14deg) scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .sponsored-stamp { animation: none; }
}

@media (hover: hover) and (pointer: fine) {
  #screen-game.active { cursor: none; }
}

@media (max-width: 800px) {
  .game-header {
    grid-template-columns: 1fr;
    justify-items: start;
    gap: 8px;
  }
  .game-header h1 {
    font-size: 11px;
    max-width: none;
    white-space: nowrap;
    line-height: 1.2;
  }
  .brand { display: none; }
  .vote-tag {
    justify-self: start;
    font-size: 8px;
    white-space: normal;
    max-width: 100%;
  }
  .game-layout { grid-template-columns: 1fr; }
  .title-sky { min-height: 0; padding-top: 16px; }
  .title-wording { font-size: 20px; }
  .cast.newcomer img, .cast.sponsor .sponsor-body { height: 92px; }
  .cast.chest img { height: 60px; }
  .cast.sponsor .sponsor-sign { height: 52px; margin-bottom: 28px; }
  .title-cast {
    margin-top: 28px;
    margin-bottom: -42px;
    min-height: 120px;
    width: 100%;
    padding: 0 16px;
    gap: 8px;
  }
  .mountains { top: -52px; }
  .mountains img { height: 56px; }
  .title-cta { padding: 12px 16px; min-width: min(320px, 94%); }
  .cta-main { font-size: 12px; }
  .cta-sub { font-size: 18px; }
  .title-sub { font-size: 16px; padding: 0 8px; margin-top: 8px; }
  .title-bottom { padding: 40px 12px 14px; }
  .cost-card { margin-top: 10px; padding: 10px 12px 8px; max-width: 340px; }
  .cost-lines li, .cost-you-pay { font-size: 16px; }
  .cost-you-pay { font-size: 17px; }
  .cost-heading { font-size: 7px; }
  .cost-note { font-size: 13px; }
  .sponsored-stamp { font-size: 11px; padding: 5px 7px 3px; }
  .footer-line { font-size: 15px; }
  .crt-bezel { padding: 14px 10px 18px; border-radius: 18px; }
  .hole { min-height: 78px; }
  body.show-mallet .mallet { display: none; } /* native tap on phones */
  #screen-game.active { cursor: auto; }
}
