/* ============================================================
   CSGame — what the games add to Shift One.
   Shift One (shift-one.css) is linked first and owns the look; this file
   only adds pieces the games need, and every colour here is one of its
   tokens, so both themes work without a rule of their own.
   ============================================================ */

/* --- Small layout helpers ------------------------------------------------ */
.hstack { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.vstack { display: flex; flex-direction: column; gap: 12px; }
.spacer { flex: 1 1 auto; }
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; } .mt-4 { margin-top: 32px; }
.mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }
.muted { color: var(--label-3); }
.hidden { display: none !important; }
.prose p + p, .prose p + ul, .prose ul + p { margin-top: 10px; }
.prose ul { margin: 8px 0; padding-left: 22px; }
.prose li { margin: 4px 0; }
.prose code, code.inline {
  font-family: var(--font-mono); font-size: 0.92em; padding: 1px 6px;
  background: var(--fill); border: 1px solid var(--separator); border-radius: var(--r-sm);
}
.prose h2 { font-size: 19px; font-weight: 600; letter-spacing: -0.018em; margin: 18px 0 8px; }
.prose h3 { font-size: 16px; font-weight: 600; margin: 14px 0 6px; }
.prose h2:first-child, .prose h3:first-child { margin-top: 0; }
.prose pre.code { margin: 12px 0; }
.kbd {
  display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px; padding: 0 6px;
  font: 600 11px var(--font-mono); color: var(--label-2);
  background: var(--bg-elevated-2); border: 1px solid var(--separator-firm); border-bottom-width: 2px; border-radius: var(--r-sm);
}

/* --- HUD ----------------------------------------------------------------- */
.hud { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 16px; }
.hud__stat {
  display: inline-flex; align-items: baseline; gap: 6px;
  padding: 7px 12px; border-radius: var(--r-md);
  background: var(--surface-wash), var(--bg-elevated); border: 1px solid var(--separator);
  box-shadow: var(--surface-edge), var(--shadow-1);
  font-size: 13px; font-weight: 500; color: var(--label-3);
}
.hud__stat b { font-size: 16px; font-weight: 700; color: var(--label); font-variant-numeric: tabular-nums; }
.hud__stat--accent b { color: var(--accent); }
.hud__stat--danger b { color: var(--danger); }
.hearts { letter-spacing: 2px; }

/* --- Questions and answers ------------------------------------------------ */
.question { font-size: 18px; font-weight: 600; letter-spacing: -0.016em; margin: 10px 0 16px; }
.option {
  display: block; width: 100%; margin: 8px 0; padding: 13px 16px; text-align: left;
  background: var(--surface-wash), var(--bg-elevated-2); color: var(--label);
  border: 1px solid var(--separator-firm); border-radius: var(--r-lg);
  font-size: 15px; font-weight: 500;
  transition: border-color 200ms var(--ease), transform 200ms var(--ease), background 200ms var(--ease);
}
.option:hover:not(:disabled) { border-color: var(--accent); transform: translateY(-1px); }
.option:disabled { cursor: default; }
.option.correct { background: var(--success-wash); border-color: var(--success); }
.option.correct::after { content: "  ✓"; color: var(--success); font-weight: 700; }
.option.wrong { background: var(--danger-wash); border-color: var(--danger); }
.option.wrong::after { content: "  ✗"; color: var(--danger); font-weight: 700; }
.option--inline { display: inline-block; width: auto; min-width: 120px; text-align: center; margin: 4px 8px 4px 0; }

.feedback { display: none; margin-top: 16px; padding: 13px 16px; border-radius: var(--r-lg); font-size: 14px; line-height: 1.55; }
.feedback.show { display: block; animation: fade-up 300ms var(--ease) both; }
.feedback.good { background: var(--success-wash); border: 1px solid color-mix(in srgb, var(--success) 40%, transparent); }
.feedback.bad { background: var(--danger-wash); border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent); }
.feedback pre.code { margin: 8px 0; }

.spec-tag {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: var(--r-sm);
  background: var(--accent-wash); color: var(--accent); border: 1px solid var(--accent-line);
  font-size: 11px; font-weight: 600; letter-spacing: 0.01em; white-space: nowrap;
}

