/* ============================================================
   LUDO ONLINE – Dark Theme Stylesheet
   ============================================================ */

/* ---------- Reset & Base ---------- */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background:
    radial-gradient(circle at 15% 10%, rgba(231, 76, 60, 0.14), transparent 40%),
    radial-gradient(circle at 85% 12%, rgba(46, 204, 113, 0.12), transparent 40%),
    radial-gradient(circle at 15% 90%, rgba(241, 196, 15, 0.1), transparent 40%),
    radial-gradient(circle at 85% 88%, rgba(52, 152, 219, 0.14), transparent 40%),
    #0d0f1d fixed;
  color: #eee;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  overflow-x: hidden;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #333; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #555; }

/* ---------- Ludo Colors ---------- */
:root {
  --ludo-red:    #e74c3c;
  --ludo-green:  #2ecc71;
  --ludo-yellow: #f1c40f;
  --ludo-blue:   #3498db;
  --bg-panel:    #1a1a2e;
  --bg-body:     #0f0f1a;
  --cyan:        #00d4ff;
  --cyan-glow:   rgba(0, 212, 255, 0.25);
}

.hidden { display: none !important; }

/* ============================================================
   SHARED BUTTON STYLES
   ============================================================ */
.btn {
  padding: 13px 40px;
  font-size: 17px;
  font-weight: 800;
  border: 2px solid;
  border-radius: 999px;
  cursor: pointer;
  letter-spacing: 1px;
  transition: all 0.2s ease;
  background: transparent;
  color: #eee;
}
.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  filter: grayscale(0.6);
}

.btn-cyan  { color: #fff; border-color: transparent; background: linear-gradient(135deg, #3498db, #00b4d8); box-shadow: 0 5px 0 #1d5f8a, 0 10px 24px rgba(0, 180, 216, 0.3); }
.btn-cyan:hover:not(:disabled) {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.btn-green { color: #fff; border-color: transparent; background: linear-gradient(135deg, #2ecc71, #1fae5c); box-shadow: 0 5px 0 #157a40, 0 10px 24px rgba(46, 204, 113, 0.28); }
.btn-green:hover:not(:disabled) {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.btn-ghost { color: #c9cbe0; border-color: rgba(255, 255, 255, 0.2); background: rgba(255, 255, 255, 0.05); }
.btn-ghost:hover { color: #fff; background: rgba(255, 255, 255, 0.1); }

.offline-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
  margin-bottom: 18px;
}

.offline-actions .btn { min-width: 190px; }
.offline-actions + .divider { margin: 4px 0 16px; }

#offline-setup {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 20px 0;
}

.offline-title {
  font-size: 30px;
  font-weight: 900;
  background: linear-gradient(135deg, var(--ludo-red), var(--ludo-yellow), var(--ludo-green), var(--ludo-blue));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.offline-difficulty {
  width: 100%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 10px 16px;
}

#offline-settings-slot { width: 100%; }
#offline-settings-slot #host-settings { max-width: none; margin-bottom: 0; }
#host-settings.offline .setting-row:has([data-setting="spectatorMode"]) { display: none; }
.offline-back { margin-top: 2px; }

#game-screen.offline #chat-section,
#game-screen.offline .panel-tab[data-tab="chat"] { display: none !important; }

#turn-banner {
  position: fixed;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%) scale(0.6);
  font-size: 40px;
  font-weight: 900;
  letter-spacing: 2px;
  text-shadow: 0 4px 0 rgba(0, 0, 0, 0.35), 0 0 24px rgba(255, 255, 255, 0.35);
  pointer-events: none;
  opacity: 0;
  z-index: 70;
  white-space: nowrap;
}

#turn-banner.show { animation: turn-banner 1.3s cubic-bezier(.2, 1.4, .4, 1) forwards; }

@keyframes turn-banner {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.6); }
  18% { opacity: 1; transform: translate(-50%, -50%) scale(1.05); }
  70% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -60%) scale(1); }
}

