/* ==========================================================================
   Sudoku Royal — 2026 Smart Edition Stylesheet
   Supports 4 Themes: emerald (KoreaKL), wood (HOMIT), obsidian, paper
   ========================================================================== */

:root {
  --bg-main: #071318;
  --bg-panel: rgba(15, 31, 38, 0.92);
  --bg-board: #0d2229;
  --cell-bg: #112a33;
  --cell-peer: #173a47;
  --cell-same-num: #065f46;
  --cell-selected: #10b981;
  --cell-selected-text: #042f2e;
  --text-main: #f8fafc;
  --text-sub: #94a3b8;
  --text-given: #f8fafc;
  --text-user: #38bdf8;
  --text-note: #94a3b8;
  --border-thin: rgba(148, 163, 184, 0.24);
  --border-thick: #34d399;
  --accent-primary: #10b981;
  --accent-amber: #f59e0b;
}

body[data-theme="wood"] {
  --bg-main: #23150d;
  --bg-panel: rgba(46, 28, 17, 0.95);
  --bg-board: #fdf8ee;
  --cell-bg: #fcf6e8;
  --cell-peer: #f3e5c8;
  --cell-same-num: #fcd34d;
  --cell-selected: #d97706;
  --cell-selected-text: #ffffff;
  --text-main: #fef3c7;
  --text-sub: #d6c3a5;
  --text-given: #1c1917;
  --text-user: #1d4ed8;
  --text-note: #57534e;
  --border-thin: rgba(120, 53, 15, 0.22);
  --border-thick: #78350f;
  --accent-primary: #d97706;
}

body[data-theme="obsidian"] {
  --bg-main: #090d16;
  --bg-panel: rgba(17, 24, 39, 0.94);
  --bg-board: #111827;
  --cell-bg: #1e293b;
  --cell-peer: #283548;
  --cell-same-num: #3730a3;
  --cell-selected: #6366f1;
  --cell-selected-text: #ffffff;
  --text-main: #f1f5f9;
  --text-sub: #94a3b8;
  --text-given: #f8fafc;
  --text-user: #60a5fa;
  --text-note: #94a3b8;
  --border-thin: rgba(148, 163, 184, 0.22);
  --border-thick: #818cf8;
  --accent-primary: #6366f1;
}

body[data-theme="paper"] {
  --bg-main: #e2e8f0;
  --bg-panel: #ffffff;
  --bg-board: #ffffff;
  --cell-bg: #ffffff;
  --cell-peer: #e0f2fe;
  --cell-same-num: #bae6fd;
  --cell-selected: #0284c7;
  --cell-selected-text: #ffffff;
  --text-main: #0f172a;
  --text-sub: #475569;
  --text-given: #0f172a;
  --text-user: #2563eb;
  --text-note: #475569;
  --border-thin: #cbd5e1;
  --border-thick: #0f172a;
  --accent-primary: #0284c7;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: "Pretendard", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
}

#confetti-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
}

.app-shell {
  max-width: 1280px;
  margin: 0 auto;
  padding: 10px 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* 1. Top HUD Bar */
.top-hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 16px;
  border-radius: 16px;
  background: var(--bg-panel);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.brand-area {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--accent-primary), #3b82f6);
  color: #ffffff;
  font-weight: 900;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.brand-title {
  display: flex;
  flex-direction: column;
  font-weight: 800;
  font-size: 16px;
  line-height: 1.2;
}

.brand-sub {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-sub);
}

.hud-center-stats {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.35);
  border: 1px solid rgba(148, 163, 184, 0.2);
  font-size: 12.5px;
}

body[data-theme="paper"] .stat-pill {
  background: #f1f5f9;
}

.stat-pill b {
  color: var(--accent-amber);
  font-weight: 800;
}

