:root {
  --bg: #0d0f12;
  --surface: #15181e;
  --surface-2: #1c2028;
  --surface-3: #232833;
  --border: #252b36;
  --border-strong: #323a49;
  --text: #eef1f6;
  --text-dim: #939db0;
  --text-muted: #5d6678;
  --accent: #4f8cff;
  --accent-hover: #659bff;
  --accent-soft: rgba(79, 140, 255, 0.13);
  --ok: #34d399;
  --ok-soft: rgba(52, 211, 153, 0.12);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.12);
  --bad: #f87171;
  --bad-soft: rgba(248, 113, 113, 0.12);
  --radius: 14px;
  --radius-sm: 10px;
  --font: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}

body.solving-mode {
  overflow: hidden;
  height: 100dvh;
}

.tnum {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

.muted-xs {
  font-size: 12px;
  color: var(--text-muted);
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.9em;
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: 5px;
  color: var(--text);
}

.app {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 12px 16px 84px;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

body.solving-mode .app {
  height: 100dvh;
  min-height: 0;
  padding: 12px 14px max(12px, env(safe-area-inset-bottom));
}

/* Header */
.topbar, .solve-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 0 14px;
  flex: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
  font-size: 15.5px;
  letter-spacing: -0.02em;
  cursor: pointer;
}

.brand-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

.desktop-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 3px;
}

.nav-btn {
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 6px 11px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.14s, color 0.14s;
}

.nav-btn:hover {
  color: var(--text);
}

.nav-btn.active {
  background: var(--surface-2);
  color: var(--text);
}

@media (max-width: 680px) {
  .desktop-nav {
    display: none;
  }
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.lakeid-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  border-radius: 10px;
  border: 1px solid rgba(79, 140, 255, 0.35);
  background: var(--accent-soft);
  color: #dbe8ff;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.14s, border-color 0.14s;
}

.lakeid-btn:hover {
  background: rgba(79, 140, 255, 0.22);
  border-color: rgba(79, 140, 255, 0.6);
}

.user-menu-wrap {
  position: relative;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 4px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.user-ava {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  text-transform: uppercase;
  font-size: 12.5px;
}

.user-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: 210px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 13px;
  padding: 6px;
  z-index: 90;
  box-shadow: 0 20px 50px -15px #000;
}

.ud-head {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

.ud-title {
  font-size: 13.5px;
  font-weight: 600;
}

.ud-sub {
  font-size: 11.5px;
  color: var(--text-muted);
}

.ud-item {
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  color: var(--text-dim);
  padding: 8px 10px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
}

.ud-item:hover {
  background: var(--surface-2);
  color: var(--text);
}

.ud-item.danger {
  color: var(--bad);
}

/* Mobile Bottom Nav */
.bottom-nav {
  display: none;
}

@media (max-width: 680px) {
  .bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 60;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 3px;
    padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
    background: rgba(13, 15, 18, 0.94);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
  }
}

.bnav-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 600;
  padding: 9px 2px;
  border-radius: 10px;
  cursor: pointer;
}

.bnav-btn.active {
  color: var(--text);
  background: var(--surface-2);
}

/* Main Views */
.main-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.tab-view {
  display: none;
  flex-direction: column;
}

.tab-view.active {
  display: flex;
}

/* Cards & Typography */
.hero-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 20px;
  margin-bottom: 12px;
  position: relative;
}

.hero-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.kicker {
  font-size: 11.5px;
  color: var(--accent);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}