.btn-small {
  padding: 5px 14px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid #444;
  border-radius: 4px;
  background: transparent;
  color: #aaa;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-small:hover { border-color: var(--cyan); color: var(--cyan); }

.btn-icon {
  background: none;
  border: 1px solid #444;
  border-radius: 6px;
  color: #aaa;
  font-size: 14px;
  padding: 6px 10px;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-icon:hover { border-color: var(--cyan); color: var(--cyan); }

/* ============================================================
   LOBBY
   ============================================================ */
#lobby {
  text-align: center;
  padding: 50px 24px 40px;
  max-width: 520px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  justify-content: center;
}

/* Title */
.ludo-title {
  font-size: 80px;
  font-weight: 900;
  letter-spacing: 18px;
  background: linear-gradient(135deg, var(--ludo-red), var(--ludo-yellow), var(--ludo-green), var(--ludo-blue));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 6px;
  text-indent: 18px;
}

.subtitle {
  color: #666;
  font-size: 15px;
  letter-spacing: 3px;
  text-transform: uppercase;
  margin-bottom: 30px;
}

/* Lobby Actions */
.lobby-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: 100%;
}

.divider {
  color: #444;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 3px;
}

.join-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

#join-code {
  padding: 12px 16px;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 6px;
  text-transform: uppercase;
  text-align: center;
  width: 180px;
  border: 2px solid #333;
  border-radius: 6px;
  background: #111;
  color: #fff;
  outline: none;
  transition: border-color 0.2s;
}
#join-code:focus { border-color: var(--ludo-green); }
#join-code::placeholder { font-size: 12px; letter-spacing: 1px; color: #555; }

.error { color: #ff4d6d; margin-top: 16px; font-size: 14px; }
.status-msg { color: #888; margin-top: 14px; font-size: 13px; min-height: 20px; }

/* ============================================================
   ROOM LOBBY
   ============================================================ */
#room-lobby {
  text-align: center;
  padding: 50px 24px 40px;
  max-width: 520px;
  width: 100%;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding-top: 60px;
}

/* Room Code */
.room-code-section { margin-bottom: 24px; }
.room-code-label {
  color: #666;
  font-size: 12px;
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.room-code-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}
#room-code {
  display: inline-block;
  font-size: 38px;
  font-weight: 800;
  letter-spacing: 10px;
  color: var(--cyan);
  padding: 10px 28px;
  border: 2px solid var(--cyan);
  border-radius: 8px;
  background: rgba(0, 212, 255, 0.06);
  text-shadow: 0 0 12px var(--cyan-glow);
  text-indent: 10px;
}

/* Player Name */
.name-section {
  margin-bottom: 22px;
  text-align: left;
  width: 100%;
  max-width: 340px;
}
.name-section label {
  display: block;
  font-size: 12px;
  color: #666;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 6px;
}
#player-name {
  width: 100%;
  padding: 10px 14px;
  font-size: 16px;
  font-weight: 600;
  border: 2px solid #2a2a3e;
  border-radius: 6px;
  background: #111;
  color: #fff;
  outline: none;
  transition: border-color 0.2s;
}
#player-name:focus { border-color: var(--cyan); }

/* Player List */
#player-list {
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 22px;
}

.player-slot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg-panel);
  border-radius: 6px;
  border-left: 4px solid #333;
  transition: border-color 0.2s, background 0.2s;
}
.player-slot[data-slot="0"] { border-left-color: var(--ludo-red); }
.player-slot[data-slot="1"] { border-left-color: var(--ludo-green); }
.player-slot[data-slot="2"] { border-left-color: var(--ludo-yellow); }
.player-slot[data-slot="3"] { border-left-color: var(--ludo-blue); }

.player-slot.occupied { background: rgba(255, 255, 255, 0.04); }

.player-color-swatch {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
}
.player-color-swatch[data-color="red"]    { background: var(--ludo-red); }
.player-color-swatch[data-color="green"]  { background: var(--ludo-green); }
.player-color-swatch[data-color="yellow"] { background: var(--ludo-yellow); }
.player-color-swatch[data-color="blue"]   { background: var(--ludo-blue); }

