* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root,
html[data-theme="light"],
html:not([data-theme]) {
  --grid-cell-size: 60px;
  --grid-gap: 8px;
  --floating-header-top: 16px;
  --floating-header-height: 84px;
  --floating-header-gap: 18px;
  --floating-header-offset: calc(var(--floating-header-top) + var(--floating-header-height) + var(--floating-header-gap));
  --halo-graphic-height: 58px;
  --halo-card-overlap: -8px;
  --side-card-extra-offset: 1px;
  --board-card-align-offset: calc(var(--halo-graphic-height) + var(--halo-card-overlap) + var(--side-card-extra-offset));
  --bg: #D0C4FF;   /* F — standby: #C8BAFF (G) */
  --surface: #EDE9FE;
  --card: #FFF0DC;   /* soft cream card surface */
  --ube: #7C3AED;
  --ube-mid: #A78BFA;
  --ube-light: #C4B5FD;
  --ube-pale: #EDE9FE;
  --pandan: #6EE7B7;
  --gulaman-pink: #F9A8D4;
  --leche: #FCD34D;
  --peach: #FDBA74;
  --text: #3B1F6B;
  --text-muted: #7C6A9E;
  --border: rgba(124,58,237,0.15);
  /* keep any existing vars still referenced elsewhere, mapped to new palette */
  --text-color: var(--text);
  --text-secondary: var(--text-muted);
  --bg-gradient: var(--bg);
  --container-bg: var(--card);
  --border-color: var(--border);
  --card-bg: var(--surface);
  --primary-color: var(--ube);
  --primary-hover: #6d28d9;
  --success-color: #22c55e;
  --error-color: #e53e3e;
  --warning-color: var(--ube-pale);
  --sidebar-bg: var(--card);
  --sidebar-shadow: 0 4px 24px rgba(124,58,237,0.12);
}

html[data-theme="dark"] {
  --bg:       #2a2438;   /* medium-dark with a warm purple undertone */
  --surface:  #332c44;   /* slightly lighter, still dark */
  --card:     #3d3550;   /* card surface, noticeably lighter than bg */
  --ube:      #a78bfa;   /* keep purple accent bright so it pops on dark bg */
  --ube-mid:  #7c3aed;
  --ube-light:#c4b5fd;
  --ube-pale: #3a3250;   /* used for header/footer — matches card range */
  --text:     #f0eeff;   /* near-white with faint purple cast */
  --text-muted: #b8afd4; /* readable muted purple-gray */
  --border:   rgba(196,181,253,0.2);
  /* keep all the alias vars pointing to the same names */
  --text-color: var(--text);
  --text-secondary: var(--text-muted);
  --bg-gradient: var(--bg);
  --container-bg: var(--card);
  --border-color: var(--border);
  --card-bg: var(--surface);
  --primary-color: var(--ube);
  --primary-hover: #8b5cf6;
  --success-color: #4ade80;
  --error-color: #f87171;
  --warning-color: var(--ube-pale);
  --sidebar-bg: var(--card);
  --sidebar-shadow: 0 4px 24px rgba(0,0,0,0.4);
}

body {
  font-family: 'Nunito', 'Segoe UI', sans-serif;
  background-color: var(--bg);
  background-image:
    repeating-linear-gradient(45deg, rgba(167,139,250,0.06) 0, rgba(167,139,250,0.06) 1px, transparent 1px, transparent 8px),
    repeating-linear-gradient(-45deg, rgba(167,139,250,0.06) 0, rgba(167,139,250,0.06) 1px, transparent 1px, transparent 8px);
  min-height: 100vh;
  color: var(--text);
  animation: pageLoad 0.15s ease-out;
  padding-top: var(--floating-header-offset);
  overflow-x: hidden;
}

@keyframes pageLoad {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes invalid-shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-2px); }
    75% { transform: translateX(2px); }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

@keyframes bounce-in {
  0%   { transform: scale(0.8); opacity: 0; }
  60%  { transform: scale(1.06); }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes pulse-empty {
  0%, 100% { border-color: var(--ube-light); box-shadow: 0 0 0 0 rgba(196,181,253,0.3); }
  50%       { border-color: var(--ube-mid);   box-shadow: 0 0 0 6px rgba(196,181,253,0); }
}

@keyframes gentle-bob {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-4px); }
}

@keyframes float-ice {
  0%   { transform: translateY(0) scale(1); opacity: 0.7; }
  100% { transform: translateY(-60px) scale(0.4); opacity: 0; }
}

@keyframes wave-anim {
  0%, 100% { d: path("M0,20 C200,0 400,40 600,20 C800,0 1000,40 1200,20 L1200,40 L0,40 Z"); }
  50%       { d: path("M0,30 C200,50 400,10 600,30 C800,50 1000,10 1200,30 L1200,40 L0,40 Z"); }
}


/* ── GLASS CARD ── */
.glass-card {
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(196, 181, 253, 0.4);
  border-radius: 20px;
  box-shadow: 0 4px 24px rgba(124,58,237,0.08), 0 1px 4px rgba(124,58,237,0.05);
}
html[data-theme="dark"] .glass-card {
  background: rgba(61, 53, 80, 0.85);
  border-color: rgba(196,181,253,0.15);
}


