/* ============================================
   Cross Clues — Polished Game UI
   ============================================ */

:root {
  /* Game palette — dark-first */
  --bg: #0d1117;
  --bg-card: #161b22;
  --bg-board: #0d1117;
  --bg-elevated: #1c2333;
  --text: #e2e8f0;
  --text-muted: #7b8ca5;
  --text-inverse: #ffffff;
  --border: #2d3748;
  --border-light: #1e293b;
  --accent: #00d4aa;
  --accent-hover: #00e8bc;
  --accent-dim: rgba(0, 212, 170, 0.12);
  --accent-glow: rgba(0, 212, 170, 0.25);
  --secondary: #ff6b81;
  --secondary-hover: #ff8fa0;
  --secondary-dim: rgba(255, 107, 129, 0.12);
  --success: #22c55e;
  --success-bg: rgba(34, 197, 94, 0.12);
  --error: #ef4444;
  --error-bg: rgba(239, 68, 68, 0.12);
  --warning: #f59e0b;
  --shadow: rgba(0, 0, 0, 0.4);
  --shadow-strong: rgba(0, 0, 0, 0.6);
  --overlay: rgba(0, 0, 0, 0.8);

  /* Card row palette */
  --row-a: #00d4aa;
  --row-b: #3b82f6;
  --row-c: #a855f7;
  --row-d: #f59e0b;
  --row-e: #ff6b81;

  /* Layout */
  --header-height: 52px;
  --hand-height: 320px;
  --hand-toggle-height: 44px;
  --radius: 8px;
  --radius-lg: 14px;
  --radius-xl: 20px;
}

/* Light theme */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f1f5f9;
    --bg-card: #ffffff;
    --bg-board: #e2e8f0;
    --bg-elevated: #ffffff;
    --text: #0f172a;
    --text-muted: #64748b;
    --text-inverse: #ffffff;
    --border: #cbd5e1;
    --border-light: #e2e8f0;
    --accent: #0d9b7a;
    --accent-hover: #00b894;
    --accent-dim: rgba(13, 155, 122, 0.08);
    --accent-glow: rgba(13, 155, 122, 0.15);
    --secondary: #e05265;
    --secondary-hover: #ff6b81;
    --secondary-dim: rgba(224, 82, 101, 0.08);
    --success: #16a34a;
    --success-bg: rgba(22, 163, 74, 0.08);
    --error: #dc2626;
    --error-bg: rgba(220, 38, 38, 0.08);
    --warning: #d97706;
    --shadow: rgba(0, 0, 0, 0.06);
    --shadow-strong: rgba(0, 0, 0, 0.12);
    --overlay: rgba(0, 0, 0, 0.5);
    --row-a: #0d9b7a;
    --row-b: #2563eb;
    --row-c: #9333ea;
    --row-d: #d97706;
    --row-e: #e05265;
  }
}

:root[data-theme="dark"] {
  --bg: #0d1117;
  --bg-card: #161b22;
  --bg-board: #0d1117;
  --bg-elevated: #1c2333;
  --text: #e2e8f0;
  --text-muted: #7b8ca5;
  --text-inverse: #ffffff;
  --border: #2d3748;
  --border-light: #1e293b;
  --accent: #00d4aa;
  --accent-hover: #00e8bc;
  --accent-dim: rgba(0, 212, 170, 0.12);
  --accent-glow: rgba(0, 212, 170, 0.25);
  --secondary: #ff6b81;
  --secondary-hover: #ff8fa0;
  --secondary-dim: rgba(255, 107, 129, 0.12);
  --success: #22c55e;
  --success-bg: rgba(34, 197, 94, 0.12);
  --error: #ef4444;
  --error-bg: rgba(239, 68, 68, 0.12);
  --warning: #f59e0b;
  --shadow: rgba(0, 0, 0, 0.4);
  --shadow-strong: rgba(0, 0, 0, 0.6);
  --overlay: rgba(0, 0, 0, 0.8);
  --row-a: #00d4aa;
  --row-b: #3b82f6;
  --row-c: #a855f7;
  --row-d: #f59e0b;
  --row-e: #ff6b81;
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
  background-image:
    linear-gradient(var(--border-light) 1px, transparent 1px),
    linear-gradient(90deg, var(--border-light) 1px, transparent 1px);
  background-size: 48px 48px;
  background-position: center center;
}
button { cursor: pointer; font: inherit; }
input, select { font: inherit; }
ul { list-style: none; }

