:root {
  --ink: #1b1340;
  --gold: #ffd23a;
  --gold-deep: #f49b00;
  --pink: #ff3f8e;
  --cyan: #29d3ff;
  --lime: #9cff3a;
  --font: "Arial Black", "Arial Rounded MT Bold", "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #7fd4ff; touch-action: none; user-select: none; -webkit-user-select: none; }
#app { position: fixed; inset: 0; font-family: var(--font); color: #fff; }
#c { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }

#flash { position: absolute; inset: 0; pointer-events: none; opacity: 0; background: radial-gradient(ellipse at center, rgba(255,255,255,0) 40%, rgba(255,40,60,.75) 100%); }

/* ---------- HUD ---------- */
#hud { position: absolute; inset: 0; pointer-events: none; padding: max(12px, env(safe-area-inset-top)) 14px 14px; }
.hud-top { display: flex; justify-content: space-between; align-items: flex-start; }
.hud-right { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.score-row { display: flex; align-items: center; gap: 8px; }
.score { font-size: clamp(26px, 5.2vmin, 44px); letter-spacing: 1px; text-shadow: 0 3px 0 var(--ink), 0 0 2px var(--ink), 2px 2px 0 var(--ink), -2px 2px 0 var(--ink); font-variant-numeric: tabular-nums; }
.mult { font-size: clamp(15px, 2.8vmin, 22px); padding: 3px 10px 4px; border-radius: 999px; background: linear-gradient(#ff7ab0, var(--pink)); box-shadow: 0 3px 0 #9b1452, inset 0 2px 0 rgba(255,255,255,.4); text-shadow: 0 2px 0 #7d0f41; transition: transform .15s; }
.mult.hot { background: linear-gradient(#b6ff6b, #39c900); box-shadow: 0 3px 0 #1d6e00, inset 0 2px 0 rgba(255,255,255,.5); text-shadow: 0 2px 0 #1d6e00; }
.coin-row { display: flex; align-items: center; gap: 7px; font-size: clamp(18px, 3.4vmin, 28px); padding: 3px 12px 4px 5px; border-radius: 999px; background: rgba(27,19,64,.55); text-shadow: 0 2px 0 var(--ink); font-variant-numeric: tabular-nums; }
.coin-ico { width: 1.15em; height: 1.15em; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff6b0 0 18%, var(--gold) 19% 55%, var(--gold-deep) 56% 100%); box-shadow: inset 0 0 0 2px #c77700; }
.bump { animation: bump .22s ease-out; }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.22); } 100% { transform: scale(1); } }

.icon-btn { pointer-events: auto; width: 44px; height: 44px; border-radius: 14px; border: 0; background: rgba(27,19,64,.55); display: grid; place-items: center; cursor: pointer; box-shadow: 0 3px 0 rgba(0,0,0,.25); }
.icon-btn svg { width: 22px; height: 22px; fill: #fff; }

.timers { position: absolute; left: 14px; bottom: max(18px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 8px; }
.timer { display: flex; align-items: center; gap: 8px; animation: slideIn .3s cubic-bezier(.2,1.6,.4,1); }
.timer .ico { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; box-shadow: 0 3px 0 rgba(0,0,0,.3), inset 0 2px 0 rgba(255,255,255,.35); }
.timer .ico svg { width: 26px; height: 26px; }
.timer .bar { width: clamp(90px, 22vmin, 160px); height: 12px; border-radius: 99px; background: rgba(27,19,64,.6); overflow: hidden; box-shadow: inset 0 0 0 2px rgba(255,255,255,.25); }
.timer .bar i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(#fff 0 25%, currentColor 26%); }
.timer.ending .ico { animation: blink .25s steps(2) infinite; }
@keyframes blink { 50% { opacity: .35; } }
@keyframes slideIn { from { transform: translateX(-120%); } to { transform: none; } }

.toast { position: absolute; left: 50%; top: 22%; transform: translate(-50%, 0) scale(.6); font-size: clamp(28px, 7vmin, 56px); opacity: 0; white-space: nowrap; text-shadow: 0 4px 0 var(--ink), 3px 3px 0 var(--ink), -3px 3px 0 var(--ink); }
.toast.show { animation: toast 1.1s cubic-bezier(.2,1.5,.4,1) forwards; }
@keyframes toast { 0% { opacity: 0; transform: translate(-50%, 20px) scale(.5); } 18% { opacity: 1; transform: translate(-50%, 0) scale(1.08); } 30% { transform: translate(-50%, 0) scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -30px) scale(1); } }
.hint { position: absolute; left: 50%; bottom: 24%; transform: translateX(-50%); font-size: clamp(18px, 3.8vmin, 30px); padding: 10px 20px 12px; border-radius: 18px; background: rgba(27,19,64,.6); opacity: 0; transition: opacity .25s; text-align: center; white-space: nowrap; }
.hint.show { opacity: 1; }
.hint b { color: var(--gold); }

/* ---------- Screens ---------- */
.screen { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: max(7vh, env(safe-area-inset-top)) 16px max(6vh, env(safe-area-inset-bottom)); pointer-events: auto; }
#title { background: linear-gradient(180deg, rgba(20,10,70,.35) 0%, rgba(20,10,70,0) 30%, rgba(20,10,70,0) 62%, rgba(20,10,70,.55) 100%); cursor: pointer; }
.logo { text-align: center; transform: rotate(-4deg); filter: drop-shadow(0 8px 0 rgba(27,19,64,.6)); animation: logoIn .7s cubic-bezier(.2,1.6,.4,1); }
@keyframes logoIn { from { transform: rotate(-4deg) scale(.4); opacity: 0; } to { transform: rotate(-4deg) scale(1); opacity: 1; } }
.logo-top, .logo-bottom { line-height: .86; letter-spacing: 2px; -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; }
.logo-top { font-size: clamp(54px, 13vmin, 120px); color: var(--cyan); text-shadow: 0 7px 0 var(--ink); }
.logo-bottom { font-size: clamp(76px, 19vmin, 172px); background: linear-gradient(#fff36b 0 30%, var(--gold) 31% 60%, #ff8a00 61%); -webkit-background-clip: text; background-clip: text; color: transparent; -webkit-text-stroke: 4px var(--ink); filter: drop-shadow(0 8px 0 var(--ink)); margin-top: -4px; }
.logo-tag { display: inline-block; margin-top: 10px; font-size: clamp(13px, 2.6vmin, 20px); padding: 6px 14px 7px; border-radius: 10px; background: var(--pink); box-shadow: 0 4px 0 #8e0f48; letter-spacing: 3px; transform: rotate(2deg); }
.title-bottom { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.best-line { font-size: clamp(14px, 2.6vmin, 20px); text-shadow: 0 2px 0 var(--ink); opacity: .95; }
.play-btn { pointer-events: auto; font-family: var(--font); font-size: clamp(22px, 4.6vmin, 36px); color: #fff; border: 0; border-radius: 22px; padding: 16px 38px 19px; cursor: pointer; background: linear-gradient(#b6ff6b, #4ad400 55%, #2fae00); box-shadow: 0 7px 0 #1d6e00, 0 12px 24px rgba(0,0,0,.25), inset 0 3px 0 rgba(255,255,255,.55); text-shadow: 0 3px 0 #1d6e00; letter-spacing: 1px; animation: pulse 1.2s ease-in-out infinite; }
.play-btn:active { transform: translateY(4px); box-shadow: 0 3px 0 #1d6e00, inset 0 3px 0 rgba(255,255,255,.55); }
@keyframes pulse { 50% { transform: scale(1.06); } }
.ghost-btn { pointer-events: auto; font-family: var(--font); font-size: 16px; color: #fff; background: rgba(255,255,255,.15); border: 2px solid rgba(255,255,255,.5); border-radius: 14px; padding: 10px 20px; cursor: pointer; }
.controls-hint { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 14px; font-size: clamp(12px, 2.2vmin, 16px); font-family: Arial, sans-serif; font-weight: 700; text-shadow: 0 2px 0 rgba(27,19,64,.8); }
.controls-hint b { display: inline-block; min-width: 1.6em; padding: 1px 5px; border-radius: 6px; background: rgba(255,255,255,.9); color: var(--ink); text-shadow: none; text-align: center; }
.touch-only { display: none; }
@media (pointer: coarse) { .touch-only { display: inline; } }

#paused, #over { justify-content: center; background: rgba(20,10,60,.45); }
.panel { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 26px 22px 24px; border-radius: 28px; background: linear-gradient(#3b2a8f, #24186a); box-shadow: 0 10px 0 #140c45, 0 20px 40px rgba(0,0,0,.35), inset 0 3px 0 rgba(255,255,255,.18); width: min(92vw, 440px); }
.panel-title { font-size: 40px; text-shadow: 0 4px 0 #140c45; }
.over-panel { animation: panelIn .45s cubic-bezier(.2,1.5,.4,1); }
@keyframes panelIn { from { transform: translateY(40px) scale(.8); opacity: 0; } to { transform: none; opacity: 1; } }
.over-title { font-size: clamp(44px, 11vmin, 64px); color: var(--gold); -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; text-shadow: 0 5px 0 var(--ink); transform: rotate(-3deg); }
.over-sub { font-family: Arial, sans-serif; font-weight: 700; font-size: 16px; opacity: .85; margin-top: -6px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; width: 100%; }
.stat { background: rgba(0,0,0,.25); border-radius: 16px; padding: 10px 4px 12px; text-align: center; }
.stat-k { font-family: Arial, sans-serif; font-weight: 800; font-size: 12px; letter-spacing: 2px; opacity: .7; }
.stat-v { font-size: clamp(20px, 5vmin, 28px); margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat-v.gold { color: var(--gold); }
.over-best { font-size: 16px; color: var(--lime); min-height: 1.2em; text-shadow: 0 2px 0 #140c45; }
.small-hint { font-family: Arial, sans-serif; font-size: 12px; opacity: .6; }

.loading { position: absolute; left: 50%; bottom: 3vh; transform: translateX(-50%); width: min(60vw, 260px); transition: opacity .4s; pointer-events: none; }
.loading .bar { height: 8px; border-radius: 99px; background: rgba(27,19,64,.5); overflow: hidden; }
.loading i { display: block; height: 100%; width: 0; background: var(--gold); border-radius: 99px; transition: width .2s; }
.loading.done { opacity: 0; }
