/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Base tokens (ACID default — cold, harsh, pure contrast) ── */
:root {
  --black:    #000000;
  --white:    #f2f2f2;
  --grey:     #666666;
  --dim:      #222222;
  --mid:      #444444;
  --code-bg:  #050505;
  --code-fg:  #cccccc;
  --font:     'Courier New', Courier, monospace;
}

/* ── LOFI theme — warm coffee, amber, analogue tape ── */
[data-theme="lofi"] {
  --black:    #0c0906;
  --white:    #f0e6cc;
  --grey:     #8a7055;
  --dim:      #281a0c;
  --mid:      #584030;
  --code-bg:  #100c06;
  --code-fg:  #c8b898;
}

/* ── RIM theme — western dust, parchment, terracotta ── */
[data-theme="rim"] {
  --black:    #0e0a04;
  --white:    #e2cfa8;
  --grey:     #906040;
  --dim:      #2a1808;
  --mid:      #604020;
  --code-bg:  #120d04;
  --code-fg:  #c0a870;
}

/* ── ACID theme — inherits :root (pure black/white) ── */
[data-theme="acid"] {
  --black:    #000000;
  --white:    #f2f2f2;
  --grey:     #666666;
  --dim:      #222222;
  --mid:      #444444;
  --code-bg:  #050505;
  --code-fg:  #cccccc;
}

/* ── SKOLA theme — educational, terminal blue ── */
[data-theme="skola"] {
  --black:    #050810;
  --white:    #dce8ff;
  --grey:     #4a6898;
  --dim:      #0a1525;
  --mid:      #183060;
  --code-bg:  #040810;
  --code-fg:  #88b8e8;
}

/* ── PROG theme — dark IDE, indigo-violet, deep focus ── */
[data-theme="prog"] {
  --black:    #070510;
  --white:    #dcd5f5;
  --grey:     #6855a8;
  --dim:      #18103a;
  --mid:      #382868;
  --code-bg:  #040312;
  --code-fg:  #9885d0;
}

/* ── TECHNO theme — industrial, deep crimson ── */
[data-theme="techno"] {
  --black:    #090506;
  --white:    #f0e0e0;
  --grey:     #703040;
  --dim:      #1a0808;
  --mid:      #380c14;
  --code-bg:  #080404;
  --code-fg:  #cc8888;
}

/* ── YT theme — youtube studio, warm red on cream paper ── */
[data-theme="yt"] {
  --black:    #14080a;
  --white:    #fbe9d8;
  --grey:     #b85c4a;
  --dim:      #2a1014;
  --mid:      #582028;
  --code-bg:  #18090b;
  --code-fg:  #f0c8a0;
}

/* ── GAME theme — arcade neon, magenta on deep purple ── */
[data-theme="game"] {
  --black:    #050018;
  --white:    #ffd0ff;
  --grey:     #c850e0;
  --dim:      #150038;
  --mid:      #3a0870;
  --code-bg:  #04001a;
  --code-fg:  #80f0c8;
}

/* ── JAZZ theme — speakeasy: brass on walnut, dim lamp ── */
[data-theme="jazz"] {
  --black:    #0a0604;
  --white:    #f0d8a8;
  --grey:     #a07840;
  --dim:      #281808;
  --mid:      #503820;
  --code-bg:  #0e0805;
  --code-fg:  #d8b878;
}

/* ── STUDY theme — desk-lamp sage on dark wood, focus mode ── */
[data-theme="study"] {
  --black:    #0a0e0a;
  --white:    #cce6c8;
  --grey:     #608a60;
  --dim:      #142014;
  --mid:      #28442c;
  --code-bg:  #0a100a;
  --code-fg:  #a8c8a8;
}

/* ── GENRES theme — record-shop magenta on midnight indigo ── */
[data-theme="genres"] {
  --black:    #0a071a;
  --white:    #f0c8e8;
  --grey:     #b06090;
  --dim:      #1a0c2e;
  --mid:      #401a58;
  --code-bg:  #0c0820;
  --code-fg:  #d8a8c8;
}