/* Views */
.view { display: none; min-height: 100dvh; }
.view.active { display: flex; flex-direction: column; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 22px;
  border: none;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.3px;
  transition: all 0.2s ease;
  text-decoration: none;
  position: relative;
  overflow: hidden;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.btn-primary {
  background: var(--accent);
  color: #0d1117;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  box-shadow: 0 0 20px var(--accent-glow);
}
.btn-secondary {
  background: transparent;
  color: var(--text);
  border: 2px solid var(--border);
}
.btn-secondary:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}
.btn-accent {
  background: var(--secondary);
  color: var(--text-inverse);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}
.btn-accent:hover:not(:disabled) {
  background: var(--secondary-hover);
  box-shadow: 0 0 20px var(--secondary-dim);
}
.btn-text { background: none; border: none; color: var(--text-muted); padding: 6px 12px; }
.btn-text:hover { color: var(--text); }
.btn-large { padding: 16px 40px; font-size: 1.1rem; border-radius: var(--radius-lg); }
.btn-icon {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 8px;
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  transition: all 0.2s;
}
.btn-icon:hover { background: var(--accent-dim); color: var(--accent); }

/* ---- Form Elements ---- */
.field-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 14px;
}
.field-label input[type="text"],
.field-label input[type="password"] {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 12px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
  transition: all 0.2s;
}
.field-label input:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.room-code-input {
  text-transform: uppercase;
  letter-spacing: 4px;
  font-weight: 700;
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 1.15rem !important;
  text-align: center;
}

.select-input {
  padding: 8px 12px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
}

/* Toggle switch */
.toggle-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}
.toggle-label input[type="checkbox"] { display: none; }
.toggle-switch {
  width: 48px;
  height: 26px;
  background: var(--border);
  border-radius: 13px;
  position: relative;
  transition: background 0.3s;
  flex-shrink: 0;
}
.toggle-switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  background: var(--text);
  border-radius: 50%;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.toggle-label input:checked + .toggle-switch { background: var(--accent); }
.toggle-label input:checked + .toggle-switch::after {
  transform: translateX(22px);
  background: #0d1117;
}

/* Board size selector */
.board-size-selector { display: flex; gap: 8px; margin-top: 6px; margin-bottom: 14px; }
.size-option {
  flex: 1;
  text-align: center;
  cursor: pointer;
}
.size-option input { display: none; }
.size-option span {
  display: block;
  padding: 10px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-weight: 700;
  font-size: 0.95rem;
  transition: all 0.2s;
}
.size-option input:checked + span {
  border-color: var(--accent);
  background: var(--accent);
  color: #0d1117;
  box-shadow: 0 0 16px var(--accent-glow);
}
.size-option:hover span { border-color: var(--accent); }

/* Badge */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 7px;
  background: var(--accent);
  color: #0d1117;
  font-size: 0.75rem;
  font-weight: 800;
  border-radius: 12px;
  vertical-align: middle;
}

/* ---- Landing View ---- */
.landing-container {
  max-width: 480px;
  width: 100%;
  margin: 0 auto;
  padding: 32px 16px;
  flex: 1;
}
.landing-header {
  text-align: center;
  margin-bottom: 36px;
}
.logo-img {
  max-width: 360px;
  width: 100%;
  height: auto;
  margin-bottom: 4px;
}
.logo {
  font-size: 2.4rem;
  font-weight: 900;
  letter-spacing: 2px;
  text-transform: uppercase;
  background: linear-gradient(135deg, var(--accent), #7dd3fc);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 2px 8px var(--accent-glow));
}
.logo-small {
  font-size: 1.3rem;
  letter-spacing: 1px;
}
.tagline {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-top: 6px;
  font-weight: 500;
  letter-spacing: 0.5px;
}

.landing-cards { display: flex; flex-direction: column; gap: 0; }
.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 24px;
  border: 1px solid var(--border);
  box-shadow: 0 4px 24px var(--shadow);
}
.card h2 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 18px;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 1px;
}
.card .btn { width: 100%; margin-top: 10px; }

.divider {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 20px 0;
  color: var(--text-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  font-weight: 600;
}
.divider::before, .divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.how-to-play {
  margin-top: 28px;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
}
.how-to-play summary {
  padding: 16px 20px;
  font-weight: 700;
  cursor: pointer;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-size: 0.85rem;
}
.how-to-play summary:hover { color: var(--text); }
.rules-content {
  padding: 0 20px 20px;
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.7;
}
.rules-content ol { padding-left: 20px; }
.rules-content li { margin-bottom: 10px; }
.rules-content strong { color: var(--text); }

/* ---- Lobby View ---- */
.lobby-container {
  max-width: 520px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 16px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.lobby-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}
.room-info { display: flex; align-items: center; gap: 10px; }
.room-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 2px;
  font-weight: 700;
}
.room-code {
  font-size: 1.4rem;
  font-weight: 900;
  letter-spacing: 4px;
  color: var(--accent);
  font-family: 'Consolas', 'Monaco', monospace;
}