.h1 {
  margin: 0 0 8px;
  font-size: 23px;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.sub-text {
  margin: 0 0 16px;
  color: var(--text-dim);
  font-size: 13.5px;
  line-height: 1.5;
}

.mmi-pill {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 12px;
  text-align: right;
  flex: none;
}

.mmi-pill-k {
  display: block;
  font-size: 10.5px;
  color: var(--text-muted);
}

.mmi-pill-v {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 12px;
}

.card-title {
  font-size: 13.5px;
  font-weight: 600;
  margin: 0 0 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Buttons */
.btn-primary {
  width: 100%;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 14px 18px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.14s, transform 0.07s;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-primary:active {
  transform: scale(0.99);
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

.btn-ghost:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border-strong);
}

.btn-sm {
  padding: 6px 10px;
  font-size: 12.5px;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 500;
}

/* Split Smart CTA + Popover */
.split-cta-wrap {
  position: relative;
}

.split-cta {
  display: flex;
  gap: 2px;
  border-radius: var(--radius);
  overflow: hidden;
}

.split-main {
  flex: 1;
  border-radius: 0;
  text-align: left;
  padding: 13px 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.split-main-title {
  font-size: 15.5px;
  font-weight: 700;
}

.split-main-sub {
  font-size: 12px;
  opacity: 0.86;
  font-weight: 500;
}

.split-arrow {
  width: 50px;
  flex: none;
  border: none;
  background: #3d79eb;
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  transition: background 0.14s;
}

.split-arrow:hover {
  background: #538af0;
}

.focus-popover {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 8px);
  z-index: 80;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  padding: 8px;
  box-shadow: 0 24px 60px -15px #000;
}

.fp-head {
  font-size: 11.5px;
  color: var(--text-muted);
  padding: 6px 10px 8px;
  font-weight: 600;
}

.fp-sep {
  height: 1px;
  background: var(--border);
  margin: 5px 4px;
}

.fp-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  text-align: left;
  background: transparent;
  border: none;
  border-radius: 10px;
  padding: 9px 10px;
  cursor: pointer;
  color: var(--text);
  font-family: inherit;
}

.fp-item:hover {
  background: var(--surface-3);
}

.fp-name {
  font-size: 13.5px;
  font-weight: 600;
}

.fp-desc {
  font-size: 11.5px;
  color: var(--text-dim);
  margin-top: 2px;
}

.fp-check {
  color: var(--accent);
  font-weight: 700;
  opacity: 0;
}

.fp-item.active {
  background: var(--accent-soft);
}

.fp-item.active .fp-check {
  opacity: 1;
}

.smart-quick-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 14px;
}

.sq-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 10px;
}

.sq-k {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.sq-v {
  font-size: 14px;
  font-weight: 600;
}

/* Meta & Grid Previews */
.meta-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.meta-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 10px;
}

.meta-k {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.meta-v {
  font-size: 14.5px;
  font-weight: 600;
}

.block-grid-preview {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  margin-bottom: 16px;
}

@media (max-width: 480px) {
  .block-grid-preview {
    grid-template-columns: 1fr;
  }
}

.bg-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 11px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
}

/* Toggles */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13.5px;
  cursor: pointer;
}

.toggle-hint {
  display: block;
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

.switch {
  position: relative;
  width: 40px;
  height: 22px;
  flex: none;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  inset: 0;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  transition: 0.16s;
}

.slider::before {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  left: 2px;
  top: 2px;
  border-radius: 50%;
  background: var(--text-dim);
  transition: 0.16s;
}

.switch input:checked + .slider {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.switch input:checked + .slider::before {
  transform: translateX(18px);
  background: var(--accent);
}

/* Free Practice Controls */
.seg-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 12px;
}

.seg-btn {
  flex: 1;
  min-width: fit-content;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 8px 10px;
  border-radius: 9px;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}

.seg-btn.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: #dbe8ff;
}

.preset-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}

.chip-btn {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 6px 10px;
  border-radius: 999px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}

.chip-btn:hover, .chip-btn.active {
  border-color: var(--accent);
  color: var(--text);
  background: var(--accent-soft);
}

.chip-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 7px;
}

.chip-grid.compact {
  grid-template-columns: repeat(4, 1fr);
}

.chip-toggle {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 9px 10px;
  border-radius: 10px;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  text-align: center;
}

.chip-toggle.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: #e4eeff;
  font-weight: 600;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

@media (max-width: 500px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
}

.field label, .field-label {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 5px;
}

.field input, .field select, .preset-save-row input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--text);
  padding: 9px 10px;
  font-family: inherit;
  font-size: 13.5px;
  outline: none;
}

.field input:focus, .field select:focus {
  border-color: var(--accent);
}

.range-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.mini-pills {
  display: flex;
  gap: 5px;
  margin-top: 6px;
}

.mini-p {
  flex: 1;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 6px;
  padding: 4px 0;
  font-family: inherit;
  font-size: 11px;
  cursor: pointer;
}