.hud-right-tools {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.hud-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 12px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: rgba(30, 41, 59, 0.65);
  color: #f8fafc;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}

body[data-theme="paper"] .hud-btn {
  background: #f1f5f9;
  color: #0f172a;
}

.hud-btn:hover {
  transform: translateY(-1px);
  border-color: var(--accent-primary);
}

.btn-primary-sm {
  background: linear-gradient(135deg, var(--accent-primary), #059669) !important;
  color: #ffffff !important;
  border-color: transparent !important;
}

.btn-mp-highlight {
  background: linear-gradient(135deg, #2563eb, #7c3aed) !important;
  color: #ffffff !important;
  border-color: rgba(167, 139, 250, 0.5) !important;
}

.mp-online-badge {
  font-style: normal;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.28);
  color: #6ee7b7;
  border: 1px solid rgba(52, 211, 153, 0.45);
}

.theme-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: 230px;
  background: #0f172a;
  border: 1px solid rgba(148, 163, 184, 0.3);
  border-radius: 12px;
  padding: 6px;
  display: none;
  flex-direction: column;
  gap: 4px;
  z-index: 200;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
}

.theme-dropdown.open {
  display: flex;
}

.theme-opt {
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  color: #e2e8f0;
  cursor: pointer;
}

.theme-opt:hover,
.theme-opt.active {
  background: rgba(16, 185, 129, 0.22);
  color: #34d399;
}

/* 2. Difficulty Bar */
.difficulty-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  padding: 6px 10px;
  border-radius: 12px;
  background: var(--bg-panel);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.diff-tab {
  padding: 7px 14px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-sub);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.15s;
}

.diff-tab:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.06);
}

.diff-tab.active {
  background: var(--accent-primary);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.28);
}

.diff-special {
  color: #fbbf24;
}

.diff-killer {
  color: #c084fc;
}

/* 3. Coach Banner */
.coach-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-radius: 14px;
  background: var(--bg-panel);
  border-left: 4px solid var(--accent-primary);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
}

.coach-banner.coach-error {
  border-left-color: #ef4444;
}

.coach-banner.coach-hint {
  border-left-color: #f59e0b;
}

.coach-icon {
  font-size: 24px;
  flex-shrink: 0;
}

.coach-text strong {
  display: block;
  font-size: 13.5px;
  margin-bottom: 2px;
}

.coach-text p {
  font-size: 12.5px;
  color: var(--text-sub);
  line-height: 1.45;
}

/* 4. Main Workspace (9x9 Board + Control Panel) */
.sudoku-workspace {
  display: grid;
  grid-template-columns: minmax(320px, 540px) minmax(300px, 440px);
  justify-content: center;
  align-items: start;
  gap: 20px;
  margin-top: 4px;
}

@media (max-width: 900px) {
  .sudoku-workspace {
    grid-template-columns: minmax(0, 1fr);
    max-width: 540px;
    margin: 0 auto;
  }

  .smart-control-panel > .panel-card:last-child {
    order: -1;
  }
}

.board-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.sudoku-board {
  width: 100%;
  max-width: 520px;
  aspect-ratio: 1 / 1;
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  grid-template-rows: repeat(9, 1fr);
  background: var(--bg-board);
  border: 3px solid var(--border-thick);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
}

.sudoku-cell {
  position: relative;
  border-right: 1px solid var(--border-thin);
  border-bottom: 1px solid var(--border-thin);
  background: var(--cell-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.1s ease, transform 0.12s ease;
}

.sudoku-cell.box-left {
  border-left: 2.5px solid var(--border-thick);
}

.sudoku-cell.box-top {
  border-top: 2.5px solid var(--border-thick);
}

.sudoku-cell.is-peer {
  background: var(--cell-peer);
}

.sudoku-cell.is-same-num {
  background: var(--cell-same-num);
  box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.25);
}

.sudoku-cell.is-selected {
  background: var(--cell-selected) !important;
  box-shadow: inset 0 0 0 2px #ffffff;
  z-index: 2;
}

.sudoku-cell.is-selected .cell-main-val {
  color: var(--cell-selected-text) !important;
}

.sudoku-cell.is-error {
  background: rgba(239, 68, 68, 0.26) !important;
}

.sudoku-cell.is-error .cell-main-val {
  color: #ef4444 !important;
}

