/* Stonk Toss: stock-terminal tickets over the meme board. */
@font-face { font-family: 'Anton'; src: url(fonts/anton-latin.woff2) format('woff2'); font-display: swap; }
@font-face { font-family: 'Share Tech Mono'; src: url(fonts/sharetechmono-latin.woff2) format('woff2'); font-display: swap; }

:root {
  --navy: #041a52;
  --navy-2: #0a2f86;
  --ink: #020b24;
  --paper: #eaf1ff;
  --green: #2bff88;
  --green-d: #0fbf5c;
  --red: #ff3d4d;
  --orange: #ff8a1c;
  --gold: #ffd34d;
  --mono: 'Share Tech Mono', ui-monospace, 'Cascadia Mono', Consolas, monospace;
  --big: Anton, Impact, 'Arial Narrow Bold', sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--navy); color: var(--paper); font-family: var(--mono); }
body { position: fixed; inset: 0; -webkit-tap-highlight-color: transparent; overscroll-behavior: none; -webkit-user-select: none; user-select: none; }
input { -webkit-user-select: text; user-select: text; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.up { color: var(--green); } .down { color: var(--red); }

#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#game.grabbing { cursor: grabbing; }
.scan { position: fixed; inset: 0; pointer-events: none; z-index: 1;
  background: repeating-linear-gradient(0deg, rgba(0,0,0,0.13) 0 1px, transparent 1px 3px);
  mix-blend-mode: multiply; }

/* ── ticker tape ─────────────────────────────────────────── */
#tape { position: fixed; top: 0; left: 0; right: 0; z-index: 5; height: calc(26px + var(--safe-t)); padding-top: var(--safe-t);
  background: #000; border-bottom: 2px solid var(--orange); overflow: hidden; pointer-events: none; }
#tape-inner { display: flex; width: max-content; animation: tape 14s linear infinite; }
#tape .live { white-space: pre; font-size: 14px; line-height: 24px; padding-right: 8px; letter-spacing: 0.04em; }
@keyframes tape { to { transform: translateX(-50%); } }

/* ── contract address bar (tap to copy) ── */
#ca-bar { position: fixed; z-index: 5; left: 0; right: 0; top: calc(26px + var(--safe-t)); height: 30px; display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 0 10px; border: 0; border-bottom: 2px solid var(--ink); background: var(--gold); color: var(--ink); cursor: pointer; font-family: var(--mono); }
#ca-bar .lbl { color: var(--ink); font-weight: 700; letter-spacing: 0.12em; }
#ca-bar code { font-family: var(--mono); font-size: clamp(10px, 2.9vw, 15px); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#ca-bar .copy { flex: none; background: var(--ink); color: var(--gold); font-family: var(--big); font-size: 14px; letter-spacing: 0.06em; padding: 1px 8px 2px; }
#ca-bar:hover .copy { background: #000; color: #fff; }
#ca-bar:active { filter: brightness(0.92); }
body.has-ca #hud { top: calc(60px + var(--safe-t)); }
body.has-ca #start { padding-top: calc(70px + var(--safe-t)); }
body.has-ca #end { padding-top: calc(66px + var(--safe-t)); }

/* ── HUD ─────────────────────────────────────────────────── */
#hud { position: fixed; z-index: 4; left: 0; right: 0; top: calc(30px + var(--safe-t)); display: flex; align-items: flex-start; justify-content: space-between;
  padding: 6px 12px; pointer-events: none; opacity: 0; transform: translateY(-10px); transition: opacity .3s, transform .3s; }
#hud.live { opacity: 1; transform: none; }
.lbl { font-family: var(--mono); font-size: 11px; letter-spacing: 0.18em; color: rgba(234,241,255,0.7); text-transform: uppercase; margin: 0; font-weight: 400; }
#hud .mc, #hud .tm { display: flex; flex-direction: column; }
#hud .tm { align-items: flex-end; }
#hud-mcap { font-family: var(--big); font-size: clamp(38px, 9vw, 76px); line-height: 0.95; color: #fff;
  text-shadow: 0 3px 0 var(--ink), 0 0 24px rgba(0,0,0,0.5); font-variant-numeric: tabular-nums; }
