/* ============================================================
   SPELLTOWER — style-v2.css
   New look, layered on top of style.css. The "Classic look" setting
   switches this file off (media="not all"), which restores the original
   design exactly. Elements that exist only here carry .v2-only.
   ============================================================ */

/* ── Palette A (light) ─────────────────────────────────── */
:root {
  --bg:          #f4f1ea;
  --surface:     #fffdf9;
  --surface2:    #f6f1e7;
  --border:      #e4dccd;
  --accent:      #2f6bff;
  --accent-fg:   #ffffff;
  --accent2:     #ff6b4a;
  --accent-soft: #e6eeff;
  --text:        #1d1a16;
  --text-dim:    #7d7468;
  --text-muted:  #b5ab9c;

  --tile-bg:        #fffdf8;
  --tile-border:    #e2d8c6;
  --tile-hover:     #f6efe2;
  --tile-edge:      #e2d8c6;
  --tile-shadow:    0 2px 0 var(--tile-edge), 0 3px 8px rgba(80, 60, 30, 0.06);
  --tile-sel:       #2f6bff;
  --tile-sel-2:     #8fb2ff;
  --tile-sel-fg:    #ffffff;
  --tile-rare:      #fff1c9;
  --tile-rare-edge: #efcf72;
  --tile-rare-fg:   #8a5a00;
  --tile-new-row:   #e6eeff;
  --tile-new-row-b: #b8ccff;
  --tile-penalty:   #ffe4dc;
  --tile-penalty-b: #ffb7a3;

  --card-shadow: 0 18px 40px rgba(60, 40, 10, 0.08);
  --head-font: 'Fraunces', Georgia, serif;
  --overlay: rgba(244, 241, 234, 0.86);

  --sb-thumb:       rgba(47, 107, 255, 0.45);
  --sb-thumb-hover: rgba(47, 107, 255, 0.75);
  --sb-track:       transparent;

  --gap: 4px;
  --tile-size: clamp(30px, min(8vw, calc((100dvh - 300px) / 12)), 46px);
  --board-w: calc(var(--cols) * var(--tile-size) + (var(--cols) - 1) * var(--gap));
  --board-h: calc(var(--rows) * var(--tile-size) + (var(--rows) - 1) * var(--gap));
  --board-pad: 12px;
  --words-w: 290px;
  --game-gap: 24px;
  --game-inner-w: calc(var(--board-w) + 2 * var(--board-pad) + var(--game-gap) + var(--words-w));
}