.sudoku-cell.pop-anim {
  animation: cellPop 0.36s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes cellPop {
  0% { transform: scale(0.84); }
  55% { transform: scale(1.1); }
  100% { transform: scale(1); }
}

.cell-main-val {
  font-size: clamp(18px, 3.2vw, 28px);
  font-weight: 800;
  color: var(--text-given);
  z-index: 2;
  letter-spacing: -0.02em;
}

.sudoku-cell.is-user .cell-main-val {
  color: var(--text-user);
  font-weight: 900;
}

/* 3x3 Mini Pencil Notes Grid */
.cell-notes-grid {
  width: 100%;
  height: 100%;
  padding: 2px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  align-items: center;
  justify-items: center;
  z-index: 2;
}

.note-item {
  font-size: clamp(8.5px, 1.1vw, 11px);
  font-weight: 700;
  color: var(--text-note);
  line-height: 1;
  white-space: nowrap;
}

.diff-lbl-short {
  display: none;
}

.note-item.note-match {
  color: #ffffff;
  background: var(--accent-primary);
  border-radius: 4px;
  padding: 1px 3px;
  font-weight: 900;
}

/* Killer Sudoku Dotted Cage Walls & Sum Badge */
.killer-cage-box {
  position: absolute;
  inset: 3px;
  pointer-events: none;
  z-index: 1;
}

.killer-cage-box.kc-top { border-top: 1.5px dashed rgba(245, 158, 11, 0.75); }
.killer-cage-box.kc-bottom { border-bottom: 1.5px dashed rgba(245, 158, 11, 0.75); }
.killer-cage-box.kc-left { border-left: 1.5px dashed rgba(245, 158, 11, 0.75); }
.killer-cage-box.kc-right { border-right: 1.5px dashed rgba(245, 158, 11, 0.75); }

.killer-sum-badge {
  position: absolute;
  top: 2px;
  left: 4px;
  font-size: 9.5px;
  font-weight: 900;
  color: #f59e0b;
  background: rgba(15, 23, 42, 0.75);
  padding: 0 3px;
  border-radius: 3px;
  z-index: 3;
}

.remote-cell-tag {
  position: absolute;
  bottom: 2px;
  right: 2px;
  font-size: 9px;
  font-weight: 800;
  color: #ffffff;
  padding: 1px 4px;
  border-radius: 4px;
  z-index: 4;
}

/* 5. Smart Control Panel & Numpad */
.smart-control-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.panel-card {
  background: var(--bg-panel);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 14px;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.22);
}

.panel-section-title {
  font-size: 12.5px;
  font-weight: 800;
  color: var(--text-sub);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.tool-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}

.tool-grid-1 {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tool-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 11px 12px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: rgba(30, 41, 59, 0.7);
  color: #f8fafc;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}

body[data-theme="paper"] .tool-btn {
  background: #f8fafc;
  color: #0f172a;
}

.tool-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: var(--accent-primary);
}

.tool-btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.tool-btn.active-mode {
  background: linear-gradient(135deg, #059669, #10b981) !important;
  color: #ffffff !important;
  border-color: #6ee7b7 !important;
}

.mode-state-pill {
  font-size: 10.5px;
  font-weight: 900;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.35);
}

.btn-accent-emerald {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.22), rgba(5, 150, 105, 0.35)) !important;
  border-color: rgba(52, 211, 153, 0.45) !important;
  color: #6ee7b7 !important;
}

body[data-theme="paper"] .btn-accent-emerald {
  color: #065f46 !important;
}

.btn-accent-amber {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.25), rgba(217, 119, 6, 0.38)) !important;
  border-color: rgba(251, 191, 36, 0.5) !important;
  color: #fde68a !important;
}

body[data-theme="paper"] .btn-accent-amber {
  color: #92400e !important;
}

.btn-accent-indigo {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.25), rgba(79, 70, 229, 0.38)) !important;
  border-color: rgba(129, 140, 248, 0.5) !important;
  color: #c7d2fe !important;
}

body[data-theme="paper"] .btn-accent-indigo {
  color: #3730a3 !important;
}

/* 1..9 Smart Numpad Grid */
.numpad-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
}

.numpad-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 0;
  overflow: hidden;
  padding: 10px 6px;
  border-radius: 13px;
  border: 1px solid rgba(148, 163, 184, 0.26);
  background: rgba(15, 23, 42, 0.65);
  color: #ffffff;
  cursor: pointer;
  transition: background-color 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease, transform 0.14s ease;
}

body[data-theme="paper"] .numpad-btn {
  background: #f8fafc;
  color: #0f172a;
}

@media (hover: hover) and (pointer: fine) {
  .numpad-btn:hover {
    transform: translateY(-2px);
    border-color: var(--accent-primary);
  }
}

.numpad-rem .rem-compact {
  display: none;
}

.numpad-btn.selected-match {
  border-color: #38bdf8;
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.35);
}