/* ── HARD BASS theme — blood-red bunker, industrial concrete ── */
[data-theme="hardbass"] {
  --black:    #0d0303;
  --white:    #f0c0c0;
  --grey:     #a04040;
  --dim:      #200808;
  --mid:      #481010;
  --code-bg:  #0d0303;
  --code-fg:  #d09898;
}

/* ── VOCALS theme — warm rose, mouth-shaped formant peach ── */
[data-theme="vocals"] {
  --black:    #1a0a0f;
  --white:    #ffd8d8;
  --grey:     #c08080;
  --dim:      #2e1218;
  --mid:      #582430;
  --code-bg:  #1a0a0f;
  --code-fg:  #e0a8a8;
}

/* ── HARMONIC theme — candlelit chapel: warm cream on contemplative blue ── */
[data-theme="harmonic"] {
  --black:    #07091a;
  --white:    #f4ead0;
  --grey:     #8088b0;
  --dim:      #10142a;
  --mid:      #28305c;
  --code-bg:  #07091a;
  --code-fg:  #d8d0b0;
}

/* ── MEDEIVAL theme — illuminated manuscript: gold leaf on vellum ── */
[data-theme="medeival"] {
  --black:    #1a1208;
  --white:    #f0d890;
  --grey:     #a08850;
  --dim:      #2a1c10;
  --mid:      #4a3418;
  --code-bg:  #1a1208;
  --code-fg:  #d8b870;
}

/* ── DEMOS theme — showcase gallery: cool slate + cyan accent ── */
[data-theme="demos"] {
  --black:    #06090e;
  --white:    #d8eef0;
  --grey:     #5090a0;
  --dim:      #11181f;
  --mid:      #244048;
  --code-bg:  #050a0e;
  --code-fg:  #a0d0d8;
}

html, body { height: 100%; overflow: hidden; }

body {
  background: var(--black);
  color: var(--white);
  font-family: var(--font);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  transition: background 0.4s ease, color 0.4s ease;
}

/* ── App shell ── */
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* ── Header ── */
.header {
  display: flex;
  align-items: stretch;
  height: 44px;
  border-bottom: 1px solid var(--dim);
  flex-shrink: 0;
  transition: border-color 0.4s ease;
}

.logo {
  display: flex;
  align-items: center;
  padding: 0 20px;
  color: var(--grey);
  font-size: 18px;
  border-right: 1px solid var(--dim);
  letter-spacing: 0.05em;
  user-select: none;
  transition: color 0.4s ease, border-color 0.4s ease;
}

.playlist-tabs {
  display: flex;
  flex: 1;
}

.tab-btn {
  background: none;
  border: none;
  border-right: 1px solid var(--dim);
  color: var(--grey);
  cursor: pointer;
  padding: 0 22px;
  font-family: var(--font);
  font-size: 10px;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  transition: color 0.15s, background 0.15s, border-color 0.4s;
  height: 100%;
}
.tab-btn:hover  { color: var(--white); background: rgba(255,255,255,0.04); }
.tab-btn.active { color: var(--black); background: var(--white); }

.shuffle-btn {
  background: none;
  border: none;
  border-left: 1px solid var(--dim);
  color: var(--grey);
  cursor: pointer;
  padding: 0 20px;
  font-size: 16px;
  font-family: var(--font);
  transition: color 0.1s, border-color 0.4s;
  height: 100%;
}
.shuffle-btn:hover   { color: var(--white); }
.shuffle-btn.active  { color: var(--white); }

/* ── Body ── */
.body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ── Sidebar ── */
.sidebar {
  width: 260px;
  border-right: 1px solid var(--dim);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: border-color 0.4s ease;
}

.song-list {
  padding: 4px 0;
  flex: 1;
  overflow-y: auto;
}