pre.code, .code {
  font-family: var(--font-mono); font-size: 13.5px; line-height: 1.55; letter-spacing: 0;
  background: var(--bg-inset); color: var(--label);
  border: 1px solid var(--separator); border-radius: var(--r-lg);
  padding: 14px 16px; overflow-x: auto; margin: 0; tab-size: 4;
}
.answer { font-family: var(--font-mono); font-size: 18px; max-width: 340px; }

/* --- Bits, arrays and tables ------------------------------------------- */
.bits { display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0; align-items: center; }
.bit {
  width: 56px; padding: 6px 0; text-align: center; cursor: pointer; user-select: none;
  background: var(--bg-elevated-2); border: 1px solid var(--separator-firm); border-radius: var(--r-md);
  transition: transform 120ms var(--ease), background 160ms var(--ease), border-color 160ms var(--ease);
}
.bit:hover { border-color: var(--label-4); }
.bit:active { transform: scale(0.94); }
.bit .pv { font-size: 11px; color: var(--label-3); font-variant-numeric: tabular-nums; }
.bit .v { font: 700 24px var(--font-mono); }
.bit.on { background: var(--accent-wash); border-color: var(--accent); color: var(--accent); }

.array { display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0; }
.cell {
  min-width: 52px; padding: 9px 8px; text-align: center; cursor: pointer; user-select: none;
  background: var(--bg-elevated-2); border: 1px solid var(--separator-firm); border-radius: var(--r-md);
  font: 600 18px var(--font-mono); font-variant-numeric: tabular-nums;
  transition: transform 160ms var(--ease), border-color 160ms var(--ease), background 160ms var(--ease), opacity 160ms var(--ease);
}
.cell:hover { transform: translateY(-2px); }
.cell small { display: block; font-size: 10px; color: var(--label-3); font-weight: 500; }
.cell.sel { border-color: var(--warning); background: var(--warning-wash); }
.cell.done { border-color: var(--success); background: var(--success-wash); }
.cell.out { opacity: 0.3; cursor: default; transform: none; }
.cell.mid { border-color: var(--accent); background: var(--accent-wash); }

table.tt { border-collapse: separate; border-spacing: 0; margin: 14px 0; font-family: var(--font-mono); border: 1px solid var(--separator-firm); border-radius: var(--r-lg); overflow: hidden; }
table.tt th, table.tt td { padding: 7px 14px; text-align: center; border-bottom: 1px solid var(--separator); border-right: 1px solid var(--separator); }
table.tt tr:last-child td { border-bottom: 0; }
table.tt th:last-child, table.tt td:last-child { border-right: 0; }
table.tt th { background: var(--bg-elevated-2); font-family: var(--font); font-size: 12px; font-weight: 600; color: var(--label-2); }
table.tt td.toggle { cursor: pointer; background: var(--bg-inset); color: var(--warning); font-weight: 700; min-width: 3.2rem; }
table.tt td.toggle:hover { background: var(--fill); }
table.tt td.toggle.right { color: var(--success); }
table.tt td.toggle.wrongc { color: var(--danger); }
.table-wrap { overflow-x: auto; border: 1px solid var(--separator); border-radius: var(--r-lg); }
.table-wrap .table th { position: static; }

.progress { height: 8px; background: var(--fill); border-radius: var(--r-pill); overflow: hidden; }
.progress > div { height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent-bright), var(--accent-fill)); transition: width 400ms var(--ease); }