.lobby-players, .lobby-settings {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 18px;
  border: 1px solid var(--border);
  box-shadow: 0 4px 24px var(--shadow);
}
.lobby-players h2, .lobby-settings h2 {
  font-size: 0.85rem;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 700;
}

.player-list { display: flex; flex-direction: column; gap: 6px; }
.player-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius);
  background: var(--bg);
  border: 1px solid var(--border-light);
}
.player-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.4);
}
.player-dot.disconnected {
  background: var(--text-muted);
  box-shadow: none;
}
.player-name { font-weight: 600; flex: 1; }
.player-host {
  font-size: 0.7rem;
  color: var(--accent);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 2px 8px;
  background: var(--accent-dim);
  border-radius: 4px;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  gap: 12px;
  font-size: 0.9rem;
  font-weight: 500;
}
.setting-row + .setting-row { border-top: 1px solid var(--border-light); }
.settings-readonly .size-option { pointer-events: none; opacity: 0.5; }
.settings-readonly .toggle-label { pointer-events: none; opacity: 0.5; }
.settings-readonly .select-input { pointer-events: none; opacity: 0.5; }

.lobby-actions { text-align: center; margin-top: auto; padding: 16px 0; }
.lobby-status { color: var(--text-muted); font-size: 0.85rem; margin-top: 12px; }

/* ---- Game View ---- */
#game-view { position: relative; overflow: hidden; }
.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  height: var(--header-height);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  z-index: 10;
  flex-shrink: 0;
}
.game-header-left, .game-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.game-header-center {
  flex: 1;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0 10px;
  font-weight: 500;
}
.room-code-small {
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--text-muted);
  letter-spacing: 1.5px;
  padding: 3px 8px;
  background: var(--bg);
  border-radius: 4px;
  border: 1px solid var(--border-light);
}
.score-display {
  font-weight: 800;
  font-size: 1rem;
  color: var(--accent);
}
.wrong-counter {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--error);
  font-weight: 800;
  font-size: 0.95rem;
}

/* Timer */
.timer-container { width: 38px; height: 38px; position: relative; }
.timer-svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.timer-bg {
  fill: none;
  stroke: var(--border);
  stroke-width: 3;
}
.timer-fg {
  fill: none;
  stroke: var(--success);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: 100;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 1s linear, stroke 0.5s;
}
.timer-fg.warning { stroke: var(--warning); }
.timer-fg.danger { stroke: var(--error); }
.timer-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.55rem;
  font-weight: 800;
  color: var(--text-muted);
  font-family: 'Consolas', 'Monaco', monospace;
}