.song-list::-webkit-scrollbar { width: 4px; }
.song-list::-webkit-scrollbar-track { background: transparent; }
.song-list::-webkit-scrollbar-thumb { background: var(--dim); }

/* ── Sidebar footer (submit ratings) ── */
.sidebar-footer {
  border-top: 1px solid var(--dim);
  padding: 9px 10px 9px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  transition: border-color 0.4s ease;
}

.submit-count {
  font-size: 10px;
  letter-spacing: 0.18em;
  color: var(--dim);
  min-width: 34px;
  font-variant-numeric: tabular-nums;
  transition: color 0.2s;
}

.submit-btn {
  flex: 1;
  background: none;
  border: 1px solid var(--dim);
  color: var(--dim);
  cursor: default;
  padding: 10px 10px;
  font-family: var(--font);
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.submit-btn:disabled { opacity: 0.45; }
.submit-btn.ready {
  border-color: var(--grey);
  color: var(--white);
  cursor: pointer;
}
.submit-btn.ready:hover { background: var(--white); color: var(--black); }
.submit-btn.submitted { border-color: var(--grey); color: var(--white); cursor: default; }
.submit-btn.error { border-color: var(--mid); color: var(--mid); cursor: pointer; }

.song-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px 9px 12px;
  cursor: pointer;
  border-left: 2px solid transparent;
  transition: background 0.08s, border-color 0.08s;
}
.song-item:hover  { background: rgba(255,255,255,0.03); }
.song-item.active {
  background: rgba(255,255,255,0.04);
  border-left-color: var(--white);
}

.si-num {
  font-size: 10px;
  color: var(--dim);
  min-width: 20px;
  text-align: right;
  flex-shrink: 0;
  letter-spacing: 0.05em;
}

.si-title {
  font-size: 12px;
  color: var(--grey);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.4;
  transition: color 0.08s;
  flex: 1;
}

/* ── Sidebar vote buttons ── */
.si-votes {
  display: flex;
  gap: 3px;
  flex-shrink: 0;
}

.si-vote-btn {
  background: none;
  border: 1px solid var(--dim);
  color: var(--dim);
  cursor: pointer;
  width: 18px;
  height: 18px;
  font-family: var(--font);
  font-size: 13px;
  font-weight: bold;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.1s, border-color 0.1s;
  flex-shrink: 0;
}
.song-item:hover .si-vote-btn       { color: var(--mid); border-color: var(--mid); }
.si-vote-btn:hover                  { color: var(--grey) !important; border-color: var(--grey) !important; }
.si-vote-btn.active                 { color: var(--white); border-color: var(--grey); }
.song-item:hover  .si-title { color: var(--white); }
.song-item.active .si-title { color: var(--white); }

/* ── Player pane ── */
.player-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 36px;
  padding: 40px 48px;
  overflow: hidden;
}

.player-pane.hidden { display: none; }

/* ── Song info ── */
.player-info {
  text-align: center;
  transition: opacity 0.25s ease;
  max-width: 680px;
  width: 100%;
}

.p-counter {
  font-size: 10px;
  letter-spacing: 0.4em;
  color: var(--mid);
  margin-bottom: 10px;
}

.p-subtitle {
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--grey);
  margin-bottom: 14px;
  min-height: 14px;
}

.p-title {
  font-size: clamp(2.4rem, 4.5vw, 4.2rem);
  font-weight: bold;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1.05;
  margin-bottom: 18px;
  word-break: break-word;
}

.p-meta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 14px;
}

.p-badge {
  font-size: 10px;
  letter-spacing: 0.15em;
  color: var(--grey);
  border: 1px solid var(--dim);
  padding: 3px 10px;
  transition: border-color 0.4s ease;
}

.p-sep {
  color: var(--dim);
  font-size: 10px;
}

.p-feel {
  font-size: 12px;
  color: var(--grey);
  font-style: italic;
  line-height: 1.55;
  margin-bottom: 6px;
  min-height: 18px;
}