.match-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 12px; }
.match-cols button {
  display: flex; align-items: center; gap: 8px; width: 100%; min-height: 52px; margin: 0 0 8px; padding: 10px 14px; text-align: left;
  background: var(--surface-wash), var(--bg-elevated-2); border: 1px solid var(--separator-firm); border-radius: var(--r-lg);
  font-size: 14px; font-weight: 500; color: var(--label);
  transition: border-color 160ms var(--ease), opacity 300ms var(--ease), transform 160ms var(--ease);
}
.match-cols button:hover { border-color: var(--label-4); }
.match-cols button.sel { border-color: var(--accent); background: var(--accent-wash); }
.match-cols button.matched { border-color: var(--success); background: var(--success-wash); opacity: 0.5; cursor: default; }
.match-cols button.shake, .shake { animation: shake 360ms var(--ease); }
.match-cols button.shake { border-color: var(--danger); }
@keyframes shake { 20% { transform: translateX(-7px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(3px); } }

.gate-svg { background: var(--bg-inset); border: 1px solid var(--separator); border-radius: var(--r-lg); max-width: 100%; height: auto; }
.stage { position: relative; background: var(--bg-inset); border: 1px solid var(--separator); border-radius: var(--r-xl); overflow: hidden; }
.stage canvas { display: block; width: 100%; height: auto; }
.stage__overlay {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  padding: 24px; text-align: center; background: color-mix(in srgb, var(--bg-base) 72%, transparent);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.stage__title { font-size: 30px; font-weight: 750; letter-spacing: -0.03em; }

/* --- Player identity, XP and celebrations ------------------------------ */
.avatar-emoji {
  display: flex; align-items: center; justify-content: center; flex: 0 0 auto;
  width: 40px; height: 40px; border-radius: var(--r-pill); font-size: 22px; line-height: 1;
  background: var(--surface-wash), var(--bg-elevated-2); border: 1px solid var(--separator-firm);
}
.avatar-emoji--lg { width: 64px; height: 64px; font-size: 36px; }
.avatar-emoji--xl { width: 88px; height: 88px; font-size: 50px; }
.identity__level {
  position: absolute; right: -4px; bottom: -4px; min-width: 20px; height: 20px; padding: 0 5px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--r-pill); border: 2px solid var(--bg-base);
  background: var(--accent-fill); color: #fff; font-size: 10.5px; font-weight: 700;
}
.xpbar { height: 6px; margin: 0 10px 4px; background: var(--fill); border-radius: var(--r-pill); overflow: hidden; }
.xpbar > div { height: 100%; background: linear-gradient(90deg, var(--accent-bright), var(--accent-fill)); border-radius: inherit; transition: width 600ms var(--ease); }
.xpbar__text { margin: 0 10px; font-size: 11px; color: var(--label-3); font-variant-numeric: tabular-nums; }
.sidebar__tools { display: flex; align-items: center; gap: 4px; margin-top: 10px; }
.nav-link .nav-emoji { width: 18px; text-align: center; font-size: 15px; line-height: 1; flex: 0 0 auto; }
.nav-link .nav-new { margin-left: auto; }

.xp-float {
  position: fixed; z-index: 70; pointer-events: none;
  font-weight: 800; font-size: 15px; color: var(--accent);
  text-shadow: 0 2px 10px color-mix(in srgb, var(--accent-fill) 50%, transparent);
  animation: xp-float 1100ms var(--ease) forwards;
}
@keyframes xp-float { 0% { opacity: 0; transform: translateY(6px) scale(0.8); } 15% { opacity: 1; transform: translateY(0) scale(1.1); } 100% { opacity: 0; transform: translateY(-46px) scale(1); } }

.combo {
  position: fixed; top: 18px; right: 22px; z-index: 65;
  display: flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: var(--r-pill);
  background: var(--surface-wash), var(--bg-elevated-2); border: 1px solid var(--warning);
  color: var(--warning); font-weight: 800; font-size: 16px; box-shadow: var(--shadow-2);
  pointer-events: none;
}
.combo.pop { animation: combo-pop 380ms var(--ease); }
@keyframes combo-pop { 0% { transform: scale(0.6); } 60% { transform: scale(1.18); } 100% { transform: scale(1); } }

.confetti { position: fixed; inset: 0; z-index: 80; pointer-events: none; width: 100vw; height: 100vh; }

.levelup { text-align: center; }
.levelup__burst { font-size: 64px; line-height: 1; animation: combo-pop 600ms var(--ease); }
.levelup__level {
  margin-top: 12px; font-size: 44px; font-weight: 800; letter-spacing: -0.04em;
  background: linear-gradient(180deg, var(--accent-bright), var(--accent-fill)); -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* --- Game cover cards --------------------------------------------------- */
div.cover__art { background: linear-gradient(135deg, var(--c1), var(--c2)); filter: blur(10px) saturate(130%); }
.cover__icon.cover__emoji { display: flex; align-items: center; justify-content: center; font-size: 30px; background: rgba(0,0,0,0.28); }
.cover__tags { position: absolute; right: 14px; top: 16px; display: flex; gap: 6px; }
.cover__chip {
  padding: 3px 8px; border-radius: var(--r-sm); font-size: 11px; font-weight: 700;
  background: rgba(0,0,0,0.35); color: #fff; border: 1px solid rgba(255,255,255,0.2);
}
.cover__chip--new { background: var(--accent-fill); border-color: rgba(255,255,255,0.3); }
.cover__best { color: rgba(255,255,255,0.85); }

.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.badge-tile {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px;
  padding: 16px 12px; border-radius: var(--r-lg);
  background: var(--surface-wash), var(--bg-elevated); border: 1px solid var(--separator);
}
.badge-tile__icon { font-size: 34px; line-height: 1; }
.badge-tile__name { font-size: 13.5px; font-weight: 600; }
.badge-tile__desc { font-size: 12px; color: var(--label-3); }
.badge-tile--locked { opacity: 0.45; }
.badge-tile--locked .badge-tile__icon { filter: grayscale(1); }
.badge-tile--earned { border-color: var(--accent-line); box-shadow: inset 0 0 0 1px var(--accent-line); }

.emoji-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); gap: 8px; }
.emoji-picker button {
  height: 46px; font-size: 24px; border-radius: var(--r-md);
  background: var(--fill); border: 1px solid transparent;
}
.emoji-picker button:hover { background: var(--fill-strong); }
.emoji-picker button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-wash); }