.numpad-btn.locked-active {
  background: linear-gradient(135deg, #d97706, #f59e0b) !important;
  color: #ffffff !important;
  border-color: #fde68a !important;
}

.numpad-btn.completed {
  opacity: 0.35;
}

.numpad-digit {
  font-size: 22px;
  font-weight: 900;
  line-height: 1.1;
}

.numpad-sub {
  font-size: 10.5px;
  color: var(--text-sub);
  margin-top: 2px;
}

.numpad-rem {
  margin-top: 4px;
  font-size: 10px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: #cbd5e1;
}

body[data-theme="paper"] .numpad-rem {
  background: #e2e8f0;
  color: #334155;
}

.numpad-rem.rem-done {
  background: rgba(16, 185, 129, 0.25);
  color: #34d399;
}

/* Multiplayer Live Progress Strip & Quick Chat */
.mp-live-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 8px 14px;
  border-radius: 12px;
  background: rgba(30, 58, 138, 0.35);
  border: 1px solid rgba(96, 165, 250, 0.35);
}

.mp-live-badge {
  font-size: 12.5px;
  font-weight: 800;
  color: #93c5fd;
}

.mp-live-players {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.mp-live-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.65);
  font-size: 12px;
}

.mp-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.mp-mini-bar {
  width: 60px;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.15);
  overflow: hidden;
}

.mp-mini-fill {
  height: 100%;
  transition: width 0.25s ease;
}

.mp-chat-floating {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 12px;
  background: var(--bg-panel);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.mp-chat-label {
  font-size: 12px;
  font-weight: 800;
  color: var(--text-sub);
}

.mp-quick-emoji {
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: rgba(15, 23, 42, 0.6);
  color: #f8fafc;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
}

.mp-quick-emoji:hover {
  border-color: var(--accent-primary);
}

/* Modals & Invite Banner */
.mp-invite-banner {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%) translateY(-150%);
  z-index: 3000;
  background: linear-gradient(135deg, #1e3a8a, #312e81);
  border: 1px solid #60a5fa;
  border-radius: 14px;
  padding: 10px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.45);
  transition: transform 0.3s ease;
}

.mp-invite-banner.show {
  transform: translateX(-50%) translateY(0);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.76);
  backdrop-filter: blur(5px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 2000;
}

.modal-overlay.open {
  display: flex;
}

.modal-card {
  width: 100%;
  max-width: 560px;
  background: #0f172a;
  color: #f8fafc;
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.5);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.16);
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 24px;
  cursor: pointer;
}

.modal-body {
  padding: 18px;
  max-height: 75vh;
  overflow-y: auto;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid rgba(148, 163, 184, 0.16);
}

.mp-profile-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.mp-input {
  flex: 1;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.3);
  background: #1e293b;
  color: #ffffff;
  font-size: 13px;
}

.mp-hero-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

@media (max-width: 600px) {
  .mp-hero-actions {
    grid-template-columns: 1fr;
  }
}

.mp-action-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: #1e293b;
  color: #ffffff;
  text-align: left;
  cursor: pointer;
}

.mp-action-card.primary {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.22), rgba(5, 150, 105, 0.35));
  border-color: rgba(52, 211, 153, 0.45);
}

.mp-action-card.accent {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.22), rgba(99, 102, 241, 0.35));
  border-color: rgba(96, 165, 250, 0.45);
}

.mac-icon {
  font-size: 28px;
}

.mac-text strong {
  display: block;
  font-size: 13.5px;
  margin-bottom: 3px;
}

.mac-text span {
  font-size: 11.5px;
  color: #cbd5e1;
}

.mp-code-join-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 0;
}

.mp-section-title {
  font-size: 12.5px;
  font-weight: 800;
  color: #94a3b8;
  margin-bottom: 8px;
}

.mp-public-rooms-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mp-room-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 10px;
  background: #1e293b;
  border: 1px solid rgba(148, 163, 184, 0.2);
}

.mp-room-item strong {
  display: block;
  font-size: 13px;
}

.mp-room-item span {
  font-size: 11.5px;
  color: #94a3b8;
}

.mp-empty-rooms {
  padding: 14px;
  border-radius: 10px;
  background: rgba(30, 41, 59, 0.5);
  color: #94a3b8;
  font-size: 12.5px;
  text-align: center;
}

.mp-room-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px;
  border-radius: 12px;
  background: #1e293b;
}

.mrb-label {
  display: block;
  font-size: 11.5px;
  color: #34d399;
  font-weight: 800;
}

.mrb-code {
  font-size: 24px;
  font-weight: 900;
  letter-spacing: 2px;
  color: #fbbf24;
}