/* ── HEADER ── */
header {
  background: rgba(237, 233, 254, 0.82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(196, 181, 253, 0.42);
  border-radius: 20px;
  padding: 16px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  box-shadow: 0 10px 28px rgba(124,58,237,0.14), 0 2px 8px rgba(124,58,237,0.08);
  position: fixed;
  top: var(--floating-header-top);
  left: 50%;
  width: min(calc(100% - 32px), 1280px);
  transform: translateX(-50%);
  z-index: 1000;
  transition: opacity 0.22s ease, background-color 0.22s ease, box-shadow 0.22s ease;
}
html[data-theme="dark"] header {
  background: rgba(58, 50, 80, 0.84);
  border-color: rgba(196,181,253,0.18);
}
header.is-overlapping-board {
  opacity: 0;
  box-shadow: 0 6px 18px rgba(124,58,237,0.10), 0 1px 4px rgba(124,58,237,0.05);
  pointer-events: none;
}
html[data-theme="dark"] header.is-overlapping-board {
  opacity: 0;
}
.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.header-glass-icon {
  font-size: 26px;
  animation: gentle-bob 3s ease-in-out infinite;
}
.header-titles {
  display: flex;
  flex-direction: column;
}
.game-title {
  font-family: 'Baloo 2', cursive;
  font-weight: 800;
  font-size: 24px;
  color: var(--ube);
  line-height: 1.1;
}
.game-subtitle {
  font-family: 'Nunito', sans-serif;
  font-weight: 600;
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.header-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  margin-left: auto;
}
.daily-pill {
  background: var(--ube);
  color: white;
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: 11px;
  padding: 4px 12px;
  border-radius: 999px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.daily-pill.hidden { display: none; }


/* ── WAVE DIVIDER ── */
.wave-divider {
  display: block;
  width: min(calc(100% - 32px), 1280px);
  height: 40px;
  overflow: hidden;
  line-height: 0;
  margin: 0 auto;
  opacity: 0.82;
}
.wave-divider svg {
  display: block;
  width: 100%;
  height: 100%;
}
html[data-theme="dark"] .wave-divider path {
  fill: #2a2438;
}


/* ── MAIN LAYOUT ── */
main {
  position: relative;
  z-index: 1;
  max-width: 1280px;
  margin: 0 auto;
  padding: 20px 24px 60px;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 300px;
  gap: 28px;
  align-items: start;
  scroll-margin-top: var(--floating-header-offset);
}
.mixes-col {
  position: sticky;
  top: var(--floating-header-offset);
  z-index: 2;
  padding-top: var(--board-card-align-offset);
}
.puzzle-col {
  display: flex;
  flex-direction: column;
  justify-self: center;
  width: 100%;
  max-width: 760px;
  margin-inline: auto;
}
.puzzle-card {
  padding: 28px;
}
.sidebar-col {
  position: sticky;
  top: var(--floating-header-offset);
  padding-top: var(--board-card-align-offset);
}
.sidebar-card {
  padding: 24px;
}


/* ── GAME CONTAINER (minimal — glass-card handles visual chrome) ── */
.game-container {
  width: 100%;
}


/* ── HALO GLASS WRAP ── */
.halo-glass-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: var(--halo-card-overlap);
}
.halo-glass-svg {
  filter: drop-shadow(0 4px 12px rgba(124,58,237,0.12));
}


/* ── H1 (backwards compat) ── */
h1 {
  font-family: 'Baloo 2', cursive;
  font-weight: 800;
  color: var(--ube);
}


/* ── DATE NAV (compact, inline in header) ── */
.date-nav {
  display: grid;
  grid-template-columns: 30px minmax(12ch, 16ch) 30px 30px;
  align-items: center;
  gap: 8px;
}
.date-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--ube);
  text-decoration: none;
  padding: 2px 6px;
  border-radius: 6px;
  transition: background 0.15s;
  user-select: none;
  width: 30px;
  height: 30px;
}
.date-arrow:hover:not(.disabled) { background: var(--ube-pale); }
.date-arrow.disabled {
  color: var(--text-muted);
  pointer-events: none;
  cursor: default;
}
.date-label {
  font-family: 'Nunito', sans-serif;
  font-weight: 600;
  font-size: 13px;
  color: var(--text-muted);
  min-width: 0;
  text-align: center;
  white-space: nowrap;
}
.date-label.is-archive { color: var(--text-muted); }
.date-today {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: var(--ube-mid);
  text-decoration: none;
  padding: 2px 6px;
  width: 30px;
  height: 30px;
}
.date-today:hover { background: var(--ube-pale); border-radius: 6px; }
.date-nav .is-inactive {
  visibility: hidden;
  pointer-events: none;
}


/* ── ICE PARTICLES ── */
.ice-particles {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}
.ice-particle {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.8);
  box-shadow: 0 0 6px rgba(196, 181, 253, 0.5);
  animation: float-ice linear infinite;
}


.sidebar-content {
    padding: 20px;
    padding-top: 40px;
}

.sidebar-section {
    margin-bottom: 20px;
    padding: 15px 0;
    background: transparent;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

.section-header h3 {
    margin: 0;
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.sidebar-section h3 {
    font-family: 'Baloo 2', cursive;
    font-weight: 800;
    font-size: 16px;
    color: var(--ube);
}

.settings-section .section-header {
    margin-bottom: 10px;
}

.setting-toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
    font-family: 'Nunito', sans-serif;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-secondary);
}

.setting-toggle input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.setting-toggle-ui {
    width: 36px;
    height: 22px;
    border-radius: 999px;
    background: rgba(124,58,237,0.18);
    border: 1px solid rgba(124,58,237,0.20);
    position: relative;
    flex-shrink: 0;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.setting-toggle-ui::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
    transition: transform 0.2s ease;
}

.setting-toggle input:checked + .setting-toggle-ui {
    background: var(--ube);
    border-color: var(--ube);
}

.setting-toggle input:checked + .setting-toggle-ui::after {
    transform: translateX(14px);
}

.setting-help {
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.4;
}

.found-count {
    font-size: 0.8rem;
    color: white;
    background: var(--primary-color);
    padding: 4px 8px;
    border-radius: 4px;
}


/* ── HEADER SECTION (existing in-game header row) ── */
.header-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 20px;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

.dark-mode-toggle {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s ease;
    color: var(--text-color);
}

.dark-mode-toggle:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: scale(1.1);
}

.new-game-top {
    font-size: 0.9rem;
    padding: 10px 20px;
    white-space: nowrap;
}

.grid-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 15px 0;
    gap: 12px;
}

.grid-board-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
}