#hud-pct { font-size: clamp(15px, 3.4vw, 22px); text-shadow: 0 2px 0 var(--ink); }
#hud-timer { font-family: var(--big); font-size: clamp(34px, 8vw, 64px); line-height: 0.95; color: #fff; text-shadow: 0 3px 0 var(--ink); font-variant-numeric: tabular-nums; }
#hud-timer.hurry { color: var(--red); animation: hurry .5s steps(2) infinite; }
@keyframes hurry { 50% { opacity: .45; } }
#combo { align-self: center; margin-top: 8px; font-family: var(--big); font-size: clamp(18px, 4.5vw, 30px); letter-spacing: 0.04em;
  padding: 2px 12px 4px; background: var(--gold); color: var(--ink); border: 2px solid var(--ink); box-shadow: 4px 4px 0 var(--ink);
  transform: rotate(-3deg) scale(0); transition: transform .2s cubic-bezier(.3,1.6,.5,1); }
#combo.on { transform: rotate(-3deg) scale(1); }
#combo.pop { animation: pop .35s cubic-bezier(.3,1.8,.5,1); }
@keyframes pop { 0% { transform: rotate(-3deg) scale(1.6); } 100% { transform: rotate(-3deg) scale(1); } }

#mute { position: fixed; z-index: 8; right: 10px; bottom: calc(10px + var(--safe-b)); width: 42px; height: 42px; border-radius: 0;
  background: rgba(2,11,36,0.75); border: 2px solid rgba(234,241,255,0.4); font-size: 18px; cursor: pointer; }
#mute:focus-visible, .btn:focus-visible, .link:focus-visible, input:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

/* ── flashes, countdown, overlays ───────────────────────── */
#flash { position: fixed; inset: 0; z-index: 3; pointer-events: none; opacity: 0; display: grid; place-items: center; }
#flash.show { animation: flash .9s ease-out; }
#flash.green { background: radial-gradient(circle, rgba(43,255,136,0.55), rgba(43,255,136,0.05) 70%); }
#flash.red { background: radial-gradient(circle, rgba(255,40,60,0.6), rgba(255,40,60,0.08) 70%); }
@keyframes flash { 0% { opacity: 1; } 70% { opacity: .85; } 100% { opacity: 0; } }
#flash-label { font-family: var(--big); font-size: clamp(34px, 10vw, 110px); color: #fff; letter-spacing: 0.02em; text-align: center;
  padding: 0 16px; text-shadow: 0 5px 0 var(--ink), 0 0 40px rgba(0,0,0,0.6); transform: rotate(-4deg); }
#flash.show #flash-label { animation: slam .9s cubic-bezier(.2,1.6,.4,1); }
@keyframes slam { 0% { transform: rotate(-4deg) scale(2.2); } 25% { transform: rotate(-4deg) scale(1); } 100% { transform: rotate(-4deg) scale(1.04); } }

#count { position: fixed; inset: 0; z-index: 6; display: grid; place-items: center; pointer-events: none;
  font-family: var(--big); font-size: clamp(120px, 34vmin, 300px); color: #fff; text-shadow: 0 8px 0 var(--ink), 0 0 60px rgba(255,138,28,0.7); }
#count.pop { animation: countpop .6s cubic-bezier(.2,1.5,.4,1); }
@keyframes countpop { 0% { transform: scale(2.4); opacity: 0; } 40% { opacity: 1; } 100% { transform: scale(1); } }

#paused { position: fixed; inset: 0; z-index: 9; display: grid; place-content: center; text-align: center; gap: 6px; background: rgba(2,11,36,0.7); cursor: pointer; }
#paused b { font-family: var(--big); font-size: 64px; font-weight: 400; letter-spacing: 0.04em; }
#paused small { font-size: 14px; letter-spacing: 0.12em; opacity: .8; }

#closed { position: fixed; inset: 0; z-index: 6; display: grid; place-content: center; text-align: center; pointer-events: none;
  background: radial-gradient(circle, rgba(2,11,36,0.25), rgba(2,11,36,0.75)); animation: fadein .25s; }
#closed .bell { font-family: var(--big); font-size: clamp(36px, 10vw, 96px); color: #fff; text-shadow: 0 5px 0 var(--ink); animation: slam .8s cubic-bezier(.2,1.6,.4,1); transform: rotate(-4deg); }
#closed-mcap { font-family: var(--big); font-size: clamp(44px, 12vw, 120px); text-shadow: 0 5px 0 var(--ink); }
@keyframes fadein { from { opacity: 0; } }

.row2 { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
#hint { font-size: 13px; color: var(--gold); opacity: 0; transition: opacity .4s; white-space: nowrap; }
#hint.show { opacity: 1; }
#hint .hand { display: inline-block; animation: tug 1.1s ease-in-out infinite; }
@keyframes tug { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-7px) rotate(-8deg); } }