/* ── Palette B (dark theme) ────────────────────────────── */
body.dark {
  --bg:          #0f1226;
  --surface:     #1a1f3f;
  --surface2:    #20264b;
  --border:      #2c3463;
  --accent:      #7c5cff;
  --accent-fg:   #ffffff;
  --accent2:     #ffb547;
  --accent-soft: #2a2f5e;
  --text:        #eef0ff;
  --text-dim:    #9aa2d6;
  --text-muted:  #5d6596;

  --tile-bg:        #272e5a;
  --tile-border:    #141938;
  --tile-hover:     #303870;
  --tile-edge:      #11152f;
  --tile-shadow:    0 4px 0 var(--tile-edge), 0 8px 18px rgba(0, 0, 0, 0.35);
  --tile-sel:       #7c5cff;
  --tile-sel-2:     #22d3ee;
  --tile-sel-fg:    #ffffff;
  --tile-rare:      #3b2f63;
  --tile-rare-edge: #ffb547;
  --tile-rare-fg:   #ffcf7a;
  --tile-new-row:   #2a3a7a;
  --tile-new-row-b: #4b63c9;
  --tile-penalty:   #5a2440;
  --tile-penalty-b: #b04a6e;

  --card-shadow: 0 30px 60px rgba(0, 0, 0, 0.45);
  --head-font: 'Nunito', sans-serif;
  --overlay: rgba(10, 12, 28, 0.82);
  --sk-shine: rgba(255, 255, 255, 0.08);

  --sb-thumb:       rgba(255, 255, 255, 0.26);
  --sb-thumb-hover: rgba(255, 255, 255, 0.45);
}
body.dark {
  background:
    radial-gradient(1200px 600px at 50% -10%, #2a2470 0%, transparent 60%),
    radial-gradient(900px 500px at 100% 30%, #123a5a 0%, transparent 55%),
    var(--bg);
  background-attachment: fixed;
}

body.high-contrast {
  --tile-sel:   #ffd600;
  --tile-sel-2: #ffd600;
  --tile-sel-fg: #000000;
}

/* ── Scrollbars ────────────────────────────────────────── */
::-webkit-scrollbar { width: 14px; height: 14px; }
::-webkit-scrollbar-track { background: var(--sb-track); }
::-webkit-scrollbar-thumb {
  background: var(--sb-thumb);
  border-radius: 99px;
  border: 3px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--sb-thumb-hover); background-clip: padding-box; }
::-webkit-scrollbar-corner { background: transparent; }

#words-list-wrap,
.modal-box {
  scrollbar-color: auto;
  scrollbar-width: auto;
}
#words-list-wrap::-webkit-scrollbar,
.modal-box::-webkit-scrollbar { width: 14px; }
#words-list-wrap::-webkit-scrollbar-track,
body.dark #words-list-wrap::-webkit-scrollbar-track { background: transparent; margin: 8px 0; }
.modal-box::-webkit-scrollbar-track { background: transparent; margin: 20px 0; }
#words-list-wrap::-webkit-scrollbar-thumb,
.modal-box::-webkit-scrollbar-thumb,
body.dark #words-list-wrap::-webkit-scrollbar-thumb,
body.dark .modal-box::-webkit-scrollbar-thumb {
  background: var(--sb-thumb);
  border-radius: 99px;
  border: 3px solid transparent;
  border-right-width: 6px;
  background-clip: padding-box;
}
#words-list-wrap::-webkit-scrollbar-thumb:hover,
.modal-box::-webkit-scrollbar-thumb:hover { background: var(--sb-thumb-hover); background-clip: padding-box; }

@supports not selector(::-webkit-scrollbar) {
  html, #words-list-wrap, .modal-box { scrollbar-color: var(--sb-thumb) transparent; scrollbar-width: thin; }
}

/* ── Top bar ───────────────────────────────────────────── */
#topbar {
  position: sticky;
  top: 0;
  z-index: 60;
  padding: 10px 20px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
body.dark #topbar { background: rgba(15, 18, 38, 0.78); }
#topbar-inner { max-width: max(var(--game-inner-w), 760px); gap: 12px; }
#topbar-left { gap: 12px; }

#logo {
  align-items: center;
  gap: 0;
  font-family: var(--head-font);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.01em;
}
#logo::before {
  content: '';
  width: 32px;
  height: 32px;
  margin-right: 10px;
  flex-shrink: 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Crect x='0' y='0' width='32' height='9' rx='3' fill='%23ff6b4a'/%3E%3Crect x='0' y='11.5' width='15' height='9' rx='3' fill='%232f6bff' fill-opacity='.85'/%3E%3Crect x='17' y='11.5' width='15' height='9' rx='3' fill='%232f6bff' fill-opacity='.6'/%3E%3Crect x='0' y='23' width='15' height='9' rx='3' fill='%232f6bff'/%3E%3Crect x='17' y='23' width='15' height='9' rx='3' fill='%232f6bff' fill-opacity='.85'/%3E%3C/svg%3E") center / contain no-repeat;
}
body.dark #logo::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Crect x='0' y='0' width='32' height='9' rx='3' fill='%23ffb547'/%3E%3Crect x='0' y='11.5' width='15' height='9' rx='3' fill='%237c5cff' fill-opacity='.85'/%3E%3Crect x='17' y='11.5' width='15' height='9' rx='3' fill='%237c5cff' fill-opacity='.6'/%3E%3Crect x='0' y='23' width='15' height='9' rx='3' fill='%237c5cff'/%3E%3Crect x='17' y='23' width='15' height='9' rx='3' fill='%237c5cff' fill-opacity='.85'/%3E%3C/svg%3E");
}
#logo .logo-line + .logo-line { color: var(--accent); }
#logo a, a#logo { color: inherit; text-decoration: none; }

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s, transform 0.08s, background 0.15s;
}
body.dark .icon-btn { background: var(--surface2); }
.icon-btn:hover { border-color: var(--accent); color: var(--text); }
.icon-btn:active { transform: scale(0.95); }
.icon-btn--auth { width: auto; padding: 0 12px; }
#auth-username-label { color: var(--text); }