.mrb-right {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.mp-qr-container {
  margin-top: 10px;
  padding: 12px;
  border-radius: 12px;
  background: #1e293b;
  display: flex;
  align-items: center;
  gap: 14px;
}

.mp-qr-container img {
  border-radius: 8px;
  background: #ffffff;
  padding: 6px;
}

.mp-seats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.mp-seat-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #1e293b;
}

.mp-seat-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.mp-seat-prog {
  margin-left: auto;
  font-size: 12px;
  color: #34d399;
  font-weight: 800;
}

.victory-stats-box {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.v-stat-item {
  padding: 12px;
  border-radius: 12px;
  background: #1e293b;
  text-align: center;
}

.v-stat-item span {
  display: block;
  font-size: 11.5px;
  color: #94a3b8;
  margin-bottom: 4px;
}

.v-stat-item strong {
  font-size: 17px;
  color: #fbbf24;
}

.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 4000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast-item {
  padding: 11px 16px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.95);
  color: #ffffff;
  border: 1px solid rgba(52, 211, 153, 0.45);
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
}

/* ==========================================================================
   Smart Pencil Note Automation & Conflict Feedback Visuals
   ========================================================================== */
.sudoku-cell.conflict-flash {
  background: rgba(239, 68, 68, 0.55) !important;
  box-shadow: inset 0 0 0 2.5px #ef4444 !important;
  animation: conflictShake 0.42s ease;
  z-index: 5;
}

@keyframes conflictShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-4px); }
  40% { transform: translateX(4px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}

.sudoku-cell.note-erased-flash {
  box-shadow: inset 0 0 0 2px #34d399 !important;
  background: rgba(16, 185, 129, 0.22) !important;
}

.note-erased-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  padding: 1px 4px;
  border-radius: 4px;
  background: #059669;
  color: #ffffff;
  font-size: 8.5px;
  font-weight: 900;
  z-index: 6;
  pointer-events: none;
  animation: badgeFadeUp 0.9s ease forwards;
}

@keyframes badgeFadeUp {
  0% { opacity: 1; transform: translateY(0) scale(0.95); }
  60% { opacity: 1; transform: translateY(-3px) scale(1); }
  100% { opacity: 0; transform: translateY(-7px) scale(0.9); }
}

.sudoku-cell.single-note-ready {
  box-shadow: inset 0 0 0 1.8px rgba(251, 191, 36, 0.75);
}

.numpad-btn.peer-blocked {
  opacity: 0.48;
  border-color: rgba(239, 68, 68, 0.35);
}

.numpad-btn.note-active {
  border-color: #34d399;
  box-shadow: 0 0 0 2px rgba(52, 211, 153, 0.38);
}

.numpad-rem.rem-blocked {
  background: rgba(239, 68, 68, 0.22);
  color: #fca5a5;
}

.numpad-rem.rem-noted {
  background: rgba(16, 185, 129, 0.25);
  color: #6ee7b7;
}

/* ==========================================================================
   Full Mobile Ergonomic Optimization (Locked Numpad & Stable Viewport Layout)
   ========================================================================== */