.daily {
  position: relative; overflow: hidden;
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent-fill) 22%, transparent), transparent 70%), var(--surface-wash), var(--bg-elevated);
  border-color: var(--accent-line);
}
.promo--daily { border-color: var(--accent-line); background: linear-gradient(135deg, var(--accent-wash), transparent 80%), var(--bg-elevated); }

@media (max-width: 640px) {
  .match-cols { grid-template-columns: minmax(0, 1fr); }
  .bit { width: calc((100% - 42px) / 8); min-width: 34px; }
  .bit .v { font-size: 20px; }
  .combo { top: auto; bottom: 18px; right: 16px; }
}

.page-tile--emoji { font-size: 24px; }
@media (max-width: 900px) { .xpwrap { display: none; } }

/* --- Python: code editor, console and lessons ---------------------------- */
.editor {
  --lh: 21px; --pad: 12px;
  display: flex; overflow: hidden;
  background: var(--bg-inset); border: 1px solid var(--separator-firm); border-radius: var(--r-lg);
  font: 14px/21px var(--font-mono); letter-spacing: 0;
  transition: border-color 200ms var(--ease), box-shadow 200ms var(--ease);
}
.editor:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3.5px var(--accent-wash); }
.editor__gutter {
  flex: 0 0 auto; min-width: 44px; padding: var(--pad) 10px; text-align: right; user-select: none;
  color: var(--label-4); background: var(--quiet-fill); border-right: 1px solid var(--separator);
}
.editor__body { position: relative; flex: 1 1 auto; min-width: 0; overflow: hidden; height: calc(var(--lines, 5) * var(--lh) + 2 * var(--pad) + 12px); }
.editor__hl, .editor__input {
  position: absolute; top: 0; left: 0; margin: 0; padding: var(--pad) 14px;
  font: inherit; line-height: var(--lh); letter-spacing: 0; white-space: pre; tab-size: 4; border: 0;
}
.editor__hl { right: auto; min-width: 100%; color: var(--label); pointer-events: none; background: none; }
.editor__input {
  width: 100%; height: 100%; resize: none; outline: none; overflow-x: auto; overflow-y: hidden;
  background: transparent; color: transparent; caret-color: var(--label); box-shadow: none;
}
.editor__input::selection { background: var(--accent-wash); color: transparent; }
.tk-k { color: var(--accent); font-weight: 600; }
.tk-s { color: var(--success); }
.tk-n, .tk-f { color: var(--warning); }
.tk-c { color: var(--label-3); font-style: italic; }
.tk-b { color: var(--accent-bright); }
:root[data-theme="light"] .tk-b { color: var(--accent-deep); }

