/*
 * Chordonomy in the site's full-screen frame, the same frame as its other tools: a slim bar with its name,
 * the score line, the play area, the keys, and a dock along the bottom with the main button. The night sky
 * fills everything between the bar and the dock, edge to edge, and keeps its own colors in both of the
 * site's modes (like a TV screen); the bar and the dock follow the page.
 *
 * Colors and typefaces come from the site's theme (its custom properties), with the dark values as
 * fall-backs so the game also looks right on a page of its own.
 */
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600&display=swap');

.cg {
  --c: #B79CFF; --ct: #B79CFF;            /* the game's color, as a fill and as lettering on the page */
  --gold: #FFD84D; --heart: #FF8FA3; --hit: #7CF0B5; --miss: #FF6B6B;
  --cg-ink: var(--ink, #F2F0EA);
  --cg-card: var(--card, #17191E); --cg-line: var(--card-line, #2E323A); --cg-line-strong: var(--line, #3A3F48);
  --cg-muted: var(--muted, #B9BCC4);
  --display: var(--font-display, 'Archivo', 'Arial Black', sans-serif);
  --body: var(--font-body, 'Figtree', 'Segoe UI', system-ui, sans-serif);
  --mono: var(--font-mono, 'IBM Plex Mono', ui-monospace, Consolas, monospace);
  --game: 'Jersey 15', var(--mono);
  --world-ink: #EDE8FF; --world-muted: #B9B0E0;
  --app-top: 0px;                                /* how far down the page the game starts; the script measures it */
  --app-pad: max(16px, calc(50vw - 600px));      /* the game stays within 1200px, the sky runs to the edges */
  --field: min(100%, 760px);
  --app-expand: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 9V4h5M15 4h5v5M20 15v5h-5M9 20H4v-5'/%3E%3C/svg%3E");

  position: relative; box-sizing: border-box; display: grid; width: 100%; margin: 0;
  height: calc(100vh - var(--app-top)); height: calc(100dvh - var(--app-top)); min-height: 560px;
  padding: 6px var(--app-pad) 0;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto auto minmax(0, 1fr) auto auto;
  grid-template-areas: "name full" "hud hud" "play play" "keys keys" "dock dock";
  column-gap: 10px;
  font-family: var(--body); font-size: 16px; line-height: 1.4; color: var(--world-ink); text-align: left;
  overflow: hidden;
}
:root[data-theme="light"] .cg { --ct: #5A3BC9; }
.cg, .cg *, .cg *::before, .cg *::after { box-sizing: border-box; }
.cg [hidden] { display: none !important; }
.cg button { font: inherit; color: inherit; }
.cg button:focus-visible { outline: 3px solid var(--focus, #4FD1C5); outline-offset: 2px; }

/* full screen: nothing above the game */
.cg:fullscreen, html.rn-full .cg { --app-top: 0px; }
.cg:fullscreen { background: var(--bg, #0E0F12); }

/* ---------- the bar: the name, and full screen ---------- */
.cg .cg-name {
  grid-area: name; display: flex; align-items: center; gap: 10px; min-height: 40px; margin-bottom: 6px; min-width: 0;
  font-family: var(--mono); font-size: 12px; font-weight: 500; letter-spacing: 0.12em; text-transform: uppercase; white-space: nowrap; color: var(--ct);
}
.cg .cg-name::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--c); box-shadow: 0 0 10px var(--c); }
/* back to the start, from anywhere but the start */
.cg .cg-back {
  flex: none; display: inline-flex; align-items: center; height: 36px; margin: 0; padding: 0 14px; border: 1px solid var(--cg-line-strong); border-radius: 999px;
  background: transparent; cursor: pointer; font-family: var(--mono); font-size: 12px; font-weight: 500; letter-spacing: 0.1em; text-transform: uppercase; color: var(--cg-ink);
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}
.cg .cg-back:hover { background: var(--c); border-color: var(--c); color: #0E0F12; }
.cg .cg-name:has(.cg-back:not([hidden]))::before { display: none; }
.cg .cg-full {
  grid-area: full; align-self: start; display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; margin: 0; padding: 0;
  border: 1px solid var(--cg-line-strong); border-radius: 999px; background: transparent; color: var(--cg-ink); cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
.cg .cg-full:hover { background: var(--c); border-color: var(--c); color: #0E0F12; }
.cg .cg-full::before { content: ""; width: 16px; height: 16px; background: currentColor; -webkit-mask: var(--app-expand) center / contain no-repeat; mask: var(--app-expand) center / contain no-repeat; }

/* ---------- the world: one canvas behind the score line, the play area and the keys ----------
   It is placed over those rows without taking part in their sizing: the script draws it at the size it is
   shown, and that size must come from the rows, never the other way round. */
.cg .cg-world {
  position: absolute; grid-row: 2 / 5; grid-column: 1 / -1; top: 0; left: calc(-1 * var(--app-pad)); display: block;
  width: calc(100% + 2 * var(--app-pad)); height: 100%; border-top: 1px solid var(--cg-line);
}

/* ---------- the score line ---------- */
.cg .cg-hud { grid-area: hud; position: relative; z-index: 2; width: var(--field); margin: 0 auto; padding: 12px 0 4px; }
.cg .cg-hud__row { display: grid; grid-template-columns: 1fr auto 1fr; align-items: end; gap: 10px; }
.cg .cg-label { display: block; font-family: var(--mono); font-size: 10px; font-weight: 500; letter-spacing: 0.14em; text-transform: uppercase; color: var(--world-muted); white-space: nowrap; }
.cg .cg-score b { display: block; font-family: var(--game); font-weight: 400; font-size: 34px; line-height: 0.85; color: var(--world-ink); transform-origin: left bottom; transition: transform 0.15s ease, color 0.15s ease; }
.cg .cg-score b.is-pop { transform: scale(1.14); color: var(--gold); }
.cg .cg-combo { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.cg .cg-combo__x { font-family: var(--game); font-size: 30px; line-height: 0.85; color: var(--gold); text-shadow: 0 0 16px color-mix(in srgb, var(--gold) 60%, transparent); transition: transform 0.15s ease; }
.cg .cg-combo__x.is-pop { transform: scale(1.35); }
.cg .cg-combo__bar { display: flex; gap: 3px; }
.cg .cg-combo__bar i { width: 10px; height: 4px; border-radius: 2px; background: rgba(255, 255, 255, 0.18); }
.cg .cg-combo__bar i.is-on { background: var(--gold); box-shadow: 0 0 6px var(--gold); }
.cg .cg-lives { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.cg .cg-lives__hearts { display: flex; gap: 4px; }
.cg .cg-lives__hearts svg { width: 22px; height: 22px; fill: var(--heart); filter: drop-shadow(0 0 6px rgba(255, 143, 163, 0.6)); transition: opacity 0.3s, transform 0.3s; }
.cg .cg-lives__hearts svg.is-gone { fill: none; stroke: rgba(255, 255, 255, 0.3); stroke-width: 2; filter: none; }
.cg .cg-level { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.cg .cg-level__name { font-family: var(--mono); font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--world-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.cg .cg-level__name b { color: var(--world-ink); font-weight: 600; }
.cg .cg-level__bar { flex: 1; min-width: 40px; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.12); overflow: hidden; }
.cg .cg-level__bar i { display: block; height: 100%; width: 0; border-radius: 3px; background: linear-gradient(90deg, var(--c), var(--gold)); transition: width 0.4s ease; }
.cg .cg-level__best { margin-left: auto; font-family: var(--mono); font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--world-muted); white-space: nowrap; }
.cg .cg-level__best b { color: var(--gold); font-family: var(--game); font-size: 18px; font-weight: 400; letter-spacing: 0; margin-left: 4px; }
.cg .cg-level__best span { margin-left: 12px; }
/* Endless: the player's place on the high scores, and what it takes to climb */
.cg .cg-level__best em { font-style: normal; font-family: var(--game); font-size: 22px; line-height: 1; letter-spacing: 0; color: var(--gold); text-shadow: 0 0 10px color-mix(in srgb, var(--gold) 50%, transparent); vertical-align: -2px; }
.cg .cg-level__best em + span { margin-left: 8px; }
.cg .cg-level__best span b { margin-left: 2px; font-family: inherit; font-size: inherit; font-weight: 700; letter-spacing: inherit; color: var(--world-ink); }
.cg .cg-level__best span.is-top { color: var(--hit); }

/* ---------- the play area: where the cards and messages sit ---------- */
.cg .cg-play { grid-area: play; position: relative; z-index: 3; width: var(--field); margin: 0 auto; min-height: 0; }

/* cards over the world: start, level, pause, results */
.cg .cg-card {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(440px, 100%); max-height: 100%; overflow: auto;
  padding: 22px 20px 20px; border: 1px solid color-mix(in srgb, var(--c) 40%, transparent); border-radius: 24px; text-align: center;
  background: rgba(10, 6, 30, 0.66); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); color: var(--world-ink);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45), 0 0 60px color-mix(in srgb, var(--c) 22%, transparent);
  scrollbar-width: none;
}
.cg .cg-card::-webkit-scrollbar { display: none; }
.cg .cg-title { margin: 0; font-family: var(--game); font-weight: 400; font-size: clamp(50px, 15vw, 84px); line-height: 0.85; color: var(--gold); text-shadow: 0 0 34px color-mix(in srgb, var(--gold) 45%, transparent); white-space: nowrap; }
.cg .cg-title--sm { font-size: clamp(40px, 11vw, 60px); }
.cg .cg-sub { margin: 8px 0 0; font-family: var(--mono); font-size: 12px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--c); }
.cg .cg-card > .cg-sub:first-child { margin: 0 0 6px; }
.cg .cg-lede { margin: 12px 0 0; font-size: 16px; color: var(--world-muted); }
.cg .cg-ways { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 8px; margin: 16px 0 0; }
.cg .cg-way { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 4px; border-radius: 14px; background: rgba(255, 255, 255, 0.07); font-size: 12px; line-height: 1.2; color: var(--world-ink); }
.cg .cg-way svg { width: 26px; height: 26px; color: var(--gold); }
.cg .cg-way.is-ready { background: color-mix(in srgb, var(--hit) 22%, transparent); box-shadow: inset 0 0 0 1px var(--hit); }
.cg .cg-note { margin: 12px 0 0; font-size: 13px; color: var(--world-muted); }
.cg .cg-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-width: 160px; height: 50px; margin-top: 16px; padding: 0 24px; border: 0; border-radius: 999px;
  background: var(--c); color: #0E0F12; cursor: pointer; transition: background-color 0.2s ease, transform 0.15s ease;
  font-family: var(--display); font-stretch: 112%; font-weight: 800; font-size: 15px; letter-spacing: 0.06em; text-transform: uppercase;
}
.cg .cg-btn:hover { background: color-mix(in srgb, var(--c) 82%, #fff); }
.cg .cg-btn:active { transform: scale(0.97); }
.cg .cg-btn--ghost { background: transparent; color: var(--world-ink); box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.4); }
.cg .cg-btn--ghost:hover { background: rgba(255, 255, 255, 0.1); }
.cg .cg-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 0 10px; }
.cg .cg-row .cg-btn { min-width: 0; flex: 1 1 120px; padding: 0 14px; font-size: 14px; white-space: nowrap; }
/* the start card's two ways in, side by side and the same size; Endless beneath */
.cg .cg-row--two .cg-btn { white-space: normal; line-height: 1.1; padding: 0 12px; }
.cg .cg-btn--alt { background: rgba(255, 255, 255, 0.14); color: var(--world-ink); box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.5); }
.cg .cg-btn--alt:hover { background: rgba(255, 255, 255, 0.22); }
.cg .cg-endless {
  display: flex; align-items: center; gap: 12px; width: 100%; margin: 12px 0 0; padding: 10px 16px; border: 1px solid color-mix(in srgb, var(--gold) 55%, transparent); border-radius: 18px;
  background: linear-gradient(100deg, color-mix(in srgb, var(--gold) 16%, transparent), rgba(255, 255, 255, 0.04)); cursor: pointer; text-align: left; color: var(--world-ink);
  transition: border-color 0.2s ease, background-color 0.2s ease;
}
.cg .cg-endless:hover { border-color: var(--gold); }
.cg .cg-endless svg { flex: none; width: 30px; height: 30px; fill: var(--gold); filter: drop-shadow(0 0 8px color-mix(in srgb, var(--gold) 70%, transparent)); }
.cg .cg-endless b { display: block; font-family: var(--game); font-weight: 400; font-size: 26px; line-height: 0.9; color: var(--gold); }
.cg .cg-endless small { display: block; margin-top: 2px; font-size: 13px; color: var(--world-muted); }
.cg .cg-endless > span { flex: 1; min-width: 0; }
.cg .cg-endless > i { flex: none; font-style: normal; font-family: var(--display); font-size: 26px; line-height: 1; color: var(--gold); }
.cg .cg-endless .cg-endless__top { margin-top: 6px; color: var(--world-ink); }
.cg .cg-endless .cg-endless__top:empty { display: none; }
.cg .cg-endless .cg-endless__top b { display: inline; font-family: inherit; font-size: inherit; line-height: inherit; color: var(--gold); font-weight: 700; margin-right: 4px; }
.cg .cg-links { display: flex; justify-content: center; align-items: baseline; gap: 4px; margin-top: 6px; color: var(--world-muted); }
.cg .cg-links .cg-link { margin: 0; }
.cg .cg-link {
  display: block; margin: 14px auto 0; padding: 4px 8px; border: 0; background: none; cursor: pointer;
  font-size: 14px; color: var(--world-muted); text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--c) 60%, transparent); text-underline-offset: 4px;
}
.cg .cg-link b { color: var(--world-ink); font-weight: 700; }
.cg .cg-link:hover b { color: var(--gold); }
.cg .cg-best { margin-top: 12px; font-family: var(--mono); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--world-muted); }
.cg .cg-best b { color: var(--gold); font-family: var(--game); font-size: 22px; font-weight: 400; letter-spacing: 0; margin-left: 6px; vertical-align: -2px; }
.cg .cg-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.cg .cg-chips--center { justify-content: center; margin-top: 12px; }
.cg .cg-chips span { padding: 2px 8px; border-radius: 999px; background: rgba(255, 255, 255, 0.1); font-family: var(--game); font-size: 17px; line-height: 1.2; color: var(--world-ink); }
.cg .cg-chips .cg-chip--note { font-family: var(--mono); font-size: 11px; line-height: 21px; letter-spacing: 0.08em; text-transform: uppercase; background: color-mix(in srgb, var(--c) 28%, transparent); color: var(--world-ink); }
.cg .cg-chips .cg-chip--memory { font-family: var(--mono); font-size: 11px; line-height: 21px; letter-spacing: 0.08em; text-transform: uppercase; background: color-mix(in srgb, var(--hit) 22%, transparent); color: var(--hit); }

/* Endless: where it starts, its power-ups, and the high scores */
.cg .cg-stepper { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 14px auto 0; }
.cg .cg-stepper button {
  width: 44px; height: 44px; border: 1px solid rgba(255, 255, 255, 0.35); border-radius: 50%; background: rgba(255, 255, 255, 0.06); cursor: pointer;
  font-family: var(--display); font-size: 24px; line-height: 1; color: var(--world-ink);
}
.cg .cg-stepper button:disabled { opacity: 0.3; cursor: default; }
.cg .cg-stepper div { min-width: 150px; }
.cg .cg-stepper b { display: block; font-family: var(--game); font-weight: 400; font-size: 32px; line-height: 0.95; color: var(--gold); }
.cg .cg-stepper small { display: block; font-size: 13px; color: var(--world-muted); }
.cg .cg-powers { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 12px; }
.cg .cg-power { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 6px; border-radius: 999px; background: rgba(255, 255, 255, 0.07); font-size: 13px; color: var(--world-ink); }
.cg .cg-power svg { width: 16px; height: 16px; }
.cg .cg-power--star svg { fill: #FFD84D; }
.cg .cg-power--moon svg { fill: #BFD7FF; }
.cg .cg-power--heart svg { fill: var(--heart); }
.cg .cg-board-wrap { margin-top: 14px; }
.cg .cg-board-wrap:empty { display: none; }
.cg .cg-board { margin: 6px 0 0; padding: 0; list-style: none; text-align: left; }
.cg .cg-board li { display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; align-items: baseline; gap: 8px; padding: 5px 10px; border-radius: 10px; }
.cg .cg-board li:nth-child(odd) { background: rgba(255, 255, 255, 0.05); }
.cg .cg-board li span { font-family: var(--mono); font-size: 12px; color: var(--world-muted); }
.cg .cg-board li b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.cg .cg-board li em { font-style: normal; font-family: var(--game); font-size: 20px; line-height: 1; color: var(--gold); }
.cg .cg-board li.is-me { background: color-mix(in srgb, var(--c) 30%, transparent); box-shadow: inset 0 0 0 1px var(--c); }
.cg .cg-save { margin: 14px 0 0; }
.cg .cg-save__row { display: flex; gap: 8px; margin-top: 6px; }
.cg .cg-save input {
  flex: 1; min-width: 0; height: 46px; padding: 0 14px; border: 1px solid rgba(255, 255, 255, 0.35); border-radius: 999px; background: rgba(0, 0, 0, 0.3);
  font: inherit; font-size: 16px; color: var(--world-ink);
}
.cg .cg-save input:focus { outline: 2px solid var(--c); outline-offset: 1px; }
.cg .cg-save .cg-btn { flex: none; min-width: 0; height: 46px; margin: 0; padding: 0 18px; }
.cg .cg-save__say { margin: 6px 0 0; min-height: 1em; font-size: 13px; color: var(--world-muted); }
.cg .cg-save__say:empty { display: none; }
.cg .cg-rank { margin-top: 12px; font-size: 16px; color: var(--world-ink); }
.cg .cg-rank b { font-family: var(--game); font-weight: 400; font-size: 28px; color: var(--hit); }

/* Endless, on a screen wide enough: the high scores beside the sky, the player among them, live */
.cg .cg-ladder { display: none; }
@media (min-width: 1220px) {
  .cg .cg-ladder:not([hidden]) {
    display: block; position: absolute; z-index: 3; grid-area: play; top: 8px; right: 0; width: 210px; padding: 10px 10px 8px; border-radius: 16px;
    background: rgba(10, 6, 30, 0.55); border: 1px solid rgba(255, 255, 255, 0.12); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  }
  .cg .cg-ladder ol { margin: 6px 0 0; padding: 0; list-style: none; }
  .cg .cg-ladder li { display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; align-items: baseline; gap: 6px; padding: 5px 8px; border-radius: 10px; font-size: 13px; transition: background-color 0.3s ease; }
  .cg .cg-ladder li span { font-family: var(--mono); font-size: 11px; color: var(--world-muted); }
  .cg .cg-ladder li b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
  .cg .cg-ladder li em { font-style: normal; font-family: var(--game); font-size: 18px; line-height: 1; color: var(--gold); }
  .cg .cg-ladder li.is-me { background: color-mix(in srgb, var(--c) 35%, transparent); box-shadow: inset 0 0 0 1px var(--c), 0 0 18px color-mix(in srgb, var(--c) 35%, transparent); }
  .cg .cg-ladder li.is-me span, .cg .cg-ladder li.is-me em { color: var(--world-ink); }
}

/* the level path: the levels climb into the sky, the newest at the top */
.cg .cg-map { position: absolute; inset: 0; overflow-y: auto; padding: 8px 4px 24px; scrollbar-width: none; }
.cg .cg-map::-webkit-scrollbar { display: none; }
.cg .cg-map__head { position: sticky; top: -8px; z-index: 2; display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin: -8px -4px 0; padding: 12px 10px 18px; background: linear-gradient(180deg, #06041C 0%, #06041C 62%, rgba(6, 4, 28, 0)); }
.cg .cg-map__head h2 { margin: 0; font-family: var(--game); font-weight: 400; font-size: 40px; line-height: 0.9; color: var(--gold); text-shadow: 0 0 20px rgba(0, 0, 0, 0.6); }
.cg .cg-map__head span { font-family: var(--mono); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--world-muted); }
.cg .cg-map__note { text-align: center; padding: 4px 10px 0; }
.cg .cg-path { position: relative; display: flex; flex-direction: column-reverse; gap: 14px; }
.cg .cg-path::before { content: ""; position: absolute; left: 31px; top: 20px; bottom: 20px; border-left: 2px dotted rgba(255, 255, 255, 0.3); }
.cg .cg-lvl {
  position: relative; display: grid; grid-template-columns: 64px minmax(0, 1fr); align-items: center; gap: 12px; width: 100%; margin: 0; padding: 0;
  border: 0; background: none; text-align: left; color: var(--world-ink); cursor: pointer;
}
.cg .cg-lvl[disabled] { cursor: default; }
.cg .cg-lvl__dot {
  position: relative; z-index: 1; display: flex; align-items: center; justify-content: center; width: 64px; height: 64px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff 0%, var(--gold) 30%, color-mix(in srgb, var(--gold) 40%, #000) 100%);
  font-family: var(--game); font-size: 32px; color: #1A1030; box-shadow: 0 0 22px color-mix(in srgb, var(--gold) 55%, transparent);
}
.cg .cg-lvl--now .cg-lvl__dot { background: radial-gradient(circle at 35% 30%, #fff 0%, var(--c) 35%, color-mix(in srgb, var(--c) 40%, #000) 100%); box-shadow: 0 0 0 6px color-mix(in srgb, var(--c) 30%, transparent), 0 0 30px var(--c); animation: cg-pulse 1.8s ease-in-out infinite; }
.cg .cg-lvl--locked .cg-lvl__dot { background: rgba(255, 255, 255, 0.08); box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.22); color: rgba(255, 255, 255, 0.45); }
.cg .cg-lvl__dot svg { width: 22px; height: 22px; }
.cg .cg-lvl__card { display: block; padding: 12px 14px; border-radius: 16px; background: rgba(10, 6, 30, 0.6); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); border: 1px solid rgba(255, 255, 255, 0.1); transition: border-color 0.2s ease; }
.cg .cg-lvl:not([disabled]):hover .cg-lvl__card { border-color: color-mix(in srgb, var(--c) 70%, transparent); }
.cg .cg-lvl--now .cg-lvl__card { border-color: var(--c); box-shadow: 0 0 24px color-mix(in srgb, var(--c) 30%, transparent); }
.cg .cg-lvl--locked .cg-lvl__card { opacity: 0.62; }
.cg .cg-lvl__top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cg .cg-lvl__name { font-family: var(--display); font-stretch: 110%; font-weight: 800; font-size: 17px; line-height: 1.1; }
.cg .cg-lvl__stars { flex: none; display: flex; gap: 2px; }
.cg .cg-lvl__stars svg { width: 15px; height: 15px; fill: var(--gold); }
.cg .cg-lvl__stars svg.is-empty { fill: rgba(255, 255, 255, 0.2); }
.cg .cg-lvl__best { flex: none; font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--gold); }
.cg .cg-lvl__what { display: block; margin-top: 3px; font-size: 13px; line-height: 1.35; color: var(--world-muted); }
.cg .cg-lvl--now .cg-chips span:not(.cg-chip--memory) { background: color-mix(in srgb, var(--c) 35%, transparent); }
.cg .cg-lvl__go { display: inline-block; margin-top: 10px; padding: 6px 14px; border-radius: 999px; background: var(--c); color: #0E0F12; font-weight: 800; font-size: 13px; letter-spacing: 0.06em; text-transform: uppercase; }
.cg .cg-lvl__lock { display: block; margin-top: 8px; font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--world-muted); }
.cg .cg-lvl__go--again { background: transparent; color: var(--world-ink); box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.4); }
@keyframes cg-pulse { 50% { box-shadow: 0 0 0 10px color-mix(in srgb, var(--c) 18%, transparent), 0 0 40px var(--c); } }

/* results */
.cg .cg-stars { display: flex; justify-content: center; gap: 8px; margin: 14px 0 4px; }
.cg .cg-stars svg { width: 46px; height: 46px; fill: var(--gold); filter: drop-shadow(0 0 12px color-mix(in srgb, var(--gold) 70%, transparent)); animation: cg-star 0.5s cubic-bezier(.2, 1.6, .4, 1) backwards; }
.cg .cg-stars svg:nth-child(2) { width: 58px; height: 58px; margin-top: -10px; animation-delay: 0.25s; }
.cg .cg-stars svg:nth-child(3) { animation-delay: 0.5s; }
.cg .cg-stars svg.is-empty { fill: rgba(255, 255, 255, 0.18); filter: none; }
.cg .cg-stars--small { margin: 10px 0 0; gap: 4px; }
.cg .cg-stars--small svg, .cg .cg-stars--small svg:nth-child(2) { width: 26px; height: 26px; margin-top: 0; animation: none; }
@keyframes cg-star { from { transform: scale(0) rotate(-90deg); opacity: 0; } }
.cg .cg-newbest { margin-top: 6px; font-family: var(--game); font-size: 24px; line-height: 1; color: var(--hit); text-shadow: 0 0 14px color-mix(in srgb, var(--hit) 50%, transparent); }
.cg .cg-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0 0; }
.cg .cg-stats div { padding: 8px 4px; border-radius: 12px; background: rgba(255, 255, 255, 0.07); }
.cg .cg-stats b { display: block; font-family: var(--game); font-weight: 400; font-size: 28px; line-height: 0.95; color: var(--world-ink); }
.cg .cg-learned { margin: 14px 0 0; }
.cg .cg-shapes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 6px; }
.cg .cg-shape { padding: 8px 6px 6px; border-radius: 12px; background: rgba(255, 255, 255, 0.07); }
.cg .cg-shape b { display: block; margin-bottom: 4px; font-family: var(--game); font-weight: 400; font-size: 22px; line-height: 1; color: var(--gold); }
.cg .cg-shape svg { display: block; width: 100%; height: auto; }

/* the moment after a miss: the chord, named, on the keys */
.cg .cg-teach {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); width: min(360px, 100%); padding: 14px 16px; border-radius: 18px; text-align: center;
  background: rgba(10, 6, 30, 0.82); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); border: 1px solid var(--gold); box-shadow: 0 0 30px color-mix(in srgb, var(--gold) 30%, transparent);
  animation: cg-in 0.3s ease backwards;
}
.cg .cg-teach__name { font-family: var(--game); font-size: 40px; line-height: 0.9; color: var(--gold); }
.cg .cg-teach__name.is-long { font-size: 30px; }
.cg .cg-teach__notes { margin-top: 4px; font-family: var(--display); font-stretch: 110%; font-weight: 800; font-size: 20px; letter-spacing: 0.08em; color: var(--world-ink); }
.cg .cg-teach__how { margin-top: 6px; font-size: 14px; color: var(--world-muted); }
.cg .cg-teach.is-got { border-color: var(--hit); }
.cg .cg-teach.is-got .cg-teach__name { color: var(--hit); }
@keyframes cg-in { from { opacity: 0; transform: translate(-50%, 12px); } }

/* small messages: a hint for first-timers, MIDI news */
.cg .cg-toast {
  position: absolute; left: 50%; top: 10px; z-index: 2; transform: translateX(-50%); max-width: 100%; padding: 8px 14px; border-radius: 999px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  background: rgba(10, 6, 30, 0.8); border: 1px solid rgba(255, 255, 255, 0.18); font-size: 13px; color: var(--world-ink);
  animation: cg-in 0.3s ease backwards; pointer-events: none;
}
.cg .cg-toast b { color: var(--gold); }
@media (max-width: 480px) { .cg .cg-toast { white-space: normal; text-align: center; border-radius: 16px; width: max-content; } }

/* ---------- the keyboard: C to E, an octave and a bit ---------- */
.cg .cg-keys {
  grid-area: keys; position: relative; z-index: 2; width: var(--field); height: 118px; margin: 0 auto 10px; touch-action: none; user-select: none; -webkit-user-select: none;
  border-radius: 0 0 12px 12px; filter: drop-shadow(0 -6px 18px color-mix(in srgb, var(--c) 30%, transparent));
}
.cg .k { position: absolute; top: 0; margin: 0; padding: 0 0 8px; border: 0; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 2px; -webkit-tap-highlight-color: transparent; }
.cg .k--w { height: 100%; border-radius: 0 0 9px 9px; background: linear-gradient(180deg, #E9E6F2 0%, #FFFFFF 70%, #F2F0F7 100%); box-shadow: inset 0 -5px 0 #CFCADD, inset -1px 0 0 #B9B3CC; color: #3A3550; }
.cg .k--b { z-index: 2; height: 62%; border-radius: 0 0 6px 6px; background: linear-gradient(180deg, #1B1726 0%, #2E2840 100%); box-shadow: inset 0 -4px 0 #0B0912, 0 3px 6px rgba(0, 0, 0, 0.4); color: #CFC8E8; }
.cg .k__name { font-family: var(--display); font-weight: 800; font-size: 13px; line-height: 1; opacity: 0; transition: opacity 0.15s; }
.cg .k--b .k__name { font-size: 10px; }
.cg .k__letter { font-family: var(--mono); font-size: 10px; line-height: 1; opacity: 0.55; }
.cg--touch .k__letter { display: none; }
.cg .k.is-c .k__name { opacity: 0.5; }
.cg .k.is-down.k--w, .cg .k.is-latched.k--w { background: linear-gradient(180deg, color-mix(in srgb, var(--c) 55%, #fff) 0%, var(--c) 100%); box-shadow: inset 0 -2px 0 color-mix(in srgb, var(--c) 60%, #000), 0 0 18px var(--c); color: #120B24; }
.cg .k.is-down.k--b, .cg .k.is-latched.k--b { background: linear-gradient(180deg, color-mix(in srgb, var(--c) 70%, #000) 0%, var(--c) 100%); box-shadow: 0 0 16px var(--c); color: #120B24; }
.cg .k.is-latched .k__name, .cg .k.is-down .k__name, .cg .k.is-teach .k__name { opacity: 1; }
.cg .k.is-latched::after { content: ""; position: absolute; left: 50%; top: 8px; width: 8px; height: 8px; margin-left: -4px; border-radius: 50%; background: #fff; box-shadow: 0 0 8px #fff; }
.cg .k.is-teach.k--w { background: linear-gradient(180deg, #FFF3B8 0%, var(--gold) 100%); box-shadow: inset 0 -2px 0 #C9A400, 0 0 22px var(--gold); color: #2A2000; animation: cg-teach 1s ease-in-out infinite; }
.cg .k.is-teach.k--b { background: linear-gradient(180deg, #8A7300 0%, var(--gold) 100%); box-shadow: 0 0 18px var(--gold); color: #2A2000; animation: cg-teach 1s ease-in-out infinite; }
.cg .k.is-wrong { background: var(--miss) !important; box-shadow: 0 0 18px var(--miss) !important; color: #fff !important; }
.cg .k.is-hit.k--w { background: linear-gradient(180deg, #FFFFFF 0%, var(--flash, var(--hit)) 100%); box-shadow: 0 0 22px var(--flash, var(--hit)); color: #120B24; }
.cg .k.is-hit.k--b { background: var(--flash, var(--hit)); box-shadow: 0 0 18px var(--flash, var(--hit)); color: #120B24; }
.cg .k.is-hit .k__name { opacity: 1; }
/* a note the chord can do without: lit, but paler */
.cg .k.is-teach.is-may.k--w { background: linear-gradient(180deg, #FFFBE6 0%, #FFEC9E 100%); box-shadow: inset 0 -2px 0 #E0CB7A; animation: none; }
.cg .k.is-teach.is-may.k--b { background: linear-gradient(180deg, #6B6040 0%, #B8A55C 100%); box-shadow: none; animation: none; }
@keyframes cg-teach { 50% { filter: brightness(1.15); } }

/* ---------- the dock: MIDI, sound and the main button ---------- */
.cg .cg-dock {
  grid-area: dock; position: relative; z-index: 4; margin: 0 calc(-1 * var(--app-pad)); padding: 10px var(--app-pad) 12px;
  background: color-mix(in srgb, var(--c) 9%, var(--cg-card)); border-top: 1px solid color-mix(in srgb, var(--c) 50%, var(--cg-line));
  box-shadow: 0 -1px 18px color-mix(in srgb, var(--c) 30%, transparent); color: var(--cg-ink);
}
.cg .cg-dock__in { display: flex; align-items: center; gap: 10px; width: var(--field); margin: 0 auto; }
.cg .cg-midi, .cg .cg-sound {
  flex: none; display: inline-flex; align-items: center; gap: 8px; height: 48px; margin: 0; padding: 0 14px; border: 1px solid var(--cg-line-strong); border-radius: 999px;
  background: transparent; cursor: pointer; font-weight: 700; font-size: 14px; color: var(--cg-ink); transition: border-color 0.2s ease, background-color 0.2s ease;
}
.cg .cg-midi:hover, .cg .cg-sound:hover { border-color: var(--c); }
.cg .cg-sound { width: 48px; padding: 0; justify-content: center; }
.cg .cg-midi svg, .cg .cg-sound svg { width: 20px; height: 20px; }
.cg .cg-midi small { font-weight: 500; color: var(--cg-muted); max-width: 9em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cg .cg-midi small:empty { display: none; }
@media (max-width: 480px) { .cg .cg-midi small { max-width: 5.5em; } .cg .cg-midi { padding: 0 12px; } }
.cg .cg-midi.is-on { border-color: var(--hit); background: color-mix(in srgb, var(--hit) 16%, transparent); box-shadow: 0 0 16px color-mix(in srgb, var(--hit) 35%, transparent); }
.cg .cg-midi.is-on::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--hit); box-shadow: 0 0 8px var(--hit); }
.cg .cg-main {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; height: 52px; min-width: 0; margin: 0; padding: 0 18px; white-space: nowrap; border: 0; border-radius: 999px;
  background: var(--c); color: #0E0F12; cursor: pointer; transition: background-color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
  font-family: var(--display); font-stretch: 112%; font-weight: 800; font-size: 16px; letter-spacing: 0.06em; text-transform: uppercase;
}
.cg .cg-main:hover { background: color-mix(in srgb, var(--c) 82%, #fff); }
.cg .cg-main:active { transform: scale(0.97); }
/* playing: the button empties to an outline and says so */
.cg[data-state="playing"] .cg-main { background: transparent; color: var(--ct); box-shadow: inset 0 0 0 2px var(--c); }

/* finding a level costs no lives */
.cg[data-mode="find"] .cg-lives { visibility: hidden; }

/* the start card, the level path and the results use the whole sky */
.cg[data-screen="start"] .cg-hud, .cg[data-screen="map"] .cg-hud, .cg[data-screen="done"] .cg-hud, .cg[data-screen="scores"] .cg-hud { display: none; }
.cg[data-screen="map"] .cg-keys { display: none; }

@media (min-width: 700px) {
  .cg { padding-top: 10px; }
  .cg .cg-keys { height: 150px; }
  .cg .cg-hud { padding-top: 14px; }
  .cg .cg-score b { font-size: 40px; }
  .cg .cg-dock { padding: 12px var(--app-pad) 16px; }
  .cg .cg-main { flex: none; min-width: 220px; margin-left: auto; }
}
@media (prefers-reduced-motion: reduce) {
  .cg .cg-lvl--now .cg-lvl__dot, .cg .k.is-teach { animation: none; }
}

/* ---------- Light show: the same game drawn as light (lightsky.js draws its sky) ----------
   The light is in the sky. The page around it is dark and quiet: Space Grotesk for headings and numbers, the
   site's mono for labels, soft off-white lettering, the original game's gold, mint and violet for scores and
   highlights, a clear pink for hearts, and one muted lavender for what to press. */
.cg.cg--light {
  --c: #9C8FD6; --ct: #B79CFF; --gold: #FFD84D; --hit: #7CF0B5; --heart: #FF5C7A;
  --game: 'Space Grotesk', var(--display);
  --world-ink: #ECE9F7; --world-muted: #B9B0E0;
  --glass: rgba(8, 6, 20, 0.8);
  --edge: rgba(255, 255, 255, 0.09);
}
:root[data-theme="light"] .cg.cg--light { --ct: #5B4FA0; }
.cg.cg--light .cg-name::before { box-shadow: none; }

/* lettering: Space Grotesk is wider than the classic pixel letters, so it is set smaller, and never shouts */
.cg.cg--light :is(.cg-title, .cg-score b, .cg-combo__x, .cg-endless b, .cg-stepper b, .cg-map__head h2, .cg-teach__name, .cg-lvl__dot, .cg-rank b, .cg-stats b) { font-weight: 600; }
/* the titles in the classic look's gold */
.cg.cg--light .cg-title { font-size: clamp(34px, 11vw, 52px); line-height: 1; letter-spacing: -0.02em; color: #FFD84D; text-shadow: 0 0 18px rgba(255, 216, 77, 0.22); }
/* the start screen's title: the name with an outline of it set just behind, and a chord of stars rising over it */
.cg .cg-logo { position: relative; isolation: isolate; padding-top: .8em; }
.cg .cg-logo__word { position: relative; display: inline-block; }
.cg .cg-logo__line { position: absolute; left: 3px; top: 3px; z-index: -1; color: transparent; text-shadow: none; -webkit-text-stroke: 1px #7A6BC4; }
.cg .cg-logo__stars { position: absolute; right: -.1em; top: -.95em; width: 2.75em; height: .93em; overflow: visible; }
.cg.cg--light .cg-title--sm { font-size: clamp(28px, 8.5vw, 42px); }
.cg.cg--light .cg-sub { color: var(--world-muted); }
.cg.cg--light .cg-score b { font-size: 28px; line-height: 1; letter-spacing: -0.01em; }
.cg.cg--light .cg-score b.is-pop { color: var(--world-ink); }
.cg.cg--light .cg-combo__x { padding: 2px 10px; border-radius: 999px; background: rgba(156, 143, 214, 0.16); font-size: 16px; line-height: 1.3; color: var(--world-ink); text-shadow: none; }
.cg.cg--light .cg-combo__bar i.is-on { background: var(--c); box-shadow: none; }
.cg.cg--light .cg-lives__hearts svg { filter: none; }
.cg.cg--light .cg-level__bar i { background: var(--c); }
.cg.cg--light .cg-level__best b { font-family: var(--game); font-size: 15px; font-weight: 600; }
.cg.cg--light .cg-level__best em { font-family: var(--game); font-size: 17px; font-weight: 600; text-shadow: none; }
.cg.cg--light .cg-level__best span b { font-family: inherit; font-size: inherit; }
.cg.cg--light .cg-endless b { font-size: 20px; line-height: 1.1; }
.cg.cg--light .cg-endless .cg-endless__top b { font-size: inherit; font-weight: 600; color: var(--world-ink); }
.cg.cg--light .cg-best b { font-size: 18px; }
.cg.cg--light .cg-chips span { font-weight: 500; font-size: 13px; line-height: 1.5; }
.cg.cg--light .cg-stepper b { font-size: 24px; line-height: 1.1; color: var(--world-ink); }
.cg.cg--light .cg-board li em { font-size: 16px; font-weight: 600; }
.cg.cg--light .cg-rank b { font-size: 22px; }
.cg.cg--light .cg-newbest { font-size: 18px; font-weight: 600; text-shadow: none; }
.cg.cg--light .cg-stats b { font-size: 22px; }
.cg.cg--light .cg-shape b { font-size: 17px; font-weight: 600; }
.cg.cg--light .cg-ladder li em { font-size: 14px; font-weight: 600; }
.cg.cg--light .cg-map__head h2 { font-size: 30px; line-height: 1; color: var(--world-ink); text-shadow: none; }
.cg.cg--light .cg-lvl__dot { font-size: 24px; }
.cg.cg--light :is(.cg-lvl__name, .cg-teach__notes) { font-family: var(--game); font-stretch: normal; font-weight: 600; }
.cg.cg--light .cg-teach__name { font-size: 32px; line-height: 1.05; color: var(--world-ink); }
.cg.cg--light .cg-teach__name.is-long { font-size: 24px; }

/* buttons: the main one in the muted lavender, the rest dark */
.cg.cg--light :is(.cg-btn, .cg-main, .cg-lvl__go) { font-family: var(--game); font-stretch: normal; font-weight: 600; letter-spacing: 0.01em; text-transform: none; color: #0E0B1C; }
.cg.cg--light .cg-btn { font-size: 15px; }
.cg.cg--light .cg-row .cg-btn { font-size: 14px; }
.cg.cg--light .cg-main { font-size: 16px; }
.cg.cg--light :is(.cg-btn--ghost, .cg-btn--alt) { background: rgba(255, 255, 255, 0.05); color: var(--world-ink); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18); }
.cg.cg--light :is(.cg-btn--ghost, .cg-btn--alt):hover { background: rgba(255, 255, 255, 0.1); }
.cg.cg--light .cg-lvl__go--again { color: var(--world-ink); }
.cg.cg--light[data-state="playing"] .cg-main { color: var(--ct); }

/* cards and panels: dark glass with a faint edge */
.cg.cg--light :is(.cg-card, .cg-teach) { background: var(--glass); border: 1px solid var(--edge); box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5); }
.cg.cg--light :is(.cg-way, .cg-lvl__card, .cg-stats div, .cg-shape) { border: 1px solid var(--edge); }
.cg.cg--light .cg-way svg { color: var(--ct); }
.cg.cg--light .cg-endless { border: 1px solid var(--edge); background: rgba(255, 255, 255, 0.04); }
.cg.cg--light .cg-endless svg { fill: var(--gold); filter: none; }
.cg.cg--light .cg-endless b, .cg.cg--light .cg-endless > i { color: var(--world-ink); }
.cg.cg--light .cg-lvl--now .cg-lvl__card { box-shadow: none; }
.cg.cg--light .cg-lvl__dot { box-shadow: none; }
.cg.cg--light .cg-lvl--now .cg-lvl__dot { box-shadow: 0 0 0 6px rgba(156, 143, 214, 0.2); animation: none; }
.cg.cg--light .cg-board li.is-me, .cg.cg--light .cg-ladder li.is-me { box-shadow: inset 0 0 0 1px var(--c); }
.cg.cg--light .cg-teach { border-color: var(--edge); }
.cg.cg--light .cg-toast { background: var(--glass); border-color: var(--edge); }

/* the keys: soft, a little grey, and a hit lights them without a blaze */
.cg.cg--light .cg-keys { filter: drop-shadow(0 -6px 18px rgba(0, 0, 0, 0.45)); }
.cg.cg--light .k--w { background: linear-gradient(180deg, #E6E3F0 0%, #C3BED6 100%); box-shadow: inset 0 -5px 0 #A49EBD, inset -1px 0 0 rgba(4, 3, 12, 0.3); color: #3D3856; }
.cg.cg--light .k--b { background: linear-gradient(180deg, #17131F 0%, #08060E 100%); box-shadow: inset 2px 0 0 rgba(255, 255, 255, 0.08), inset 0 -4px 0 #000, 0 3px 6px rgba(0, 0, 0, 0.5); color: #C9C3E0; }
.cg.cg--light .k.is-hit.k--w { box-shadow: 0 0 16px var(--flash, var(--hit)); }
.cg.cg--light .k.is-hit.k--b { box-shadow: 0 0 14px var(--flash, var(--hit)); }

/* the dock: quiet */
.cg.cg--light .cg-dock { border-top-color: var(--edge); box-shadow: none; }
@media (min-width: 700px) {
  .cg.cg--light .cg-score b { font-size: 32px; }
}
