:root {
  --ink: #202224;
  --paper: #f8f1dc;
  --red: #e94337;
  --red-dark: #a52526;
  --yellow: #ffd242;
  --blue: #3d9be9;
  --mint: #b8ddd0;
  --green: #54b878;
  --purple: #8654d2;
  --orange: #f38a38;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; color: var(--ink); background: var(--paper); font-family: "DM Sans", sans-serif; overflow-x: hidden; }
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; }
button:focus-visible, a:focus-visible { outline: 4px solid var(--blue); outline-offset: 3px; }
button:disabled { cursor: default; opacity: .48; }

body[data-theme="berry"] { --red: #8654d2; --red-dark: #573295; --mint: #c8dfef; --yellow: #ffcf4b; }
body[data-theme="mint"] { --red: #2b9a79; --red-dark: #17664f; --mint: #f0c5cf; --yellow: #ffd65b; }

.tile-wall { position: fixed; inset: 0 0 auto; height: 61vh; z-index: -2; background-color: var(--mint); background-image: linear-gradient(rgba(255,255,255,.35) 1px,transparent 1px),linear-gradient(90deg,rgba(255,255,255,.35) 1px,transparent 1px); background-size: 42px 42px; border-bottom: 5px solid var(--ink); transition: background-color .3s; }
.tile-wall::after { content: ""; position: absolute; inset: auto 0 -39vh; height: 39vh; background-color: #f3e8c8; background-image: linear-gradient(45deg,#e7d8b1 25%,transparent 25%),linear-gradient(-45deg,#e7d8b1 25%,transparent 25%),linear-gradient(45deg,transparent 75%,#e7d8b1 75%),linear-gradient(-45deg,transparent 75%,#e7d8b1 75%); background-size: 64px 64px; background-position: 0 0,0 32px,32px -32px,-32px 0; }

.topbar { height: 88px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 0 clamp(18px,4vw,58px); border-bottom: 3px solid var(--ink); background: rgba(248,241,220,.94); backdrop-filter: blur(10px); position: relative; z-index: 20; }
.brand { display: inline-flex; width: fit-content; align-items: center; gap: 11px; color: var(--ink); text-decoration: none; font: 800 19px/.82 "Baloo 2",sans-serif; }
.brand-mark { width: 46px; height: 46px; position: relative; display: block; }
.brand-mark i { position: absolute; width: 23px; height: 23px; border: 2px solid var(--ink); border-radius: 50%; }
.brand-mark i:nth-child(1) { left: 2px; top: 3px; background: var(--red); }
.brand-mark i:nth-child(2) { right: 1px; top: 8px; background: var(--yellow); }
.brand-mark i:nth-child(3) { left: 11px; bottom: 1px; background: var(--blue); }
.top-stats { display: flex; height: 58px; border: 2px solid var(--ink); background: #fffaf0; box-shadow: 4px 4px 0 var(--ink); }
.stat { min-width: 114px; display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 4px 18px; border-right: 2px solid var(--ink); }
.stat:last-child { border: 0; }
.stat span { font-size: 10px; font-weight: 800; text-transform: uppercase; }
.stat strong { font: 800 25px/1 "Baloo 2",sans-serif; }
.timer-stat { background: var(--yellow); }
.timer-stat.warning { background: var(--red); color: white; animation: tick .65s infinite alternate; }
.header-actions { display: flex; justify-content: flex-end; gap: 8px; }
.icon-button { width: 42px; height: 42px; border: 2px solid var(--ink); background: #fffaf0; display: grid; place-items: center; cursor: pointer; box-shadow: 3px 3px 0 var(--ink); transition: transform .15s,box-shadow .15s; }
.icon-button:hover { transform: translate(-1px,-1px); box-shadow: 4px 4px 0 var(--ink); }
.icon-button:active { transform: translate(2px,2px); box-shadow: 1px 1px 0 var(--ink); }
.icon-button svg { width: 19px; }

.game-shell { width: min(1160px,calc(100% - 34px)); margin: 0 auto; min-height: calc(100vh - 88px); display: grid; grid-template-columns: minmax(520px,1fr) 330px; align-items: center; gap: clamp(30px,5vw,72px); padding: 24px 0 42px; }
.machine-stage { min-height: 790px; display: flex; flex-direction: column; align-items: center; justify-content: center; position: relative; }
.machine { position: relative; width: 430px; height: 613px; filter: drop-shadow(0 15px 0 rgba(56,54,44,.14)); z-index: 2; transition: filter .25s; }
.machine-cap { position: absolute; z-index: 5; top: 0; left: 74px; width: 282px; height: 73px; border: 4px solid var(--ink); border-radius: 50% 50% 8px 8px; background: var(--red); box-shadow: inset 0 -11px 0 var(--red-dark); display: grid; place-items: center; transition: background .3s,box-shadow .3s; }
.machine-cap::before { content: ""; position: absolute; width: 16px; height: 27px; background: #f7d86b; border: 3px solid var(--ink); border-radius: 4px; top: -20px; }
.machine-cap span { color: white; font: 800 19px "Baloo 2",sans-serif; letter-spacing: 0; text-shadow: 2px 2px 0 var(--ink); margin-top: 3px; }
.globe-wrap { position: absolute; top: 37px; left: 31px; width: 368px; height: 365px; overflow: hidden; border: 5px solid var(--ink); border-radius: 47% 47% 42% 42%; background: rgba(225,247,247,.76); box-shadow: inset 0 0 0 9px rgba(255,255,255,.3); }
#globeCanvas { width: 100%; height: 100%; display: block; }
.glass-shine { position: absolute; left: 47px; top: 44px; width: 35px; height: 118px; border-radius: 50%; background: rgba(255,255,255,.62); transform: rotate(18deg); pointer-events: none; }
.intake-marker { position: absolute; z-index: 3; left: 50%; bottom: 2px; width: 82px; height: 34px; transform: translateX(-50%); border: 3px solid var(--ink); border-bottom: 0; border-radius: 50% 50% 0 0; background: rgba(32,34,36,.2); pointer-events: none; }
.intake-marker i { position: absolute; left: 50%; bottom: 5px; width: 16px; height: 16px; border: 3px solid var(--ink); border-radius: 50%; background: var(--yellow); transform: translateX(-50%); animation: intakePulse 1s infinite alternate; }
.neck { position: absolute; z-index: 1; left: 80px; top: 353px; width: 270px; height: 55px; background: var(--red-dark); border: 4px solid var(--ink); }
.machine-body { position: absolute; z-index: 4; left: 51px; top: 382px; width: 328px; height: 194px; background: var(--red); border: 5px solid var(--ink); border-radius: 8px 8px 25px 25px; box-shadow: inset 0 -12px 0 var(--red-dark); transition: background .3s,box-shadow .3s; }
.machine-body::before,.machine-body::after { content: ""; position: absolute; top: 20px; bottom: 30px; width: 10px; border-radius: 8px; background: rgba(255,255,255,.18); }
.machine-body::before { left: 17px; }
.machine-body::after { right: 17px; }
.coin-slot { position: absolute; left: 38px; top: 27px; width: 68px; height: 80px; border-radius: 6px; border: 3px solid var(--ink); background: #e8e1cd; box-shadow: inset 5px 5px 0 rgba(255,255,255,.5),3px 3px 0 var(--red-dark); text-align: center; }
.coin-slot span { font: 800 14px/34px "Baloo 2"; }
.coin-slot i { display: block; width: 11px; height: 30px; margin: -2px auto; border-radius: 5px; background: var(--ink); box-shadow: inset 3px 0 #74716a; }
.knob { position: absolute; left: 128px; top: 30px; width: 72px; height: 72px; border-radius: 50%; border: 4px solid var(--ink); background: #e6dec9; box-shadow: inset 0 0 0 8px #f8f0dd,4px 5px 0 var(--red-dark); cursor: pointer; transition: transform .1s; }
.knob-grip { position: absolute; width: 68px; height: 19px; left: -2px; top: 22px; border: 3px solid var(--ink); border-radius: 5px; background: #f7d55b; box-shadow: inset 0 -5px #d7a82f; }
.machine.turning .knob { animation: turnKnob .55s cubic-bezier(.35,.05,.25,1); }
.machine.shaking { animation: machineShake .45s; }
.machine.nudge-left { animation: nudgeLeft .28s; }
.machine.nudge-right { animation: nudgeRight .28s; }
.chute { position: absolute; left: 122px; top: 113px; width: 83px; height: 55px; border-radius: 8px 8px 19px 19px; background: #e8e1cd; border: 4px solid var(--ink); box-shadow: inset 4px 4px rgba(255,255,255,.55); padding: 9px 11px; }
.chute-dark { width: 100%; height: 100%; position: relative; overflow: hidden; border-radius: 5px 5px 12px 12px; background: #282625; border: 2px solid #111; }
.dispensed-ball { position: absolute; left: 14px; top: -36px; width: 30px; height: 30px; border: 2px solid var(--ink); border-radius: 50%; opacity: 0; box-shadow: inset -6px -7px 0 rgba(0,0,0,.17),inset 5px 5px 0 rgba(255,255,255,.28); }
.dispensed-ball.drop { animation: chuteDrop .75s cubic-bezier(.25,.9,.35,1) forwards; }
.machine-badge { position: absolute; top: 37px; right: 30px; width: 62px; height: 62px; padding-top: 13px; background: var(--yellow); border: 3px solid var(--ink); border-radius: 50%; transform: rotate(9deg); text-align: center; font: 800 11px/1 "Baloo 2"; }
.machine-foot { position: absolute; z-index: 3; left: 35px; bottom: 0; width: 360px; height: 58px; border: 5px solid var(--ink); border-radius: 20px 20px 8px 8px; background: var(--red-dark); }
.machine-foot::before { content: ""; position: absolute; left: 24px; right: 24px; top: 9px; height: 20px; border: 3px solid var(--ink); border-radius: 50%; background: var(--red); }

.skill-controls { z-index: 6; width: min(500px,100%); margin-top: -8px; display: grid; grid-template-columns: 42px 1fr 42px 94px; align-items: end; gap: 8px; }
.control-button,.shake-button { height: 42px; border: 2px solid var(--ink); background: #fffaf0; box-shadow: 3px 3px 0 var(--ink); cursor: pointer; display: flex; align-items: center; justify-content: center; }
.control-button svg { width: 18px; }
.shake-button { gap: 6px; background: var(--blue); color: white; font: 800 12px "Baloo 2"; }
.shake-button svg { width: 17px; }
.timing-control { min-width: 0; }
.timing-label { display: flex; justify-content: space-between; margin-bottom: 4px; font: 800 10px "Baloo 2"; text-transform: uppercase; }
.timing-label strong[data-grade="perfect"] { color: #16865b; }
.timing-label strong[data-grade="risky"] { color: var(--red-dark); }
.timing-track { position: relative; height: 18px; border: 2px solid var(--ink); background: linear-gradient(90deg,#ef7a6f 0 20%,#ffd242 20% 37%,#72ce94 37% 63%,#ffd242 63% 80%,#ef7a6f 80%); }
.timing-track .perfect-zone { position: absolute; inset: 0 auto 0 42%; width: 16%; background: rgba(255,255,255,.3); border-left: 1px solid rgba(32,34,36,.45); border-right: 1px solid rgba(32,34,36,.45); }
.timing-track b { position: absolute; z-index: 2; top: -5px; width: 5px; height: 24px; background: var(--ink); transform: translateX(-50%); }
.shake-meter { grid-column: 4; height: 5px; border: 1px solid var(--ink); background: #ddd4c0; }
.shake-meter i { display: block; width: 100%; height: 100%; background: var(--blue); }
.drop-command { z-index: 5; display: flex; flex-direction: column; align-items: center; margin-top: 14px; }
.drop-command button,.modal-card button { min-width: 220px; height: 54px; border: 3px solid var(--ink); background: var(--yellow); box-shadow: 5px 5px 0 var(--ink); color: var(--ink); cursor: pointer; font: 800 16px "Baloo 2"; display: flex; align-items: center; justify-content: center; gap: 9px; transition: transform .15s,box-shadow .15s; }
.drop-command button:hover,.modal-card button:hover { transform: translate(-2px,-2px); box-shadow: 7px 7px 0 var(--ink); }
.drop-command button:active,.modal-card button:active { transform: translate(3px,3px); box-shadow: 2px 2px 0 var(--ink); }
.drop-command button.active { background: var(--red); color: white; }
.drop-command svg { width: 19px; }
.drop-command p { margin: 10px 0 0; font-size: 11px; font-weight: 700; opacity: .7; }

.game-panel { width: 330px; background: #fffaf0; border: 3px solid var(--ink); box-shadow: 9px 9px 0 var(--ink); align-self: center; }
.panel-heading { height: 46px; display: flex; align-items: center; gap: 9px; padding: 0 15px; border-bottom: 3px solid var(--ink); background: var(--yellow); font: 800 13px "Baloo 2"; text-transform: uppercase; }
.panel-heading strong { margin-left: auto; padding-left: 9px; border-left: 2px solid var(--ink); }
.panel-help { width: 28px; height: 28px; margin-left: auto; padding: 0; border: 0; background: transparent; display: grid; place-items: center; cursor: pointer; }
.panel-help + strong { margin-left: 0; }
.panel-help svg { width: 18px; }
.round-dot { width: 10px; height: 10px; border-radius: 50%; background: #8e8a7e; border: 2px solid var(--ink); }
.round-dot.live { background: #50b96d; box-shadow: 0 0 0 4px rgba(80,185,109,.2); }
.game-panel section { padding: 13px 15px; border-bottom: 2px dashed #9a9588; }
.section-label { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.section-label h2 { margin: 0; font: 800 12px "Baloo 2"; text-transform: uppercase; }
.section-label span { font: 800 12px "Baloo 2"; color: var(--red-dark); }
.mode-tabs { display: grid; grid-template-columns: repeat(3,1fr); border: 2px solid var(--ink); }
.mode-tabs button { height: 32px; border: 0; border-right: 2px solid var(--ink); background: #fffaf0; cursor: pointer; font: 800 11px "Baloo 2"; }
.mode-tabs button:last-child { border: 0; }
.mode-tabs button.selected { background: var(--yellow); }
.mode-tabs button:disabled { opacity: .66; }
.order-queue { border: 2px solid var(--ink); }
.queue-order { min-height: 45px; display: grid; grid-template-columns: 22px 48px 1fr auto; align-items: center; gap: 7px; padding: 5px 8px; border-bottom: 1px solid #bdb5a4; background: #fffaf0; }
.queue-order:last-child { border: 0; }
.queue-order.primary { min-height: 54px; background: #f6e8ba; }
.queue-rank { font: 800 11px "Baloo 2"; opacity: .55; }
.queue-balls { display: flex; align-items: center; }
.queue-ball { width: 26px; height: 26px; margin-right: -6px; border: 2px solid var(--ink); border-radius: 50%; background: var(--ball); box-shadow: inset -4px -4px rgba(0,0,0,.15),inset 4px 4px rgba(255,255,255,.28); }
.queue-ball.done { opacity: .28; }
.queue-order strong,.queue-order small { display: block; }
.queue-order strong { font: 800 11px "Baloo 2"; text-transform: uppercase; }
.queue-order small { font-size: 9px; opacity: .65; }
.queue-order > b { font: 800 11px "Baloo 2"; color: var(--red-dark); }
.combo-track { display: grid; grid-template-columns: repeat(5,1fr); gap: 5px; }
.combo-track i { height: 12px; background: #e4ddcc; border: 2px solid var(--ink); }
.combo-track i.on { background: var(--orange); }
.round-phase { margin-top: 8px; display: grid; grid-template-columns: 70px 1fr; align-items: center; gap: 8px; font: 800 9px "Baloo 2"; text-transform: uppercase; }
.round-phase > i { height: 6px; background: #ddd5c5; border: 1px solid var(--ink); }
.round-phase b { display: block; width: 0; height: 100%; background: var(--red); transition: width .25s; }
.power-slot { width: 100%; min-height: 48px; border: 2px solid var(--ink); background: #e8e0cd; display: grid; grid-template-columns: 32px 1fr; align-items: center; gap: 9px; padding: 7px 10px; text-align: left; }
.power-slot.ready { background: var(--blue); color: white; cursor: pointer; box-shadow: 3px 3px 0 var(--ink); opacity: 1; }
.power-slot svg { width: 22px; }
.power-slot strong,.power-slot small { display: block; }
.power-slot strong { font: 800 12px "Baloo 2"; }
.power-slot small { font-size: 9px; line-height: 1.25; }
.collection-grid { display: grid; grid-template-columns: repeat(8,1fr); gap: 4px; }
.collection-grid div { aspect-ratio: 1; min-width: 0; display: grid; place-items: center; background: #e8e0cd; border: 1px solid var(--ink); box-shadow: inset 0 3px rgba(0,0,0,.06); }
.collection-grid span { display: block; width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--ink); box-shadow: inset -5px -5px rgba(0,0,0,.16),inset 4px 4px rgba(255,255,255,.25); animation: popIn .35s cubic-bezier(.2,1.6,.4,1); }
.gold-note { min-height: 58px; display: flex; align-items: center; gap: 12px; padding: 10px 15px; background: #27282a; color: white; }
.gold-note p { margin: 0; font-size: 9px; line-height: 1.35; }
.gold-note strong { color: var(--yellow); font-size: 11px; }
.mini-gold { flex: 0 0 auto; width: 29px; height: 29px; border: 2px solid #111; border-radius: 50%; background: #f6c83c; box-shadow: inset -5px -6px #c8891e,inset 5px 5px rgba(255,255,255,.38); }

.burst { position: absolute; z-index: 0; width: 140px; height: 140px; opacity: .48; background: repeating-conic-gradient(var(--yellow) 0 8deg,transparent 8deg 17deg); clip-path: polygon(50% 0,56% 38%,79% 8%,66% 42%,100% 31%,69% 49%,99% 66%,64% 58%,78% 94%,56% 64%,50% 100%,44% 63%,20% 94%,36% 58%,0 68%,32% 50%,1% 32%,37% 42%,21% 7%,44% 38%); }
.burst-left { left: 1%; top: 22%; transform: rotate(-17deg); }
.burst-right { right: 0; bottom: 19%; transform: rotate(23deg); background: repeating-conic-gradient(var(--blue) 0 8deg,transparent 8deg 17deg); }
.toast { position: fixed; z-index: 70; left: 50%; top: 104px; transform: translate(-50%,-20px); min-width: 170px; padding: 10px 18px; border: 3px solid var(--ink); background: white; box-shadow: 5px 5px 0 var(--ink); opacity: 0; pointer-events: none; text-align: center; font: 800 14px "Baloo 2"; }
.toast.show { animation: toastUp 1.15s both; }
.toast.match { background: var(--yellow); }
.toast.perfect { background: #65cb8b; }
.toast.miss { background: #fffaf0; }
.toast.gold { background: #27282a; color: var(--yellow); }
.toast.power { background: var(--blue); color: white; }
.achievement-pop { position: fixed; z-index: 75; right: 22px; top: 108px; display: flex; align-items: center; gap: 10px; width: 245px; padding: 11px 13px; border: 3px solid var(--ink); background: var(--yellow); box-shadow: 5px 5px 0 var(--ink); transform: translateX(calc(100% + 40px)); }
.achievement-pop.show { animation: achievementIn 3.2s both; }
.achievement-pop svg { width: 24px; }
.achievement-pop small,.achievement-pop strong { display: block; }
.achievement-pop small { font: 800 9px "Baloo 2"; }
.achievement-pop strong { font: 800 12px "Baloo 2"; }

.rules-modal { position: fixed; z-index: 79; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(32,34,36,.74); backdrop-filter: blur(5px); opacity: 0; pointer-events: none; transition: opacity .2s; }
.rules-modal.open { opacity: 1; pointer-events: auto; }
.rules-sheet { width: min(720px,100%); max-height: min(760px,calc(100vh - 40px)); overflow-y: auto; border: 4px solid var(--ink); background: #fffaf0; box-shadow: 11px 11px 0 var(--yellow); }
.rules-heading { min-height: 82px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 15px 18px; border-bottom: 3px solid var(--ink); background: var(--yellow); }
.rules-heading span { display: block; font: 800 10px "Baloo 2"; color: var(--red-dark); }
.rules-heading h2 { margin: 0; font: 800 27px/1 "Baloo 2"; }
.rules-heading button { flex: 0 0 auto; width: 38px; height: 38px; padding: 0; border: 2px solid var(--ink); background: #fffaf0; box-shadow: 3px 3px 0 var(--ink); display: grid; place-items: center; cursor: pointer; }
.rules-heading svg { width: 19px; }
.rules-grid { display: grid; grid-template-columns: repeat(2,1fr); }
.rules-grid section { min-height: 138px; padding: 16px 18px; border-right: 1px solid #b9b09e; border-bottom: 1px solid #b9b09e; }
.rules-grid section:nth-child(2n) { border-right: 0; }
.rules-grid h3 { margin: 0 0 5px; font: 800 14px "Baloo 2"; text-transform: uppercase; }
.rules-grid p { margin: 0; font-size: 12px; line-height: 1.5; }
.rules-controls { display: flex; flex-wrap: wrap; gap: 8px 18px; padding: 13px 18px; background: #27282a; color: white; font-size: 10px; font-weight: 700; }
.rules-controls span { display: inline-flex; align-items: center; gap: 5px; }
kbd { min-width: 24px; height: 24px; padding: 3px 6px; border: 1px solid white; background: #444648; box-shadow: 0 2px 0 #111; color: white; font: 800 11px "DM Sans"; text-align: center; }

.modal { position: fixed; z-index: 80; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(32,34,36,.74); backdrop-filter: blur(5px); opacity: 0; pointer-events: none; transition: opacity .2s; }
.modal.open { opacity: 1; pointer-events: auto; }
.modal-card { width: min(410px,100%); padding: 25px; border: 4px solid var(--ink); background: #fffaf0; box-shadow: 11px 11px 0 var(--yellow); text-align: center; transform: translateY(16px) rotate(-1deg); transition: transform .28s cubic-bezier(.2,1.2,.4,1); }
.modal.open .modal-card { transform: translateY(0) rotate(-1deg); }
.modal-kicker { font: 800 11px "Baloo 2"; color: var(--red-dark); }
.modal-card h2 { margin: 2px 0 14px; font: 800 36px/1 "Baloo 2"; }
.final-score { padding: 13px; border: 3px solid var(--ink); background: var(--yellow); margin-bottom: 10px; }
.final-score span,.final-score strong,.final-score small { display: block; }
.final-score span { font-size: 10px; font-weight: 800; text-transform: uppercase; }
.final-score strong { font: 800 40px/1 "Baloo 2"; }
.final-score small { margin-top: 3px; font: 800 9px "Baloo 2"; }
.result-grid { display: grid; grid-template-columns: repeat(2,1fr); border: 2px solid var(--ink); }
.result-grid div { padding: 8px; border-right: 1px solid var(--ink); border-bottom: 1px solid var(--ink); }
.result-grid div:nth-child(2n) { border-right: 0; }
.result-grid div:nth-last-child(-n+2) { border-bottom: 0; }
.result-grid span,.result-grid strong { display: block; }
.result-grid span { font-size: 9px; text-transform: uppercase; }
.result-grid strong { font: 800 18px "Baloo 2"; }
.next-goal { margin-top: 10px; padding: 9px; background: #e8e0cd; text-align: left; }
.next-goal span,.next-goal strong { display: block; }
.next-goal span { font-size: 9px; text-transform: uppercase; }
.next-goal strong { font: 800 12px "Baloo 2"; }
.modal-card button { width: 100%; margin-top: 16px; }
.confetti { position: fixed; z-index: 77; width: 10px; height: 16px; top: -20px; pointer-events: none; animation: confettiFall 1.8s linear forwards; }

@keyframes turnKnob { 0%{transform:rotate(0)}55%{transform:rotate(190deg)}100%{transform:rotate(360deg)} }
@keyframes chuteDrop { 0%{opacity:1;transform:translateY(0) scale(.7)}65%{opacity:1;transform:translateY(36px) scale(1)}100%{opacity:0;transform:translateY(52px) scale(1)} }
@keyframes popIn { from{transform:scale(0) rotate(-30deg)}to{transform:scale(1) rotate(0)} }
@keyframes toastUp { 0%{opacity:0;transform:translate(-50%,-18px) scale(.8)}18%,76%{opacity:1;transform:translate(-50%,0) scale(1)}100%{opacity:0;transform:translate(-50%,-8px)} }
@keyframes achievementIn { 0%,100%{transform:translateX(calc(100% + 40px))}12%,82%{transform:translateX(0)} }
@keyframes tick { to{transform:scale(1.04)} }
@keyframes intakePulse { to{transform:translateX(-50%) scale(1.16);background:#fff} }
@keyframes machineShake { 0%,100%{transform:translateX(0) rotate(0)}20%{transform:translateX(-9px) rotate(-1deg)}40%{transform:translateX(8px) rotate(1deg)}60%{transform:translateX(-6px)}80%{transform:translateX(4px)} }
@keyframes nudgeLeft { 50%{transform:translateX(-9px) rotate(-.7deg)} }
@keyframes nudgeRight { 50%{transform:translateX(9px) rotate(.7deg)} }
@keyframes confettiFall { to{transform:translate(var(--drift),105vh) rotate(740deg)} }

@media (max-width: 900px) {
  .topbar { height: 76px; }
  .stat { min-width: 96px; padding: 4px 12px; }
  .game-shell { grid-template-columns: 1fr; width: min(600px,calc(100% - 24px)); padding-bottom: 90px; gap: 20px; }
  .machine-stage { min-height: 770px; }
  .game-panel { width: 100%; }
  .order-queue { display: grid; grid-template-columns: 1.3fr 1fr 1fr; }
  .queue-order { border-bottom: 0; border-right: 1px solid #bdb5a4; grid-template-columns: 18px 40px 1fr; }
  .queue-order:last-child { border-right: 0; }
  .queue-order > b { display: none; }
  .header-actions .icon-button:last-child { display: none; }
}

@media (max-width: 560px) {
  .topbar { display: flex; justify-content: center; padding: 0 10px; }
  .brand,.header-actions { display: none; }
  .top-stats { width: calc(100% - 12px); }
  .stat { flex: 1; min-width: 0; }
  .stat strong { font-size: 21px; }
  .game-shell { width: 100%; padding-top: 10px; }
  .machine-stage { min-height: 660px; overflow: hidden; }
  .machine { transform: scale(.78); transform-origin: center top; height: 478px; }
  .skill-controls { width: calc(100% - 24px); grid-template-columns: 40px 1fr 40px 82px; margin-top: -1px; }
  .shake-button { font-size: 10px; }
  .drop-command { margin-top: 11px; }
  .drop-command button { min-width: 205px; }
  .game-panel { width: calc(100% - 24px); }
  .order-queue { display: block; }
  .queue-order { border-right: 0; border-bottom: 1px solid #bdb5a4; grid-template-columns: 22px 48px 1fr auto; }
  .queue-order:last-child { border-bottom: 0; }
  .queue-order > b { display: block; }
  .collection-grid span { width: 22px; height: 22px; }
  .burst { display: none; }
  .toast { top: 84px; max-width: calc(100% - 28px); font-size: 12px; }
  .achievement-pop { top: 84px; right: 14px; width: calc(100% - 28px); }
  .rules-modal { padding: 12px; }
  .rules-sheet { max-height: calc(100vh - 24px); }
  .rules-heading { min-height: 70px; padding: 12px 14px; }
  .rules-heading h2 { font-size: 23px; }
  .rules-grid { grid-template-columns: 1fr; }
  .rules-grid section { min-height: 0; padding: 13px 14px; border-right: 0; }
  .rules-controls { padding: 12px 14px; gap: 8px 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *,*::before,*::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}