.player-slot-name {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
  color: #ccc;
  text-align: left;
}
.player-slot-name.waiting { color: #555; font-weight: 400; }

.player-host-badge {
  font-size: 16px;
  color: #f1c40f;
  filter: drop-shadow(0 0 4px rgba(241, 196, 15, 0.5));
}

.btn-kick {
  background: none;
  border: 1px solid #555;
  color: #888;
  font-size: 16px;
  line-height: 1;
  width: 26px;
  height: 26px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-kick:hover { border-color: #e74c3c; color: #e74c3c; }

/* Color Picker */
.color-picker-section { margin-bottom: 24px; }
.section-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
  color: #666;
  text-transform: uppercase;
  margin-bottom: 10px;
}

#color-picker {
  display: flex;
  gap: 14px;
  justify-content: center;
}

.color-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  position: relative;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}
.color-btn[data-color="red"]    { background: var(--ludo-red); }
.color-btn[data-color="green"]  { background: var(--ludo-green); }
.color-btn[data-color="yellow"] { background: var(--ludo-yellow); }
.color-btn[data-color="blue"]   { background: var(--ludo-blue); }

.color-btn:hover:not(:disabled) {
  transform: scale(1.15);
  box-shadow: 0 0 16px rgba(255, 255, 255, 0.2);
}
.color-btn.selected {
  border-color: #fff;
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.35);
  transform: scale(1.1);
}
.color-btn:disabled {
  opacity: 0.25;
  cursor: not-allowed;
  transform: none;
}

.color-check {
  color: #fff;
  font-size: 20px;
  font-weight: 700;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  pointer-events: none;
}

/* ============================================================
   HOST SETTINGS
   ============================================================ */
#host-settings {
  width: 100%;
  max-width: 400px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  padding: 18px 20px;
  margin-bottom: 24px;
  text-align: left;
}
#host-settings .section-label { margin-bottom: 14px; text-align: center; }

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}
.setting-row:last-child { border-bottom: none; }

.setting-name {
  font-size: 13px;
  color: #aaa;
  font-weight: 500;
}

.btn-group {
  display: flex;
  gap: 2px;
  background: #111;
  border-radius: 5px;
  overflow: hidden;
}

.btn-opt {
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  border: none;
  background: transparent;
  color: #666;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.btn-opt:hover { color: #bbb; }
.btn-opt.active {
  background: linear-gradient(135deg, #3498db, #00b4d8);
  color: #fff;
  border-radius: 4px;
}

/* Start Button */
.btn-start {
  width: 100%;
  max-width: 340px;
  padding: 16px;
  font-size: 20px;
  letter-spacing: 2px;
  margin-top: 8px;
}

/* ============================================================
   GAME SCREEN
   ============================================================ */
#game-screen {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 10px 16px 20px;
  position: relative;
}

/* ---------- HUD ---------- */
#game-hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  margin-bottom: 12px;
}

#hud-players {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.hud-player {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 6px;
  border: 2px solid transparent;
  background: rgba(255, 255, 255, 0.03);
  transition: all 0.3s ease;
  font-size: 13px;
}
.hud-player.active-turn {
  border-color: var(--cyan);
  background: rgba(0, 212, 255, 0.08);
  box-shadow: 0 0 10px var(--cyan-glow);
}
.hud-player[data-color="red"]    .hud-swatch { background: var(--ludo-red); }
.hud-player[data-color="green"]  .hud-swatch { background: var(--ludo-green); }
.hud-player[data-color="yellow"] .hud-swatch { background: var(--ludo-yellow); }
.hud-player[data-color="blue"]   .hud-swatch { background: var(--ludo-blue); }

.hud-swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.hud-name {
  font-weight: 700;
  color: #ddd;
}

.hud-tokens {
  color: #777;
  font-size: 11px;
  white-space: nowrap;
}

/* Turn Timer */
#hud-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

#turn-timer {
  position: relative;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.timer-ring {
  width: 40px;
  height: 40px;
  transform: rotate(-90deg);
}
.timer-bg {
  fill: none;
  stroke: #222;
  stroke-width: 3;
}
.timer-fg {
  fill: none;
  stroke: var(--cyan);
  stroke-width: 3;
  stroke-dasharray: 100;
  stroke-dashoffset: 0;
  stroke-linecap: round;
  transition: stroke-dashoffset 1s linear, stroke 0.3s;
}
.timer-fg.urgent { stroke: var(--ludo-red); }