.grid-section.puzzle-cross .grid-board-row {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    width: fit-content;
    max-width: 100%;
    margin: 0 auto;
}

.grid-section.puzzle-parallel .grid-board-row {
    flex-direction: column;
}

.grid-stage {
    position: relative;
    flex: 0 0 auto;
    width: auto;
    max-width: 100%;
}

.grid-action-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 3;
}

.crossword-grid {
    display: flex;
    justify-content: center;
    position: relative;
    z-index: 1;
}

.grid-inline-actions {
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.grid-section.puzzle-cross .grid-inline-actions {
    position: absolute;
    right: calc(100% + 12px);
    bottom: 0;
    justify-content: flex-end;
}

.grid-inline-actions .btn {
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(-8px);
    transition: opacity 0.18s ease-out, transform 0.24s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.18s ease-out;
}

.grid-inline-actions .btn.is-visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
}

.grid-controls {
    gap: 10px;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.grid-with-labels {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 20px;
    background: var(--card-bg);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.row-container {
    display: flex;
    align-items: center;
    gap: 15px;
}

.row-label {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 180px;
    padding: 8px 12px;
    background: var(--card-bg);
    border-radius: 4px;
    font-weight: 500;
}

.row-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    background: var(--ube-mid);
    color: white;
    border-radius: 50%;
    font-size: 12px;
    font-weight: bold;
}

.row-text {
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 14px;
}

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

.row-grid {
    display: grid;
    gap: var(--grid-gap);
}

.grid-cell {
    width: var(--grid-cell-size);
    height: var(--grid-cell-size);
    background: var(--container-bg);
    border: 1px solid var(--border-color);
    position: relative;
}

.grid-cell.active {
    width: var(--grid-cell-size);
    height: var(--grid-cell-size);
    flex-shrink: 0;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Fredoka', cursive;
    font-weight: 700;
    font-size: clamp(18px, calc(var(--grid-cell-size) * 0.43), 26px);
    color: var(--text-secondary);
    cursor: text;
    transition: border-color 0.12s ease, background 0.12s ease, box-shadow 0.12s ease;
    /* unfilled state — color comes from tc-* when filled */
    background: white;
    border: 2px solid rgba(167, 139, 250, 0.28);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.55);
    animation: none;
}

html[data-theme="dark"] .grid-cell.active {
    background: rgba(51, 44, 68, 0.9);
    border-color: var(--ube-light);
}

html[data-theme="dark"] .grid-cell.active.intersection {
    background: rgba(139, 92, 246, 0.15);
    border-color: var(--ube-mid);
}

.grid-cell.active:focus {
    outline: none;
}

.grid-cell.active.selected {
    outline: 2px solid var(--ube);
    outline-offset: 1px;
    border-color: rgba(139, 92, 246, 0.5);
}

.grid-cell.active.word-active:not(.intersection) {
    box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.16);
}

.grid-cell.active.intersection {
    background: rgba(167, 139, 250, 0.12);
    border: 2px solid rgba(139, 92, 246, 0.36);
}

.grid-cell.active.intersection.selected {
    outline: 2px solid var(--ube);
    outline-offset: 1px;
}

.grid-cell.active.drop-active {
    transition: border-color 0.12s ease, background 0.12s ease, box-shadow 0.12s ease, transform 0.12s ease;
}

.grid-cell.active.drop-target {
    border-color: rgba(124, 58, 237, 0.75);
    box-shadow: 0 0 0 4px rgba(167, 139, 250, 0.18);
    transform: scale(1.03);
}

.letter-bank-shell.drop-active {
    transition: box-shadow 0.12s ease, background 0.12s ease, border-color 0.12s ease;
}

.letter-bank-shell.drop-target {
    box-shadow: 0 0 0 4px rgba(167, 139, 250, 0.16);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.28);
}

.grid-cell.active.filled {
    animation: none;
    cursor: text;
}

.grid-cell .grid-tile {
    width: 100%;
    height: 100%;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.10), 0 1px 4px rgba(0,0,0,0.06);
    cursor: grab;
    touch-action: none;
    user-select: none;
    position: relative;
    z-index: 2;
    animation: bounce-in 0.35s ease-out both;
    will-change: transform;
}

.grid-cell .grid-tile.dragging {
    transition: none !important;
    animation: none !important;
    cursor: grabbing;
    z-index: 50;
    filter: brightness(1.04);
    box-shadow: 0 12px 28px rgba(0,0,0,0.16), 0 4px 12px rgba(0,0,0,0.10);
}

.grid-cell .cell-letter {
    pointer-events: none;
    user-select: none;
    transform: none !important;
}

.grid-cell.active.intersection.filled {
    box-shadow: 0 4px 12px rgba(0,0,0,0.10), 0 1px 4px rgba(0,0,0,0.06), 0 0 0 2px var(--ube-mid);
}

.grid-cell .cell-number {
    position: absolute;
    top: 2px;
    left: 3px;
    z-index: 3;
    font-size: 10px;
    font-weight: bold;
    color: var(--text-secondary);
    line-height: 1;
    pointer-events: none;
}

/* ── INVALID (MOLDY) STATE ─────────────────────────────────── */
.moldy {
    border:    2px solid #6b7840 !important;
    animation: invalid-shake 0.5s ease-in-out;
}

