/* Ghost Loop — Game CMB. System fonts only (no third-party font requests). */
[hidden] { display: none !important; }

:root {
  --bg: #07061a;
  --bg2: #0e0b2a;
  --panel: rgba(16, 12, 44, 0.86);
  --line: rgba(255, 255, 255, 0.12);
  --text: #eef0ff;
  --muted: #a8a9d6;
  --cyan: #5ff3ff;
  --violet: #9a6bff;
  --pink: #ff5fd2;
  --gold: #ffd23d;
  --red: #ff4a6e;
  --green: #5dffa8;
  --header-h: 52px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: radial-gradient(1200px 600px at 50% -10%, #1b1450 0%, var(--bg) 60%) fixed, var(--bg);
  color: var(--text);
  font: 16px/1.6 var(--font);
}
a { color: var(--cyan); }
img { max-width: 100%; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 12px; top: 8px; z-index: 50; background: #000; padding: 6px 10px; }

/* --------------------------------------------------------------- header */
.site-header {
  height: var(--header-h);
  display: flex; align-items: center; gap: 18px;
  padding: 0 16px;
  max-width: 1100px; margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none; font-weight: 700; letter-spacing: .3px; }
.brand b { color: var(--pink); }
.crumbs { font-size: 13px; color: var(--muted); display: flex; gap: 6px; flex-wrap: nowrap; overflow: hidden; white-space: nowrap; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--text); }

/* ---------------------------------------------------------------- stage */
.game-wrap { max-width: 1100px; margin: 0 auto; padding: 0 10px; }
.stage {
  position: relative;
  height: calc(100vh - var(--header-h) - 10px);
  height: calc(100svh - var(--header-h) - 10px);
  min-height: 480px; max-height: 1000px;
  display: flex; flex-direction: column;
  background: #05040f;
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  touch-action: none;
  user-select: none; -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: contain;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .45), 0 0 0 1px rgba(95, 243, 255, .05) inset;
}
#game { flex: 1 1 auto; min-height: 0; width: 100%; display: block; cursor: crosshair; }

/* ------------------------------------------------------------------ HUD */
.hud {
  flex: none; height: 56px;
  display: flex; align-items: center; gap: 10px;
  padding: 0 12px;
  background: linear-gradient(180deg, rgba(20, 14, 56, .95), rgba(10, 8, 30, .9));
  border-bottom: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}