.p-chords {
  font-size: 11px;
  color: var(--mid);
  letter-spacing: 0.12em;
  min-height: 16px;
}

/* ── Countdown ring ── */
.ring-wrap {
  position: relative;
  width: 200px;
  height: 200px;
  flex-shrink: 0;
}

.ring-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.ring-track {
  fill: none;
  stroke: var(--dim);
  stroke-width: 1;
}

.ring-fill {
  fill: none;
  stroke: var(--grey);
  stroke-width: 1;
  stroke-linecap: butt;
  transition: stroke-dashoffset 0.12s linear, stroke 0.4s ease;
}

.ring-fill.playing { stroke: var(--white); }

.ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  pointer-events: none;
}

.ring-time {
  font-size: 2rem;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.ring-label {
  font-size: 9px;
  letter-spacing: 0.5em;
  color: var(--mid);
}

/* ── Transport controls ── */
.controls {
  display: flex;
  align-items: center;
  gap: 16px;
}

.ctrl {
  background: none;
  border: 1px solid var(--dim);
  color: var(--grey);
  cursor: pointer;
  width: 44px;
  height: 44px;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font);
  transition: color 0.1s, border-color 0.1s, background 0.1s;
}
.ctrl:hover   { color: var(--white); border-color: var(--mid); }
.ctrl:active  { transform: scale(0.94); }

.ctrl-play {
  width: 60px;
  height: 60px;
  font-size: 18px;
  border-color: var(--white);
  color: var(--white);
  transition: color 0.1s, border-color 0.1s, background 0.1s;
}
.ctrl-play:hover { background: var(--white); color: var(--black); }

/* ── Timer ── */
.timer-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.timer-label {
  font-size: 9px;
  letter-spacing: 0.35em;
  color: var(--mid);
}

.timer-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 180px;
  height: 1px;
  background: var(--dim);
  cursor: pointer;
  outline: none;
}
.timer-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 8px;
  height: 8px;
  background: var(--white);
  cursor: pointer;
}
.timer-slider::-moz-range-thumb {
  width: 8px;
  height: 8px;
  background: var(--white);
  border: none;
  cursor: pointer;
}

.timer-val {
  font-size: 11px;
  color: var(--grey);
  min-width: 40px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.hints {
  font-size: 9px;
  letter-spacing: 0.3em;
  color: var(--dim);
}

/* ── Code pane ── */
.code-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.code-pane.hidden { display: none; }

.code-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 16px 24px 12px;
  border-bottom: 1px solid var(--dim);
  flex-shrink: 0;
  gap: 16px;
}

.code-title {
  font-size: 13px;
  font-weight: bold;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.code-counter {
  font-size: 10px;
  color: var(--mid);
  letter-spacing: 0.3em;
  flex-shrink: 0;
}

.code-hints-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 7px 24px;
  border-bottom: 1px solid var(--dim);
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--mid);
  flex-shrink: 0;
}

.code-hints-bar .dot { color: var(--dim); }

.code-area {
  flex: 1;
  background: var(--code-bg);
  color: var(--code-fg);
  border: none;
  border-bottom: 1px solid var(--dim);
  font-family: var(--font);
  font-size: 12.5px;
  line-height: 1.65;
  padding: 20px 24px;
  resize: none;
  outline: none;
  tab-size: 2;
  transition: background 0.4s ease, color 0.4s ease;
  /* subtle scanline overlay */
  background-image: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 1.63em,
    rgba(255,255,255,0.018) 1.63em,
    rgba(255,255,255,0.018) 1.65em
  );
}

.code-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 24px;
  flex-shrink: 0;
}

.code-btn {
  background: none;
  border: 1px solid var(--dim);
  color: var(--grey);
  cursor: pointer;
  padding: 7px 18px;
  font-family: var(--font);
  font-size: 10px;
  letter-spacing: 0.2em;
  transition: color 0.1s, border-color 0.1s, background 0.1s;
}
.run-btn:hover  { color: var(--white); border-color: var(--white); }
.stop-btn:hover { color: var(--white); border-color: var(--white); }