/* ── Mode dropdown ─────────────────────────────────────── */
:root {
  --ico-daily: 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%3Crect x='3' y='4' width='18' height='18' rx='3'/%3E%3Cline x1='16' y1='2' x2='16' y2='6'/%3E%3Cline x1='8' y1='2' x2='8' y2='6'/%3E%3Cline x1='3' y1='10' x2='21' y2='10'/%3E%3C/svg%3E");
  --ico-tower: 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%3Crect x='4' y='3' width='16' height='5' rx='1.5'/%3E%3Crect x='4' y='10' width='7' height='5' rx='1.5'/%3E%3Crect x='13' y='10' width='7' height='5' rx='1.5'/%3E%3Crect x='4' y='17' width='16' height='5' rx='1.5'/%3E%3C/svg%3E");
  --ico-puzzle: 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%3Cpolyline points='12 13 12 3'/%3E%3Cpolyline points='7 8 12 3 17 8'/%3E%3Crect x='3' y='16' width='18' height='5' rx='1.5'/%3E%3C/svg%3E");
  --ico-zen: 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='M11 20A7 7 0 0 1 9.8 6.1C15.5 5 17 4.48 19 2c1 2 2 4.18 2 8 0 5.5-4.78 10-10 10Z'/%3E%3Cpath d='M2 21c0-3 1.85-5.36 5.08-6C9.5 14.52 12 13 13 12'/%3E%3C/svg%3E");
  --ico-check: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E");
}

.mode-dropdown-btn {
  height: 38px;
  gap: 8px;
  padding: 0 12px 0 12px;
  border-radius: 99px;
  background: var(--surface);
  font-size: 14px;
  font-weight: 800;
  transition: border-color 0.15s, box-shadow 0.15s;
}
body.dark .mode-dropdown-btn { background: var(--surface2); }
.mode-dropdown-btn:hover { border-color: var(--accent); }
.mode-dropdown-btn[aria-expanded="true"] {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.mode-dropdown-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.mode-dropdown-btn::before {
  content: '';
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  background: var(--accent);
  -webkit-mask: var(--ico-daily) center / contain no-repeat;
  mask: var(--ico-daily) center / contain no-repeat;
}
#mode-select:has(.mode-dropdown-opt.active[data-value="tower"]) .mode-dropdown-btn::before { -webkit-mask-image: var(--ico-tower); mask-image: var(--ico-tower); }
#mode-select:has(.mode-dropdown-opt.active[data-value="puzzle"]) .mode-dropdown-btn::before { -webkit-mask-image: var(--ico-puzzle); mask-image: var(--ico-puzzle); }
#mode-select:has(.mode-dropdown-opt.active[data-value="zen"]) .mode-dropdown-btn::before { -webkit-mask-image: var(--ico-zen); mask-image: var(--ico-zen); }
.mode-chevron { width: 14px; height: 14px; }

.mode-dropdown-panel {
  top: calc(100% + 8px);
  min-width: 290px;
  padding: 6px;
  border-radius: 16px;
  box-shadow: 0 18px 44px rgba(40, 25, 5, 0.16);
  transform: translateY(-6px) scale(0.98);
  transform-origin: top left;
  transition: opacity 0.16s ease, transform 0.16s ease;
}
body.dark .mode-dropdown-panel { background: var(--surface); box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55); }
.mode-dropdown-panel.open { transform: none; }

