:root {
  --cyan: #3df2ff;
  --magenta: #ff3fd1;
  --violet: #8b5cff;
  --bg: #05060d;
  --font: "Orbitron", "Arial Black", Impact, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: #e8f0ff; font-family: var(--font); overflow: hidden; touch-action: none; -webkit-user-select: none; user-select: none; }
#wrap { position: fixed; inset: 0; }
#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#touch { position: absolute; inset: 0; z-index: 2; }
#vignette { position: absolute; inset: 0; pointer-events: none; z-index: 3; background: radial-gradient(ellipse at center, rgba(0,0,0,0) 55%, rgba(0,0,0,0.55) 100%); }

#hud { position: absolute; top: max(10px, env(safe-area-inset-top)); left: 14px; right: 14px; display: flex; justify-content: space-between; align-items: flex-start; z-index: 5; pointer-events: none; }
.hud-block { display: flex; flex-direction: column; gap: 4px; }
.hud-block.right { align-items: flex-end; margin-right: 96px; }
.hud-label { font-size: 11px; letter-spacing: 3px; color: var(--cyan); opacity: 0.8; }
.hud-value { font-size: clamp(22px, 4vw, 34px); font-weight: 900; letter-spacing: 1px; text-shadow: 0 0 14px rgba(61,242,255,0.6), 0 2px 4px #000; font-variant-numeric: tabular-nums; }
.hud-chip { font-size: 12px; font-weight: 700; letter-spacing: 2px; padding: 5px 10px; border: 1px solid rgba(61,242,255,0.5); border-radius: 999px; background: rgba(5,6,13,0.55); color: #cfe9ff; text-shadow: 0 0 8px rgba(61,242,255,0.5); }
.hud-chip.hot { border-color: var(--magenta); color: #ffd0f4; text-shadow: 0 0 10px var(--magenta); }
#toast { position: absolute; left: 50%; top: 18%; transform: translate(-50%, -10px); z-index: 6; pointer-events: none; padding: 8px 16px; border-radius: 10px; background: rgba(5,6,13,0.7); border: 1px solid rgba(255,63,209,0.6); color: #ffd0f4; font-size: 13px; letter-spacing: 1px; opacity: 0; transition: opacity 0.25s, transform 0.25s; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

.topbtns { position: absolute; top: max(10px, env(safe-area-inset-top)); right: 14px; display: flex; gap: 8px; z-index: 7; }
.iconbtn { width: 40px; height: 40px; border-radius: 10px; border: 1px solid rgba(61,242,255,0.4); background: rgba(5,6,13,0.6); color: #fff; font-size: 18px; cursor: pointer; }
.iconbtn:active { background: rgba(61,242,255,0.25); }

#power { position: absolute; right: 18px; bottom: calc(150px + env(safe-area-inset-bottom)); width: 14px; height: 140px; border: 1px solid rgba(61,242,255,0.6); border-radius: 8px; background: rgba(5,6,13,0.6); z-index: 6; overflow: hidden; opacity: 0; transition: opacity 0.15s; pointer-events: none; }
#power.on { opacity: 1; }
#powerFill { position: absolute; left: 0; right: 0; bottom: 0; height: 0%; background: linear-gradient(to top, var(--cyan), var(--magenta)); box-shadow: 0 0 12px var(--cyan); }
.bigbtn { position: absolute; right: 18px; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 6; width: 118px; height: 118px; border-radius: 50%; border: 2px solid var(--cyan); background: radial-gradient(circle at 30% 30%, rgba(61,242,255,0.35), rgba(5,6,13,0.85)); color: #fff; font-family: var(--font); font-weight: 900; font-size: 13px; letter-spacing: 1px; line-height: 1.3; box-shadow: 0 0 24px rgba(61,242,255,0.45); cursor: pointer; touch-action: none; }
.bigbtn small { font-weight: 500; font-size: 10px; opacity: 0.8; }
.bigbtn:active { transform: scale(0.96); }
.smallbtn { position: absolute; left: 18px; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 6; padding: 12px 16px; border-radius: 999px; border: 1px solid rgba(255,63,209,0.7); background: rgba(5,6,13,0.7); color: #ffd0f4; font-family: var(--font); font-weight: 700; font-size: 12px; letter-spacing: 2px; cursor: pointer; touch-action: none; }
.smallbtn:active { background: rgba(255,63,209,0.3); }
.hidden { display: none !important; }

#loader { position: absolute; inset: 0; z-index: 20; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; background: var(--bg); color: var(--cyan); letter-spacing: 2px; font-size: 13px; }
.spinner { width: 46px; height: 46px; border-radius: 50%; border: 3px solid rgba(61,242,255,0.2); border-top-color: var(--cyan); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.overlay { position: absolute; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center; padding: 20px; background: rgba(3,4,10,0.55); backdrop-filter: blur(4px); }
.panel { width: min(520px, 100%); max-height: 92vh; overflow: auto; padding: 28px 26px; border-radius: 18px; background: linear-gradient(160deg, rgba(14,18,40,0.92), rgba(6,7,16,0.94)); border: 1px solid rgba(61,242,255,0.35); box-shadow: 0 0 60px rgba(61,242,255,0.15), 0 30px 80px rgba(0,0,0,0.6); text-align: center; }
.logo { margin: 0; font-size: clamp(56px, 12vw, 96px); font-weight: 900; letter-spacing: 8px; color: #eaffff; text-shadow: 0 0 18px var(--cyan), 0 0 50px var(--cyan), 0 0 90px rgba(61,242,255,0.5); }
.sub { margin: 6px 0 18px; color: #b9c8ea; font-size: 13px; letter-spacing: 1px; line-height: 1.5; }
.howto { text-align: left; display: grid; gap: 8px; margin-bottom: 20px; }
.ht { font-size: 12px; line-height: 1.5; color: #cdd8f5; font-family: system-ui, sans-serif; }
.ht b { color: var(--cyan); font-family: var(--font); letter-spacing: 1px; }
.kbd { display: inline-block; padding: 1px 7px; border: 1px solid rgba(255,255,255,0.35); border-bottom-width: 3px; border-radius: 6px; font-family: var(--font); font-size: 11px; color: #fff; background: rgba(255,255,255,0.06); }
.btn { padding: 14px 30px; border-radius: 12px; border: 1px solid var(--cyan); background: linear-gradient(135deg, rgba(61,242,255,0.35), rgba(139,92,255,0.35)); color: #fff; font-family: var(--font); font-weight: 900; font-size: 16px; letter-spacing: 3px; cursor: pointer; box-shadow: 0 0 24px rgba(61,242,255,0.35); transition: transform 0.1s, box-shadow 0.1s; }
.btn:hover { transform: translateY(-1px); box-shadow: 0 0 34px rgba(61,242,255,0.55); }
.btn.ghost { background: transparent; border-color: rgba(255,255,255,0.3); box-shadow: none; }
.best { margin: 14px 0 0; font-size: 12px; letter-spacing: 2px; color: var(--magenta); }
.grade { margin: 0 0 8px; font-size: 34px; letter-spacing: 4px; color: #ffd0f4; text-shadow: 0 0 20px var(--magenta); }
.r-score { margin: 0; font-size: clamp(36px, 8vw, 56px); font-weight: 900; color: #fff; text-shadow: 0 0 20px var(--cyan); }
.r-text { color: #b9c8ea; font-size: 13px; letter-spacing: 2px; margin: 8px 0 20px; }
.row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

@media (max-width: 640px) {
  .hud-block.right { margin-right: 92px; }
  .panel { padding: 20px 16px; }
  .howto { gap: 6px; }
}
@media (hover: hover) and (pointer: fine) {
  #nudge { display: none; }
}
