@font-face { font-family: "Areal Mono"; src: url(../fonts/areal-mono.woff) format("woff"); font-display: swap; }
@font-face { font-family: "Areal"; src: url(../fonts/areal.woff) format("woff"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Areal"; src: url(../fonts/areal-bold.woff) format("woff"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Biedermeier"; src: url(../fonts/biedermeier.woff) format("woff"); font-display: swap; }
/* Cyrillic stand-in for the mono UI, and the scheme labels (same face as in Figma) */
@font-face { font-family: "IBM Plex Mono"; src: url(../fonts/cyr-mono.woff) format("woff"); font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url(../fonts/cyr-mono-bold.woff) format("woff"); font-weight: 700; font-display: swap; }

:root {
  --base: #c3c4c6;
  --hot: #ff3d14;
  --ink: #111;
  --paper: #f6f5f1;
  --mono: "Areal Mono", "IBM Plex Mono", "Courier New", monospace;
  --bold: "Areal", "Helvetica Neue", Arial, sans-serif;
  --line: 1.5px solid var(--ink);
  --rh: 52px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--base);
  color: var(--ink);
  font: 12px/1.4 var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: 100dvh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; text-transform: inherit; letter-spacing: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
button:disabled { cursor: default; }
input, textarea { font: inherit; color: inherit; letter-spacing: 0; }
button:focus-visible, input:focus-visible, textarea:focus-visible, .chip:focus-within, summary:focus-visible { outline: 2px solid var(--hot); outline-offset: 2px; }

/* ---------- header ---------- */

.top { display: flex; align-items: center; gap: 18px; padding: 8px 18px; border-bottom: var(--line); }
.logo { font: 46px/1 "Biedermeier", Georgia, serif; text-transform: none; letter-spacing: 0; color: var(--ink); text-decoration: none; padding-top: 6px; }
.title { font-size: 11px; line-height: 1.18; letter-spacing: 0.06em; }
.steps { display: flex; gap: 0; margin: 0 0 0 auto; padding: 0; list-style: none; counter-reset: s; font-size: 10px; }
.steps li { counter-increment: s; padding: 4px 10px; border: var(--line); margin-left: -1.5px; white-space: nowrap; }
.steps li::before { content: counter(s) " "; font-weight: 700; color: var(--hot); -webkit-text-stroke: 0.3px var(--ink); }

.code { display: flex; align-items: center; gap: 6px; margin-left: 12px; }
.code .txt { width: 92px; padding: 4px 7px; font-size: 11px; }
.code .unl { display: none; font-size: 10px; background: var(--ink); color: var(--hot); padding: 4px 7px; white-space: nowrap; }
body.unlocked .code .txt { display: none; }
body.unlocked .code .unl { display: inline-block; }
.nav { display: none; align-items: center; gap: 4px; font-size: 10px; }
body.unlocked .nav { display: flex; }
.nav .chip { padding: 3px 8px; }
.nav .chip:disabled { opacity: 0.3; }
.spins b { font-size: 14px; color: var(--hot); -webkit-text-stroke: 0.4px var(--ink); }

/* ---------- layout ---------- */

main { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.08fr) 270px; min-height: 0; }
.col { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.col + .col { border-left: var(--line); }

.bar { display: flex; flex-wrap: wrap; gap: 5px; padding: 10px 12px; border-bottom: var(--line); }
.textrow { display: flex; gap: 5px; padding: 8px 12px; border-bottom: var(--line); }
.textrow[hidden] { display: none; }
.stage { position: relative; flex: 1; min-height: 0; overflow: hidden; }
#srcStage { background: #b6b7ba; }
#srcCanvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: crosshair; -webkit-user-select: none; user-select: none; }
.empty { position: absolute; inset: 14px; display: grid; place-items: center; text-align: center; border: 2px dashed var(--ink); font-size: 12px; line-height: 1.5; pointer-events: none; opacity: 0.7; }
#srcStage.drop .empty { display: grid !important; background: rgba(255, 255, 255, 0.35); opacity: 1; }
.hint { position: absolute; left: 10px; right: 10px; bottom: 10px; margin: 0; text-align: center; pointer-events: none; }
.hint span { display: inline-block; background: var(--ink); color: var(--base); padding: 5px 9px; font-size: 11px; }
.hint:empty { display: none; }

.tracks { border-top: var(--line); padding: 8px 12px; }
.tracks summary { cursor: pointer; font-size: 11px; list-style: none; }
.tracks summary::before { content: "+ "; }
.tracks[open] summary::before { content: "− "; }
.tracks textarea { margin-top: 8px; }

/* ---------- result + machine ---------- */

.preview { background: var(--paper); transition: background 0.35s; }
.preview svg.res { position: absolute; inset: 6%; width: 88%; height: 88%; display: block; }
.preview .empty { opacity: 0.55; }
.rareflash { position: absolute; top: 12px; left: 12px; background: var(--ink); color: #ffd84a; padding: 5px 9px; font-size: 11px; animation: buzz 0.5s steps(2) 6; }
@keyframes buzz { 50% { opacity: 0.35; } }

.machine { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: end; padding: 12px; border-top: var(--line); }
.reels { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.reel { min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.reel .rl { font-size: 10px; opacity: 0.7; }
.window { height: var(--rh); border: var(--line); background: var(--paper); overflow: hidden; position: relative; cursor: pointer;
  box-shadow: inset 0 9px 8px -8px rgba(0, 0, 0, 0.35), inset 0 -9px 8px -8px rgba(0, 0, 0, 0.35); }
.reel.held .window { background: var(--ink); color: var(--paper); }
.strip { will-change: transform; }
.it { height: var(--rh); display: flex; align-items: center; justify-content: center; gap: 6px; padding: 0 6px; white-space: nowrap; overflow: hidden; }
.it b { font: 700 17px/1 var(--bold); text-transform: lowercase; letter-spacing: -0.01em; overflow: hidden; text-overflow: ellipsis; }
.it.q b { opacity: 0.35; }
.it .sw { width: 12px; height: 22px; border: 1px solid var(--ink); flex: none; }
.it.pal b { font-size: 14px; }
.hold { border: var(--line); padding: 4px 6px; font-size: 10px; text-align: center; }
.hold:disabled { opacity: 0.35; }
.reel.held .hold { background: var(--ink); color: var(--base); }

.lever { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.spins { font-size: 10px; display: flex; gap: 4px; align-items: center; white-space: nowrap; }
.spins i { width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid var(--ink); display: inline-block; }
.spins i.on { background: var(--hot); }
.go {
  width: 84px; height: 84px; border-radius: 50%;
  background: var(--hot); border: var(--line);
  font: 700 17px/1 var(--bold); text-transform: lowercase; letter-spacing: -0.01em;
  box-shadow: 0 5px 0 var(--ink);
  transition: transform 0.12s, box-shadow 0.12s, opacity 0.2s;
}
.go:active:not(:disabled), .go.busy { transform: translateY(5px); box-shadow: 0 0 0 var(--ink); }
.go:disabled { opacity: 0.4; }
.go.ready { animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.06); } }

.actions { display: flex; align-items: center; gap: 10px; padding: 0 12px 12px; }
.status { flex: 1; margin: 0; font-size: 11px; line-height: 1.35; min-height: 30px; display: flex; align-items: center; }

/* ---------- tray ---------- */

.trayhead { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: var(--line); }
.trayhead h2 { font: 700 22px/1 var(--bold); text-transform: lowercase; letter-spacing: -0.02em; margin: 0; }
.count { font-size: 11px; opacity: 0.7; flex: 1; }
.traygrid { flex: 1; overflow: auto; padding: 10px 12px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; align-content: start; scrollbar-width: thin; }
.trayempty { grid-column: 1 / -1; font-size: 10px; opacity: 0.6; margin: 0; line-height: 1.5; }
.card { border: var(--line); background: var(--paper); display: flex; flex-direction: column; min-width: 0; }
.card.fresh { animation: drop 0.45s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes drop { from { transform: translateY(-24px) scale(0.92); opacity: 0; } }
.thumb { aspect-ratio: 1; display: grid; place-items: center; padding: 8%; border-bottom: var(--line); position: relative; }
.thumb img { max-width: 100%; max-height: 100%; display: block; }
.thumb .star { position: absolute; top: 4px; left: 5px; font-size: 12px; }
.cname { font-size: 9px; line-height: 1.25; padding: 4px 5px 2px; min-height: 26px; }
.cbtns { display: flex; flex-wrap: wrap; border-top: 1px solid rgba(0, 0, 0, 0.2); }
.cbtns button { flex: 1; font-size: 10px; padding: 5px 0; min-width: 0; }
.cbtns button:hover { background: var(--ink); color: var(--paper); }
.cbtns .share { display: none; }
.canshare .cbtns .share { display: block; }
.trayfoot { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 12px; border-top: var(--line); }

/* ---------- controls ---------- */

.chip { border: var(--line); padding: 4px 8px; font-size: 11px; line-height: 1.25; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; background: transparent; }
.chip:hover { background: rgba(255, 255, 255, 0.35); }
.chip.on { background: var(--ink); color: var(--base); }
.chip.primary { background: var(--hot); }
.btn { border: var(--line); padding: 7px 11px; font-size: 11px; }
.btn:hover:not(:disabled) { background: var(--ink); color: var(--base); }
.btn.primary { background: var(--hot); }
.btn.primary:hover:not(:disabled) { background: var(--ink); color: var(--hot); }
.btn:disabled { opacity: 0.35; }
.txt, textarea { width: 100%; min-width: 0; background: rgba(255, 255, 255, 0.35); border: var(--line); border-radius: 0; padding: 5px 8px; font-size: 12px; outline: none; text-transform: none; }
textarea { display: block; resize: vertical; min-height: 64px; line-height: 1.38; font-family: var(--mono); }
.txt:focus, textarea:focus { background: var(--paper); }

#toast {
  position: fixed; top: 74px; left: 50%; transform: translate(-50%, -6px);
  background: var(--ink); color: var(--hot); padding: 8px 13px; font-size: 11px;
  opacity: 0; transition: opacity 0.2s, transform 0.2s; pointer-events: none; z-index: 20; max-width: calc(100% - 32px); text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- smaller laptops ---------- */

@media (max-width: 1180px) {
  .steps { display: none; }
  main { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 230px; }
  .traygrid { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- phone: one column, scrolls ---------- */

@media (max-width: 820px) {
  body { display: block; height: auto; overflow: auto; }
  .top { position: sticky; top: 0; z-index: 10; background: var(--base); padding: 6px 14px; gap: 12px; }
  .logo { font-size: 36px; }
  .title { font-size: 10px; }
  .code { margin-left: auto; }
  .code .txt { width: 74px; }
  body.unlocked .nav { justify-content: center; }
  main { display: block; }
  .col + .col { border-left: 0; border-top: var(--line); }
  .bar { padding: 10px 14px; }
  .chip { padding: 7px 10px; font-size: 12px; }
  #srcStage { flex: none; height: min(56vh, 100vw); }
  .preview { flex: none; height: min(44vh, 86vw); }
  .machine { grid-template-columns: minmax(0, 1fr); padding: 12px 14px; }
  .lever { flex-direction: row; justify-content: space-between; }
  .go { width: 100%; height: 64px; border-radius: 40px; font-size: 20px; }
  .lever { display: grid; grid-template-columns: minmax(0, 1fr); }
  .spins { justify-content: center; }
  .it b { font-size: 15px; }
  .it.pal .sw:nth-child(3) { display: none; }
  .actions { flex-direction: column; align-items: stretch; padding: 0 14px 14px; }
  .actions .btn { padding: 12px; font-size: 13px; }
  .traygrid { grid-template-columns: repeat(2, minmax(0, 1fr)); overflow: visible; padding: 12px 14px; }
  .cbtns button { padding: 9px 0; font-size: 11px; }
  .trayfoot { padding: 12px 14px 28px; }
  #toast { top: 64px; }
}

@media (prefers-reduced-motion: reduce) {
  .go.ready, .card.fresh { animation: none; }
}

/* ---------- jackpot + free play ---------- */

.it.jack b { font-size: 30px; color: var(--hot); -webkit-text-stroke: 1px var(--ink); }
.machine.jackpot-flash { animation: jackflash 0.26s steps(2) 5; }
@keyframes jackflash { 50% { background: #ffe14a; } }
.machine.jackpot-flash .window { background: #ffe14a; }
body.jackpot .code .unl { background: #ffe14a; color: var(--ink); animation: buzz 1s steps(2) infinite; }
body.unlocked .window { cursor: pointer; }
body.unlocked .window::after { content: "▾"; position: absolute; right: 5px; bottom: 2px; font-size: 10px; opacity: 0.5; }
.reel { position: relative; }
.picker {
  position: absolute; left: 0; right: 0; bottom: calc(100% - 14px); z-index: 30;
  max-height: min(56vh, 420px); overflow: auto; background: var(--paper); border: var(--line);
  box-shadow: 0 6px 0 var(--ink); display: flex; flex-direction: column;
}
.picker button { border-bottom: 1px solid rgba(0, 0, 0, 0.15); text-align: left; }
.picker button:hover, .picker button.on { background: var(--ink); color: var(--paper); }
.picker .it { height: 38px; justify-content: flex-start; }
.picker .it b { font-size: 14px; }
@media (max-width: 820px) {
  .picker { position: fixed; left: 14px; right: 14px; bottom: 14px; max-height: 60vh; }
}