.code-nav {
  margin-left: auto;
  display: flex;
  gap: 8px;
}

.cnav-btn {
  background: none;
  border: 1px solid var(--dim);
  color: var(--mid);
  cursor: pointer;
  padding: 7px 14px;
  font-family: var(--font);
  font-size: 10px;
  letter-spacing: 0.15em;
  transition: color 0.1s, border-color 0.1s;
}
.cnav-btn:hover { color: var(--white); border-color: var(--mid); }

/* ── Board button ── */
.board-btn {
  background: none;
  border: none;
  border-left: 1px solid var(--dim);
  color: var(--grey);
  cursor: pointer;
  padding: 0 18px;
  font-family: var(--font);
  font-size: 10px;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  transition: color 0.1s, border-color 0.4s;
  height: 100%;
}
.board-btn:hover  { color: var(--white); }
.board-btn.active { color: var(--white); }

/* ── Board pane ── */
.board-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.board-pane.hidden { display: none; }

.board-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px 12px;
  border-bottom: 1px solid var(--dim);
  flex-shrink: 0;
}

.board-title {
  font-size: 10px;
  letter-spacing: 0.35em;
  color: var(--grey);
  font-weight: normal;
}

.board-refresh-timer {
  font-size: 9px;
  letter-spacing: 0.2em;
  color: var(--dim);
  transition: color 0.2s;
}
.board-refresh-timer.live    { color: var(--white); animation: live-pulse 1.6s ease-in-out infinite; }
.board-refresh-timer.loading { color: var(--grey); }

@keyframes live-pulse {
  0%, 100% { opacity: 0.55; }
  50%      { opacity: 1; }
}

.board-content {
  flex: 1;
  overflow-y: auto;
}
.board-content::-webkit-scrollbar { width: 4px; }
.board-content::-webkit-scrollbar-track { background: transparent; }
.board-content::-webkit-scrollbar-thumb { background: var(--dim); }

.board-empty, .board-loading {
  padding: 40px 24px;
  color: var(--dim);
  font-size: 10px;
  letter-spacing: 0.3em;
  text-align: center;
}

/* ── Leaderboard table ── */
.lb-table { padding: 4px 0; }

.lb-head, .lb-row {
  display: grid;
  grid-template-columns: 32px 1fr 64px 32px 32px 52px;
  padding: 8px 24px;
  gap: 0 8px;
}

.lb-head {
  font-size: 9px;
  letter-spacing: 0.3em;
  color: var(--mid);
  border-bottom: 1px solid var(--dim);
  padding-bottom: 10px;
}

.lb-row {
  font-size: 11px;
  border-bottom: 1px solid rgba(255,255,255,0.02);
  transition: background 0.08s;
}
.lb-row:hover { background: rgba(255,255,255,0.025); }

.lb-rank {
  font-size: 9px;
  color: var(--dim);
  letter-spacing: 0.05em;
  align-self: center;
}

.lb-name {
  color: var(--white);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: 0.04em;
  align-self: center;
}

.lb-tag {
  font-size: 9px;
  color: var(--grey);
  letter-spacing: 0.2em;
  text-align: center;
  align-self: center;
}

.lb-up, .lb-down {
  font-size: 10px;
  color: var(--grey);
  text-align: center;
  align-self: center;
  letter-spacing: 0.05em;
}

.lb-score {
  font-size: 12px;
  text-align: right;
  letter-spacing: 0.05em;
  align-self: center;
  color: var(--grey);
}
.lb-score.positive { color: var(--white); }
.lb-score.negative { color: var(--mid); }

/* ── Off-screen Strudel engine ── */
#engine {
  position: fixed;
  top: 0;
  left: -640px;
  width: 500px;
  height: 400px;
  pointer-events: none;
  opacity: 0;
}