#timer-text {
  position: absolute;
  font-size: 12px;
  font-weight: 800;
  color: #ddd;
}

/* ---------- Game Area ---------- */
#game-area {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

#board-wrap {
  flex-shrink: 0;
  border-radius: 16px;
  overflow: hidden;
  border: 6px solid #6b4a2f;
  background: #111;
  line-height: 0;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5), inset 0 0 0 2px rgba(255, 255, 255, 0.15);
}

#boardCanvas {
  display: block;
  width: 600px;
  height: 600px;
  max-width: 100%;
  touch-action: none;
}

/* ---------- Side Panel ---------- */
#side-panel {
  flex: 1;
  min-width: 260px;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 620px;
}

.panel-section {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  padding: 14px;
}

/* Dice */
#dice-section { text-align: center; }

#dice-area {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 10px 0 14px;
}

#dice-display {
  width: 80px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, #ffffff, #e6e3dc);
  border-radius: 18px;
  border: 0;
  box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.12), inset 0 3px 0 rgba(255, 255, 255, 0.9), 0 8px 18px rgba(0, 0, 0, 0.4);
  transition: transform 0.15s;
}
#dice-display.rolling {
  animation: dice-shake 0.12s ease infinite;
}

#dice-face {
  font-size: 36px;
  font-weight: 900;
  color: #2b2f45;
  line-height: 1;
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#dice-face[data-v] {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  align-items: stretch;
  justify-items: stretch;
  padding: 7px;
  gap: 3px;
}

#dice-face i {
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #4a4f6a, #1c1f30);
  visibility: hidden;
}

#dice-face[data-v="1"] i:nth-child(5) { visibility: visible; background: radial-gradient(circle at 35% 35%, #ff7b6b, #c0392b); transform: scale(1.35); }
#dice-face[data-v="2"] i:nth-child(1), #dice-face[data-v="2"] i:nth-child(9),
#dice-face[data-v="3"] i:nth-child(1), #dice-face[data-v="3"] i:nth-child(5), #dice-face[data-v="3"] i:nth-child(9),
#dice-face[data-v="4"] i:nth-child(1), #dice-face[data-v="4"] i:nth-child(3), #dice-face[data-v="4"] i:nth-child(7), #dice-face[data-v="4"] i:nth-child(9),
#dice-face[data-v="5"] i:nth-child(1), #dice-face[data-v="5"] i:nth-child(3), #dice-face[data-v="5"] i:nth-child(5), #dice-face[data-v="5"] i:nth-child(7), #dice-face[data-v="5"] i:nth-child(9),
#dice-face[data-v="6"] i:nth-child(1), #dice-face[data-v="6"] i:nth-child(3), #dice-face[data-v="6"] i:nth-child(4), #dice-face[data-v="6"] i:nth-child(6), #dice-face[data-v="6"] i:nth-child(7), #dice-face[data-v="6"] i:nth-child(9) { visibility: visible; }

#dice-face.dice-landed { animation: dice-land 0.3s cubic-bezier(.2, 1.6, .4, 1); }

@keyframes dice-land {
  40% { transform: scale(1.18); }
  100% { transform: scale(1); }
}

@keyframes dice-shake {
  0%, 100% { transform: rotate(0deg) scale(1); }
  25%  { transform: rotate(-8deg) scale(1.04); }
  50%  { transform: rotate(6deg) scale(0.97); }
  75%  { transform: rotate(-4deg) scale(1.02); }
}

.btn-roll {
  width: 100%;
  padding: 12px;
  font-size: 16px;
  margin-bottom: 8px;
}

.toggle-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 12px;
  color: #777;
  cursor: pointer;
}
.toggle-hint input[type="checkbox"] {
  accent-color: var(--cyan);
  width: 14px;
  height: 14px;
  cursor: pointer;
}