/* ── shared bits ────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 2px solid var(--ink); border-radius: 0; cursor: pointer;
  font-family: var(--big); font-size: 22px; letter-spacing: 0.05em; padding: 10px 18px 11px; text-decoration: none; color: var(--ink);
  box-shadow: 5px 5px 0 var(--ink); transition: transform .08s, box-shadow .08s; min-height: 48px; }
.btn:active { transform: translate(3px, 3px); box-shadow: 2px 2px 0 var(--ink); }
.btn.buy { background: var(--green); }
.btn.buy:hover { background: #66ffaa; }
.btn.x { background: #fff; }
.btn.x:hover { background: var(--gold); }
.btn.ghost { background: transparent; color: var(--paper); border-color: rgba(234,241,255,0.55); box-shadow: 4px 4px 0 rgba(0,0,0,0.5); font-size: 17px; min-height: 42px; }
.btn.mini { font-size: 15px; padding: 4px 10px; min-height: 30px; box-shadow: 3px 3px 0 var(--ink); }
.btn:disabled { opacity: .5; cursor: default; }
.link { background: none; border: 0; padding: 4px 2px; color: var(--paper); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; font-family: var(--mono); font-size: 14px; }

.board { list-style: none; margin: 0; padding: 0; font-size: 14px; }
.board li { display: grid; grid-template-columns: 2.6em 1fr auto 5.2em; gap: 8px; align-items: baseline; padding: 5px 4px; border-bottom: 1px dashed rgba(234,241,255,0.18); }
.board li:nth-child(1) .r { color: var(--gold); }
.board .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board .s { color: var(--green); font-variant-numeric: tabular-nums; }
.board .t { color: rgba(234,241,255,0.55); font-size: 12px; text-align: right; }
.board li.me { background: rgba(255,211,77,0.16); }
.board li.nap { display: block; color: rgba(234,241,255,0.7); padding: 10px 4px; border: 0; }

/* ── start screen ───────────────────────────────────────── */
#start { position: fixed; inset: 0; z-index: 6; pointer-events: none; display: flex; flex-direction: column; justify-content: space-between;
  padding: calc(40px + var(--safe-t)) 16px calc(64px + var(--safe-b)); }
