:root {
  --bg: #07071a;
  --panel: #10103a;
  --panel2: #181850;
  --line: rgba(140, 160, 255, 0.16);
  --text: #eef0ff;
  --muted: #a3a8d6;
  --pink: #ff5ec8;
  --cyan: #5ef2ff;
  --gold: #ffd24a;
  --header: 52px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: radial-gradient(1200px 700px at 50% -10%, #1d1a5e 0%, var(--bg) 60%) fixed, var(--bg);
  color: var(--text);
  font: 16px/1.65 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
a { color: var(--cyan); }
a:hover { color: #fff; }

.top {
  height: var(--header);
  display: flex; align-items: center; justify-content: space-between;
  max-width: 1100px; margin: 0 auto; padding: 0 16px;
}
.logo {
  display: inline-flex; align-items: center; gap: 9px;
  color: #fff; text-decoration: none; font-weight: 900; font-size: 20px; letter-spacing: .3px;
}
.logo img { width: 28px; height: 28px; }
.logo span { color: var(--pink); }
.top nav { display: flex; gap: 18px; font-size: 14px; font-weight: 600; }
.top nav a { color: var(--muted); text-decoration: none; }
.top nav a:hover { color: #fff; }

.play {
  display: flex; justify-content: center; align-items: flex-start; gap: 28px;
  padding: 0 8px 20px;
}
.game {
  --sh: clamp(420px, min(calc(100svh - var(--header) - 60px), calc((100vw - 16px) * 860 / 480)), 1000px);
  width: calc(var(--sh) * 480 / 860);
  display: flex; flex-direction: column;
}
.hud {
  display: flex; align-items: center; gap: 8px;
  width: 100%; height: 48px; padding: 0 2px 6px;
}
.hud-item {
  display: flex; flex-direction: column; justify-content: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 2px 10px; height: 40px; min-width: 0;
}
.hud-item small { font-size: 10px; font-weight: 700; letter-spacing: 1px; color: var(--muted); line-height: 1.2; }
.hud-item b { font-size: 17px; line-height: 1.15; font-variant-numeric: tabular-nums; white-space: nowrap; }
.hud-score { flex: 1; }
.hud-score b { color: var(--gold); font-size: 20px; }
.hud-btn {
  width: 40px; height: 40px; flex: none;
  display: grid; place-items: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  color: var(--text); cursor: pointer; padding: 0;
}
.hud-btn:hover { background: var(--panel2); }
.hud-btn svg { width: 20px; height: 20px; }
.hud-btn .ico-off { display: none; }
.hud-btn.off .ico-on { display: none; }
.hud-btn.off .ico-off { display: block; }

.stage {
  position: relative;
  container-type: inline-size;
  width: 100%;
  height: var(--sh);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 0 0 1px var(--line), 0 20px 60px rgba(0, 0, 0, .55), 0 0 80px rgba(255, 94, 200, .12);
  touch-action: none;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
.stage canvas { display: block; width: 100%; height: 100%; }
.stage canvas[hidden] { display: none; }
.hud-view { font: 900 13px system-ui, sans-serif; letter-spacing: .5px; }
.hud-view:disabled { opacity: .5; cursor: progress; }

#msg {
  position: absolute; left: 0; right: 0; top: 30%;
  text-align: center; pointer-events: none;
  opacity: 0; transform: scale(.85);
  transition: opacity .25s, transform .25s;
}
#msg.show { opacity: 1; transform: scale(1); }
#msg .m1 {
  font: 900 clamp(26px, 8.5cqw, 44px)/1.05 "Arial Black", Impact, system-ui, sans-serif;
  color: var(--gold);
  -webkit-text-stroke: 1px #2a0a3a;
  text-shadow: 0 0 18px rgba(255, 94, 200, .9), 0 3px 0 #2a0a3a;
}
#msg .m2 { margin-top: 6px; font: 700 15px system-ui, sans-serif; color: #fff; text-shadow: 0 2px 6px #000; }
#hint {
  position: absolute; left: 0; right: 0; top: 56%;
  text-align: center; pointer-events: none;
  font: 800 15px system-ui, sans-serif; color: #fff; text-shadow: 0 2px 8px #000;
  animation: pulse 1.4s ease-in-out infinite;
}
#hint[hidden] { display: none; }
@keyframes pulse { 50% { opacity: .35; } }

#overlay {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  background: rgba(5, 5, 20, 0.62);
  backdrop-filter: blur(2px);
}
#overlay[hidden] { display: none; }
.ov-box { text-align: center; padding: 24px; max-width: 320px; }
.ov-title {
  font: 900 44px/1.05 "Arial Black", Impact, system-ui, sans-serif;
  color: var(--gold); text-shadow: 0 0 22px rgba(255, 94, 200, .7);
  margin-bottom: 12px; text-transform: uppercase;
}
.ov-score { font-size: 40px; font-weight: 900; font-variant-numeric: tabular-nums; }
.ov-text { color: #dfe2ff; margin: 8px 0 18px; font-size: 15px; }
.ov-text b {
  display: inline-block; min-width: 22px; padding: 0 5px; margin: 0 1px;
  border: 1px solid rgba(255,255,255,.35); border-radius: 5px; font-size: 13px;
}
.ov-tops { list-style: none; counter-reset: t; margin: 0 auto 18px; padding: 0; max-width: 200px; text-align: left; }
.ov-tops li { counter-increment: t; display: flex; justify-content: space-between; color: var(--muted); font-variant-numeric: tabular-nums; }
.ov-tops li::before { content: counter(t) "."; }
.ov-btn {
  display: block; width: 100%;
  font: 800 18px system-ui, sans-serif; color: #170826;
  background: linear-gradient(180deg, #ffe17a, var(--gold));
  border: 0; border-radius: 12px; padding: 13px 20px; cursor: pointer;
  box-shadow: 0 6px 24px rgba(255, 210, 74, .35);
}
.ov-btn:hover { filter: brightness(1.06); }
.ov-link {
  margin-top: 12px; background: none; border: 0; color: var(--cyan);
  font: 700 15px system-ui, sans-serif; cursor: pointer; padding: 6px 10px;
}

.side {
  width: 260px; margin-top: 54px;
  display: none; flex-direction: column; gap: 14px;
}
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px;
}
.card h2 { margin: 0 0 10px; font-size: 13px; letter-spacing: 1.2px; text-transform: uppercase; color: var(--muted); }
.keys { list-style: none; margin: 0; padding: 0; font-size: 14px; }
.keys li { display: flex; justify-content: space-between; gap: 10px; padding: 4px 0; border-bottom: 1px dashed var(--line); }
.keys li:last-child { border: 0; }
kbd {
  font: 700 12px system-ui, sans-serif; color: #fff;
  border: 1px solid rgba(255,255,255,.3); border-bottom-width: 2px; border-radius: 5px; padding: 1px 6px;
}
.pts { list-style: none; margin: 0; padding: 0; font-size: 14px; }
.pts li { display: flex; justify-content: space-between; padding: 3px 0; }
.pts li span:last-child { color: var(--gold); font-variant-numeric: tabular-nums; }
@media (min-width: 900px) and (min-height: 560px) { .side { display: flex; } }

.content { max-width: 760px; margin: 0 auto; padding: 24px 18px 40px; }
.content h1 { font-size: 32px; line-height: 1.2; margin: 10px 0 14px; }
.content h2 { font-size: 23px; margin: 36px 0 10px; }
.content h3 { font-size: 18px; margin: 22px 0 6px; }
.content p, .content li { color: #d9dcf5; }
.content ul, .content ol { padding-left: 22px; }
.content table { width: 100%; border-collapse: collapse; margin: 10px 0 18px; font-size: 15px; }
.content th, .content td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.content th { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .6px; }
.content td:last-child { font-variant-numeric: tabular-nums; }
.lead { font-size: 18px; color: #e8eaff; }
.faq details { border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; margin: 10px 0; background: rgba(16,16,58,.6); }
.faq summary { cursor: pointer; font-weight: 700; }
.faq details p { margin: 10px 0 2px; }

.foot {
  border-top: 1px solid var(--line);
  padding: 22px 16px 36px; text-align: center; color: var(--muted); font-size: 14px;
}
.foot a { color: var(--muted); margin: 0 8px; }
.foot a:hover { color: #fff; }

.page { max-width: 720px; margin: 0 auto; padding: 18px 18px 50px; }
.page h1 { font-size: 32px; margin: 18px 0 4px; }
.page h2 { font-size: 18px; margin: 28px 0 8px; color: var(--gold); }
.page p, .page li { color: #d9dcf5; }
.page .meta { color: var(--muted); font-size: 14px; }

@media (max-width: 520px) {
  .top nav { display: none; }
  .play { padding: 0 4px 16px; }
  .game { --sh: clamp(380px, min(calc(100svh - var(--header) - 52px), calc((100vw - 8px) * 860 / 480)), 1000px); }
  .stage { border-radius: 12px; }
  .hud-item { padding: 2px 8px; }
  .hud-item b { font-size: 15px; }
  .hud-score b { font-size: 18px; }
  .content h1 { font-size: 26px; }
}