/* Game Log */
#log-section { flex: 1; display: flex; flex-direction: column; min-height: 0; }
#game-log {
  flex: 1;
  overflow-y: auto;
  max-height: 140px;
  font-family: 'Courier New', Courier, monospace;
  font-size: 11px;
  line-height: 1.6;
  color: #888;
  padding: 4px 0;
}
#game-log .log-entry {
  padding: 2px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}
#game-log .log-entry[data-color="red"]    .log-player { color: var(--ludo-red); }
#game-log .log-entry[data-color="green"]  .log-player { color: var(--ludo-green); }
#game-log .log-entry[data-color="yellow"] .log-player { color: var(--ludo-yellow); }
#game-log .log-entry[data-color="blue"]   .log-player { color: var(--ludo-blue); }

/* Chat */
#chat-section { display: flex; flex-direction: column; min-height: 0; }

#chat-messages {
  flex: 1;
  overflow-y: auto;
  max-height: 150px;
  min-height: 80px;
  padding: 4px 0;
  margin-bottom: 8px;
}

.chat-msg {
  padding: 4px 0;
  font-size: 12px;
  line-height: 1.5;
  color: #aaa;
  word-break: break-word;
}
.chat-msg .chat-author {
  font-weight: 700;
}
.chat-msg .chat-author[data-color="red"]    { color: var(--ludo-red); }
.chat-msg .chat-author[data-color="green"]  { color: var(--ludo-green); }
.chat-msg .chat-author[data-color="yellow"] { color: var(--ludo-yellow); }
.chat-msg .chat-author[data-color="blue"]   { color: var(--ludo-blue); }

.chat-msg.system-msg { color: #555; font-style: italic; font-size: 11px; }

.chat-input-row {
  display: flex;
  gap: 6px;
}

#chat-input {
  flex: 1;
  padding: 8px 10px;
  font-size: 13px;
  border: 1px solid #2a2a3e;
  border-radius: 6px;
  background: #111;
  color: #eee;
  outline: none;
  transition: border-color 0.2s;
}
#chat-input:focus { border-color: var(--cyan); }

/* Emoji Bar */
#emoji-bar {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-top: 10px;
  flex-wrap: wrap;
}

.emoji-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid #2a2a3e;
  background: rgba(255, 255, 255, 0.03);
  font-size: 18px;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.emoji-btn:hover {
  transform: scale(1.25);
  border-color: #555;
  background: rgba(255, 255, 255, 0.08);
}
.emoji-btn:active { transform: scale(0.95); }

/* ============================================================
   GAME OVERLAY
   ============================================================ */
#game-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: rgba(15, 15, 26, 0.88);
  z-index: 80;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

#overlay-title {
  font-size: 48px;
  font-weight: 900;
  letter-spacing: 4px;
  margin-bottom: 12px;
  text-align: center;
}
#overlay-title.win { color: var(--ludo-green); text-shadow: 0 0 20px rgba(46, 204, 113, 0.4); }
#overlay-title.lose { color: var(--ludo-red); }
#overlay-title.paused { color: var(--ludo-yellow); }

#overlay-msg {
  font-size: 17px;
  color: #888;
  margin-bottom: 28px;
  text-align: center;
  max-width: 400px;
  line-height: 1.5;
}

#overlay-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

/* ============================================================
   RECONNECT BANNER
   ============================================================ */
#reconnect-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  padding: 10px 20px;
  background: #f1c40f;
  color: #1a1a2e;
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transform: translateY(100%);
  animation: slide-in-up 0.3s ease forwards;
}
#reconnect-banner.hidden {
  display: none !important;
  animation: none;
}