.title-block { text-align: center; }
.kicker { margin: 0 0 4px; font-size: 13px; letter-spacing: 0.25em; color: var(--orange); text-shadow: 0 1px 0 #000; animation: rise .5s .15s both; }
h1 { margin: 0; font-family: var(--big); font-weight: 400; line-height: 0.82; letter-spacing: 0.01em; font-size: clamp(52px, 19vw, 190px); }
h1 span { display: inline-block; color: #fff;
  background: linear-gradient(#ffffff 0 52%, #d0d0d8 53% 100%); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  filter: drop-shadow(3px 4px 0 #2a2a36) drop-shadow(0 0 22px rgba(255,138,28,0.55)); }
h1 .w1 { animation: dropin .7s .05s cubic-bezier(.2,1.5,.4,1) both; transform-origin: 50% 100%; }
h1 .w2 { animation: dropin .7s .22s cubic-bezier(.2,1.5,.4,1) both; margin-left: .18em; color: var(--orange);
  background: linear-gradient(#ffb15c 0 52%, #ff8a1c 53% 100%); -webkit-background-clip: text; background-clip: text; }
@keyframes dropin { 0% { transform: translateY(-120%) rotate(-8deg) scale(1.3); opacity: 0; } 60% { opacity: 1; } 100% { transform: none; } }
@keyframes rise { from { transform: translateY(12px); opacity: 0; } }
.sub { margin: 10px auto 0; max-width: 34em; font-size: clamp(13px, 3.4vw, 17px); line-height: 1.45; text-shadow: 0 1px 0 #000, 0 0 12px rgba(0,0,0,0.8); animation: rise .5s .45s both; }
.sub b { font-weight: 400; }

.ticket { pointer-events: auto; align-self: center; width: min(460px, 100%); background: rgba(2,11,36,0.88); border: 2px solid var(--paper);
  box-shadow: 8px 8px 0 rgba(0,0,0,0.55); padding: 14px 14px 10px; position: relative; animation: rise .5s .6s both; }
.ticket::before { content: 'ORDER TICKET · MKT'; position: absolute; top: -11px; left: 12px; background: var(--orange); color: var(--ink); font-size: 11px; letter-spacing: 0.2em; padding: 2px 8px; }
.ticket .row { display: flex; gap: 10px; margin-top: 6px; }
#name { flex: 1; min-width: 0; height: 48px; padding: 0 12px; font: 20px var(--mono); color: #fff; background: #000; border: 2px solid rgba(234,241,255,0.55); border-radius: 0; }
#name::placeholder { color: rgba(234,241,255,0.35); }
#name[aria-invalid="true"] { border-color: var(--red); }
.msg { min-height: 1.3em; margin: 6px 0 0; font-size: 13px; color: #ffb3ba; }
#start-board-wrap { max-height: 34vh; overflow: auto; margin-top: 6px; border-top: 1px solid rgba(234,241,255,0.25); }

/* ── end screen ─────────────────────────────────────────── */
#end { position: fixed; inset: 0; z-index: 7; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: calc(34px + var(--safe-t)) 12px calc(60px + var(--safe-b)); background: linear-gradient(rgba(2,11,36,0.1), rgba(2,11,36,0.65) 40%); animation: fadein .3s; }
.end-grid { max-width: 980px; margin: 0 auto; display: grid; grid-template-columns: 1fr; gap: 16px; }
.result, .side { background: rgba(2,11,36,0.9); border: 2px solid var(--paper); box-shadow: 8px 8px 0 rgba(0,0,0,0.55); padding: 16px; }
.result { animation: rise .4s both; }
.side { animation: rise .4s .1s both; }
.big { font-family: var(--big); font-size: clamp(64px, 17vw, 128px); line-height: 0.95; margin-top: 4px; text-shadow: 0 5px 0 #000; }
.verdict { font-family: 'Arial Black', 'Arial Bold', Arial, sans-serif; font-weight: 900; font-size: clamp(30px, 8vw, 48px); color: #f4f4f6; margin: -2px 0 8px;
  text-shadow: 1px 1px 0 #6a6a74, 2px 2px 0 #4a4a54, 3px 3px 0 #2a2a34, 4px 5px 6px rgba(0,0,0,0.6); }
.stats { display: flex; gap: 18px; margin: 0 0 6px; flex-wrap: wrap; }
.stats div { display: flex; flex-direction: column; }
.stats dt { font-size: 11px; letter-spacing: 0.16em; opacity: .7; }
.stats dd { margin: 0; font-family: var(--big); font-size: 26px; }
.rank { margin: 4px 0 10px; font-family: var(--big); font-size: 26px; letter-spacing: 0.03em; min-height: 1.2em; }
.rank.gold { color: var(--gold); }
.rank.muted { font-family: var(--mono); font-size: 14px; color: rgba(234,241,255,0.75); letter-spacing: 0; }
.actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 8px; }
.actions .btn { flex: 1 1 180px; font-size: 24px; min-height: 56px; }
.actions .btn.x { flex-basis: 220px; }
.actions.small { align-items: center; }
.actions.small .btn { flex: 0 0 auto; font-size: 17px; min-height: 42px; }
.tip { font-size: 12px; opacity: .65; margin: 10px 0 0; line-height: 1.4; }
#card-img { display: block; width: 100%; height: auto; aspect-ratio: 1200 / 675; background: #0a2f86; border: 1px solid rgba(234,241,255,0.3); margin-bottom: 12px; }
.side h2 { margin: 0 0 4px; }
@media (min-width: 820px) {
  .end-grid { grid-template-columns: 1.05fr 1fr; align-items: start; }
}

/* ── footer ─────────────────────────────────────────────── */
#coin { position: fixed; z-index: 8; left: 10px; bottom: calc(10px + var(--safe-b)); right: 62px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  font-size: 13px; pointer-events: none; }
#coin > * { pointer-events: auto; }
#coin .tick { background: var(--orange); color: var(--ink); padding: 2px 8px; font-weight: 700; letter-spacing: 0.06em; }
#coin code { font-family: var(--mono); background: rgba(0,0,0,0.6); padding: 2px 6px; }
body[data-state="play"] #coin, body[data-state="countdown"] #coin { opacity: .35; }

#toast { position: fixed; z-index: 10; left: 50%; bottom: calc(70px + var(--safe-b)); transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--gold); color: var(--ink); padding: 8px 14px; border: 2px solid var(--ink); box-shadow: 4px 4px 0 var(--ink); transition: .2s; font-size: 14px; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
.noscript { position: fixed; inset: 0; display: grid; place-items: center; text-align: center; padding: 20px; z-index: 20; background: var(--navy); }

@media (max-height: 560px) and (orientation: landscape) {
  #start { padding-top: calc(30px + var(--safe-t)); padding-bottom: calc(48px + var(--safe-b)); }
  h1 { font-size: clamp(48px, 15vh, 110px); }
  .sub { display: none; }
  .title-block { text-align: left; }
  .ticket { padding: 10px 12px 6px; align-self: flex-end; width: min(400px, 50vw); }
  #hint { display: none; }
}
@media (max-height: 680px) and (orientation: portrait) {
  .sub { display: none; }
  #start { padding-top: calc(34px + var(--safe-t)); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  #tape-inner { animation: none; }
}