/* ══════════════════════════════════════════════════════════════
   Mobile (≤ 768px) — stacked layout, compact controls
   ══════════════════════════════════════════════════════════════
   On phones the 260px sidebar swallowed the whole screen. We:
   - flip body to column, sidebar above the player
   - cap sidebar at 30vh so the player is always visible
   - shrink padding, ring, badges, buttons to fit
   - allow header tabs to scroll horizontally (more playlists than fit)
   - tighten code pane and leaderboard for narrow widths
   ══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {

  body { font-size: 13px; }

  /* Header: scroll horizontally if needed, smaller logo / buttons. */
  .header {
    height: 40px;
  }
  .logo       { padding: 0 12px; font-size: 16px; }
  .playlist-tabs {
    overflow-x: auto;
    scrollbar-width: none;
  }
  .playlist-tabs::-webkit-scrollbar { display: none; }
  .tab-btn    { padding: 0 14px; font-size: 9px; letter-spacing: 0.18em; flex-shrink: 0; }
  .board-btn  { padding: 0 12px; font-size: 9px; letter-spacing: 0.18em; }
  .shuffle-btn{ padding: 0 14px; font-size: 14px; }

  /* Body becomes column so sidebar sits above the player. */
  .body { flex-direction: column; }

  /* Sidebar: full width, capped height. Song list and footer share a row. */
  .sidebar {
    width: 100%;
    max-height: 30vh;
    border-right: none;
    border-bottom: 1px solid var(--dim);
  }
  .song-item     { padding: 7px 10px; }
  .si-title      { font-size: 11px; }
  .si-vote-btn   { width: 22px; height: 22px; } /* easier to tap */
  .sidebar-footer { padding: 7px 10px; }
  .submit-btn    { font-size: 9px; padding: 7px 6px; }

  /* Player pane: smaller everything. */
  .player-pane {
    padding: 16px 18px 20px;
    gap: 16px;
    justify-content: flex-start;
    overflow-y: auto;
  }
  .player-info { max-width: 100%; }
  .p-title     { font-size: clamp(1.5rem, 7vw, 2.4rem); margin-bottom: 10px; }
  .p-counter   { margin-bottom: 6px; }
  .p-subtitle  { margin-bottom: 8px; }
  .p-feel      { font-size: 11px; }
  .p-chords    { font-size: 10px; }

  .ring-wrap   { width: 140px; height: 140px; }
  .ring-time   { font-size: 1.4rem; }
  .ring-label  { font-size: 8px; }

  .controls    { gap: 12px; }
  .ctrl        { width: 40px; height: 40px; }
  .ctrl-play   { width: 52px; height: 52px; }

  .timer-row     { gap: 8px; flex-wrap: wrap; justify-content: center; }
  .timer-slider  { width: 60vw; max-width: 220px; }
  .hints         { display: none; } /* keyboard shortcuts irrelevant on phone */

  /* Code pane: full-width textarea, smaller padding. */
  .code-header   { padding: 12px 14px 10px; }
  .code-hints-bar{ padding: 6px 14px; font-size: 9px; }
  .code-area     { padding: 14px 14px; font-size: 12px; }
  .code-controls { padding: 10px 14px; gap: 8px; flex-wrap: wrap; }
  .code-btn      { padding: 6px 12px; font-size: 9px; }
  .cnav-btn      { padding: 6px 10px; font-size: 9px; }

  /* Leaderboard: collapse to essential columns on narrow screens. */
  .lb-head, .lb-row {
    grid-template-columns: 28px 1fr 28px 28px 44px;
    padding: 7px 14px;
    font-size: 10px;
  }
  .lb-head .lb-tag, .lb-row .lb-tag { display: none; }
}

/* Very narrow (≤ 380px, e.g. iPhone SE): tighten further. */
@media (max-width: 380px) {
  .tab-btn   { padding: 0 10px; }
  .p-title   { font-size: clamp(1.3rem, 6.5vw, 2rem); }
  .ring-wrap { width: 120px; height: 120px; }
  .ring-time { font-size: 1.2rem; }
}