.mini-p:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

.preset-save-row {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

/* Solving Stage */
.solve-hud-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.solve-title {
  font-weight: 600;
  font-size: 14px;
}

.solve-hud-right {
  display: flex;
  align-items: center;
  gap: 7px;
}

.tier-badge {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 7px;
  border-radius: 6px;
}

.solve-view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.progress-track {
  width: 100%;
  height: 3px;
  background: var(--surface-2);
  border-radius: 99px;
  overflow: hidden;
  flex: none;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  transition: width 0.22s ease;
}

.slot-timer-track {
  width: 100%;
  height: 2px;
  margin-top: 4px;
  overflow: hidden;
  flex: none;
}

.slot-timer-fill {
  height: 100%;
  width: 100%;
  background: var(--text-muted);
  transform-origin: left center;
}

.slot-timer-fill.warn { background: var(--warn); }
.slot-timer-fill.danger { background: var(--bad); }

.stage {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 8px 4px;
}

.q-view {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.block-intro-panel {
  width: 100%;
  max-width: 440px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 24px 20px;
}

.block-intro-kicker {
  font-size: 12px;
  color: var(--accent);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}

.block-intro-title {
  font-size: 22px;
  margin: 0 0 8px;
}

.block-intro-desc {
  font-size: 13.5px;
  color: var(--text-dim);
  line-height: 1.5;
  margin: 0 0 12px;
}

.prompt-wrap {
  width: 100%;
  min-height: 100px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}

.prompt-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
  min-height: 16px;
}

.prompt-text {
  font-size: clamp(2rem, 8.5vw, 3.4rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
  word-break: break-word;
}

.prompt-text.chain-text {
  font-size: clamp(1.5rem, 6vw, 2.3rem);
  line-height: 1.3;
}

.prompt-text.flash-text {
  font-size: clamp(3rem, 13vw, 4.8rem);
  transition: opacity 0.05s linear;
}

.flash-dots {
  display: flex;
  gap: 6px;
  margin-top: 12px;
  min-height: 8px;
}

.flash-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--surface-3);
}

.flash-dot.done {
  background: var(--accent);
}

.answer-box {
  width: 100%;
  max-width: 300px;
  height: 58px;
  border-radius: 14px;
  background: var(--surface);
  border: 1.5px solid var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 600;
  transition: border-color 0.14s, background 0.14s;
}

.answer-box.focused { border-color: var(--accent); }
.answer-box.disabled { opacity: 0.45; pointer-events: none; }
.answer-box.feedback-ok { border-color: var(--ok); background: var(--ok-soft); color: var(--ok); }
.answer-box.feedback-bad { border-color: var(--bad); background: var(--bad-soft); color: var(--bad); }

.answer-placeholder {
  color: var(--text-muted);
  font-size: 15px;
  font-weight: 400;
}

.feedback-line {
  height: 22px;
  line-height: 22px;
  margin-top: 10px;
  font-size: 13px;
  color: var(--text-dim);
  overflow: hidden;
}

.tip-line {
  min-height: 36px;
  margin-top: 4px;
  font-size: 12.5px;
  color: var(--text-muted);
  max-width: 440px;
  line-height: 1.4;
}

.mode-help-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 9px 11px;
  margin-bottom: 12px;
  font-size: 12.5px;
  color: var(--text-dim);
  line-height: 1.45;
}

.mode-help-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.mode-help-toggle {
  flex: none;
  background: transparent;
  border: none;
  color: var(--accent);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
}

.mode-help-all {
  margin-top: 9px;
  padding-top: 9px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
}

.mode-help-all strong {
  color: var(--text);
}

.hint-actions {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.btn-hint {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 999px;
  padding: 5px 13px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.14s, color 0.14s, border-color 0.14s;
}

.btn-hint:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border-strong);
}

.hint-box {
  margin-top: 8px;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 10px 13px;
  font-size: 12.5px;
  line-height: 1.45;
  color: #cfd8e8;
  text-align: left;
}

/* Numpad */
.numpad-wrap {
  flex: none;
  width: 100%;
  max-width: 380px;
  margin: 0 auto;
}

.numpad-wrap.desktop-hidden {
  display: none;
}

.numpad {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
}