.mode-dropdown-opt {
  display: grid;
  grid-template-columns: 36px 1fr 18px;
  grid-template-rows: auto auto;
  column-gap: 12px;
  row-gap: 1px;
  align-items: center;
  padding: 9px 10px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 900;
  line-height: 1.2;
  outline: none;
}
.mode-opt-ico {
  grid-row: 1 / 3;
  grid-column: 1;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--surface2);
  border: 1px solid var(--border);
}
.mode-opt-ico::before {
  content: '';
  width: 18px;
  height: 18px;
  background: var(--accent);
  -webkit-mask: var(--opt-ico) center / contain no-repeat;
  mask: var(--opt-ico) center / contain no-repeat;
}
.mode-opt-name { grid-row: 1; grid-column: 2; align-self: end; }
.mode-dropdown-opt::after {
  content: attr(data-desc);
  grid-row: 2;
  grid-column: 2;
  align-self: start;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-dim);
}
.mode-dropdown-opt::before {
  content: '';
  grid-row: 1 / 3;
  grid-column: 3;
  width: 16px;
  height: 16px;
  background: var(--accent);
  -webkit-mask: var(--ico-check) center / contain no-repeat;
  mask: var(--ico-check) center / contain no-repeat;
  opacity: 0;
}
.mode-dropdown-opt:hover,
.mode-dropdown-opt:focus-visible { background: var(--surface2); }
.mode-dropdown-opt:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); }
.mode-dropdown-opt.active { background: var(--accent-soft); color: var(--text); }
.mode-dropdown-opt.active::before { opacity: 1; }
.mode-dropdown-opt.active .mode-opt-ico { background: var(--accent); border-color: transparent; }
.mode-dropdown-opt.active .mode-opt-ico::before { background: #fff; }
.mode-dropdown-opt[data-value="daily"]  { --opt-ico: var(--ico-daily); }
.mode-dropdown-opt[data-value="tower"]  { --opt-ico: var(--ico-tower); }
.mode-dropdown-opt[data-value="puzzle"] { --opt-ico: var(--ico-puzzle); }
.mode-dropdown-opt[data-value="zen"]    { --opt-ico: var(--ico-zen); }

/* ── Game area ─────────────────────────────────────────── */
#game-area { padding: 10px 20px 4px; gap: var(--game-gap); overflow: visible; }
#game-left { gap: 10px; }

#word-display {
  height: 46px;
  width: auto;
  min-width: var(--board-w);
}
#current-word {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 99px;
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 0.18em;
  color: var(--text);
  background: transparent;
  border: 1px solid transparent;
  transition: background 0.12s, border-color 0.12s;
}
#current-word.has-word {
  background: var(--surface);
  border-color: var(--border);
  box-shadow: 0 6px 20px rgba(60, 40, 10, 0.07);
}
body.dark #current-word.has-word { background: var(--surface2); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35); }
#current-word:empty::before {
  content: 'Drag across letters to spell a word';
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0;
  color: var(--text-muted);
}
#current-pts {
  margin-left: 8px;
  padding: 5px 10px;
  border-radius: 99px;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0;
}
#current-pts:empty { display: none; }

#board-wrapper {
  padding: var(--board-pad);
  border-radius: 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--card-shadow);
}
body.dark #board-wrapper {
  background: rgba(26, 31, 63, 0.78);
  box-shadow: var(--card-shadow), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
#board-container { background: transparent; overflow: visible; }