@media (max-width: 768px) {
  .app-shell {
    padding: 6px 8px 16px;
    gap: 6px;
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
  }

  .top-hud,
  .difficulty-bar,
  .coach-banner,
  .sudoku-workspace,
  .board-stage,
  .smart-control-panel,
  .panel-card {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .top-hud {
    padding: 7px 9px;
    gap: 6px;
    border-radius: 12px;
  }

  .brand-area {
    gap: 6px;
    min-width: 0;
  }

  .brand-logo {
    width: 28px;
    height: 28px;
    font-size: 13px;
    flex-shrink: 0;
  }

  .brand-title {
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .brand-sub {
    display: none;
  }

  .hud-center-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
    width: 100%;
    order: 3;
  }

  .stat-pill {
    padding: 4px 4px;
    font-size: 10.5px;
    gap: 3px;
    min-width: 0;
    justify-content: center;
    white-space: nowrap;
    overflow: hidden;
  }

  .stat-pill b {
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .diff-lbl-full {
    display: none;
  }

  .diff-lbl-short {
    display: inline;
  }

  .hud-right-tools {
    gap: 4px;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    max-width: 100%;
    padding-bottom: 1px;
  }

  .hud-right-tools::-webkit-scrollbar,
  .difficulty-bar::-webkit-scrollbar {
    display: none;
  }

  .theme-dropdown {
    position: fixed;
    top: 56px;
    right: 10px;
    z-index: 2500;
  }

  .hud-btn {
    padding: 5px 8px;
    font-size: 11px;
    border-radius: 8px;
    white-space: nowrap;
    flex-shrink: 0;
    transform: none !important;
  }

  .difficulty-bar {
    padding: 4px 6px;
    gap: 4px;
    border-radius: 10px;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .diff-tab {
    padding: 5px 10px;
    font-size: 11.5px;
    flex-shrink: 0;
  }

  /* Place variable-height coach banner below controls on mobile so board & numpad Y-positions never shift */
  .coach-banner {
    order: 6;
    padding: 8px 10px;
    gap: 8px;
    border-radius: 10px;
  }

  .coach-icon {
    font-size: 18px;
  }

  .coach-text {
    min-width: 0;
  }

  .coach-text strong {
    font-size: 12px;
  }

  .coach-text p {
    font-size: 11px;
    line-height: 1.38;
    word-break: keep-all;
  }

  .sudoku-workspace {
    display: flex;
    flex-direction: column;
    gap: 7px;
    margin-top: 0;
  }

  .board-stage {
    width: 100%;
  }

  /* Use stable svh (not dynamic dvh) so mobile browser address-bar animation never resizes the board or shifts buttons */
  .sudoku-board {
    width: 100%;
    max-width: min(100%, 420px);
    width: min(100%, 49svh, 420px);
    border-width: 2.5px;
    border-radius: 11px;
  }

  .cell-main-val {
    font-size: clamp(16px, 4.8vw, 22px);
  }

  .sudoku-board[data-numeral-mode="native"] .cell-main-val {
    font-size: clamp(11.5px, 3.4vw, 15px);
    letter-spacing: -0.04em;
  }

  .note-item {
    font-size: 8px;
  }

  .sudoku-board[data-numeral-mode="native"] .note-item {
    font-size: 6.5px;
    letter-spacing: -0.05em;
  }

  .smart-control-panel {
    width: 100%;
    gap: 7px;
  }

  /* Put 1..9 Smart Numpad directly beneath the 9x9 board on mobile */
  .smart-control-panel > .panel-card:last-child {
    order: -1;
    padding: 6px 5px;
  }

  .smart-control-panel > .panel-card:first-child {
    padding: 8px;
  }

  .panel-section-title {
    display: none;
  }

  /* Strict 9-Column Locked Thumb Bar: 1..9 never shift X/Y position and 8, 9 are always 100% visible */
  .numpad-grid {
    display: grid;
    grid-template-columns: repeat(9, minmax(0, 1fr));
    gap: 3px;
    width: 100%;
  }

  .numpad-btn {
    min-width: 0;
    width: 100%;
    height: 54px;
    padding: 4px 1px;
    border-radius: 9px;
    overflow: hidden;
    transform: none !important;
  }

  .numpad-btn:active {
    opacity: 0.82;
  }

  .numpad-digit {
    font-size: clamp(16px, 4.6vw, 20px);
    line-height: 1.08;
    white-space: nowrap;
  }

  .numpad-grid[data-numeral-mode="native"] .numpad-digit {
    font-size: clamp(11px, 3.2vw, 13.5px);
    letter-spacing: -0.04em;
  }

  .numpad-sub {
    display: none;
  }

  .numpad-rem {
    font-size: 8.5px;
    height: 15px;
    line-height: 13px;
    padding: 1px 2px;
    margin-top: 3px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: clip;
    max-width: calc(100% - 2px);
  }

  .numpad-rem .rem-full {
    display: none;
  }

  .numpad-rem .rem-compact {
    display: inline;
  }

  .tool-grid-2 {
    gap: 6px;
    margin-bottom: 6px;
  }

  .tool-grid-1 {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 6px;
  }

  #btn-smart-hint {
    grid-column: span 2;
  }

  .tool-btn {
    min-width: 0;
    padding: 7px 5px;
    gap: 4px;
    font-size: 11px;
    border-radius: 9px;
    transform: none !important;
  }

  .mode-state-pill {
    font-size: 9.5px;
    padding: 1.5px 5px;
    flex-shrink: 0;
  }

  .tool-btn strong,
  .tool-btn .tool-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .toast-container {
    left: 10px;
    right: 10px;
    bottom: 12px;
  }
}