.nkey {
  height: 52px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 20px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  touch-action: manipulation;
}

.nkey:active { background: var(--surface-3); transform: scale(0.97); }
.nkey.muted { background: var(--surface-2); color: var(--text-dim); font-size: 17px; }
.nkey.submit { background: var(--accent); border-color: var(--accent); color: #fff; grid-row: span 2; height: auto; }
.nkey.submit-tall { background: var(--accent); border-color: var(--accent); color: #fff; grid-row: span 3; height: auto; }
.nkey.zero { grid-column: span 2; }

.kbd-layout-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
}

@media (max-width: 480px) {
  .kbd-layout-grid {
    grid-template-columns: 1fr;
  }
}

.kbd-opt {
  text-align: left;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 10px;
  color: var(--text-dim);
  font-family: inherit;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: border-color 0.14s, background 0.14s, color 0.14s;
}

.kbd-opt:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

.kbd-opt.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: #e4eeff;
}

.kbd-opt-title {
  font-size: 13px;
  font-weight: 600;
}

.kbd-opt-sub {
  font-size: 11px;
  color: var(--text-muted);
}

.kbd-opt.active .kbd-opt-sub {
  color: #a8c6ff;
}

.kb-hint {
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}

/* Bars, Results & Profile */
.block-bars {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bbar-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 13px;
  margin-bottom: 5px;
}

.bbar-track {
  height: 6px;
  border-radius: 99px;
  background: var(--bg);
  overflow: hidden;
}

.bbar-fill {
  height: 100%;
  border-radius: 99px;
  background: var(--accent);
}

.res-hero {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 24px 20px;
  text-align: center;
  margin-bottom: 12px;
}

.res-kicker {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}

.res-score {
  font-size: clamp(2.6rem, 11vw, 3.6rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 6px;
}

.res-rank {
  display: inline-block;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 4px 12px;
  border-radius: 999px;
  margin-bottom: 12px;
}

.res-delta {
  font-size: 13px;
  margin-bottom: 14px;
}

.res-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

.res-stat-k { font-size: 11px; color: var(--text-muted); margin-bottom: 2px; }
.res-stat-v { font-size: 15px; font-weight: 600; }

.advice-list { display: flex; flex-direction: column; gap: 8px; }
.advice-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-dim);
}
.advice-item strong { color: var(--text); }

.review-toggle {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 11px 14px;
  border-radius: 12px;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
}

.review-list { display: none; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.review-list.open { display: flex; }

.rev-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px 13px;
  font-size: 13px;
}

.rev-top { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.rev-expr { font-weight: 600; font-size: 14px; }
.rev-meta { font-size: 12px; color: var(--text-dim); white-space: nowrap; }
.rev-ans { font-size: 12.5px; color: var(--text-dim); margin-bottom: 4px; }
.rev-tip { font-size: 12px; color: var(--text-muted); border-top: 1px dashed var(--border); padding-top: 5px; margin-top: 5px; }

.actions-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 24px;
}

/* Profile Charts, Heatmap & Skills Table */
.prof-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.chart-box {
  width: 100%;
  min-height: 110px;
}

.hm-grid {
  display: grid;
  grid-template-columns: 24px repeat(8, 1fr);
  gap: 4px;
}

.hm-hdr {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  height: 26px;
}

