/* Chain Reaction — GameCMB (gamecmb.com) */
[hidden] { display: none !important; }

:root {
  --bg: #080B18;
  --bg2: #05060f;
  --cyan: #35E7FF;
  --purple: #8B5CFF;
  --pink: #FF4FD8;
  --gold: #FFD84D;
  --text: #E8F1FF;
  --muted: #93A3C8;
  --panel: rgba(14, 18, 44, 0.86);
  --line: rgba(53, 231, 255, 0.22);
  --bar-h: 44px;
  --cue-h: 34px;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: radial-gradient(120% 80% at 50% 0%, #10173a 0%, var(--bg) 45%, var(--bg2) 100%) fixed;
  color: var(--text);
  font-family: var(--font);
  line-height: 1.55;
  overflow-x: hidden;
}
a { color: var(--cyan); }
button { font-family: inherit; }

/* ---------- site bar ---------- */
.site-bar {
  height: var(--bar-h);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 0 max(14px, env(safe-area-inset-left)) 0 max(14px, env(safe-area-inset-right));
  border-bottom: 1px solid rgba(255,255,255,0.06);
  background: rgba(5, 6, 15, 0.7);
}
.brand { display: flex; align-items: center; gap: 8px; color: #fff; text-decoration: none; font-weight: 700; letter-spacing: .02em; }
.brand b { color: var(--cyan); }
.brand-mark { width: 22px; height: 22px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff 0 12%, var(--cyan) 30%, var(--purple) 75%); box-shadow: 0 0 12px var(--cyan); }
.crumbs { font-size: 13px; color: var(--muted); display: flex; gap: 6px; white-space: nowrap; overflow: hidden; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: #fff; }

/* ---------- stage ---------- */
.stage {
  position: relative;
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  height: calc(100vh - var(--bar-h) - var(--cue-h));
  height: calc(100dvh - var(--bar-h) - var(--cue-h));
  min-height: 420px;
  max-height: 780px;
  overflow: hidden;
  overscroll-behavior: contain;
  user-select: none; -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  background: var(--bg);
}
@media (min-width: 900px) {
  .stage { border-radius: 0 0 22px 22px; box-shadow: 0 20px 60px rgba(0,0,0,.5), 0 0 0 1px rgba(53,231,255,.08); }
}
.stage:fullscreen { max-width: none; max-height: none; height: 100%; border-radius: 0; }
#game { position: absolute; inset: 0; display: block; touch-action: none; cursor: crosshair; }

/* ---------- HUD ---------- */
.hud {
  position: absolute; left: 0; right: 0; top: 0;
  padding: 10px max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left));
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: start; row-gap: 6px;
  pointer-events: none; z-index: 2;
}
.hud-left { display: flex; flex-direction: column; gap: 4px; }
.hud-level { font-weight: 900; font-size: 15px; letter-spacing: .08em; color: #fff; text-shadow: 0 0 10px var(--cyan); }
.hearts { display: flex; gap: 4px; }
.heart {
  width: 18px; height: 16px; display: inline-block;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 22'%3E%3Cpath fill='%23FF4FD8' d='M12 21.4 10.3 19.9C4.2 14.4.2 10.8.2 6.4.2 2.8 3 0 6.6 0c2 0 4 .9 5.4 2.5C13.4.9 15.4 0 17.4 0c3.6 0 6.4 2.8 6.4 6.4 0 4.4-4 8-10.1 13.5L12 21.4z'/%3E%3C/svg%3E") center/contain no-repeat;
  filter: drop-shadow(0 0 5px rgba(255,79,216,.8));
  transition: transform .2s;
}
.heart.empty {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 22'%3E%3Cpath fill='none' stroke='%235A6690' stroke-width='2' d='M12 20 10.9 19C4.9 13.6 1.2 10.3 1.2 6.4 1.2 3.3 3.6 1 6.6 1c1.9 0 3.9 1 5.4 2.7C13.5 2 15.5 1 17.4 1c3 0 5.4 2.3 5.4 5.4 0 3.9-3.7 7.2-9.7 12.6L12 20z'/%3E%3C/svg%3E");
  filter: none; transform: scale(.9);
}
.hud-center { text-align: center; }
.hud-score { font-weight: 900; font-size: clamp(22px, 5.4vw, 32px); line-height: 1; color: #fff; text-shadow: 0 0 14px rgba(53,231,255,.8); font-variant-numeric: tabular-nums; }
.hud-best { font-size: 11px; letter-spacing: .12em; color: var(--muted); margin-top: 3px; }
.icon-row { justify-self: end; display: flex; gap: 6px; pointer-events: auto; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; border: 1px solid rgba(255,255,255,.12);
  background: rgba(12, 16, 40, .7); color: #fff; display: grid; place-items: center; cursor: pointer;
  padding: 0; transition: background .15s, transform .1s, border-color .15s;
}
.icon-btn:hover { background: rgba(53,231,255,.16); border-color: rgba(53,231,255,.45); }
.icon-btn:active { transform: scale(.94); }
.icon-btn:focus-visible, .btn:focus-visible, .tabs button:focus-visible, .theme:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.icon-btn svg { width: 22px; height: 22px; fill: currentColor; stroke: currentColor; }
.icon-btn .off { display: none; }
.icon-btn.is-off { color: #6c7799; }
.icon-btn.is-off .on { display: none; }
.icon-btn.is-off .off { display: inline; stroke: var(--pink); }

.goal { grid-column: 1 / -1; justify-self: center; width: min(420px, 78%); display: flex; align-items: center; gap: 10px; }
.goal-bar { flex: 1; height: 8px; border-radius: 99px; background: rgba(255,255,255,.08); overflow: hidden; box-shadow: inset 0 0 0 1px rgba(255,255,255,.06); }
.goal-fill { height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, var(--cyan), var(--purple)); box-shadow: 0 0 12px var(--cyan); transition: width .12s ease-out; }
.goal.met .goal-fill { background: linear-gradient(90deg, #7CFF9A, var(--gold)); box-shadow: 0 0 14px var(--gold); }
.goal-text { font-weight: 800; font-size: 13px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.goal-text small { color: var(--muted); font-size: 10px; letter-spacing: .12em; margin-left: 2px; }
.goal.met .goal-text { color: var(--gold); }

/* ---------- screens & buttons ---------- */
.screen { position: absolute; inset: 0; z-index: 5; display: flex; align-items: center; justify-content: center; padding: 16px; }
.menu { background: radial-gradient(ellipse at center, rgba(5,6,15,.25) 0%, rgba(5,6,15,.7) 75%); }
.menu-inner { width: min(420px, 100%); display: flex; flex-direction: column; align-items: stretch; gap: 10px; text-align: center; }
.logo { display: flex; flex-direction: column; line-height: .9; font-weight: 900; letter-spacing: .04em; margin-bottom: 2px; animation: logoIn .7s cubic-bezier(.2,1.4,.4,1) both; }
.logo .l1 { font-size: clamp(46px, 13vw, 88px); color: #fff; text-shadow: 0 0 10px var(--cyan), 0 0 34px var(--cyan), 0 0 70px rgba(53,231,255,.5); }
.logo .l2 { font-size: clamp(30px, 8.6vw, 58px); background: linear-gradient(90deg, var(--pink), var(--gold)); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 0 14px rgba(255,79,216,.7)); }
@keyframes logoIn { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.tagline { margin: 0 0 8px; font-weight: 800; letter-spacing: .28em; font-size: 12px; color: var(--muted); }

.btn {
  appearance: none; border: 0; cursor: pointer; font-weight: 900; letter-spacing: .08em;
  border-radius: 14px; padding: 12px 16px; font-size: 15px; color: #fff;
  transition: transform .1s, box-shadow .2s, background .2s, opacity .2s;
  touch-action: manipulation;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: linear-gradient(135deg, #22c7ff 0%, var(--purple) 60%, var(--pink) 100%); box-shadow: 0 6px 24px rgba(139,92,255,.45), inset 0 1px 0 rgba(255,255,255,.35); }
.btn-primary:hover:not(:disabled) { box-shadow: 0 8px 34px rgba(53,231,255,.55), inset 0 1px 0 rgba(255,255,255,.35); }
.btn-xl { font-size: 24px; padding: 16px; border-radius: 18px; animation: pulse 2.2s ease-in-out infinite; }
.btn-lg { font-size: 19px; padding: 14px; }
@keyframes pulse { 0%, 100% { box-shadow: 0 6px 24px rgba(139,92,255,.45), 0 0 0 0 rgba(53,231,255,.45); } 50% { box-shadow: 0 6px 30px rgba(139,92,255,.6), 0 0 0 10px rgba(53,231,255,0); } }
.btn-daily { background: rgba(255,216,77,.08); border: 1.5px solid rgba(255,216,77,.6); color: var(--gold); display: flex; flex-direction: column; gap: 2px; }
.btn-daily small { font-weight: 600; letter-spacing: .02em; font-size: 12px; color: #FFE9A8; }
.btn-daily:hover { background: rgba(255,216,77,.16); }
.btn-ghost { background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.14); font-size: 12px; padding: 11px 10px; }
.btn-ghost:hover { background: rgba(53,231,255,.12); border-color: rgba(53,231,255,.4); }
.menu-row { display: flex; gap: 8px; }
.menu-row .btn { flex: 1; }
.menu-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 6px 0 0; }
.menu-stats div { background: rgba(10,14,36,.6); border: 1px solid rgba(255,255,255,.07); border-radius: 12px; padding: 8px 4px; }
.menu-stats dt { font-size: 10px; letter-spacing: .14em; color: var(--muted); }
.menu-stats dd { margin: 0; font-weight: 900; font-size: 18px; font-variant-numeric: tabular-nums; }
.menu-hint { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.menu-toggles { position: absolute; top: 10px; right: max(12px, env(safe-area-inset-right)); display: flex; gap: 6px; }

/* ---------- modals ---------- */
.modal-back { background: rgba(3,4,12,.68); backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px); z-index: 8; }
.modal {
  position: relative; width: min(460px, 100%); max-height: calc(100% - 8px); overflow-y: auto;
  background: linear-gradient(180deg, rgba(22,28,66,.95), rgba(10,12,32,.96));
  border: 1px solid var(--line); border-radius: 22px; padding: 22px 20px 18px;
  box-shadow: 0 24px 70px rgba(0,0,0,.6), 0 0 40px rgba(53,231,255,.08);
  display: flex; flex-direction: column; gap: 10px; text-align: center;
  animation: pop .28s cubic-bezier(.2,1.3,.4,1) both;
}
.modal.small { width: min(340px, 100%); }
@keyframes pop { from { transform: scale(.88); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal h2 { margin: 0; font-size: 26px; font-weight: 900; letter-spacing: .06em; text-shadow: 0 0 16px rgba(53,231,255,.6); }
.close { position: absolute; top: 8px; right: 10px; width: 38px; height: 38px; border-radius: 10px; border: 0; background: transparent; color: var(--muted); font-size: 28px; line-height: 1; cursor: pointer; }
.close:hover { color: #fff; background: rgba(255,255,255,.08); }

.over-kicker { margin: 0; font-size: 12px; font-weight: 800; letter-spacing: .2em; color: var(--muted); }
.new-best { align-self: center; font-weight: 900; letter-spacing: .12em; font-size: 14px; color: #1a0a1f; background: linear-gradient(90deg, var(--gold), var(--pink)); border-radius: 99px; padding: 4px 14px; animation: glowPulse 1.2s ease-in-out infinite; }
@keyframes glowPulse { 50% { box-shadow: 0 0 22px rgba(255,79,216,.8); } }
.over-score { font-size: clamp(44px, 12vw, 60px); font-weight: 900; line-height: 1; font-variant-numeric: tabular-nums; background: linear-gradient(180deg, #fff, var(--cyan)); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 0 16px rgba(53,231,255,.5)); }
.over-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 0; }
.over-stats div { background: rgba(255,255,255,.05); border-radius: 12px; padding: 7px 2px; }
.over-stats dt { font-size: 9px; letter-spacing: .1em; color: var(--muted); }
.over-stats dd { margin: 0; font-weight: 900; font-size: 17px; font-variant-numeric: tabular-nums; }
.over-next { margin: 0; font-size: 13px; color: #FFE9A8; }
.submit-box { display: flex; flex-direction: column; gap: 6px; text-align: left; background: rgba(0,0,0,.2); border: 1px solid rgba(255,255,255,.08); border-radius: 14px; padding: 10px; }
.submit-box label { font-size: 11px; font-weight: 800; letter-spacing: .14em; color: var(--muted); }
.submit-row { display: flex; gap: 8px; }
.submit-row input {
  flex: 1; min-width: 0; font: inherit; font-size: 16px; font-weight: 700; color: #fff;
  background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.18); border-radius: 12px; padding: 10px 12px;
}
.submit-row input:focus { outline: none; border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(53,231,255,.2); }
.submit-row .btn { padding: 10px 12px; font-size: 13px; white-space: nowrap; }
.submit-msg { margin: 0; min-height: 1.2em; font-size: 13px; }
.submit-msg.err { color: #FF8FA8; }
.submit-msg.ok { color: #7CFF9A; }
.over-actions { display: flex; flex-direction: column; gap: 8px; }
.kbd-hint { margin: 0; font-size: 11px; color: #5d6a90; }
@media (pointer: coarse) { .kbd-hint { display: none; } }
.check { display: flex; gap: 8px; align-items: center; justify-content: center; font-size: 13px; color: var(--muted); cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--cyan); }

/* leaderboard */
.tabs { display: flex; gap: 4px; background: rgba(0,0,0,.25); border-radius: 12px; padding: 4px; }
.tabs button { flex: 1; border: 0; background: transparent; color: var(--muted); font-weight: 800; font-size: 11px; letter-spacing: .08em; padding: 9px 2px; border-radius: 9px; cursor: pointer; }
.tabs button[aria-selected="true"] { background: linear-gradient(135deg, rgba(53,231,255,.25), rgba(139,92,255,.3)); color: #fff; }
.board-me { margin: 0; font-size: 13px; font-weight: 700; color: var(--gold); min-height: 1.2em; }
.board-wrap { max-height: min(46vh, 380px); overflow-y: auto; border-radius: 12px; background: rgba(0,0,0,.2); }
.board-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.board-table th { position: sticky; top: 0; background: #11163a; font-size: 10px; letter-spacing: .12em; color: var(--muted); padding: 8px 6px; text-align: left; }
.board-table td { padding: 8px 6px; border-top: 1px solid rgba(255,255,255,.05); text-align: left; font-variant-numeric: tabular-nums; }
.board-table td:nth-child(2) { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.board-table td:nth-child(3) { font-weight: 800; }
.board-table tr.top1 td:first-child { color: var(--gold); font-weight: 900; }
.board-table tr.top2 td:first-child { color: #d9e3ff; font-weight: 900; }
.board-table tr.top3 td:first-child { color: #ffb27a; font-weight: 900; }
.board-table tr.me td { background: rgba(53,231,255,.14); color: #fff; }
.board-empty { padding: 18px; margin: 0; color: var(--muted); }
@media (max-width: 420px) { .hide-sm { display: none; } }

/* how to play */
.howto-list { text-align: left; margin: 0; padding-left: 20px; font-size: 14px; display: flex; flex-direction: column; gap: 6px; }
.orb-legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; text-align: left; font-size: 14px; }
.orb-legend li { display: flex; align-items: center; gap: 10px; }
.orb { width: 24px; height: 24px; border-radius: 50%; flex: 0 0 24px; display: grid; place-items: center; font-style: normal; font-weight: 900; font-size: 10px; color: #fff; }
.o-normal { background: radial-gradient(circle at 38% 34%, #fff 0 10%, #35E7FF 35%, #0b5e7a 100%); box-shadow: 0 0 10px #35E7FF; }
.o-gold { background: radial-gradient(circle at 38% 34%, #fff 0 10%, #FFD84D 35%, #8a6200 100%); box-shadow: 0 0 10px #FFD84D; }
.o-mult { background: radial-gradient(circle at 38% 34%, #d9ccff 0 10%, #8B5CFF 45%, #34197a 100%); box-shadow: 0 0 10px #8B5CFF; }
.o-mega { width: 30px; height: 30px; flex-basis: 30px; background: radial-gradient(circle at 38% 34%, #fff 0 10%, #FF4FD8 40%, #7a0f63 100%); box-shadow: 0 0 0 3px rgba(255,214,247,.5), 0 0 12px #FF4FD8; }
.o-bomb { background: radial-gradient(circle at 50% 50%, #fff 0 14%, #FF7A3D 36%, #7a1a10 100%); box-shadow: 0 0 0 2px #FFD84D, 0 0 12px #FF3D6E; }
.small-print { font-size: 13px; color: var(--muted); margin: 0; }

/* themes & achievements */
.themes { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.theme { border: 1px solid rgba(255,255,255,.14); background: rgba(255,255,255,.04); border-radius: 12px; padding: 8px 2px 6px; color: #fff; font-size: 11px; font-weight: 800; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 5px; }
.theme.active { border-color: var(--gold); box-shadow: 0 0 14px rgba(255,216,77,.35); }
.theme.locked { opacity: .45; cursor: not-allowed; }
.swatch { width: 28px; height: 28px; border-radius: 50%; }
.theme-neon .swatch { background: radial-gradient(circle, #fff 0 15%, #35E7FF 40%, #1E7CFF 75%, #FF4FD8); }
.theme-solar .swatch { background: radial-gradient(circle, #fff 0 15%, #FFD84D 40%, #FF7A1A 75%, #FF3D6E); }
.theme-toxic .swatch { background: radial-gradient(circle, #fff 0 15%, #7CFF4F 40%, #12C98A 75%, #35E7FF); }
.theme-plasma .swatch { background: radial-gradient(circle, #fff 0 15%, #C38BFF 40%, #8B5CFF 75%, #FF4FD8); }
.theme-prism .swatch { background: conic-gradient(#ff4f4f, #ffd84d, #7cff4f, #35e7ff, #8b5cff, #ff4fd8, #ff4f4f); }
.ach-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; text-align: left; }
.ach-list li { display: flex; flex-direction: column; background: rgba(255,255,255,.04); border-radius: 10px; padding: 7px 10px; font-size: 13px; opacity: .6; }
.ach-list li.done { opacity: 1; border: 1px solid rgba(124,255,154,.35); }
.ach-list li.done b { color: #7CFF9A; }
.ach-list span { color: var(--muted); font-size: 12px; }

/* toasts */
.toasts { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 9; display: flex; flex-direction: column; gap: 6px; pointer-events: none; width: min(340px, 90%); }
.toast { background: rgba(14,18,44,.94); border: 1px solid rgba(255,216,77,.5); border-radius: 14px; padding: 8px 14px; display: flex; flex-direction: column; text-align: center; box-shadow: 0 10px 30px rgba(0,0,0,.5); animation: toastIn .3s cubic-bezier(.2,1.3,.4,1) both; transition: opacity .4s, transform .4s; }
.toast b { color: var(--gold); font-size: 14px; }
.toast span { font-size: 12px; color: var(--muted); word-break: break-word; }
.toast.out { opacity: 0; transform: translateY(8px); }
@keyframes toastIn { from { transform: translateY(12px) scale(.9); opacity: 0; } }
.noscript { position: absolute; inset: 0; display: grid; place-items: center; padding: 20px; text-align: center; font-weight: 700; }

/* ---------- below the game ---------- */
.scroll-cue { display: flex; align-items: center; justify-content: center; gap: 6px; height: var(--cue-h); font-size: 13px; color: var(--muted); text-decoration: none; }
.scroll-cue:hover { color: #fff; }
.ad-slot { display: block; max-width: 970px; margin: 8px auto 0; min-height: 0; text-align: center; }
.ad-slot:empty { display: none; }
.content { max-width: 820px; margin: 18px auto 40px; padding: 0 18px; }
.content h1 { font-size: clamp(26px, 5vw, 36px); line-height: 1.2; margin: 16px 0 12px; }
.content h2 { font-size: 22px; margin: 34px 0 10px; color: #fff; border-left: 4px solid var(--cyan); padding-left: 10px; }
.content h3 { font-size: 17px; margin: 20px 0 6px; color: #d7e6ff; }
.content p, .content li { color: #c6d2ee; }
.content .lead { font-size: 17px; }
.content .lead strong { color: #e8f1ff; font-weight: 600; }
.content table { width: 100%; border-collapse: collapse; font-size: 15px; margin: 8px 0; }
.content th, .content td { border: 1px solid rgba(255,255,255,.1); padding: 8px 10px; text-align: left; vertical-align: top; }
.content th { background: rgba(53,231,255,.08); }
.related { display: grid; gap: 6px; }
.site-foot { text-align: center; font-size: 13px; color: var(--muted); padding: 24px 16px 40px; border-top: 1px solid rgba(255,255,255,.06); }

@media (max-width: 520px) {
  .crumbs { display: none; }
  .icon-btn { width: 36px; height: 36px; border-radius: 10px; }
  .icon-btn svg { width: 20px; height: 20px; }
  .modal { padding: 18px 14px 14px; border-radius: 18px; }
  .over-stats dd { font-size: 15px; }
  .goal { width: 92%; }
}
@media (max-height: 560px) {
  .logo .l1 { font-size: 44px; } .logo .l2 { font-size: 30px; }
  .menu-stats, .menu-hint { display: none; }
  .btn-xl { font-size: 20px; padding: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .btn-xl, .new-best, .logo { animation: none; }
  .modal, .toast { animation: none; }
}