.hud-cell { display: flex; flex-direction: column; align-items: flex-start; min-width: 54px; line-height: 1.05; }
.hud-cell.right { align-items: flex-end; }
.hud-cell small { font-size: 10px; letter-spacing: 1.5px; color: var(--muted); font-weight: 700; }
.hud-cell strong { font-size: 20px; font-weight: 800; }
.hud-mid { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px; min-width: 0; }
.hud-score { display: flex; align-items: baseline; gap: 8px; line-height: 1; }
.hud-score strong { font-size: 24px; font-weight: 900; letter-spacing: .5px; display: inline-block; }
.hud-score strong.bump { animation: bump .28s ease-out; }
.hud-score em { font-style: normal; font-weight: 800; font-size: 13px; color: var(--gold); }
@keyframes bump { 0% { transform: scale(1.25); color: #fff6c2; } 100% { transform: scale(1); } }
.timer { width: min(260px, 100%); height: 6px; border-radius: 6px; background: rgba(255, 255, 255, .1); overflow: hidden; }
.timer-fill { height: 100%; width: 100%; background: linear-gradient(90deg, var(--cyan), var(--violet)); border-radius: 6px; }
.timer[data-state="urgent"] .timer-fill { background: linear-gradient(90deg, var(--red), #ff9a5f); animation: urgent .5s infinite alternate; }
.timer[data-state="safe"] .timer-fill { background: linear-gradient(90deg, var(--green), #b8ffdc); }
@keyframes urgent { to { opacity: .55; } }
.icon-btn {
  flex: none; width: 40px; height: 40px; border-radius: 12px;
  border: 1px solid var(--line); background: rgba(255, 255, 255, .06); color: var(--text);
  font-size: 14px; font-weight: 900; cursor: pointer;
}
.icon-btn:hover { background: rgba(255, 255, 255, .12); }

/* --------------------------------------------------------------- banner */
.banner {
  position: absolute; left: 50%; top: 22%; z-index: 5;
  width: min(92%, 560px); margin-left: calc(min(92%, 560px) / -2);
  display: flex; flex-direction: column; align-items: center; text-align: center;
  pointer-events: none;
  text-shadow: 0 0 24px rgba(95, 243, 255, .6), 0 3px 0 rgba(0, 0, 0, .5);
}
.banner strong { font-size: clamp(30px, 7vw, 54px); font-weight: 900; letter-spacing: 2px; line-height: 1.05; }
.banner span { font-size: clamp(14px, 3.4vw, 18px); font-weight: 700; color: #d9dcff; margin-top: 6px; }
.banner[data-tone="gold"] strong { color: var(--gold); text-shadow: 0 0 26px rgba(255, 210, 61, .7); }
.banner[data-tone="red"] strong { color: #ff8aa0; text-shadow: 0 0 26px rgba(255, 74, 110, .8); }
.banner.run { animation: bannerIn var(--dur, 1400ms) ease-out forwards; }
@keyframes bannerIn {
  0% { opacity: 0; letter-spacing: 12px; }
  12% { opacity: 1; letter-spacing: 2px; }
  80% { opacity: 1; }
  100% { opacity: 0; }
}

.replay-tag {
  position: absolute; top: 66px; left: 50%; z-index: 6;
  width: max-content; max-width: 92%; margin: 0 auto; right: 0; left: 0;
  padding: 6px 14px; border-radius: 20px;
  background: rgba(255, 74, 110, .9); color: #fff; font-weight: 800; font-size: 13px; letter-spacing: .5px;
  pointer-events: none;
  animation: urgent .7s infinite alternate;
}

.toasts { position: absolute; left: 0; right: 0; bottom: 14px; z-index: 7; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }
.toast {
  padding: 8px 16px; border-radius: 14px; background: rgba(12, 10, 36, .92);
  border: 1px solid var(--line); font-weight: 700; font-size: 14px; max-width: 92%;
  animation: toastIn .25s ease-out; transition: opacity .4s, transform .4s;
}
.toast.gold { border-color: rgba(255, 210, 61, .6); color: var(--gold); }
.toast.ok { border-color: rgba(93, 255, 168, .6); color: var(--green); }
.toast.warn { border-color: rgba(255, 138, 90, .6); color: #ffb08a; }
.toast.out { opacity: 0; transform: translateY(8px); }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } }

/* ------------------------------------------------------- screens/modals */
.screen, .modal {
  position: absolute; inset: 0; z-index: 10;
  display: flex; align-items: center; justify-content: center;
  padding: 14px;
  overflow-y: auto;
}
.screen.menu { background: radial-gradient(circle at 50% 40%, rgba(7, 6, 26, .25), rgba(7, 6, 26, .78)); }
.screen.over, .screen.pause { background: rgba(5, 4, 16, .62); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.modal { z-index: 20; background: rgba(5, 4, 16, .72); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }

.menu-card { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; width: min(100%, 420px); margin: auto; }
.logo { width: 84px; height: 84px; filter: drop-shadow(0 0 18px rgba(95, 243, 255, .55)); animation: float 3s ease-in-out infinite; }
@keyframes float { 50% { transform: translateY(-8px); } }
.title { margin: 0; font-weight: 900; font-size: clamp(44px, 12vw, 76px); line-height: .95; letter-spacing: 3px; display: flex; flex-direction: column; }
.title span:first-child { color: var(--cyan); text-shadow: 0 0 28px rgba(95, 243, 255, .75); }
.title span:last-child { color: var(--pink); text-shadow: 0 0 28px rgba(255, 95, 210, .75); }
.tagline { margin: 0 0 6px; color: #d9dcff; font-weight: 600; }
.keys { margin: 4px 0 0; font-size: 12px; color: var(--muted); }

.card {
  width: min(100%, 440px); margin: auto;
  background: var(--panel);
  border: 1px solid rgba(154, 107, 255, .35);
  border-radius: 22px;
  padding: 20px 18px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .55), 0 0 40px rgba(154, 107, 255, .15);
  display: flex; flex-direction: column; gap: 10px;
}
.card.small { width: min(100%, 340px); }
.card h2 { margin: 0; font-size: 30px; font-weight: 900; letter-spacing: 2px; }
.card h3 { margin: 8px 0 0; font-size: 16px; color: var(--muted); letter-spacing: 1px; text-transform: uppercase; }
.over .card h2 { color: #ff8aa0; text-shadow: 0 0 20px rgba(255, 74, 110, .6); }
.mode { margin: 0; font-size: 11px; letter-spacing: 2px; color: var(--muted); font-weight: 800; }
.cause { margin: 0; color: #d9dcff; }
.score-big { position: relative; font-size: 52px; font-weight: 900; line-height: 1.05; color: #fff; text-shadow: 0 0 24px rgba(95, 243, 255, .5); font-variant-numeric: tabular-nums; }
.badge { display: inline-block; vertical-align: middle; margin-left: 8px; padding: 4px 10px; border-radius: 10px; background: var(--gold); color: #251a00; font-size: 13px; letter-spacing: 1px; text-shadow: none; animation: bump .6s ease-out; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 0; }
.stats div { background: rgba(255, 255, 255, .05); border-radius: 12px; padding: 6px 4px; }
.stats dt { font-size: 10px; letter-spacing: .5px; color: var(--muted); text-transform: uppercase; }
.stats dd { margin: 0; font-size: 20px; font-weight: 800; }
.best { margin: 0; color: var(--muted); font-size: 14px; }
.hint { margin: 0; color: var(--gold); font-size: 13px; }
.status { margin: 0; min-height: 1.3em; font-size: 14px; font-weight: 600; }
.status[data-tone="ok"] { color: var(--green); }
.status[data-tone="warn"] { color: #ffb08a; }
.nick { display: flex; flex-direction: column; gap: 6px; text-align: left; }
.nick label { font-size: 13px; color: var(--muted); }
.nick-row { display: flex; gap: 8px; }
.nick input {
  flex: 1; min-width: 0; height: 44px; border-radius: 12px; border: 1px solid rgba(95, 243, 255, .4);
  background: rgba(0, 0, 0, .35); color: #fff; padding: 0 12px; font: 600 16px var(--font);
}
.nick input:focus { outline: 2px solid var(--cyan); outline-offset: 1px; }
.err { margin: 0; color: #ff8aa0; font-size: 13px; min-height: 1em; }
.saved { margin: 0; font-size: 14px; color: #d9dcff; }
.link { background: none; border: 0; color: var(--cyan); text-decoration: underline; cursor: pointer; font: inherit; padding: 0; }

/* -------------------------------------------------------------- buttons */
.btn {
  appearance: none; border: 0; cursor: pointer;
  min-height: 44px; padding: 10px 16px; border-radius: 14px;
  font: 800 15px var(--font); color: #fff; letter-spacing: .5px;
  background: rgba(255, 255, 255, .08);
  transition: transform .08s, filter .15s, background .15s;
}
.btn:hover { filter: brightness(1.15); }
.btn:active { transform: scale(.97); }
.btn:focus-visible, .tgl:focus-visible, .icon-btn:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.btn.primary { background: linear-gradient(135deg, #25e0ff, #8a5bff 55%, #ff4fcf); box-shadow: 0 8px 26px rgba(138, 91, 255, .45); }
.btn.big { width: 100%; min-height: 58px; font-size: 22px; letter-spacing: 2px; border-radius: 18px; }
.btn.daily { width: 100%; background: rgba(255, 210, 61, .12); border: 1px solid rgba(255, 210, 61, .45); color: var(--gold); }
.btn.daily small { display: block; font-size: 11px; color: #e8d99a; font-weight: 700; }
.btn.ghost { background: rgba(255, 255, 255, .06); border: 1px solid var(--line); font-size: 13px; padding: 8px 10px; }
.row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; width: 100%; }
.row .btn { flex: 1 1 0; min-width: 0; white-space: nowrap; }
.toggles { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.tgl { border: 1px solid var(--line); background: rgba(255, 255, 255, .04); color: var(--muted); border-radius: 20px; padding: 6px 12px; font: 700 12px var(--font); cursor: pointer; min-height: 34px; }
.tgl[aria-pressed="true"] { color: #fff; border-color: rgba(95, 243, 255, .6); background: rgba(95, 243, 255, .12); }

/* ------------------------------------------------------ how / board / skins */
.steps { text-align: left; margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 6px; }
.controls { text-align: left; font-size: 14px; color: #d9dcff; margin: 0; }
.tabs { display: flex; gap: 4px; background: rgba(255, 255, 255, .05); border-radius: 12px; padding: 4px; }
.tabs button { flex: 1; border: 0; background: none; color: var(--muted); font: 700 13px var(--font); padding: 8px 4px; border-radius: 9px; cursor: pointer; }
.tabs button[aria-selected="true"] { background: rgba(95, 243, 255, .16); color: #fff; }
.board-list { list-style: none; margin: 0; padding: 0; max-height: 46vh; overflow-y: auto; text-align: left; }
.board-list li { display: grid; grid-template-columns: 44px 1fr auto auto; gap: 8px; align-items: center; padding: 8px 10px; border-radius: 10px; font-variant-numeric: tabular-nums; }
.board-list li:nth-child(odd) { background: rgba(255, 255, 255, .04); }
.board-list li.me { background: rgba(95, 243, 255, .15); outline: 1px solid rgba(95, 243, 255, .5); }
.board-list li.muted { display: block; color: var(--muted); text-align: center; }
.board-list .rk { color: var(--muted); font-weight: 800; }
.board-list li:nth-child(1) .rk { color: var(--gold); }
.board-list .nm { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-list .rd { color: var(--muted); font-size: 13px; }
.board-list .sc { font-weight: 800; }
.board-me { margin: 0; color: var(--cyan); font-weight: 700; min-height: 1.2em; }
.skin-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.skin { border: 1px solid var(--line); background: rgba(255, 255, 255, .04); color: var(--text); border-radius: 14px; padding: 10px 6px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 4px; font: 600 13px var(--font); }
.skin .dot { width: 30px; height: 30px; border-radius: 50% 50% 40% 40%; background: #fff; box-shadow: 0 0 16px var(--glow), 0 0 0 3px var(--glow) inset; }
.skin small { font-size: 11px; color: var(--muted); line-height: 1.25; }
.skin.on { border-color: var(--glow); background: rgba(255, 255, 255, .1); }
.skin.locked { opacity: .55; cursor: not-allowed; }
.skin.locked .dot { filter: grayscale(1); }
.ach { list-style: none; margin: 0; padding: 0; text-align: left; display: flex; flex-direction: column; gap: 4px; max-height: 26vh; overflow-y: auto; }
.ach li { display: flex; flex-direction: column; padding: 6px 10px; border-radius: 10px; background: rgba(255, 255, 255, .03); color: var(--muted); font-size: 13px; }
.ach li strong { color: #cfd1f5; font-size: 14px; }
.ach li.done strong { color: var(--gold); }

.boot-error { position: absolute; inset: auto 12px 12px; z-index: 30; padding: 12px; border-radius: 12px; background: #3a0d18; color: #ffd0da; text-align: center; }

/* ------------------------------------------------------------------ ads */
.ad-slot { margin: 12px auto 0; min-height: 90px; max-width: 970px; border: 1px dashed rgba(255, 255, 255, .12); border-radius: 12px; display: flex; align-items: center; justify-content: center; }
.ad-slot span { font-size: 11px; letter-spacing: 1.5px; color: rgba(255, 255, 255, .3); text-transform: uppercase; }

/* ---------------------------------------------------------------- guide */
.guide { max-width: 820px; margin: 30px auto 0; padding: 0 18px 30px; color: #dcdcf5; }
.guide h1 { font-size: clamp(26px, 5vw, 36px); line-height: 1.2; color: #fff; }
.guide h2 { margin-top: 34px; color: #fff; font-size: 24px; }
.guide .lede { font-size: 17px; background: rgba(95, 243, 255, .06); border-left: 3px solid var(--cyan); padding: 12px 16px; border-radius: 0 12px 12px 0; }
.guide table { width: 100%; border-collapse: collapse; font-size: 15px; }
.guide th, .guide td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.guide th { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .5px; }
.faq { border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; margin: 8px 0; background: rgba(255, 255, 255, .02); }
.faq summary { cursor: pointer; font-weight: 700; color: #fff; }
.faq p { margin: 8px 0 0; }
.related li { margin: 4px 0; }
.site-footer { text-align: center; color: var(--muted); font-size: 13px; padding: 20px 16px 40px; border-top: 1px solid var(--line); }

/* ---------------------------------------------------------- responsive */
@media (max-width: 640px) {
  :root { --header-h: 46px; }
  .crumbs { display: none; }
  .game-wrap { padding: 0; }
  .stage { border-radius: 0; border-left: 0; border-right: 0; height: calc(100svh - var(--header-h)); }
  .hud { height: 52px; gap: 6px; padding: 0 8px; }
  .hud-cell { min-width: 44px; }
  .hud-cell strong { font-size: 17px; }
  .hud-score strong { font-size: 20px; }
  .icon-btn { width: 36px; height: 36px; }
  .card { padding: 16px 14px; gap: 8px; }
  .score-big { font-size: 42px; }
  .stats dd { font-size: 17px; }
  .skin-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-height: 640px) {
  .logo { width: 56px; height: 56px; }
  .title { font-size: 40px; }
  .btn.big { min-height: 50px; font-size: 19px; }
}
@media (prefers-reduced-motion: reduce) {
  .logo, .replay-tag, .timer[data-state="urgent"] .timer-fill { animation: none; }
}