/* Per-letter moldy colors (light mode) */
.moldy.tc-ube { background: #7a7055 !important; color: #2a2010 !important; }
.moldy.tc-pan { background: #5a7a50 !important; color: #1a2a10 !important; }
.moldy.tc-lec { background: #8b8a35 !important; color: #2a2805 !important; }
.moldy.tc-gul { background: #8a6868 !important; color: #2a1818 !important; }
.moldy.tc-pea { background: #8a6535 !important; color: #2a1c08 !important; }
.moldy.tc-ubl { background: #7a7a68 !important; color: #252520 !important; }

/* Per-letter moldy colors (dark mode) */
html[data-theme="dark"] .moldy.tc-ube { background: #655a42 !important; color: #e0d8c0 !important; }
html[data-theme="dark"] .moldy.tc-pan { background: #48623e !important; color: #d0e8c0 !important; }
html[data-theme="dark"] .moldy.tc-lec { background: #706e2a !important; color: #e8e4a8 !important; }
html[data-theme="dark"] .moldy.tc-gul { background: #6e5252 !important; color: #e8d0d0 !important; }
html[data-theme="dark"] .moldy.tc-pea { background: #6e5028 !important; color: #e8d8a8 !important; }
html[data-theme="dark"] .moldy.tc-ubl { background: #606060 !important; color: #e0dcd8 !important; }

/* Cross grid empty cells */
.grid-cell.empty {
    border: none;
    background: transparent;
    pointer-events: none;
    box-shadow: none;
}

.grid-cell.intersection {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.grid-cell.intersection.filled {
    /* background intentionally absent — tc-* color wins via source-order specificity */
}



.letters-pool {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid rgba(196,181,253,0.24);
}

.bank-setting {
    margin-bottom: 10px;
}

.letter-bank-settings {
    margin-bottom: 12px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: rgba(255,255,255,0.34);
    overflow: hidden;
}

html[data-theme="dark"] .letter-bank-settings {
    background: rgba(30, 24, 44, 0.45);
}

.letter-bank-settings > summary {
    list-style: none;
    cursor: pointer;
    padding: 10px 14px;
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
    font-size: 12px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ube);
}

.letter-bank-settings > summary::-webkit-details-marker {
    display: none;
}

.letter-bank-settings-body {
    padding: 0 14px 14px;
}

.settings-toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-family: 'Nunito', sans-serif;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
}

.settings-toggle input {
    width: 16px;
    height: 16px;
    accent-color: var(--ube);
}

/* ── UI TOOLTIP MODULE ───────────────────────────────────────────────────── */
.ui-inline-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.ui-tooltip {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.ui-tooltip-trigger {
    width: 20px;
    height: 20px;
    border: 1px solid rgba(167,139,250,0.45);
    border-radius: 999px;
    background: rgba(255,255,255,0.16);
    color: var(--ube);
    font-family: 'Nunito', sans-serif;
    font-size: 12px;
    font-weight: 800;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
}

.ui-tooltip-trigger:focus-visible {
    outline: 2px solid rgba(167,139,250,0.55);
    outline-offset: 2px;
}

.ui-tooltip-content {
    position: absolute;
    left: 50%;
    bottom: calc(100% + 8px);
    transform: translateX(-50%) translateY(4px);
    min-width: max-content;
    max-width: 180px;
    padding: 8px 10px;
    border-radius: 10px;
    background: rgba(45, 35, 66, 0.96);
    color: #f4f1ff;
    font-family: 'Nunito', sans-serif;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.35;
    box-shadow: 0 10px 24px rgba(0,0,0,0.20);
    opacity: 0;
    pointer-events: none;
    transition: opacity 140ms ease, transform 140ms ease;
    z-index: 20;
    text-align: center;
}

.ui-tooltip-content::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-width: 6px 5px 0 5px;
    border-style: solid;
    border-color: rgba(45, 35, 66, 0.96) transparent transparent transparent;
}

.ui-tooltip:hover .ui-tooltip-content,
.ui-tooltip:focus-within .ui-tooltip-content {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.setting-help {
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.4;
}

.letters-header {
    display: flex;
    align-items: center;
    margin-bottom: 10px;
}

.letters-header-copy {
    display: flex;
    align-items: center;
    gap: 8px;
}

.letters-header h3 {
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--ube);
    margin: 0;
}

.letters-header p {
    margin: 0;
    font-family: 'Nunito', sans-serif;
    font-size: 12px;
    color: var(--text-muted);
}

.letters-pool h3 {
    margin: 0;
    color: var(--text-secondary);
}

.shuffle-btn {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px 12px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-secondary);
}

.shuffle-btn:hover:not(:disabled) {
    background: var(--primary-color);
    color: white;
    transform: translateY(-1px);
}

.shuffle-btn:active:not(:disabled) {
    transform: translateY(0);
}

.shuffle-btn:disabled {
    opacity: 0.45;
    cursor: default;
}

.letters-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    width: 100%;
    max-width: 540px;
    margin: 0 auto;
}

.letter-bank-controls {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 16px;
    flex-wrap: wrap;
}

.letter-bank-controls .btn {
    min-width: 132px;
}

.letter-bank-controls #clear-all-btn {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(-8px);
    transition: opacity 0.18s ease-out, transform 0.24s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.18s ease-out;
}

.letter-bank-controls .btn-mobile-backspace {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(-8px);
    transition: opacity 0.18s ease-out, transform 0.24s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.18s ease-out;
}

.letter-bank-controls #clear-all-btn.is-visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
}

.letter-bank-controls .btn-mobile-backspace.is-visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
}

.bank-empty-state {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 700;
    letter-spacing: 0.02em;
}

.letter-tile.used,
.letter-tile.used.crossing {
    opacity: 1;
    filter: none;
    box-shadow: 0 0 0 2px rgba(124,58,237,0.30), 0 6px 18px rgba(124,58,237,0.18);
}

.letter-tile.shared-visible {
    position: relative;
    opacity: 1;
    filter: none;
    box-shadow: 0 0 0 2px rgba(124,58,237,0.30), 0 8px 22px rgba(124,58,237,0.20);
}

.letter-tile.shared-visible::after {
    content: "";
    position: absolute;
    inset: -4px;
    border-radius: inherit;
    box-shadow: 0 0 0 2px rgba(167,139,250,0.30);
    pointer-events: none;
}

.grid-word-clear {
    position: absolute;
    z-index: 4;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 999px;
    border: 1px solid rgba(124,58,237,0.20);
    background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(237,233,254,0.94));
    color: var(--ube);
    box-shadow: 0 8px 18px rgba(124,58,237,0.12);
    line-height: 1;
    pointer-events: none;
    opacity: 0;
    transform: translateY(4px) scale(0.92);
    transition: opacity 0.14s ease, transform 0.14s ease, box-shadow 0.14s ease, border-color 0.14s ease;
    font-size: 18px;
    padding: 0;
}

.grid-word-clear .clear-emoji {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transform: translateY(1px);
}

.grid-word-clear.is-visible {
    pointer-events: auto;
    opacity: 0.96;
    transform: translateY(0) scale(1);
}

.grid-word-clear.is-active {
    border-color: rgba(124,58,237,0.30);
    box-shadow: 0 10px 22px rgba(124,58,237,0.18);
}

.grid-word-clear:hover {
    transform: translateY(-1px) scale(1.06);
    opacity: 1;
    box-shadow: 0 12px 24px rgba(124,58,237,0.22);
}

html[data-theme="dark"] .grid-word-clear {
    background: linear-gradient(180deg, rgba(74,64,98,0.98), rgba(61,53,80,0.96));
    color: var(--ube-light);
    border-color: rgba(196,181,253,0.22);
    box-shadow: 0 10px 22px rgba(0,0,0,0.28);
}

html[data-theme="dark"] .grid-word-clear.is-active {
    border-color: rgba(196,181,253,0.34);
    box-shadow: 0 12px 24px rgba(0,0,0,0.34);
}

/* Create keyboard-style staggered two-row layout */
.letters-container .keyboard-row {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
}

.letters-container .keyboard-row:nth-child(2) {
    margin-left: 22px; /* Half a tile width + gap to create stagger effect */
}


html[data-theme="dark"] .primary-stat {
    background: rgba(139, 92, 246, 0.15);
}

/* ── SIDEBAR STATS ── */
.primary-stat {
    background: var(--ube-pale);
    border-radius: 12px;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.primary-stat .stat-label {
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    font-size: 12px;
    color: var(--text-muted);
}

.primary-stat .stat-value {
    font-family: 'Baloo 2', cursive;
    font-weight: 700;
    font-size: 22px;
    color: var(--ube);
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: var(--surface);
    border-radius: 10px;
    margin-bottom: 8px;
    transition: all 0.2s ease;
}

.stat-item:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.stat-label {
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-family: 'Baloo 2', cursive;
    font-weight: 700;
    font-size: 22px;
    color: var(--ube);
}


/* ── LETTER TILE ── */
.letter-tile {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Fredoka', cursive;
    font-weight: 700;
    font-size: 22px;
    color: var(--text-color);
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    box-shadow: 0 4px 16px rgba(124,58,237,0.20), 0 2px 6px rgba(0,0,0,0.10);
    user-select: none;
}

.letter-tile:hover {
    transform: translateY(-4px) scale(1.05);
}

.letter-tile:active {
    transform: translateY(-1px);
}

.letter-tile.dragging {
    opacity: 0.5;
    transition: none !important;
    z-index: 50;
    cursor: grabbing;
    filter: brightness(1.04);
    box-shadow: 0 12px 28px rgba(124,58,237,0.24), 0 4px 12px rgba(0,0,0,0.12);
}

body.drag-in-progress {
    cursor: grabbing;
}

body.drag-in-progress .grid-cell.active:not(.filled) {
    cursor: copy;
}

.letter-tile.used {
    background: #d1d5db !important;
    color: #9ca3af !important;
    opacity: 0.45;
    filter: grayscale(0.6);
    cursor: default;
    pointer-events: none;
    transform: none !important;
}

/* Letter tile that is locked in the crossing cell */
.letter-tile.used.crossing {
    opacity: 1;
    filter: none;
    box-shadow: 0 0 0 2px var(--ube-mid);
    cursor: default;
}

/* When the toggle is on, the shared tile is promoted to the active styling. */
.letter-tile.crossing.shared-visible.tc-ube { background: #9775f7 !important; color: #fff !important; text-shadow: 1px 2px 0 rgba(0,0,0,0.28) !important; }
.letter-tile.crossing.shared-visible.tc-pan { background: #4cd9a6 !important; color: #fff !important; text-shadow: 1px 2px 0 rgba(0,0,0,0.28) !important; }
.letter-tile.crossing.shared-visible.tc-lec { background: #f9c733 !important; color: #fff !important; text-shadow: 1px 2px 0 rgba(0,0,0,0.28) !important; }
.letter-tile.crossing.shared-visible.tc-gul { background: #f48ac3 !important; color: #fff !important; text-shadow: 1px 2px 0 rgba(0,0,0,0.28) !important; }
.letter-tile.crossing.shared-visible.tc-pea { background: #fa9f52 !important; color: #fff !important; text-shadow: 1px 2px 0 rgba(0,0,0,0.28) !important; }
.letter-tile.crossing.shared-visible.tc-ubl { background: #b2affa !important; color: #fff !important; text-shadow: 1px 2px 0 rgba(0,0,0,0.28) !important; }

html[data-theme="dark"] .letter-tile.crossing.shared-visible.tc-ube { background: #9775f7 !important; color: #fff !important; }
html[data-theme="dark"] .letter-tile.crossing.shared-visible.tc-pan { background: #4cd9a6 !important; color: #fff !important; }
html[data-theme="dark"] .letter-tile.crossing.shared-visible.tc-lec { background: #f9c733 !important; color: #fff !important; }
html[data-theme="dark"] .letter-tile.crossing.shared-visible.tc-gul { background: #f48ac3 !important; color: #fff !important; }
html[data-theme="dark"] .letter-tile.crossing.shared-visible.tc-pea { background: #fa9f52 !important; color: #fff !important; }
html[data-theme="dark"] .letter-tile.crossing.shared-visible.tc-ubl { background: #b2affa !important; color: #fff !important; }


/* ── BUTTONS ── */
.controls {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin: 20px 0;
    flex-wrap: wrap;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: none;
    letter-spacing: 0;
}

.btn-primary {
    background: var(--ube);
    color: white;
    border-radius: 10px;
}

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

.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 10px;
}

.btn-secondary:hover {
    background: var(--ube-pale);
}

.btn-warning {
    background: var(--ube-pale);
    color: var(--ube);
    border: 1px solid var(--ube-light);
    border-radius: 10px;
}

.btn-warning:hover {
    background: var(--ube-light);
    color: var(--ube);
}

/* Dark mode warning button text override */
html[data-theme="dark"] .btn-warning {
    color: var(--text-color);
}

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-success:hover {
    opacity: 0.9;
}

.share-row {
    display: flex;
    justify-content: center;
    margin-top: 12px;
}

.solved-badge {
    margin-bottom: 16px;
}

.btn-solved-badge {
    width: 100%;
    text-align: center;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 14px;
}

.btn-share,
#share-btn {
    background: linear-gradient(135deg, var(--ube) 0%, #9333EA 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-family: 'Baloo 2', cursive;
    font-weight: 600;
    font-size: 14px;
    padding: 10px 20px;
    box-shadow: 0 4px 16px rgba(124,58,237,0.3);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.btn-share:hover,
#share-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(124,58,237,0.4);
}

.btn-sm {
    padding: 4px 10px;
    font-size: 0.8rem;
}


/* ── MESSAGE ── */
.message,
#message {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    text-align: center;
    padding: 15px 25px;
    border-radius: 12px;
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    transition: all 0.3s ease;
    max-width: 400px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    background: var(--ube);
    color: white;
}

.message.success {
    background: var(--success-color);
    color: white;
}

.message.error {
    background: var(--error-color);
    color: white;
}

.message.info {
    background: var(--ube);
    color: white;
}


/* ── VICTORY MODAL ── */
.victory-modal {
    position: fixed;
    inset: 0;
    background: rgba(26, 16, 48, 0.7);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2100;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

body.modal-open {
    overflow: hidden;
    touch-action: none;
}

.victory-modal.show {
    opacity: 1;
    visibility: visible;
}

.victory-content {
    background: rgba(255,255,255,0.92);
    border-radius: 20px;
    border: 1px solid rgba(196,181,253,0.5);
    box-shadow: 0 8px 40px rgba(124,58,237,0.2);
    padding: 36px 32px;
    text-align: center;
    max-width: 400px;
    width: 90%;
    transform: scale(0.8);
    transition: transform 0.3s ease;
}

html[data-theme="dark"] .victory-content {
    background: rgba(58, 50, 80, 0.97);
}

.victory-modal.show .victory-content {
    transform: scale(1);
}

.victory-content h2 {
    font-family: 'Baloo 2', cursive;
    font-weight: 800;
    font-size: 28px;
    color: var(--ube);
    margin-bottom: 20px;
}

#victory-progress {
    font-size: 1.2rem;
    color: var(--text-muted);
    margin-bottom: 30px;
    line-height: 1.5;
}

.victory-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.victory-actions .btn {
    min-width: 140px;
}

.metric-suggestions {
    margin: 0 0 20px;
    padding: 14px 16px;
    border-radius: 14px;
    background: rgba(124, 58, 237, 0.06);
    border: 1px solid rgba(124, 58, 237, 0.12);
}

.metric-suggestions-title {
    margin: 0 0 6px;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--ube);
}

.metric-suggestions-current {
    margin: 0;
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-muted);
}

.metric-suggestions-options {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 12px;
}

.btn-metric {
    min-width: unset !important;
    padding-inline: 14px;
}

.remix-prompt-text {
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 16px;
    color: var(--text-primary);
}

.remix-tooltip {
    font-size: 13px;
    color: var(--text-muted);
    font-style: italic;
    margin: 12px 0 0;
    line-height: 1.5;
    max-width: 320px;
    margin-inline: auto;
}

.remix-info-btn {
    min-width: unset !important;
    padding: 8px 14px;
    font-size: 14px;
}

.word-input {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin: 20px 0;
    flex-wrap: wrap;
}

.word-input input {
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    text-align: center;
    min-width: 150px;
    background: var(--container-bg);
    color: var(--text-color);
}

.word-input input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 1px rgba(124, 58, 237, 0.3);
}


/* ── LEGACY STATS ── */
.stats {
    display: flex;
    justify-content: space-around;
    margin: 20px 0;
    padding: 15px;
    background: var(--card-bg);
    border-radius: 8px;
    flex-wrap: wrap;
    gap: 10px;
}

.stat {
    text-align: center;
}


/* ── FOUND SOLUTIONS ── */
.found-solutions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 400px;
    overflow-y: auto;
}

.solution-item {
    background: var(--surface);
    border-radius: 12px;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: flex-start;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.solution-item:hover {
    background: rgba(124, 58, 237, 0.04);
    border-color: rgba(124, 58, 237, 0.18);
    transform: translateY(-1px);
}

.solution-item:focus-visible {
    outline: none;
    border-color: rgba(124, 58, 237, 0.34);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.16);
}

.solution-item.is-selected {
    background: rgba(124, 58, 237, 0.08);
    border-color: rgba(124, 58, 237, 0.32);
    box-shadow: 0 6px 18px rgba(124, 58, 237, 0.10);
}

.solution-words {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 8px;
}

.solution-word {
    font-family: 'Courier New', monospace;
    font-weight: bold;
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.solution-meta {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--text-muted);
}

.solution-preview {
    display: grid;
    gap: 4px;
    justify-content: start;
    align-items: start;
}

.mini-grid {
    display: flex;
    gap: 5px;
    align-items: center;
}

.mini-row {
    display: flex;
    gap: 1px;
}

.mini-cell {
    width: 24px;
    height: 24px;
    border-radius: 7px;
    font-family: 'Fredoka', cursive;
    font-weight: 700;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.mini-cell.empty {
    background: transparent;
    border: none;
    box-shadow: none;
    visibility: hidden;
}

.mini-cell.intersection {
    outline: 2px solid rgba(255, 255, 255, 0.75);
    outline-offset: -2px;
}


/* ── DETAILED STATS TOGGLE ── */
.detailed-stats-toggle {
    width: 100%;
    margin: 10px 0;
}

.toggle-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 8px 16px;
    cursor: pointer;
    font-size: 0.8em;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s ease;
    width: 100%;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.toggle-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(124, 58, 237, 0.3);
}

.toggle-icon {
    font-size: 0.8em;
    transition: transform 0.3s ease;
}

.toggle-btn.expanded .toggle-icon {
    transform: rotate(180deg);
}

.detailed-stats {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out, opacity 0.2s ease;
    opacity: 0;
}

.detailed-stats.expanded {
    max-height: 200px;
    opacity: 1;
    transition: max-height 0.3s ease-in, opacity 0.2s ease 0.1s;
}

.detailed-stats .stat-item {
    margin-bottom: 6px;
}

.detailed-stats .stat-item:last-child {
    margin-bottom: 0;
}


/* ── UTILITY ── */
.hidden {
    display: none;
}

.fade-in {
    animation: fadeIn 0.5s ease-in;
}

.pulse {
    animation: pulse 2s infinite;
}

/* Mobile-only elements */
.mobile-only {
    display: none;
}

.btn-mobile-backspace {
    background: linear-gradient(145deg, #e53e3e, #c53030);
    color: white;
    font-size: 1.2rem;
    padding: 10px 16px;
    min-width: 50px;
}

.btn-mobile-backspace:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(229, 62, 62, 0.4);
}


/* ── FOOTER ── */
footer {
  background: var(--ube-pale);
  padding: 24px;
  text-align: center;
  border-top: 1px solid rgba(196,181,253,0.3);
  width: 100%;
}
.footer-text {
  font-family: 'Nunito', sans-serif;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.footer-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
}
.footer-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}


/* ── RESPONSIVE ── */
@media (max-width: 720px) {
  :root,
  html[data-theme="light"],
  html:not([data-theme]),
  html[data-theme="dark"] {
    --floating-header-height: 80px;
    --floating-header-offset: calc(var(--floating-header-top) + var(--floating-header-height) + 14px);
    --halo-graphic-height: 58px;
    --halo-card-overlap: -8px;
    --side-card-extra-offset: 0px;
    --board-card-align-offset: 0px;
  }
  main {
    grid-template-columns: 1fr;
    padding: 20px 16px 48px;
  }
  .mixes-col {
    position: static;
    top: auto;
    z-index: auto;
    padding-top: 0;
    order: 2;
  }
  .puzzle-col {
    order: 1;
    max-width: none;
  }
  .sidebar-col {
    position: static;
    top: auto;
    padding-top: 0;
    order: 3;
  }
  .word-log-card,
  .sidebar-card {
    padding: 18px;
  }
  header {
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 16px;
    width: calc(100% - 20px);
  }
  .header-left {
    flex: 0 1 auto;
    min-width: 0;
    gap: 10px;
  }
  .header-glass-icon {
    font-size: 22px;
  }
  .game-title {
    font-size: 21px;
  }
  .game-subtitle {
    display: none;
  }
  .header-right {
    flex: 1 1 auto;
    min-width: 0;
    flex-wrap: nowrap;
    gap: 6px;
  }
  .daily-pill {
    display: none;
  }
  .wave-divider {
    width: 100%;
    opacity: 0.7;
  }
  .date-nav {
    grid-template-columns: 24px minmax(8ch, 11ch) 24px 24px;
    gap: 4px;
  }
  .date-arrow,
  .date-today {
    width: 24px;
    height: 24px;
    font-size: 15px;
    padding: 0;
  }
  .date-label {
    font-size: 12px;
  }
  .dark-mode-toggle {
    width: 38px;
    height: 38px;
    font-size: 1rem;
  }
  footer {
    width: 100vw;
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
    padding-inline: 16px;
  }
}

@media (max-width: 768px) {
    .sidebar-content {
        padding: 15px;
        padding-top: 30px;
    }

    .game-container {
        padding: 20px;
    }

    .header-section {
        flex-direction: column;
        text-align: center;
        gap: 15px;
    }

    .header-controls {
        justify-content: center;
    }
}

@media (max-width: 600px) {
    .mobile-only {
        display: inline-block;
    }

    .mixes-col,
    .sidebar-col {
        width: 100%;
    }

    .word-log-columns {
        grid-template-columns: 1fr;
    }

    .grid-board-row,
    .grid-section.puzzle-cross .grid-board-row,
    .grid-section.puzzle-parallel .grid-board-row {
        display: flex;
        flex-direction: column;
        align-items: center;
        width: 100%;
    }

    .grid-stage,
    .crossword-grid,
    .grid-with-labels,
    .cross-grid {
        width: fit-content;
        max-width: 100%;
        margin-inline: auto;
    }

    .row-grid {
        justify-content: center;
    }

    .grid-section.puzzle-cross .grid-inline-actions,
    .grid-section.puzzle-parallel .grid-inline-actions {
        position: static;
        justify-content: center;
    }

    .game-container {
        padding: 15px;
        margin: 0;
    }

    .new-game-top {
        font-size: 0.8rem;
        padding: 8px 16px;
    }

    .letter-tile {
        width: 52px;
        height: 52px;
        font-size: 1.25rem;
    }

    .letters-container .keyboard-row {
        gap: 10px;
    }

    .letters-container .keyboard-row:nth-child(2) {
        margin-left: 0;
    }

    .letter-bank-controls {
        width: 100%;
    }

    .letter-bank-controls #clear-all-btn {
        order: 1;
    }

    .letter-bank-controls .btn-mobile-backspace {
        order: 2;
    }

    .letter-bank-controls .btn {
        flex: 1 1 140px;
        max-width: 220px;
    }

    h1 {
        font-size: 2rem;
    }

    .controls {
        flex-direction: column;
        align-items: center;
    }

    .btn {
        width: 100%;
        max-width: 200px;
    }

    .grid-controls {
        flex-wrap: wrap;
        justify-content: center;
    }

    .victory-content {
        width: min(92vw, 400px);
        max-height: calc(100dvh - 32px);
        overflow: auto;
        padding: 26px 18px;
        align-self: center;
    }

    .victory-actions {
        flex-direction: column;
        align-items: center;
    }

    .victory-actions .btn {
        min-width: unset;
        width: min(100%, 280px);
    }
}

/* ══ TILE COLORS ══════════════════════════════════════════════════════════
   Per-letter ingredient color system. To swap: replace only this block
   and the LETTER_COLORS object in game.js.
   ═══════════════════════════════════════════════════════════════════════ */

/* Unified palette — same colors in light and dark for sharing consistency.
   All tiles use white text + sharp drop shadow for legibility across both modes. */
.tc-ube  { background: #9775f7; color: #fff; text-shadow: 1px 2px 0 rgba(0,0,0,0.28); }
.tc-pan  { background: #4cd9a6; color: #fff; text-shadow: 1px 2px 0 rgba(0,0,0,0.28); }
.tc-lec  { background: #f9c733; color: #fff; text-shadow: 1px 2px 0 rgba(0,0,0,0.28); }
.tc-gul  { background: #f48ac3; color: #fff; text-shadow: 1px 2px 0 rgba(0,0,0,0.28); }
.tc-pea  { background: #fa9f52; color: #fff; text-shadow: 1px 2px 0 rgba(0,0,0,0.28); }
.tc-ubl  { background: #b2affa; color: #fff; text-shadow: 1px 2px 0 rgba(0,0,0,0.28); }

/* Dark mode overrides exist only for specificity — values match light mode. */
html[data-theme="dark"] .tc-ube  { background: #9775f7; color: #fff; }
html[data-theme="dark"] .tc-pan  { background: #4cd9a6; color: #fff; }
html[data-theme="dark"] .tc-lec  { background: #f9c733; color: #fff; }
html[data-theme="dark"] .tc-gul  { background: #f48ac3; color: #fff; }
html[data-theme="dark"] .tc-pea  { background: #fa9f52; color: #fff; }
html[data-theme="dark"] .tc-ubl  { background: #b2affa; color: #fff; }

/* Grid cells: tc-* must override the grid-cell base background (light and dark). */
.grid-cell.moldy .grid-tile.tc-ube { background: #7a7055 !important; color: #2a2010 !important; }
.grid-cell.moldy .grid-tile.tc-pan { background: #5a7a50 !important; color: #1a2a10 !important; }
.grid-cell.moldy .grid-tile.tc-lec { background: #8b8a35 !important; color: #2a2805 !important; }
.grid-cell.moldy .grid-tile.tc-gul { background: #8a6868 !important; color: #2a1818 !important; }
.grid-cell.moldy .grid-tile.tc-pea { background: #8a6535 !important; color: #2a1c08 !important; }
.grid-cell.moldy .grid-tile.tc-ubl { background: #7a7a68 !important; color: #252520 !important; }

html[data-theme="dark"] .grid-cell.moldy .grid-tile.tc-ube { background: #655a42 !important; color: #e0d8c0 !important; }
html[data-theme="dark"] .grid-cell.moldy .grid-tile.tc-pan { background: #48623e !important; color: #d0e8c0 !important; }
html[data-theme="dark"] .grid-cell.moldy .grid-tile.tc-lec { background: #706e2a !important; color: #e8e4a8 !important; }
html[data-theme="dark"] .grid-cell.moldy .grid-tile.tc-gul { background: #6e5252 !important; color: #e8d0d0 !important; }
html[data-theme="dark"] .grid-cell.moldy .grid-tile.tc-pea { background: #6e5028 !important; color: #e8d8a8 !important; }
html[data-theme="dark"] .grid-cell.moldy .grid-tile.tc-ubl { background: #606060 !important; color: #e0dcd8 !important; }

/* ══ END TILE COLORS ═════════════════════════════════════════════════════ */

/* ══ EXPERIMENTAL MIXES ══════════════════════════════════════════════════ */
.word-log-card { padding: 16px; }
.word-log-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
}
.word-log-header h3 {
    line-height: 1.2;
}
.word-log-assist-toggle {
    width: 100%;
}
.word-log-assist-toggle .setting-toggle-text strong {
    display: block;
}
.word-log-columns {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}
.word-log-column {
    min-width: 0;
}
.word-log-column-title {
    margin-bottom: 8px;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
}
.word-log-list { display: flex; flex-direction: column; gap: 6px; }
.word-log-entry {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    padding: 5px 6px;
    border-radius: 8px;
    cursor: default;
    transition: opacity 0.18s ease, background-color 0.18s ease, transform 0.18s ease;
}
.word-log-entry.state-flagged { background: rgba(167,139,250,0.12); }
.word-log-entry.state-dead { opacity: 0.4; }
.word-log-entry.is-selected {
    background: rgba(124,58,237,0.16);
    outline: 1px solid rgba(124,58,237,0.24);
}
.word-log-entry.is-match {
    background: rgba(110,231,183,0.16);
}
.word-log-entry.is-dim {
    opacity: 0.28;
}
.wl-state { cursor: pointer; width: 16px; text-align: center; flex-shrink: 0; }
.wl-word {
    cursor: pointer;
    font-weight: 600;
    letter-spacing: 0.05em;
    flex: 1;
    min-width: 0;
}
.wl-word:hover { text-decoration: underline; }
.word-log-empty {
    font-size: 0.78rem;
    color: var(--text-muted);
    padding: 4px 2px;
}
.state-dead .wl-word { text-decoration: line-through; }