.hm-cell {
  height: 30px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-dim);
  font-size: 10.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.hm-cell.fast { background: rgba(52, 211, 153, 0.18); border-color: rgba(52, 211, 153, 0.45); color: #a7f3d0; }
.hm-cell.mid { background: rgba(79, 140, 255, 0.18); border-color: rgba(79, 140, 255, 0.4); color: #cfe0ff; }
.hm-cell.slow { background: rgba(251, 191, 36, 0.16); border-color: rgba(251, 191, 36, 0.4); color: #fde68a; }
.hm-cell.bad { background: rgba(248, 113, 113, 0.18); border-color: rgba(248, 113, 113, 0.45); color: #fecaca; }

.skills-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.skills-table {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.sk-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.sk-name { font-size: 13px; font-weight: 600; }
.sk-sub { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }
.sk-right { text-align: right; flex: none; }
.sk-sr { font-size: 13px; font-weight: 700; }
.sk-st { font-size: 11px; }

.history-items { display: flex; flex-direction: column; gap: 6px; }
.history-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 9px;
  font-size: 13px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 76px;
  transform: translate(-50%, 10px);
  opacity: 0;
  pointer-events: none;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 9px 15px;
  border-radius: 11px;
  font-size: 13px;
  font-weight: 500;
  z-index: 120;
  transition: opacity 0.18s, transform 0.18s;
  max-width: calc(100vw - 32px);
  text-align: center;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

.ok-c { color: var(--ok); }
.warn-c { color: var(--warn); }
.bad-c { color: var(--bad); }

.offline-pill {
  color: var(--warn);
  border-color: rgba(251, 191, 36, 0.4);
  background: var(--warn-soft);
}

.game-hub-card {
  width: 100%;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
  color: var(--text);
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  transition: border-color 0.14s, background 0.14s;
}

.game-hub-card:hover {
  border-color: var(--border-strong);
  background: var(--surface-2);
}

.ghc-title {
  font-size: 16.5px;
  font-weight: 700;
  margin-bottom: 4px;
}

.ghc-sub {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.45;
}

.ghc-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
}

.ghc-arrow {
  font-size: 18px;
  color: var(--accent);
  font-weight: 700;
}

/* Mini-Games: Doomsday */
.dd-bars-box {
  width: 100%;
  overflow-x: auto;
  padding-bottom: 4px;
}

.dd-bars-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  min-height: 148px;
  padding: 20px 4px 0;
}

.dd-bar-col {
  flex: 1 0 38px;
  max-width: 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  background: transparent;
  border: none;
  padding: 0;
  color: inherit;
  font-family: inherit;
  cursor: pointer;
}

.dd-bar-val {
  font-size: 10.5px;
  color: var(--text-dim);
  white-space: nowrap;
}

.dd-bar-track {
  width: 100%;
  height: 92px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 7px;
  padding: 2px;
}

.dd-bar-fill {
  width: 100%;
  min-height: 6px;
  border-radius: 5px;
  background: var(--accent);
  transition: opacity 0.14s, transform 0.14s;
}

.dd-bar-col:hover .dd-bar-fill, .dd-bar-col.active .dd-bar-fill {
  background: var(--ok);
}

.dd-bar-lbl {
  font-size: 10.5px;
  color: var(--text-muted);
}

.wd-mini-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
}

.wd-mini-cell {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 7px 4px;
  text-align: center;
}

.wd-mini-k { font-size: 11.5px; font-weight: 700; color: var(--text); }
.wd-mini-v { font-size: 10.5px; color: var(--text-dim); margin-top: 2px; }

/* Doomsday Play Pad */
.dd-pad-wrap {
  flex: none;
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
}

.dd-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.dd-key {
  height: 54px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  user-select: none;
  touch-action: manipulation;
  transition: background 0.1s, border-color 0.1s, transform 0.06s;
}

.dd-key:active {
  background: var(--surface-3);
  transform: scale(0.97);
}

.dd-key.dd-sun {
  grid-column: span 3;
  height: 48px;
}

.dd-key.dd-ok {
  background: var(--ok-soft);
  border-color: var(--ok);
  color: var(--ok);
}

.dd-key.dd-bad {
  background: var(--bad-soft);
  border-color: var(--bad);
  color: var(--bad);
}

.dd-k-name { font-size: 15.5px; font-weight: 650; }
.dd-k-num { font-size: 11.5px; color: var(--text-muted); }

/* Reference Guide Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 140;
  background: rgba(7, 9, 12, 0.82);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
}

.modal-card {
  width: 100%;
  max-width: 580px;
  max-height: 90dvh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  padding: 18px;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.g-sec {
  margin-bottom: 14px;
}

.g-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 7px;
}

.g-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.g-chips span {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 9px;
  font-size: 12.5px;
}

.g-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

@media (max-width: 480px) {
  .g-grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

.g-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 12.5px;
}

.g-box span { color: var(--accent); font-weight: 600; }

.g-box-wide {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 10px 12px;
  font-size: 12.5px;
  color: var(--text-dim);
}

.g-months-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

@media (max-width: 460px) {
  .g-months-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.g-months-grid > div {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 7px 9px;
  font-size: 12.5px;
}