/* ── Tiles ─────────────────────────────────────────────── */
.tile {
  border-radius: calc(var(--tile-size) * 0.24);
  background: var(--tile-bg);
  box-shadow: var(--tile-shadow);
  transition: background 0.08s, transform 0.08s, box-shadow 0.08s;
}
body.dark .tile:not(.empty):not(.selected):not(.rare) {
  background: linear-gradient(180deg, #2e3668, #252c57);
}
.tile .letter {
  font-size: calc(var(--tile-size) * 0.46);
  font-weight: 900;
}
.tile .pts {
  display: block;
  position: absolute;
  right: calc(var(--tile-size) * 0.1);
  bottom: calc(var(--tile-size) * 0.05);
  font-size: max(8px, calc(var(--tile-size) * 0.21));
  font-weight: 800;
  line-height: 1.1;
  color: var(--text-muted);
  pointer-events: none;
}
.tile.rare {
  background: var(--tile-rare);
  box-shadow: 0 2px 0 var(--tile-rare-edge), 0 3px 8px rgba(160, 110, 0, 0.12);
}
body.dark .tile.rare:not(.selected) {
  background: linear-gradient(180deg, #4a3a7a, #3b2f63);
  box-shadow: 0 4px 0 #1d1640, inset 0 0 0 1.5px var(--tile-rare-edge), 0 8px 18px rgba(0, 0, 0, 0.35);
}
.tile.rare .letter, .tile.rare .pts { color: var(--tile-rare-fg); }

.tile.selected {
  background: color-mix(in srgb, var(--tile-sel) calc((1 - var(--sel-t, 0)) * 100%), var(--tile-sel-2)) !important;
  box-shadow: 0 2px 0 color-mix(in srgb, var(--tile-sel) 60%, #000), 0 6px 14px color-mix(in srgb, var(--tile-sel) 35%, transparent);
  transform: translateY(-1px);
}
body.dark .tile.selected { box-shadow: 0 4px 0 #2b1d7a, 0 0 18px rgba(124, 92, 255, 0.55); }
body.high-contrast .tile.selected { background: var(--tile-sel) !important; }
.tile.selected .letter, .tile.selected .pts { color: var(--tile-sel-fg); }
.tile.selected .pts { opacity: 0.8; }

@media (hover: hover) {
  .tile:not(.empty):not(.selected):hover { background: var(--tile-hover); transform: translateY(-1px); }
  body.dark .tile:not(.empty):not(.selected):hover { background: var(--tile-hover); }
}

.tile.empty,
body.dark .tile.empty {
  background: color-mix(in srgb, var(--surface2) 70%, transparent) !important;
  box-shadow: none;
  transform: none;
}
body.dark .tile.empty { background: rgba(255, 255, 255, 0.025) !important; }

@keyframes newRowFade {
  0%   { background: var(--tile-new-row); }
  66%  { background: var(--tile-new-row); }
  100% { background: var(--tile-bg); }
}
@keyframes penaltyFade {
  0%   { background: var(--tile-penalty); }
  66%  { background: var(--tile-penalty); }
  100% { background: var(--tile-bg); }
}

/* ── Action bar ────────────────────────────────────────── */
#word-and-controls { background: transparent; padding: 14px 20px 6px; }
#controls-main { width: calc(var(--board-w) + 2 * var(--board-pad)); gap: 10px; }
#controls-replay { width: var(--words-w); }
.btn-icon { display: inline-block; }
.ctrl-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 18px;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0.06em;
}
.ctrl-btn.secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}
body.dark .ctrl-btn.secondary { background: var(--surface2); }
.ctrl-btn.secondary:hover { border-color: var(--accent); color: var(--text); }
.ctrl-btn.primary {
  background: var(--accent);
  color: #fff;
  padding: 0 28px;
  box-shadow: 0 8px 20px color-mix(in srgb, var(--accent) 35%, transparent);
}
.ctrl-btn.primary:hover { opacity: 1; filter: brightness(1.06); }
#btn-submit { flex: 1.4; }
#btn-undo, #btn-clear { flex: 1; }

/* ── Side panel: score card + words + streak ───────────── */
#words-panel {
  width: var(--words-w);
  height: auto;
  max-height: calc(var(--board-h) + 2 * var(--board-pad));
  margin-top: 56px;
  background: transparent;
  overflow: visible;
  gap: 14px;
}
.side-card,
#words-panel-body {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
}
body.dark .side-card,
body.dark #words-panel-body { background: rgba(26, 31, 63, 0.82); }
#words-panel-body { padding: 12px; min-height: 180px; }

#score-card { padding: 16px; flex-shrink: 0; }
.sc-top { display: flex; align-items: baseline; gap: 8px; }
#sc-score { font-size: 40px; font-weight: 900; line-height: 1; }
.sc-max { color: var(--text-dim); font-weight: 800; }
#sc-badge {
  margin-left: auto;
  font-size: 12px;
  font-weight: 900;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 4px 10px;
  border-radius: 99px;
  white-space: nowrap;
}
.sc-bar {
  position: relative;
  height: 10px;
  margin: 16px 6px 6px;
  border-radius: 99px;
  background: var(--surface2);
}
body.dark .sc-bar { background: #11152f; }
#sc-fill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 0;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  transition: width 0.35s ease;
}
.sc-bar b {
  position: absolute;
  top: -3px;
  width: 16px;
  height: 16px;
  margin-left: -8px;
  border-radius: 50%;
  background: var(--surface);
  border: 3px solid var(--border);
  transition: border-color 0.2s;
}
.sc-bar b.passed { border-color: var(--accent2); }
.sc-ms { position: relative; height: 14px; margin: 0 6px; font-size: 11px; font-weight: 800; color: var(--text-dim); }
.sc-ms span { position: absolute; transform: translateX(-50%); }
.sc-ms span:last-child { transform: translateX(-100%); }
.sc-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.sc-stats div { background: var(--surface2); border-radius: 10px; padding: 8px 4px; text-align: center; min-width: 0; }
.sc-stats strong { display: block; font-size: 17px; font-weight: 900; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sc-stats span { font-size: 11px; font-weight: 800; color: var(--text-dim); }

#words-tabs {
  border: none;
  background: var(--surface2);
  border-radius: 10px;
  padding: 3px;
  gap: 3px;
}
.words-tab {
  border-radius: 8px !important;
  padding: 7px 6px;
  font-size: 11px;
  font-weight: 900;
}
.words-tab.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08); }
body.dark .words-tab.active { background: var(--accent); color: #fff; }
#words-count-row { border: none; padding: 8px 4px 6px; }
#words-list-wrap { margin-right: -8px; }
#words-list .wl-item,
#words-list .wl-group-item {
  border: none;
  border-radius: 8px;
  padding: 7px 10px;
  margin-right: 4px;
}
#words-list .wl-item:nth-child(odd) { background: var(--surface2); }
#words-list .wl-item:hover { background: var(--accent-soft); }
#words-list .wl-group-header { background: var(--surface); border: none; padding: 10px 10px 4px; }
.wl-word { font-size: 14px; font-weight: 800; }
.wl-pts { color: var(--text-dim); font-weight: 900; }