.console {
  min-height: 110px; max-height: 360px; overflow: auto; margin: 0; padding: 12px 14px;
  background: var(--bg-inset); border: 1px solid var(--separator); border-radius: var(--r-lg);
  font: 13.5px/1.6 var(--font-mono); letter-spacing: 0; white-space: pre-wrap; word-break: break-word; color: var(--label);
}
.console__placeholder, .console__note { color: var(--label-3); font-style: italic; }
.console__err { color: var(--danger); }
.console__ok { color: var(--success); }
.console__typed { color: var(--accent); }
.console__input { font: inherit; color: var(--accent); background: transparent; border: 0; border-bottom: 1px dashed var(--accent); outline: none; min-width: 160px; width: 50%; padding: 0; }
.runbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 10px 0; }
.py-status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--label-3); }
.py-status .dot { width: 8px; height: 8px; border-radius: var(--r-pill); background: var(--label-4); }
.py-status[data-state="ready"] .dot { background: var(--success); }
.py-status[data-state="loading"] .dot, .py-status[data-state="running"] .dot { background: var(--warning); animation: pulse 1s infinite; }
.py-status[data-state="error"] .dot { background: var(--danger); }
@keyframes pulse { 50% { opacity: 0.3; } }
.err-help { margin-top: 8px; padding: 10px 12px; border-radius: var(--r-md); background: var(--warning-wash); border: 1px solid color-mix(in srgb, var(--warning) 35%, transparent); font-size: 13.5px; }

.lesson-section { scroll-margin-top: 20px; }
.lesson-section + .lesson-section { margin-top: 16px; }
.task-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.task-head__title { font-size: 17px; font-weight: 600; letter-spacing: -0.016em; }
.tests { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.test {
  display: grid; grid-template-columns: auto minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr); gap: 10px; align-items: start;
  padding: 10px 12px; border-radius: var(--r-md); border: 1px solid var(--separator); background: var(--quiet-fill); font-size: 13px;
}
.test pre { margin: 2px 0 0; font: 12.5px/1.5 var(--font-mono); white-space: pre-wrap; word-break: break-word; }
.test__label { font-size: 11px; font-weight: 600; color: var(--label-3); text-transform: uppercase; letter-spacing: 0.04em; }
.test--pass { border-color: color-mix(in srgb, var(--success) 35%, transparent); }
.test--fail { border-color: color-mix(in srgb, var(--danger) 35%, transparent); background: var(--danger-wash); }
.lesson-progress { position: sticky; top: 0; z-index: 5; padding: 10px 0; background: var(--chrome); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); }
@media (max-width: 640px) { .test { grid-template-columns: auto minmax(0, 1fr); } }
@media (max-width: 900px) { .lesson-progress { top: 58px; } }
.cover .cover__meta { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
/* A grid item with aspect-ratio doesn't stretch, so Shift One's min-height would make covers
   330px wide – wider than their track. Fill the track instead. */
.covers .cover { min-width: 0; width: 100%; }

/* --- Accounts -------------------------------------------------------------- */
.account-cta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 4px 10px 0; }
.account-cta .btn { flex: 1 1 auto; }
.account-cta__note { flex-basis: 100%; font-size: 11.5px; color: var(--label-3); }
.auth { max-width: 460px; margin: 0 auto; }
.auth-links { margin-top: 14px; text-align: center; font-size: 13px; color: var(--label-3); }
.auth-links a { color: var(--accent); font-weight: 600; }
@media (max-width: 900px) { .account-cta { padding: 0; flex-wrap: nowrap; } .account-cta__note { display: none; } }
.class-leave { margin-left: 4px; width: 18px; height: 18px; border-radius: var(--r-pill); color: inherit; font-size: 14px; line-height: 1; opacity: 0.7; }
.class-leave:hover { opacity: 1; background: var(--fill-strong); }

/* --- Logo -------------------------------------------------------------------------- */
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 10px; border-radius: var(--r-md); color: var(--label); text-decoration: none; }
.brand:hover .logo-cursor { animation: logo-blink 1s steps(1) 3; }
.logo-mark { flex: 0 0 auto; display: block; }
/* The cursor blinks a few times when the page opens, then stays on. */
.logo-cursor { animation: logo-blink 1s steps(1) 3; }
@keyframes logo-blink { 50% { opacity: 0; } }
.brand__text { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; }
.brand__name { font-size: 18px; font-weight: 800; letter-spacing: -0.025em; }
.brand__cs { color: var(--accent); }
.brand__tag { font-size: 11px; font-weight: 500; color: var(--label-3); }
.auth__mark { margin: 0 auto 14px; }
@media (max-width: 900px) {
  .brand { padding: 0; }
  .brand__text { display: none; }
}