/* Clue Banner */
.clue-banner {
  background: linear-gradient(135deg, var(--accent), #0ea5e9);
  color: #0d1117;
  padding: 10px 16px;
  text-align: center;
  z-index: 9;
  flex-shrink: 0;
  animation: slideDown 0.3s ease;
}
@keyframes slideDown {
  from { transform: translateY(-100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.clue-banner-content {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}
.clue-giver { font-size: 0.85rem; font-weight: 600; opacity: 0.8; }
.clue-word {
  font-size: 1.4rem;
  font-weight: 900;
  letter-spacing: 2px;
  text-transform: uppercase;
}

/* Game Board */
.game-board-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
.game-board {
  display: grid;
  gap: 3px;
  width: 100%;
  max-width: 500px;
  aspect-ratio: 1;
}

.board-label {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 2px;
  min-width: 0;
}
.board-label-letter, .board-label-number {
  font-weight: 900;
  font-size: clamp(0.95rem, 3vw, 1.3rem);
  color: var(--accent);
  text-transform: uppercase;
}
.board-label[data-row="a"] .board-label-letter { color: var(--row-a); }
.board-label[data-row="b"] .board-label-letter { color: var(--row-b); }
.board-label[data-row="c"] .board-label-letter { color: var(--row-c); }
.board-label[data-row="d"] .board-label-letter { color: var(--row-d); }
.board-label[data-row="e"] .board-label-letter { color: var(--row-e); }
.board-label-word {
  font-size: clamp(0.5rem, 1.8vw, 0.7rem);
  color: var(--text-muted);
  text-transform: uppercase;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
  letter-spacing: 0.5px;
  line-height: 1.2;
  font-weight: 600;
}

.board-corner { /* empty top-left corner */ }

.board-cell {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: clamp(0.75rem, 2.5vw, 1.05rem);
  color: var(--text-muted);
  min-height: 48px;
  position: relative;
  transition: all 0.25s ease;
  user-select: none;
}
.board-cell.placed {
  background: var(--success-bg);
  border-color: var(--success);
  color: var(--success);
}
.board-cell.placed .cell-coord {
  font-weight: 900;
  font-size: clamp(0.85rem, 2.5vw, 1.15rem);
  letter-spacing: 1px;
}
.board-cell.guessable {
  cursor: pointer;
  border-color: var(--accent);
  border-style: dashed;
  animation: guessGlow 2s infinite;
}
@keyframes guessGlow {
  0%, 100% { box-shadow: 0 0 0 0 var(--accent-glow); }
  50% { box-shadow: 0 0 12px 2px var(--accent-glow); }
}
.board-cell.guessable:hover {
  background: var(--accent-dim);
  transform: scale(1.04);
  border-style: solid;
}
.board-cell.guessable:active { transform: scale(0.96); }

@keyframes correctPulse {
  0% { transform: scale(1); box-shadow: none; }
  50% { transform: scale(1.1); box-shadow: 0 0 20px rgba(34, 197, 94, 0.4); }
  100% { transform: scale(1); box-shadow: none; }
}
.board-cell.just-placed { animation: correctPulse 0.5s ease; }

@keyframes wrongShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-5px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}
.board-cell.wrong-flash {
  animation: wrongShake 0.4s ease;
  border-color: var(--error) !important;
  background: var(--error-bg) !important;
}

/* Clue action area */
.clue-action-area {
  padding: 10px 16px;
  text-align: center;
  flex-shrink: 0;
}
.btn-have-clue {
  padding: 14px 32px;
  font-size: 1rem;
  border-radius: var(--radius-xl);
  animation: cluePulse 2.5s infinite;
}
@keyframes cluePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 107, 129, 0.4); }
  50% { box-shadow: 0 0 0 10px rgba(255, 107, 129, 0); }
}

/* Hand Panel */
.hand-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--hand-height);
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  box-shadow: 0 -8px 32px var(--shadow-strong);
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 20;
  display: flex;
  flex-direction: column;
}
.hand-panel.open { transform: translateY(0); }

.hand-drag-handle {
  display: flex;
  justify-content: center;
  padding: 10px;
  cursor: grab;
  touch-action: none;
}
.drag-bar {
  width: 40px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
}

.hand-content {
  flex: 1;
  overflow-y: auto;
  padding: 0 16px 16px;
}
.hand-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.hand-header h3 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 700;
}
.hand-count {
  background: var(--secondary);
  color: var(--text-inverse);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 800;
}

.hand-cards {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* Coordinate cards with row-based coloring */
.hand-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 12px 16px;
  background: linear-gradient(145deg, var(--accent), #0ea5e9);
  color: #0d1117;
  border-radius: var(--radius);
  font-weight: 900;
  font-size: 1.15rem;
  letter-spacing: 1px;
  min-width: 64px;
  min-height: 52px;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  user-select: none;
  position: relative;
  border: 2px solid transparent;
  box-shadow: 0 2px 8px var(--shadow);
}
.hand-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 16px var(--shadow-strong);
}
.hand-card:active { transform: scale(0.95); }
.hand-card.selected {
  border-color: var(--text-inverse);
  box-shadow: 0 0 0 3px var(--accent-glow), 0 6px 20px var(--shadow-strong);
  transform: translateY(-4px);
}
.hand-card.inactive {
  opacity: 0.4;
  cursor: default;
  pointer-events: none;
  filter: grayscale(0.5);
}