#streak-card { display: flex; align-items: center; gap: 12px; padding: 12px 14px; flex-shrink: 0; }
#streak-card.hidden-card { display: none; }
#streak-num {
  flex: 0 0 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #ffb547, #ff6b4a);
  color: #fff;
  font-weight: 900;
  font-size: 16px;
}
#streak-card strong { display: block; font-weight: 900; font-size: 15px; }
#streak-card small { display: block; color: var(--text-dim); font-weight: 700; font-size: 12px; }

/* ── Overlays and modals ───────────────────────────────── */
.modal, #gameover-overlay { background: var(--overlay); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
body.dark .modal, body.dark #gameover-overlay { background: var(--overlay); }
.modal-box, #gameover-box {
  border-radius: 22px;
  box-shadow: 0 24px 60px rgba(30, 20, 5, 0.16);
}
body.dark .modal-box, body.dark #gameover-box { box-shadow: 0 30px 70px rgba(0, 0, 0, 0.55); }
.modal-title, #gameover-title { font-family: var(--head-font); letter-spacing: 0; }
#gameover-score { color: var(--accent); }
.modal-close, .modal-icon-btn { border-radius: 10px; }
.tab-btn.active { color: var(--accent); }
.toggle-input:checked + .toggle-slider { background: var(--accent); }
#burger-menu { top: 62px; border-radius: 16px; }
.feedback-toast { border-radius: 99px; font-weight: 900; }
.feedback-toast.success { background: color-mix(in srgb, var(--accent) 92%, transparent); }
.feedback-toast.error { background: rgba(225, 72, 52, 0.92); }