@keyframes slide-in-up {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

.reconnect-spinner {
  width: 16px;
  height: 16px;
  border: 3px solid rgba(26, 26, 46, 0.25);
  border-top-color: #1a1a2e;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============================================================
   MOBILE TABS (side panel)
   ============================================================ */
#panel-tabs {
  display: none; /* shown via media query */
  gap: 2px;
  background: #111;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 8px;
}

.panel-tab {
  flex: 1;
  padding: 8px 0;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1px;
  border: none;
  background: transparent;
  color: #666;
  cursor: pointer;
  transition: all 0.15s;
}
.panel-tab:hover { color: #aaa; }
.panel-tab.active {
  background: linear-gradient(135deg, #3498db, #00b4d8);
  color: #fff;
  border-radius: 6px;
}

.mobile-only { display: none; }

/* ============================================================
   RESPONSIVE — Tablet / Small Desktop
   ============================================================ */
@media (max-width: 960px) {
  #side-panel { max-width: 280px; min-width: 240px; }
}

/* ============================================================
   RESPONSIVE — Mobile (< 768px)
   ============================================================ */
@media (max-width: 768px) {
  body { align-items: flex-start; }

  #game-screen { padding: 8px 8px 16px; }

  #game-hud { flex-wrap: wrap; gap: 6px; padding: 8px 10px; }
  #hud-players { gap: 4px; }
  .hud-player { padding: 4px 8px; font-size: 11px; }
  .hud-tokens { display: none; }

  #game-area {
    flex-direction: column;
    align-items: center;
  }

  #board-wrap { width: 100%; max-width: 500px; }
  #boardCanvas { width: 100%; height: auto; }

  #side-panel {
    max-width: 100%;
    width: 100%;
    max-height: none;
  }

  /* Tabs visible */
  .mobile-only { display: flex; }
  #panel-tabs { display: flex; }

  /* Tab content: only active tab shown */
  #side-panel .panel-section[data-tab-content] { display: none; }
  #side-panel .panel-section[data-tab-content].active { display: block; }
  #side-panel #dice-section.active { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; align-items: center; column-gap: 14px; padding: 10px 14px; }
  #dice-section #dice-area { grid-row: 1 / span 2; padding: 0; }
  #dice-section .btn-roll { margin-bottom: 4px; }
  /* Default: dice visible */
  #dice-section { display: block; }
  #dice-section.tab-active { display: block; }
}

/* ============================================================
   RESPONSIVE — Small Phone (< 500px)
   ============================================================ */
@media (max-width: 500px) {
  #lobby { padding: 36px 14px 24px; }
  .ludo-title { font-size: 52px; letter-spacing: 10px; text-indent: 10px; }
  .subtitle { font-size: 12px; letter-spacing: 2px; margin-bottom: 20px; }

  .btn { padding: 11px 28px; font-size: 15px; }

  #room-code { font-size: 28px; letter-spacing: 8px; padding: 8px 18px; }

  #player-list { max-width: 100%; }
  .player-slot { padding: 8px 10px; }

  #host-settings { padding: 14px 12px; }
  .setting-name { font-size: 12px; }
  .btn-opt { padding: 4px 8px; font-size: 11px; }

  .btn-start { font-size: 17px; padding: 14px; }

  #board-wrap { border-width: 1px; border-radius: 6px; }

  .hud-player { padding: 3px 6px; font-size: 10px; gap: 4px; }
  .hud-name { font-size: 10px; }

  #dice-display { width: 64px; height: 64px; border-radius: 14px; }
  #dice-face { font-size: 30px; width: 52px; height: 52px; }
  #dice-face[data-v] { padding: 5px; gap: 2px; }
  .offline-actions .btn { min-width: 0; flex: 1; }
  #turn-banner { font-size: 30px; }

  .emoji-btn { width: 32px; height: 32px; font-size: 16px; }

  #overlay-title { font-size: 32px; }
  #overlay-msg { font-size: 14px; }
}

.how-to { max-width: 370px; text-align: left; margin: 0 auto 32px; padding: 14px 18px; background: rgba(255,255,255,0.04); border-radius: 8px; font-size: 13px; line-height: 1.7; color: #aaa; }
.how-to-title { font-size: 11px; font-weight: 700; letter-spacing: 2px; color: #666; margin-bottom: 8px; text-transform: uppercase; }

[data-theme="light"] html,
[data-theme="light"] body { background: var(--gp-page-grad) fixed; color: var(--gp-ink); }
[data-theme="light"] ::-webkit-scrollbar-thumb { background: #c9c5dd; }
[data-theme="light"] .btn { color: var(--gp-ink); }
[data-theme="light"] .btn-small, [data-theme="light"] .btn-icon, [data-theme="light"] .status-msg, [data-theme="light"] .setting-name, [data-theme="light"] .btn-kick, [data-theme="light"] #game-log, [data-theme="light"] .chat-msg, [data-theme="light"] #overlay-msg { color: var(--gp-ink-2); }
[data-theme="light"] #join-code, [data-theme="light"] #player-name, [data-theme="light"] #chat-input { background: var(--gp-surface); color: var(--gp-ink); border-color: var(--gp-line); }
[data-theme="light"] .player-slot-name, [data-theme="light"] .hud-name, [data-theme="light"] #timer-text { color: var(--gp-ink); }
[data-theme="light"] .player-host-badge { color: #b7791f; }
[data-theme="light"] .btn-group, [data-theme="light"] #panel-tabs { background: var(--gp-surface-2); }
[data-theme="light"] .btn-opt:hover, [data-theme="light"] .panel-tab:hover { color: var(--gp-ink); }
[data-theme="light"] #dice-display { box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.1), inset 0 3px 0 rgba(255, 255, 255, 0.9), 0 6px 14px rgba(60, 50, 120, 0.22); }
[data-theme="light"] #dice-face { color: var(--gp-ink); }
[data-theme="light"] .btn-cyan, [data-theme="light"] .btn-green { color: #fff; }
[data-theme="light"] .btn-ghost { color: var(--gp-ink-2); background: var(--gp-surface); border-color: var(--gp-line); }
[data-theme="light"] .offline-difficulty, [data-theme="light"] #host-settings, [data-theme="light"] .panel-section, [data-theme="light"] #game-hud { background: var(--gp-surface); border-color: var(--gp-line); }
[data-theme="light"] #game-overlay { background: var(--gp-overlay); color: var(--gp-ink); }
[data-theme="light"] .chat-name, [data-theme="light"] #overlay-title { filter: brightness(0.72) saturate(1.3); }
[data-theme="light"] .how-to { background: rgba(31, 27, 69, 0.05); color: var(--gp-ink-2); }
[data-theme="light"] .how-to-title { color: var(--gp-ink-3); }

.gp-btn-music.off { opacity: .4; }

@media (max-width: 768px) and (orientation: portrait) {
  #board-wrap { width: auto; max-width: none; }
  #boardCanvas {
    width: min(calc(100vw - 28px), calc(100vh - var(--gp-header-h, 48px) - 205px), 500px);
    width: min(calc(100vw - 28px), calc(100dvh - var(--gp-header-h, 48px) - 205px), 500px);
    height: auto;
  }
}

@media (orientation: landscape) and (max-height: 500px) {
  #game-screen { padding: 4px 8px 8px; }
  #game-hud { padding: 4px 8px; margin-bottom: 6px; flex-wrap: nowrap; }
  .hud-player { padding: 2px 6px; font-size: 11px; }
  .hud-tokens { display: none; }
  #game-area { flex-direction: row; align-items: flex-start; justify-content: center; gap: 10px; }
  #board-wrap { width: auto; max-width: none; border-width: 3px; }
  #boardCanvas {
    width: calc(100vh - var(--gp-header-h, 48px) - 66px);
    height: calc(100vh - var(--gp-header-h, 48px) - 66px);
    width: calc(100dvh - var(--gp-header-h, 48px) - 66px);
    height: calc(100dvh - var(--gp-header-h, 48px) - 66px);
  }
  #side-panel { width: 240px; min-width: 200px; max-width: 260px; max-height: none; gap: 8px; }
  #side-panel #dice-section.active { display: block; }
  #dice-area { padding: 4px 0 8px; }
  #dice-display { width: 56px; height: 56px; border-radius: 12px; }
  #dice-face { width: 46px; height: 46px; font-size: 26px; }
  #dice-face[data-v] { padding: 4px; gap: 2px; }
  .btn-roll { padding: 9px; font-size: 14px; }
  #game-log { max-height: 70px; }
}
