/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #f4f2ed;
  color: #1a1a1a;
  min-height: 100vh;
}

/* ── Screens ── */
.screen { display: none; }
.screen.active { display: block; }

/* ── Auth ── */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.logo-block { text-align: center; margin-bottom: 16px; }
.logo { font-size: 36px; font-weight: 700; color: #1a1a1a; letter-spacing: -1px; }
.logo span, .logo-sm span { color: #534AB7; }
.logo-sm { font-size: 18px; font-weight: 700; letter-spacing: -0.5px; }
.tagline { font-size: 15px; color: #666; margin-top: 6px; }
.invite-note { font-size: 12px; color: #999; margin-top: 16px; text-align: center; }

/* ── Cards ── */
.card {
  background: #fff;
  border: 0.5px solid rgba(0,0,0,0.1);
  border-radius: 14px;
  padding: 24px 28px;
  width: 100%;
  max-width: 400px;
}
.card h2 { font-size: 18px; font-weight: 600; margin-bottom: 6px; }
.card .hint { font-size: 13px; color: #666; margin-bottom: 16px; line-height: 1.5; }
.card label { display: block; font-size: 12px; font-weight: 600; color: #555; margin-bottom: 5px; margin-top: 12px; text-transform: uppercase; letter-spacing: 0.4px; }
.card input, .card select {
  width: 100%;
  padding: 10px 13px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 14px;
  background: #fafafa;
  color: #1a1a1a;
  outline: none;
  transition: border-color .15s;
}
.card input:focus, .card select:focus { border-color: #534AB7; background: #fff; }
.divider { text-align: center; margin: 16px 0; position: relative; color: #aaa; font-size: 12px; }
.divider::before { content: ''; position: absolute; top: 50%; left: 0; right: 0; height: 1px; background: #eee; }
.divider span { background: #fff; padding: 0 10px; position: relative; }

/* ── Buttons ── */
.btn-primary {
  display: block; width: 100%; margin-top: 16px;
  padding: 11px; border-radius: 8px;
  background: #534AB7; color: #fff; border: none;
  font-size: 14px; font-weight: 600; cursor: pointer;
  transition: background .15s;
}
.btn-primary:hover { background: #3C3489; }
.btn-primary:disabled { background: #aaa; cursor: default; }
.btn-secondary {
  display: block; width: 100%; margin-top: 10px;
  padding: 10px; border-radius: 8px;
  background: transparent; color: #534AB7;
  border: 1px solid #534AB7;
  font-size: 14px; font-weight: 500; cursor: pointer;
  transition: background .15s;
}
.btn-secondary:hover { background: #f0effe; }
.btn-danger {
  padding: 0 14px; height: 36px; border-radius: 8px;
  background: #E24B4A; color: #fff; border: none;
  font-size: 13px; font-weight: 500; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.btn-danger:hover { background: #A32D2D; }
.btn-sm {
  padding: 0 14px; height: 36px; border-radius: 7px;
  background: transparent; color: #1a1a1a;
  border: 0.5px solid rgba(0,0,0,0.2);
  font-size: 13px; cursor: pointer;
  transition: background .15s;
  display: inline-flex; align-items: center; justify-content: center;
}
.btn-sm:hover { background: rgba(0,0,0,0.05); }
.btn-shuffle { background: #AFA9EC; border-color: #534AB7; color: #fff; border-radius: 7px; border: 1px solid #534AB7; padding: 0 14px; height: 36px; font-size: 13px; cursor: pointer; font-weight: 600; }
.btn-shuffle:hover { background: #7F77DD; }

/* ── Nav ── */
.topnav {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px;
  background: #fff;
  border-bottom: 0.5px solid rgba(0,0,0,0.08);
  position: sticky; top: 0; z-index: 10;
}
.nav-right { display: flex; align-items: center; gap: 8px; }
.nav-left  { display: flex; align-items: center; gap: 8px; }
.nav-games { display: flex; align-items: center; gap: 6px; margin-left: 12px; }
.username-badge {
  font-size: 13px; font-weight: 600; color: #534AB7;
  background: #f0effe; padding: 4px 10px; border-radius: 20px;
}

/* ── Lobby ── */
.lobby-wrap {
  max-width: 860px; margin: 24px auto; padding: 0 16px;
  display: flex; gap: 20px; flex-wrap: wrap;
}
.lobby-col { flex: 1; min-width: 280px; }
.option-row { display: flex; align-items: center; justify-content: space-between; padding: 5px 0; border-top: 0.5px solid #eee; margin-top: 2px; }
.toggle-label { display: block; font-size: 14px; font-weight: 500; }
.mode-row-inner { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.mode-row-title { font-weight: 600; font-size: 14px; }
.mode-row-sub { font-size: 11px; color: #888; margin-top: 0; }
.info-icon-link { color: #534AB7; font-size: 13px; text-decoration: none; margin-left: 3px; vertical-align: middle; opacity: 0.7; }
.info-icon-link:hover { opacity: 1; }
.toggle {
  width: 42px; height: 24px; border-radius: 12px;
  background: #ccc; border: none; cursor: pointer;
  position: relative; transition: background .2s; padding: 0;
}
.toggle.on { background: #534AB7; }
.toggle::after {
  content: ''; position: absolute;
  width: 18px; height: 18px; background: #fff; border-radius: 50%;
  top: 3px; left: 3px; transition: left .2s;
}
.toggle.on::after { left: 21px; }

.games-list-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 0; border-bottom: 0.5px solid #f0f0f0;
  gap: 10px;
}
.games-list-item:last-child { border-bottom: none; }
.gli-left .vs { font-size: 14px; font-weight: 600; }
.gli-left .meta { font-size: 12px; color: #888; margin-top: 2px; }
.badge {
  font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 20px;
}
.badge.your-turn { background: #f0effe; color: #534AB7; }
.badge.waiting { background: #f5f5f5; color: #888; }
.badge.finished { background: #eee; color: #555; }
.loading { font-size: 13px; color: #aaa; padding: 12px 0; }

/* ── Game Top Bar ── */
.topbar {
  display: flex; gap: 8px; padding: 8px 12px;
  background: #fff; border-bottom: 0.5px solid rgba(0,0,0,0.08);
  flex-wrap: wrap;
}
.sc-card {
  border-radius: 8px; padding: 7px 12px; min-width: 100px;
  border: 2px solid transparent; background: #f4f2ed;
}
.sc-card.active { border-color: #EF9F27; }
.sc-card .pn { font-size: 11px; color: #888; }
.sc-card .pts { font-size: 20px; font-weight: 700; }
.sc-card .tb { font-size: 10px; color: #BA7517; font-weight: 600; min-height: 14px; }
.ibox { background: #f4f2ed; border-radius: 8px; padding: 7px 12px; flex: 1; min-width: 100px; }
.ibox .ilbl { font-size: 11px; color: #888; margin-bottom: 2px; }
.ibox .ival { font-size: 13px; font-weight: 600; }
#gt-val { font-size: 12px; line-height: 1.4; font-weight: 500; }

/* ── Legend ── */
.legend {
  display: flex; gap: 8px; flex-wrap: wrap;
  padding: 6px 12px; background: #fff;
  border-bottom: 0.5px solid rgba(0,0,0,0.06);
}
.leg { display: flex; align-items: center; gap: 4px; font-size: 11px; color: #666; }
.ld { width: 12px; height: 12px; border-radius: 3px; }

/* ── Board ── */
.main { display: flex; gap: 12px; padding: 12px; flex-wrap: wrap; }
.board-wrap { overflow-x: auto; }
.board {
  display: grid;
  grid-template-columns: repeat(15, 36px);
  gap: 2px;
}
.cell {
  width: 36px; height: 36px; border-radius: 3px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 11px; font-weight: 600;
  position: relative; border: 1px solid transparent;
  transition: transform .1s; user-select: none;
}
.cell:hover { transform: scale(1.07); }
.cell.norm { background: #C0DD97; color: #3B6D11; }
.cell.dl   { background: #B5D4F4; color: #185FA5; }
.cell.tl   { background: #378ADD; color: #fff; }
.cell.dw   { background: #F4C0D1; color: #72243E; }
.cell.tw   { background: #A32D2D; color: #fff; }
.cell.star { background: #FAC775; color: #854F0B; }
.cell.golden { background: #EF9F27 !important; color: #fff !important; animation: pulse 1.4s infinite; }
@keyframes pulse { 0%,100%{box-shadow:0 0 0 0 rgba(239,159,39,.5)} 50%{box-shadow:0 0 0 5px rgba(239,159,39,0)} }
.cell.placed { background: #534AB7 !important; color: #EF9F27 !important; font-size: 15px; font-weight: 700; border: 2px dashed #AFA9EC !important; }
.cell.placed.practice { background: #534AB7 !important; color: #FAC775 !important; font-size: 15px; font-weight: 700; border: 2px dashed #AFA9EC !important; opacity: 0.7; }
.cell.locked { background: #534AB7 !important; color: #fff !important; font-size: 15px; font-weight: 700; }
.cell.locked.last-played { background: #8F8BD8 !important; box-shadow: inset 0 0 0 1.5px #6560C8; }
.cell.locked.gt-used {
  background: #534AB7 !important;
  box-shadow: 0 0 0 2px #EF9F27, 0 0 8px 2px rgba(239,159,39,0.5) !important;
}
.cell.gt-vacated {
  outline: 2px dashed #EF9F27 !important;
  outline-offset: -3px;
  background: #FFFBE6 !important;
}
.cell.placed.on-golden {
  box-shadow: 0 0 0 2px #EF9F27, 0 0 8px 2px rgba(239,159,39,0.5) !important;
}
.cell.blank-tile { box-shadow: inset 0 0 0 2px rgba(255,255,255,0.4) !important; }
.blank-letter { text-decoration: underline; text-underline-offset: 2px; }
.cell .lp { font-size: 8px; font-weight: 600; position: absolute; bottom: 1px; right: 2px; opacity: .85; }

/* ── Side Panel ── */
.side { flex: 1; min-width: 200px; display: flex; flex-direction: column; gap: 8px; }
.scard { background: #f4f2ed; border-radius: 8px; padding: 10px 12px; }
.rack-lbl { font-size: 11px; color: #888; margin-bottom: 6px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; }
.rack { display: flex; gap: 4px; flex-wrap: wrap; background: #f0eeee; border-radius: 10px; padding: 6px; }
.rack-slot { width: 36px; height: 44px; border-radius: 6px; border: 1.5px dashed #ddd; background: #fff; flex-shrink: 0; }
.tile {
  width: 38px; height: 38px; border-radius: 6px;
  background: #EEEDFE; border: 1px solid #AFA9EC; color: #3C3489;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  cursor: pointer; font-size: 15px; font-weight: 600;
  position: relative; transition: transform .1s; user-select: none;
}
.tile:hover { transform: translateY(-3px); }
.tile.sel { background: #EF9F27; color: #fff; border-color: #BA7517; transform: translateY(-3px); }
.tile.reorder-sel { background: #534AB7; color: #fff; border-color: #3C3489; transform: translateY(-3px); }
.tile .tp { font-size: 7px; position: absolute; bottom: 2px; right: 3px; }
.tile.blank { background: #F1EFE8; color: #5F5E5A; border-color: #B4B2A9; }
.btns { display: flex; gap: 6px; flex-wrap: wrap; align-items: stretch; }
.msg {
  font-size: 13px; background: #f4f2ed; border-radius: 8px;
  padding: 8px 12px; min-height: 36px; color: #1a1a1a;
}
.emoji-bar { display: flex; gap: 5px; flex-wrap: wrap; }
.ebtn {
  font-size: 18px; padding: 4px 7px; border-radius: 7px;
  border: 0.5px solid rgba(0,0,0,0.1); background: transparent;
  cursor: pointer; line-height: 1;
}
.ebtn:hover { background: rgba(0,0,0,0.06); }
.ebtn-more { font-size: 14px; color: #888; letter-spacing: 1px; }
.log-wrap { background: #f4f2ed; border-radius: 8px; padding: 10px 12px; flex: 1; }
.log-lbl { font-size: 11px; color: #888; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 5px; }
.log { max-height: 180px; overflow-y: auto; }
.le { font-size: 12px; padding: 2px 0; border-bottom: 0.5px solid rgba(0,0,0,0.05); color: #1a1a1a; }
.le.good { color: #3B6D11; }
.le.bad  { color: #A32D2D; }
.le.gold { color: #854F0B; }
.le.sys  { color: #888; }

/* ── Turn banner ── */
.turn-banner {
  background: #f0effe; border-top: 1px solid #d0caf5;
  text-align: center; padding: 10px;
  font-size: 13px; font-weight: 500; color: #534AB7;
}

/* ── Stats ── */
.stats-wrap { max-width: 560px; margin: 24px auto; padding: 0 16px; }
.info-tab-content { max-width: 560px; margin: 0 auto; padding: 0 16px; }
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 12px; }
.stat-c { background: #f4f2ed; border-radius: 8px; padding: 10px 14px; }
.stats-tabs { display: flex; gap: 6px; margin: 12px 0 16px; flex-wrap: wrap; }
.stats-tab {
  padding: 6px 14px; border-radius: 20px; font-size: 13px; font-weight: 500;
  border: 1px solid rgba(0,0,0,0.15); background: transparent; cursor: pointer;
  color: #555; transition: all .15s;
}
.stats-tab:hover { background: #f4f2ed; }
.stats-tab.active { background: #534AB7; color: #fff; border-color: #534AB7; }
.stat-c .sl { font-size: 12px; color: #888; margin-bottom: 3px; }
.stat-c .sv { font-size: 18px; font-weight: 700; }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 20px;
}
.modal-box {
  background: #fff; border-radius: 14px; padding: 24px 28px;
  max-width: 360px; width: 100%;
  max-height: 90vh; overflow-y: auto;
}
.modal-box h2 { font-size: 17px; font-weight: 600; margin-bottom: 8px; }
.modal-box p { font-size: 13px; color: #666; margin-bottom: 14px; }
.alpha-grid { display: grid; grid-template-columns: repeat(7, 40px); gap: 5px; margin-bottom: 14px; }
.alph-btn {
  width: 40px; height: 40px; border-radius: 6px;
  background: #EEEDFE; border: 1px solid #AFA9EC; color: #3C3489;
  font-size: 15px; font-weight: 600; cursor: pointer;
}
.alph-btn:hover { background: #CECBF6; }
.swap-t {
  width: 36px; height: 36px; border-radius: 6px;
  background: #EEEDFE; border: 1px solid #AFA9EC; color: #3C3489;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 14px; font-weight: 600;
}
.swap-t.ss { background: #E24B4A; color: #fff; border-color: #A32D2D; }

/* ── Toast ── */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #3C3489; color: #fff; padding: 8px 18px;
  border-radius: 24px; font-size: 13px; font-weight: 500;
  z-index: 200; pointer-events: none;
  animation: toastIn .25s ease;
}
@keyframes toastIn { from{opacity:0;transform:translateX(-50%) translateY(8px)} to{opacity:1;transform:translateX(-50%) translateY(0)} }

/* ── Error ── */
.error-msg { margin-top: 10px; font-size: 13px; color: #A32D2D; background: #fff0f0; padding: 8px 12px; border-radius: 7px; }

/* ── Legend collapsible ── */
.legend { position: relative; }
.legend-toggle {
  margin-left: auto; background: none; border: none; cursor: pointer;
  font-size: 10px; color: #aaa; padding: 2px 4px; line-height: 1;
}
.legend.collapsed .leg { display: none; }
.legend.collapsed { padding: 4px 12px; }
.legend.collapsed .legend-toggle { transform: rotate(180deg); }

/* ── Letters-left collapsible ── */
.ll-toggle {
  background: none; border: none; cursor: pointer; padding: 0;
  width: 100%; text-align: center;
}
.ll-body { display: block; } /* visible by default on desktop */
.letters-left-panel.ll-open .ll-body { display: block; }

/* ── Side extras (reactions + log) collapsible ── */
.side-extras { margin-top: 0; }
.side-extras-toggle {
  font-size: 11px; font-weight: 600; color: #888;
  text-transform: uppercase; letter-spacing: 0.4px;
  list-style: none; cursor: pointer; padding: 8px 12px;
  background: #f4f2ed; border-radius: 8px; user-select: none;
  display: none; /* hidden on desktop — always open */
}
.side-extras-toggle::-webkit-details-marker { display: none; }
.side-extras[open] .side-extras-toggle { border-radius: 8px 8px 0 0; }

/* ── Info button ── */
.btn-info { font-size: 16px; padding: 0 10px; }

/* ── Info screen ── */
.info-tabs { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.info-tab-content .card { margin-top: 0; }
.info-body p { font-size: 14px; color: #333; line-height: 1.6; margin-bottom: 10px; }
.info-body h3 { font-size: 15px; font-weight: 600; margin: 16px 0 6px; color: #1a1a1a; }
.info-body ul { padding-left: 18px; margin-bottom: 10px; }
.info-body ul li { font-size: 14px; color: #333; line-height: 1.6; margin-bottom: 4px; }
.info-note { font-size: 12px; color: #888; margin-top: 8px; }
.bonus-grid { display: flex; flex-direction: column; gap: 14px; margin-bottom: 8px; }
.bonus-row { display: flex; gap: 12px; align-items: flex-start; }
.bonus-row > div:last-child p { font-size: 13px; color: #555; margin: 2px 0 0; line-height: 1.5; }
.bonus-row strong { font-size: 14px; font-weight: 600; }
.bonus-swatch {
  width: 40px; height: 40px; border-radius: 7px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
}
.dl-swatch { background: #B5D4F4; color: #185FA5; }
.tl-swatch { background: #378ADD; color: #fff; }
.dw-swatch { background: #F4C0D1; color: #72243E; }
.tw-swatch { background: #A32D2D; color: #fff; }
.star-swatch { background: #FAC775; color: #854F0B; }
.bingo-swatch { background: #534AB7; color: #fff; font-size: 16px; font-weight: 700; }
.palin-swatch { background: #EEEDFE; color: #3C3489; font-size: 20px; }
.gt-effects-list { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.gt-effect-row { display: flex; gap: 10px; align-items: flex-start; }
.gt-effect-badge {
  background: #EF9F27; color: #fff; border-radius: 6px;
  padding: 4px 8px; font-size: 12px; font-weight: 600; white-space: nowrap; flex-shrink: 0;
}
.gt-effect-desc { font-size: 13px; color: #555; line-height: 1.5; padding-top: 2px; }


/* ── Game submit button ── */
.btns {
  flex-wrap: wrap;
  margin-top: 8px;
}
/* Wrapper makes submit button match the rack's natural width */
.rack-submit-wrap {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: fit-content;
  min-width: 332px;
}
.rack-submit-wrap .rack {
  margin-bottom: 0;
  min-height: 52px; /* keep height even when rack is empty */
}
#btn-submit {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 12px 20px;
  font-size: 15px;
  background: #2e9e5b;
  border-radius: 10px;
  white-space: nowrap;
}
#btn-submit:hover:not(:disabled) { background: #237a46; }
#btn-submit:disabled {
  background: #aaa;
  cursor: default;
}
#btn-submit.invalid-word {
  background: #c9a000;
}
#btn-submit.invalid-word:hover {
  background: #a88200;
}

/* ── Letters left panel ── */
.letters-left-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 6px;
  background: #f4f2ed;
  border-radius: 10px;
  min-width: 52px;
  max-width: 60px;
  gap: 4px;
  align-self: flex-start;
}
.ll-label {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: #888;
  text-align: center;
}
.ll-bag-count {
  font-size: 12px;
  font-weight: 700;
  color: #333;
  text-align: center;
}
.ll-grid {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
}
.ll-tile {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1px 4px;
  border-radius: 4px;
  background: #e8e5de;
  font-size: 11px;
}
.ll-letter { font-weight: 700; color: #1a1a1a; }
.ll-count  { font-size: 10px; color: #333; font-weight: 600; }
.ll-total  { font-size: 9px; color: #aaa; font-weight: 400; }
.ll-tile-empty { opacity: 0.35; }

/* ── Opponent face-down rack ── */
.opp-rack {
  display: flex; gap: 2px; flex-wrap: wrap;
  margin-top: 4px; min-height: 16px;
}
.tile-back {
  width: 18px; height: 22px; border-radius: 3px;
  background: #534AB7; border: 1px solid #3C3489;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.tile-back-inner {
  width: 10px; height: 14px; border-radius: 2px;
  border: 1.5px solid rgba(255,255,255,0.25);
  background: repeating-linear-gradient(
    45deg,
    rgba(255,255,255,0.04) 0px,
    rgba(255,255,255,0.04) 2px,
    transparent 2px,
    transparent 6px
  );
}

/* ── Coin badge ── */
.coin-badge {
  font-size: 12px; font-weight: 700; color: #854F0B;
  background: #FAC775; padding: 3px 8px;
  border-radius: 20px; cursor: default;
  white-space: nowrap;
}

/* ── Tile colours: placed vs locked ── */
/* placed (tentative, dashed border) already in .cell.placed above */
/* On mobile shrink tile-backs */

/* ── Chaos Mode ── */
.cell.chaos-drifter {
  box-shadow: 0 0 0 3px #E24B4A, 0 0 8px 2px rgba(226,75,74,0.5) !important;
  animation: drifter-pulse 1s infinite;
  z-index: 2;
}
@keyframes drifter-pulse {
  0%,100% { box-shadow: 0 0 0 3px #E24B4A, 0 0 6px 2px rgba(226,75,74,0.4) !important; }
  50%      { box-shadow: 0 0 0 3px #E24B4A, 0 0 12px 4px rgba(226,75,74,0.7) !important; }
}
.cell.chaos-target {
  box-shadow: 0 0 0 2px #EF9F27 !important;
  animation: target-pulse 1.2s infinite;
}
@keyframes target-pulse {
  0%,100% { box-shadow: 0 0 0 2px rgba(239,159,39,0.6) !important; }
  50%      { box-shadow: 0 0 0 2px rgba(239,159,39,1) !important; }
}
.cell.chaos-broken {
  background: rgba(180,50,50,0.12) !important;
}
.cell.chaos-broken::after {
  content: '';
  position: absolute; inset: 0;
  border: 1px dashed rgba(180,50,50,0.4);
  border-radius: 3px;
  pointer-events: none;
}

/* ── Invite rows ── */
.invite-row {
  background: #f0effe;
  border: 1px solid #d0caf5;
  border-radius: 8px;
  margin-bottom: 6px;
}

/* ── Favorites heart button ── */
.btn-fav {
  width: 36px; height: 36px; border-radius: 8px;
  border: 1px solid rgba(0,0,0,0.12); background: #fff;
  font-size: 18px; cursor: pointer; line-height: 1;
  color: #ccc; transition: all .15s; flex-shrink: 0;
}
.btn-fav:hover { color: #E24B4A; border-color: #E24B4A; }
.btn-fav.faved { color: #E24B4A; border-color: #E24B4A; background: #fff5f5; }

/* ── Mode badges in games list ── */
.mode-badges { display: inline-flex; gap: 4px; vertical-align: middle; }
.mode-badge {
  display: inline-block; font-size: 10px; font-weight: 600;
  padding: 1px 6px; border-radius: 10px; letter-spacing: 0.2px;
}
.mode-badge.normal  { background: #f0f0f0; color: #888; }
.mode-badge.golden  { background: #FEF3DC; color: #854F0B; }
.mode-badge.diag    { background: #EEF4FF; color: #2B5BD7; }
.mode-badge.chaos   { background: #FFF0F0; color: #A32D2D; }

/* ── Skull confetti ── */
.skull-confetti {
  position: fixed; inset: 0; pointer-events: none;
  z-index: 300; overflow: hidden;
}
@keyframes skull-fall {
  0%   { transform: translateY(0) rotate(0deg);   opacity: 1; }
  100% { transform: translateY(105vh) rotate(360deg); opacity: 0.2; }
}

/* ── Nuke selectable tiles ── */
.cell.locked.nuke-selectable {
  box-shadow: 0 0 0 2px #E24B4A !important;
  cursor: crosshair !important;
}
.cell.locked.nuke-selectable:hover {
  box-shadow: 0 0 0 3px #E24B4A, 0 0 8px rgba(226,75,74,0.5) !important;
}

/* ── Finished game outcome badges ── */
.badge.finished.won  { background: #d4edda; color: #155724; }
.badge.finished.lost { background: #f8d7da; color: #721c24; }
.badge.finished.tied { background: #e2e3e5; color: #383d41; }

/* ── Finished game items in lobby ── */
.games-list-item.finished-item {
  background: #f8f8f8;
  opacity: 0.8;
}
.games-list-item.finished-item:hover {
  background: #f4f2ed;
  opacity: 1;
}

/* ── Drag reorder ── */
.tile.drag-over {
  outline: 2px dashed #534AB7;
  outline-offset: 2px;
}
.cell.drag-over-board {
  outline: 2px dashed #534AB7 !important;
  outline-offset: -2px;
}
.tile[draggable="true"] { cursor: grab; }
.tile[draggable="true"]:active { cursor: grabbing; }


/* Mobile-only elements: hidden on desktop */
.mobile-dock,
.mobile-extra-panel,
.mobile-extra-backdrop { display: none; }

/* ══════════════════════════════════════════════════════════════
   MOBILE GAME LAYOUT (≤ 600px)
   ══════════════════════════════════════════════════════════════ */
@media (max-width: 600px) {

  /* ── Game screen: flex column filling viewport ── */
  #screen-game {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    overflow: hidden;
  }

  /* ── Top nav: compact single row ── */
  #screen-game .topnav {
    padding: 6px 10px;
    flex-shrink: 0;
  }
  #screen-game .topnav .logo-sm { font-size: 14px; }
  .btn-sm { font-size: 12px; padding: 0 9px; height: 30px; }

  /* ── Topbar: two score cards + status only, rest hidden ── */
  .topbar {
    padding: 4px 8px;
    gap: 4px;
    flex-shrink: 0;
    flex-wrap: nowrap;
    overflow: hidden;
  }
  .sc-card { min-width: 64px; padding: 4px 6px; flex-shrink: 0; }
  .sc-card .pn { font-size: 10px; }
  .sc-card .pts { font-size: 15px; }
  .ibox { padding: 4px 6px; }
  .ibox .ilbl { font-size: 9px; }
  .ibox .ival { font-size: 11px; }
  /* Hide less critical iboxes on mobile */
  #gt-box, #chaos-box, #move-ct, #test-badge { display: none !important; }
  /* Collapse bag/opp and mode into tiny pills */
  #bag-ct { font-size: 10px; }

  /* ── Legend: hidden on mobile (accessible via info page) ── */
  .legend { display: none; }

  /* ── Board area: pannable/zoomable viewport ── */
  .main {
    flex: 1;
    overflow: hidden;
    padding: 0;
    gap: 0;
    flex-direction: column;
    position: relative;
  }
  .board-wrap {
    flex: 1;
    overflow: hidden;
    width: 100%;
    position: relative;
    touch-action: none; /* we handle touch manually */
  }
  .board {
    /* Full-size board — pan/zoom applied via JS transform */
    grid-template-columns: repeat(15, 34px);
    gap: 2px;
    transform-origin: top left;
    position: absolute;
    top: 0; left: 0;
    cursor: grab;
  }
  .board:active { cursor: grabbing; }
  .cell { width: 34px; height: 34px; font-size: 10px; }
  .cell.placed, .cell.locked { font-size: 12px; }
  .cell .lp { display: none; }

  /* ── Letters-left: hidden on mobile by default ── */
  .letters-left-panel { display: none; }

  /* ── Side panel: not shown in main flow on mobile ── */
  .side { display: none; }

  /* ── Bottom dock: always-visible rack + controls ── */
  .mobile-dock {
    display: flex !important;
    flex-shrink: 0;
    background: #fff;
    border-top: 1px solid rgba(0,0,0,0.1);
    padding: 8px 10px;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.08);
    display: flex;
    flex-direction: column;
    gap: 6px;
  }
  .mobile-dock-top {
    display: flex;
    align-items: center;
    gap: 6px;
  }
  .mobile-dock .rack {
    flex: 1;
    flex-wrap: nowrap;
    gap: 3px;
    overflow-x: auto;
    padding-bottom: 2px;
  }
  .mobile-dock .tile {
    width: 36px; height: 36px;
    font-size: 14px;
    flex-shrink: 0;
  }
  .mobile-dock-actions {
    display: flex;
    gap: 5px;
    align-items: center;
  }
  .mobile-dock #btn-submit {
    flex: 1;
    padding: 10px 12px;
    font-size: 14px;
    margin: 0;
  }
  .mobile-dock .btn-sm {
    height: 36px;
    padding: 0 10px;
    flex-shrink: 0;
  }
  /* Word preview on mobile */
  .mobile-wp {
    font-size: 12px;
    color: #555;
    min-height: 18px;
    text-align: center;
  }

  /* ── Mobile menu overlay (log, reactions, unseen) ── */
  .mobile-extra-panel {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: #fff;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
    z-index: 50;
    padding: 16px;
    max-height: 65vh;
    overflow-y: auto;
    transform: translateY(100%);
    transition: transform 0.25s ease;
  }
  .mobile-extra-panel.open {
    transform: translateY(0);
  }
  .mobile-extra-backdrop {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.3);
    z-index: 49;
    display: none;
  }
  .mobile-extra-backdrop.open { display: block; }

  /* ── Turn banner on mobile ── */
  .turn-banner { font-size: 12px; padding: 6px; flex-shrink: 0; }

  /* ── Admin banner ── */
  #admin-banner { font-size: 11px; padding: 6px 8px; flex-shrink: 0; }

  /* ── Info/Stats screens on mobile: normal scroll ── */
  #screen-info, #screen-stats {
    height: 100dvh;
    overflow-y: auto;
  }
}

/* ── Level badge ── */
.level-badge {
  font-size: 11px; font-weight: 700; color: #534AB7;
  background: #EEEDFE; padding: 3px 8px;
  border-radius: 20px; cursor: default;
  white-space: nowrap;
}

/* ── Classic mode badge in lobby ── */
.mode-badge.classic { background: #E8F4E8; color: #2D6A2D; }

.mode-badge.ranked { background: #1a1a2e; color: #EF9F27; font-weight: 700; }