#tutorial-banner { background: var(--accent); color: #fff; }
.tut-dot.active { background: var(--accent); }
#tutorial-board { gap: 4px; }
.tut-tile { border-radius: 10px; background: var(--tile-bg); box-shadow: var(--tile-shadow); }
.tut-tile.tut-empty { box-shadow: none; }
.tut-tile.tut-selected { background: var(--tile-sel); color: #fff; }
.tut-btn.primary { background: var(--accent); color: #fff; }
@keyframes tut-flash {
  0%   { background: var(--tile-sel); color: #fff; transform: scale(1.12); }
  50%  { transform: scale(1.18); }
  100% { background: var(--tile-sel); color: #fff; transform: scale(1); }
}

/* ── Guide and footer ──────────────────────────────────── */
#guide { max-width: 820px; margin-top: 40px; }
#guide h1 {
  font-family: var(--head-font);
  font-size: 2.1rem;
  letter-spacing: -0.01em;
  margin: 0 0 14px;
}
#guide h1 + p {
  font-size: 1.08rem;
  color: var(--text);
}
#guide h2 {
  font-family: var(--head-font);
  font-size: 1.6rem;
  letter-spacing: -0.01em;
  margin: 42px 0 14px;
}
#guide h3 { font-size: 1.12rem; font-weight: 900; }
#guide h3 a { color: var(--accent); text-decoration: none; }
#guide h3 a:hover { text-decoration: underline; }
#guide a { color: var(--accent); }
#guide ol { padding-left: 0; list-style: none; counter-reset: step; }
#guide ol > li {
  counter-increment: step;
  position: relative;
  padding: 14px 16px 14px 56px;
  margin: 0 0 10px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
}
#guide ol > li::before {
  content: counter(step);
  position: absolute;
  left: 16px;
  top: 14px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #fff;
  font-weight: 900;
  font-size: 14px;
}
#guide ul > li::marker { color: var(--accent2); }
#guide table {
  border-collapse: separate;
  border-spacing: 0;
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
}
#guide th, #guide td { border: none; border-bottom: 1px solid var(--border); }
#guide tr:last-child td { border-bottom: none; }
#guide th { background: var(--surface2); font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; }
#guide details { border-radius: 14px; transition: border-color 0.15s; }
#guide details[open] { border-color: var(--accent); }
#guide summary { list-style: none; position: relative; padding-right: 44px; }
#guide summary::-webkit-details-marker { display: none; }
#guide summary::after {
  content: '';
  position: absolute;
  right: 18px;
  top: 50%;
  width: 8px;
  height: 8px;
  border-right: 2.5px solid var(--text-dim);
  border-bottom: 2.5px solid var(--text-dim);
  transform: translateY(-70%) rotate(45deg);
  transition: transform 0.2s;
}
#guide details[open] summary::after { transform: translateY(-30%) rotate(-135deg); }
#guide a.ng-card { border-radius: 14px; }

#site-footer { background: var(--surface); }
body.dark #site-footer { background: rgba(15, 18, 38, 0.6); }
#site-footer a:hover { color: var(--accent); }

@media (prefers-reduced-motion: reduce) {
  .tile, .ctrl-btn, #sc-fill, .mode-dropdown-panel, .mode-chevron { transition: none; }
}

/* ── Mobile ────────────────────────────────────────────── */
@media (max-width: 640px) {
  :root {
    --gap: 3px;
    --board-pad: 8px;
    --tile-size: min(
      calc((100vw - 12px - 2 * var(--board-pad) - 7 * var(--gap)) / 8),
      calc((100dvh - 226px - 11 * var(--gap)) / 12)
    );
  }

  #topbar { padding: 8px 10px; }
  #topbar-inner { gap: 8px; }
  #topbar-right { gap: 6px; }
  #logo { display: flex; }
  #logo::before { width: 28px; height: 28px; margin-right: 0; }
  #logo .logo-line { display: none; }
  #btn-auth { display: none; }
  .mode-dropdown-btn { height: 36px; font-size: 13px; padding: 0 10px; gap: 6px; }
  .mode-dropdown-panel { min-width: 270px; }
  #auth-username-label { display: none; }
  .icon-btn--auth { width: 38px; padding: 0; }
  #burger-menu { top: 58px; }

  #words-panel-summary {
    flex: 0 1 auto;
    min-width: 0;
    margin-left: auto;
    padding: 7px 10px;
    border-radius: 99px;
    border: 1px solid var(--border);
    background: var(--surface);
    white-space: nowrap;
  }
  body.dark #words-panel-summary { background: var(--surface2); }


  #game-area { padding: 4px 6px 0; min-height: 0; }
  #game-left { gap: 6px; }
  #board-wrapper { margin-top: 0; border-radius: 18px; }
  #word-display { height: 42px; min-width: 0; }
  #current-word { min-height: 38px; font-size: 19px; padding: 0 14px; }
  #current-word:empty::before { font-size: 13px; }
  #mobile-float-controls,
  #mobile-float-controls.visible { display: none; }

  #words-panel { width: 100%; height: 0; max-height: none; margin: 0; }
  #words-panel-body { border-radius: 0 0 16px 16px; padding: 10px; }
  #words-panel .side-card { display: none; }

  #word-and-controls {
    display: flex;
    padding: 10px 6px 4px;
  }
  #controls-main { width: 100%; max-width: calc(var(--board-w) + 2 * var(--board-pad)); }
  #controls-replay { display: none; }
  .ctrl-btn { min-width: 0; padding: 0 12px; }
  #btn-undo .btn-text, #btn-clear .btn-text { display: none; }

  #guide h1 { font-size: 1.6rem; }
  #guide h2 { font-size: 1.3rem; }
}
