/* Cube Hop */
.ch { --ch-hud: 52px; display: flex; flex-direction: column; min-height: 0; }
.ch-stage { position: relative; width: 100%; height: min(78vh, 680px); min-height: 380px; overflow: hidden; background: #04060f; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.ch-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; outline: none; cursor: pointer; }

.ch-hud { position: absolute; left: 0; right: 0; top: 0; height: var(--ch-hud); display: flex; align-items: center; gap: 12px; padding: 0 8px 0 14px; z-index: 6; pointer-events: none; background: linear-gradient(180deg, rgba(4,6,15,0.82), rgba(4,6,15,0)); }
.ch-hud > button { pointer-events: auto; }
.ch-stat { display: flex; flex-direction: column; line-height: 1.05; min-width: 42px; }
.ch-lab { font-size: 10px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: #8aa3c4; }
.ch-stat b { font-size: 21px; font-weight: 800; color: #fff; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; display: inline-block; transform-origin: left center; transition: transform .18s cubic-bezier(.3,1.6,.5,1), color .18s; }
.ch-stat b.ch-pop { transform: scale(1.2); color: #b8f6ff; }
.ch-stat-lvl b { font-size: 18px; color: #ffd166; }
.ch-chain { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 4px 9px 5px; border-radius: 12px; border: 1px solid #1c2b4a; background: rgba(11,19,40,0.8); min-width: 46px; transition: border-color .2s, box-shadow .2s, transform .18s cubic-bezier(.3,1.6,.5,1); }
.ch-chain b { font-size: 17px; font-weight: 800; color: #8aa3c4; line-height: 1; font-variant-numeric: tabular-nums; }
.ch-chain.is-hot { border-color: #ffd166; box-shadow: 0 0 14px rgba(255,209,102,0.35); }
.ch-chain.is-hot b { color: #ffd166; }
.ch-chain.ch-pop { transform: scale(1.14); }
.ch-pips { display: flex; gap: 3px; }
.ch-pips i { width: 7px; height: 4px; border-radius: 2px; background: #1c2b4a; transition: background .15s; }
.ch-pips i.on { background: #55d6ff; box-shadow: 0 0 6px rgba(85,214,255,0.7); }
.ch-goal { display: flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 700; color: #8aa3c4; letter-spacing: 0.04em; }
.ch-goal i { width: 18px; height: 12px; border-radius: 4px; display: inline-block; box-shadow: inset 0 0 0 1px rgba(255,255,255,0.18); }
.ch-goal em { font-style: normal; color: #dfe9ff; }
.ch-spacer { flex: 1 1 auto; }
.ch-lives { display: flex; gap: 3px; align-items: center; }
.ch-lives svg { width: 17px; height: 17px; display: block; }
.ch-lives .off { opacity: 0.22; }
.ch-lives b { font-size: 17px; font-weight: 800; color: #fff; margin-left: 2px; font-variant-numeric: tabular-nums; }
.ch-narrow .ch-goal .ch-from, .ch-narrow .ch-goal em span { display: none; }
.ch-narrow .ch-goal em { font-size: 15px; font-weight: 800; }
.ch-tool { flex: 0 0 40px; width: 40px; height: 40px; border-radius: 12px; border: 1px solid #1c2b4a; background: rgba(11,19,40,0.8); color: #dfe9ff; display: grid; place-items: center; cursor: pointer; padding: 0; font: inherit; }
.ch-tool:hover { border-color: #55d6ff; color: #fff; }
.ch-tool:focus-visible, .ch-btn:focus-visible, .ch-seg button:focus-visible, .ch-step button:focus-visible, .ch-link:focus-visible { outline: 2px solid #55d6ff; outline-offset: 2px; }
#ch-sound .ch-cross { display: none; }
#ch-sound.is-muted .ch-wave { display: none; }
#ch-sound.is-muted .ch-cross { display: inline; }
#ch-sound.is-muted { color: #8aa3c4; }

.ch-banner { position: absolute; left: 50%; top: calc(var(--ch-hud) + 10px); transform: translate(-50%, -8px); z-index: 4; padding: 8px 16px; border-radius: 999px; border: 1px solid #1c2b4a; background: rgba(8,13,30,0.9); color: #dfe9ff; font-size: 14px; font-weight: 700; line-height: 1.35; text-align: center; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; width: max-content; max-width: min(calc(100% - 24px), 460px); border-radius: 16px; }
.ch-banner.is-on { opacity: 1; transform: translate(-50%, 0); }
.ch-banner b { color: #ffd166; }

.ch-overlay { position: absolute; inset: 0; z-index: 5; pointer-events: none; display: none; align-items: center; justify-content: center; padding: 14px; background: radial-gradient(ellipse at center, rgba(4,6,15,0.3), rgba(4,6,15,0.74)); }
.ch-overlay.is-on { display: flex; }
.ch-panel { pointer-events: auto; width: min(100%, 372px); max-height: 100%; overflow: auto; border-radius: 18px; border: 1px solid #1c2b4a; background: rgba(8,13,30,0.9); box-shadow: 0 18px 60px rgba(0,0,0,0.55), 0 0 0 1px rgba(85,214,255,0.05) inset; padding: 20px 20px 18px; text-align: center; color: #dfe9ff; animation: ch-in .22s ease-out; }
@keyframes ch-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: none; } }
.ch-logo { margin: 0 0 4px; font-size: 34px; font-weight: 900; letter-spacing: -0.02em; line-height: 1; background: linear-gradient(135deg, #55d6ff, #b28dff 55%, #ff6b81); -webkit-background-clip: text; background-clip: text; color: transparent; }
.ch-sub { margin: 0 0 14px; font-size: 13.5px; color: #8aa3c4; line-height: 1.45; }
.ch-h { margin: 0 0 6px; font-size: 22px; font-weight: 800; color: #fff; }
.ch-seg { display: flex; gap: 6px; padding: 4px; border-radius: 13px; border: 1px solid #1c2b4a; background: #070c1c; margin: 0 0 10px; }
.ch-seg button { flex: 1 1 0; min-height: 40px; border: 0; border-radius: 10px; background: transparent; color: #8aa3c4; font: inherit; font-size: 14px; font-weight: 700; cursor: pointer; }
.ch-seg button[aria-checked="true"] { background: #16233f; color: #fff; box-shadow: inset 0 0 0 1px #2b4370; }
.ch-modeinfo { min-height: 38px; margin: 0 0 12px; font-size: 13px; color: #8aa3c4; line-height: 1.45; }
.ch-modeinfo b { color: #ffd166; }
.ch-step { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 0 0 12px; font-size: 13.5px; color: #dfe9ff; }
.ch-step button { width: 40px; height: 40px; border-radius: 12px; border: 1px solid #1c2b4a; background: #0b1328; color: #dfe9ff; font: inherit; font-size: 18px; font-weight: 800; cursor: pointer; }
.ch-step button:disabled { opacity: 0.35; cursor: default; }
.ch-step b { min-width: 76px; color: #fff; }
.ch-btn { display: block; width: 100%; min-height: 46px; border: 0; border-radius: 13px; font: inherit; font-size: 16px; font-weight: 800; cursor: pointer; color: #04101c; background: linear-gradient(135deg, #3dffb5, #55d6ff); box-shadow: 0 6px 22px rgba(61,255,181,0.22); }
.ch-btn:hover { filter: brightness(1.08); }
.ch-btn.ch-ghost { background: #0b1328; color: #dfe9ff; box-shadow: inset 0 0 0 1px #1c2b4a; }
.ch-row { display: flex; gap: 8px; margin-top: 8px; }
.ch-row .ch-btn { min-height: 42px; font-size: 14.5px; }
.ch-link { display: inline-block; margin-top: 10px; min-height: 40px; padding: 0 12px; border: 0; background: transparent; color: #55d6ff; font: inherit; font-size: 13.5px; font-weight: 700; cursor: pointer; border-radius: 10px; }
.ch-keys { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px 12px; margin: 10px auto 12px; max-width: 250px; font-size: 13px; color: #dfe9ff; text-align: left; }
.ch-keys kbd, .ch-how kbd { display: inline-block; min-width: 24px; padding: 2px 6px; margin-right: 6px; border-radius: 6px; border: 1px solid #2b4370; background: #16213a; color: #bfe9ff; font: inherit; font-weight: 800; text-align: center; }
.ch-how { margin: 0 0 12px; padding: 0; list-style: none; text-align: left; font-size: 13.5px; line-height: 1.45; color: #c9d6ee; }
.ch-how li { padding: 5px 0 5px 26px; position: relative; }
.ch-how li i { position: absolute; left: 0; top: 8px; width: 16px; height: 11px; border-radius: 4px; }
.ch-how b { color: #fff; }
.ch-big { font-size: 46px; font-weight: 900; line-height: 1; color: #fff; font-variant-numeric: tabular-nums; margin: 4px 0 2px; }
.ch-bestline { font-size: 13px; color: #8aa3c4; margin: 0 0 10px; }
.ch-bestline b { color: #ffd166; }
.ch-newbest { display: inline-block; margin: 4px 0 8px; padding: 4px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 800; color: #1c1300; background: linear-gradient(90deg, #ffd166, #fff0b8, #ffd166); background-size: 200% 100%; animation: ch-shine 1.6s linear infinite; }
@keyframes ch-shine { to { background-position: -200% 0; } }
.ch-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 0 0 10px; }
.ch-grid div { padding: 7px 4px; border-radius: 11px; border: 1px solid #1c2b4a; background: #070c1c; }
.ch-grid b { display: block; font-size: 17px; color: #fff; font-variant-numeric: tabular-nums; }
.ch-grid span { font-size: 10.5px; color: #8aa3c4; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 700; }
.ch-badges { display: flex; flex-wrap: wrap; gap: 5px; justify-content: center; margin: 0 0 12px; }
.ch-badges span { padding: 4px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; color: #ffd166; border: 1px solid rgba(255,209,102,0.4); background: rgba(255,209,102,0.08); }
.ch-opt { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0 0 12px; font-size: 13px; color: #c9d6ee; text-align: left; }
.ch-opt button { min-height: 40px; padding: 0 12px; border-radius: 11px; border: 1px solid #1c2b4a; background: #0b1328; color: #dfe9ff; font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; white-space: nowrap; }
.ch-daily { font-size: 12.5px; color: #8aa3c4; margin: 0 0 10px; min-height: 0; }
.ch-sr { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

.ch-help .hint-touch { display: none; }
@media (pointer: coarse) { .ch-help .hint-kb { display: none; } .ch-help .hint-touch { display: inline; } }

/* the score bar and its two buttons stay above the menus, except on a short stage where a menu needs the room */
.ch-short .ch-hud { z-index: 3; }
.ch-short .ch-panel { padding: 12px 16px; }
.ch-short .ch-logo { font-size: 26px; }
.ch-short .ch-sub, .ch-short .ch-modeinfo { margin-bottom: 8px; min-height: 0; font-size: 12.5px; }
.ch-short .ch-big { font-size: 34px; }
.ch-short .ch-badges, .ch-short .ch-keys { display: none; }
.ch-short .ch-link { margin-top: 2px; }

@media (max-width: 600px) {
  .ch-stage { height: auto; aspect-ratio: 4 / 5; max-height: 76vh; }
}
@media (max-width: 420px) {
  .ch-hud { gap: 8px; padding-left: 10px; }
  .ch-stat b { font-size: 19px; }
  .ch-stat-lvl b { font-size: 16px; }
}
.stage.is-immersive .stage-body > .ch { min-height: 0; }
.stage.is-immersive .ch-stage { flex: 1 1 auto; height: auto; aspect-ratio: auto; max-height: none; min-height: 0; }
.stage.is-immersive .ch-help { display: none; }

@media (prefers-reduced-motion: reduce) {
  .ch-panel, .ch-newbest { animation: none; }
  .ch-stat b, .ch-chain, .ch-banner { transition: none; }
}

/* while a run is live the stage owns every touch; on the menus the page still scrolls */
.ch-live .ch-stage, .ch-live .ch-stage canvas { touch-action: none; }
.ch-idle .ch-stat, .ch-idle .ch-chain, .ch-idle .ch-goal, .ch-idle .ch-lives, .ch-idle #ch-pause, .ch-ended #ch-pause { visibility: hidden; }

/* four hop buttons for thumbs */
.ch-pad { position: absolute; left: 0; right: 0; bottom: 0; z-index: 3; display: none; grid-template-columns: 1fr 1fr; gap: 8px; padding: 8px 10px 10px; pointer-events: none; }
.ch-pad button { pointer-events: auto; touch-action: none; height: 52px; border-radius: 14px; border: 1px solid #2b4370; background: rgba(13,22,46,0.82); color: #bfe9ff; display: grid; place-items: center; padding: 0; font: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.ch-pad button:active { background: #1d3157; border-color: #55d6ff; color: #fff; transform: scale(0.96); }
.ch-pad button:focus-visible { outline: 2px solid #55d6ff; outline-offset: 2px; }
@media (pointer: coarse) {
  .ch-live .ch-pad { display: grid; }
  .ch-live:not(.ch-narrow) .ch-pad { grid-template-columns: 84px 84px; justify-content: space-between; padding: 8px 10px 12px; }
  .ch-live:not(.ch-narrow) .ch-pad button { height: 60px; }
}
@media (max-width: 600px) and (pointer: coarse) {
  .ch-stage { aspect-ratio: 2 / 3; }
}