/* Row-based card colors */
.hand-card[data-row="a"] { background: linear-gradient(145deg, #00d4aa, #00b894); }
.hand-card[data-row="b"] { background: linear-gradient(145deg, #3b82f6, #2563eb); }
.hand-card[data-row="c"] { background: linear-gradient(145deg, #a855f7, #9333ea); }
.hand-card[data-row="d"] { background: linear-gradient(145deg, #f59e0b, #d97706); }
.hand-card[data-row="e"] { background: linear-gradient(145deg, #ff6b81, #e05265); }

/* Clue input area in hand panel */
.clue-input-area {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}
.clue-words {
  text-align: center;
  margin-bottom: 14px;
  font-size: 1rem;
  color: var(--text);
  font-weight: 500;
}
.clue-words .word {
  font-weight: 800;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.clue-words .connector { margin: 0 8px; color: var(--text-muted); font-weight: 400; }
.clue-form {
  display: flex;
  gap: 8px;
}
.clue-form input {
  flex: 1;
  min-width: 0;
  padding: 12px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
}
.clue-form .btn { flex-shrink: 0; }
.clue-form input:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-dim);
}

/* Hand toggle button */
.hand-toggle-btn {
  position: fixed;
  bottom: 14px;
  right: 14px;
  z-index: 25;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  background: var(--secondary);
  color: var(--text-inverse);
  border: none;
  border-radius: 28px;
  font-weight: 700;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  box-shadow: 0 4px 16px var(--shadow-strong);
  transition: all 0.2s;
}
.hand-toggle-btn:hover {
  background: var(--secondary-hover);
  transform: translateY(-1px);
}
.hand-toggle-btn:active { transform: scale(0.95); }
.hand-badge {
  background: rgba(255,255,255,0.25);
  padding: 2px 7px;
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: 800;
}

/* ---- Results View ---- */
#results-view { align-items: center; justify-content: center; }
.results-container {
  text-align: center;
  padding: 40px 24px;
  max-width: 420px;
  width: 100%;
}
.results-title {
  font-size: 2rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 8px;
  background: linear-gradient(135deg, var(--accent), #7dd3fc);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.results-rating {
  font-size: 1.1rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 28px;
  line-height: 1.5;
}
.score-big {
  font-size: 3.5rem;
  font-weight: 900;
  color: var(--accent);
  letter-spacing: 2px;
}
.score-label {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 28px;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
}
.results-stats {
  display: flex;
  justify-content: center;
  gap: 40px;
  margin-bottom: 36px;
}
.stat { text-align: center; }
.stat-value {
  display: block;
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text);
}
.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}
.results-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}

/* ---- Overlays ---- */
.overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
[hidden] { display: none !important; }
.overlay-content {
  text-align: center;
  color: var(--text-inverse);
}
.overlay-card {
  background: var(--bg-card);
  color: var(--text);
  padding: 32px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: 0 16px 48px var(--shadow-strong);
  min-width: 300px;
}
.overlay-card h2 {
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 800;
}
.overlay-card p { color: var(--text-muted); margin-bottom: 18px; font-size: 0.9rem; }
.overlay-card input {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
  margin-bottom: 14px;
}
.overlay-card input:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.overlay-card .btn { width: 100%; }

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255,255,255,0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Toasts ---- */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 14px;
  z-index: 50;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--bg-elevated);
  color: var(--text);
  padding: 12px 20px;
  border-radius: var(--radius);
  box-shadow: 0 4px 24px var(--shadow-strong);
  font-size: 0.9rem;
  font-weight: 600;
  max-width: 340px;
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
  pointer-events: auto;
  border-left: 3px solid var(--accent);
}
.toast.error { border-left-color: var(--error); }
.toast.success { border-left-color: var(--success); }
@keyframes toastIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
@keyframes toastOut {
  to { transform: translateX(100%); opacity: 0; }
}

/* ---- Tablet (768px+) ---- */
@media (min-width: 768px) {
  .landing-container { padding: 48px 24px; }
  .logo { font-size: 3rem; }
  .game-board { max-width: 560px; }
  .hand-panel { --hand-height: 350px; }
  .board-cell { min-height: 58px; }
}

/* ---- Desktop (1024px+) ---- */
@media (min-width: 1024px) {
  #game-view { flex-direction: column; }
  .game-board-wrapper { padding: 20px; }
  .game-board { max-width: 620px; }

  .hand-panel {
    position: fixed;
    top: var(--header-height);
    bottom: 0;
    left: auto;
    right: 0;
    width: 300px;
    height: auto;
    border-radius: 0;
    border-top: none;
    border-left: 1px solid var(--border);
    box-shadow: -4px 0 24px var(--shadow);
    transform: translateX(100%);
  }
  .hand-panel.open { transform: translateX(0); }
  .hand-drag-handle { display: none; }

  .hand-toggle-btn {
    bottom: auto;
    top: calc(var(--header-height) + 14px);
    right: 14px;
  }

  .board-cell { min-height: 68px; }
}

/* ---- Utility ---- */
.hidden { display: none !important; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
