/* =========================================
   1. VARIABLES DE TEMA (OSCURO Y CLARO)
   ========================================= */
:root {
  /* Tema Oscuro (Por defecto) */
  --bg-color: #1e2024;
  --text-main: #f0f2f5;
  --text-muted: #9aa0a6;
  --accent: #00f5d4;
  --accent-glow: rgba(0, 245, 212, 0.35);

  /* Acentos Neón */
  --neon-aqua: #00f5d4;
  --neon-yellow: #fee440;
  --neon-green: #00f59b;

  /* Sombras Neumórficas Oscuras */
  --neu-shadow-out: 6px 6px 12px #151619, -6px -6px 12px #272a2f;
  --neu-shadow-in: inset 4px 4px 8px #151619, inset -4px -4px 8px #272a2f;
  --neu-btn-active: inset 3px 3px 6px #151619, inset -3px -3px 6px #272a2f;

  /* Variables Glassmorphism Oscuro */
  --glass-bg: rgba(30, 32, 36, 0.72);
  --glass-border: rgba(255, 255, 255, 0.12);
  --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.45);
}

[data-theme="light"] {
  /* Tema Claro */
  --bg-color: #e6e9ef;
  --text-main: #2d3436;
  --text-muted: #636e72;
  --accent: #00b894;
  --accent-glow: rgba(0, 184, 148, 0.25);

  /* Acentos Neón en Claro */
  --neon-aqua: #00b894;
  --neon-yellow: #e1b12c;
  --neon-green: #00a86b;

  /* Sombras Neumórficas Claras */
  --neu-shadow-out: 6px 6px 12px #c8ccd3, -6px -6px 12px #ffffff;
  --neu-shadow-in: inset 4px 4px 8px #c8ccd3, inset -4px -4px 8px #ffffff;
  --neu-btn-active: inset 3px 3px 6px #c8ccd3, inset -3px -3px 6px #ffffff;

  /* Variables Glassmorphism Claro */
  --glass-bg: rgba(255, 255, 255, 0.68);
  --glass-border: rgba(255, 255, 255, 0.6);
  --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.15);
}

/* =========================================
   2. RESET Y BASE MOBILE-FIRST (ANDROID)
   ========================================= */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

body {
  background-color: var(--bg-color);
  color: var(--text-main);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  transition: background-color 0.3s ease, color 0.3s ease;
  overflow-x: hidden;
  user-select: none;
}

input,
textarea,
select {
  user-select: text;
}

.hidden {
  display: none !important;
}

/* =========================================
   3. COMPONENTES NEUMÓRFICOS Y GLASS
   ========================================= */
.neu-card {
  background: var(--bg-color);
  border-radius: 24px;
  box-shadow: var(--neu-shadow-out);
  padding: 20px;
}

.neu-inset {
  background: var(--bg-color);
  border-radius: 16px;
  box-shadow: var(--neu-shadow-in);
  padding: 12px;
}

.neu-btn {
  background: var(--bg-color);
  color: var(--text-main);
  border: none;
  border-radius: 14px;
  box-shadow: var(--neu-shadow-out);
  padding: 12px 18px;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  touch-action: manipulation;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.neu-btn:active,
.neu-btn.active {
  box-shadow: var(--neu-btn-active);
  color: var(--neon-aqua);
  border-bottom: 2px solid var(--neon-aqua);
}

.primary-btn {
  width: 100%;
  padding: 15px;
  font-size: 1.1rem;
  color: #141722;
  font-weight: 800;
  background: linear-gradient(135deg, var(--neon-aqua), var(--neon-green));
  box-shadow: 0 6px 18px var(--accent-glow);
  margin-top: 10px;
}

.primary-btn:active {
  transform: scale(0.98);
  box-shadow: 0 2px 8px var(--accent-glow);
}

.glass-panel {
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  border-radius: 18px;
}

/* =========================================
   4. BARRA SUPERIOR (HEADER)
   ========================================= */
.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 18px;
  z-index: 10;
}

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

.app-logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  object-fit: cover;
  box-shadow: var(--neu-shadow-out);
}

.brand h1 {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.5px;
}

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

.icon-btn {
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 50%;
  font-size: 1.2rem;
}

/* =========================================
   5. PANTALLA 1: CONFIGURACIÓN DE JUGADORES
   ========================================= */
.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 10px 16px 24px;
  max-width: 540px;
  width: 100%;
  margin: 0 auto;
}

.setup-container h2 {
  text-align: center;
  margin-bottom: 18px;
  font-size: 1.3rem;
}

.control-group {
  margin-bottom: 18px;
}

.control-group label {
  display: block;
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 10px;
  font-weight: 600;
}

.count-selector {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
}

.count-btn {
  padding: 10px 0;
  font-size: 1.05rem;
}

.players-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: 52dvh;
  overflow-y: auto;
  padding: 4px;
  margin-bottom: 14px;
}

.player-config-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.avatar-preview,
.color-preview {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: #fff;
  font-size: 1.1rem;
  box-shadow: var(--neu-shadow-out);
}

.avatar-preview {
  object-fit: cover;
  border: 3px solid transparent;
  background-color: var(--bg-color);
}

.player-details {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.player-name-input {
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 2px solid var(--glass-border);
  color: var(--text-main);
  font-size: 1rem;
  font-weight: 600;
  padding: 4px 2px;
  outline: none;
}

.player-name-input:focus {
  border-bottom-color: var(--neon-aqua);
}

.color-palette {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.color-swatch {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.15s ease;
}

.color-swatch.selected {
  transform: scale(1.25);
  border-color: var(--neon-yellow);
  box-shadow: 0 0 10px var(--neon-yellow);
}

/* =========================================
   6. PANTALLA 2: TABLERO Y CONTROLES
   ========================================= */
#game-screen {
  justify-content: space-between;
  gap: 12px;
}

.game-top-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.game-top-controls #turn-banner {
  flex: 1;
}

#turn-banner {
  padding: 12px 16px;
  text-align: center;
  font-size: 1.05rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.reset-btn {
  width: 46px;
  height: 46px;
  padding: 0;
  border-radius: 16px;
  font-size: 1.35rem;
  flex-shrink: 0;
}

#board-container {
  flex: 1;
  padding: 10px;
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  grid-template-rows: repeat(10, 1fr);
  gap: 4px;
  aspect-ratio: 1 / 1;
  width: 100%;
  max-height: 62dvh;
  margin: 0 auto;
}

.tile {
  position: relative;
  border-radius: 8px;
  background: var(--bg-color);
  box-shadow: inset 2px 2px 4px rgba(0, 0, 0, 0.25),
              inset -2px -2px 4px rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-muted);
}

[data-theme="light"] .tile {
  box-shadow: inset 2px 2px 4px #c8ccd3,
              inset -2px -2px 4px #ffffff;
}

.tile.special-start {
  color: var(--neon-green);
  font-weight: 900;
  text-shadow: 0 0 8px rgba(0, 245, 155, 0.4);
}

.tile.special-end {
  background: linear-gradient(135deg, var(--neon-yellow), #e67e22);
  color: #141722;
  font-weight: 900;
  box-shadow: 0 0 12px rgba(254, 228, 64, 0.55);
}

.tile.strip-tile {
  border: 1px dashed rgba(255, 255, 255, 0.55);
}

[data-theme="light"] .tile.strip-tile {
  border: 1px dashed rgba(0, 0, 0, 0.35);
}

.strip-tag {
  position: absolute;
  bottom: 1px;
  right: 2px;
  font-size: 0.52rem;
  line-height: 1;
}

.tile.active-step {
  outline: 2px solid var(--neon-aqua);
  box-shadow: 0 0 12px var(--accent-glow);
  z-index: 3;
}

/* Zonas de color por tramos (1 a 100) */
.tile.zone-1-20 {
  background-color: rgba(255, 143, 177, 0.22);
  color: #ffd6e3;
}

.tile.zone-21-40 {
  background-color: rgba(255, 183, 107, 0.24);
  color: #ffe5c2;
}

.tile.zone-41-60 {
  background-color: rgba(219, 68, 125, 0.30);
  color: #ffb8d2;
}

.tile.zone-61-80 {
  background-color: rgba(255, 94, 94, 0.34);
  color: #ffc2c2;
}

.tile.zone-81-100 {
  background-color: rgba(214, 24, 42, 0.45);
  color: #ffffff;
}

[data-theme="light"] .tile.zone-1-20 {
  background-color: rgba(255, 143, 177, 0.32);
  color: #6e273d;
}

[data-theme="light"] .tile.zone-21-40 {
  background-color: rgba(255, 179, 92, 0.34);
  color: #6b3b08;
}

[data-theme="light"] .tile.zone-41-60 {
  background-color: rgba(219, 68, 125, 0.38);
  color: #5e112e;
}

[data-theme="light"] .tile.zone-61-80 {
  background-color: rgba(255, 82, 82, 0.42);
  color: #691010;
}

[data-theme="light"] .tile.zone-81-100 {
  background-color: rgba(200, 16, 36, 0.52);
  color: #ffffff;
}

.tokens-wrapper {
  position: absolute;
  inset: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 2px;
  z-index: 2;
}

.player-token {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
  transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  object-fit: cover;
}

/* =========================================
   7. CONTROLES, DADO Y AURA DEL JUGADOR
   ========================================= */
#controls-area,
.controls-dock {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 6px 4px;
  min-height: 112px;
}

.dice-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex: 1;
}

.dice-btn {
  width: 68px;
  height: 68px;
  border-radius: 20px;
  font-size: 2rem;
  font-weight: 900;
  cursor: pointer;
  user-select: none;
}

.dice-btn.rolling {
  animation: rollDice 0.45s ease-in-out infinite;
  color: var(--neon-yellow);
}

.dice-hint {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: 600;
}

.active-player-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  --aura-color: var(--neon-aqua);
}

.active-player-card {
  width: 104px;
  height: 104px;
  border-radius: 22px;
  padding: 8px;
  background: #141722;
  border: 1.5px solid var(--aura-color);
  box-shadow:
    0 0 14px var(--aura-color),
    0 0 32px -4px var(--aura-color),
    inset 0 0 14px rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: visible;
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

.active-player-card::before {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 26px;
  background: radial-gradient(circle, var(--aura-color) 0%, transparent 72%);
  opacity: 0.35;
  filter: blur(10px);
  z-index: -1;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.active-player-card.stepping {
  transform: scale(1.06);
  box-shadow:
    0 0 20px var(--aura-color),
    0 0 42px var(--aura-color),
    inset 0 0 16px rgba(0, 0, 0, 0.85);
}

.active-player-card.stepping::before {
  opacity: 0.6;
  transform: scale(1.08);
}

.active-player-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: transparent;
  border: none;
  position: relative;
  z-index: 2;
  filter:
    drop-shadow(0 0 5px var(--aura-color))
    drop-shadow(0 0 12px var(--aura-color));
}

.active-player-badge {
  width: 68px;
  height: 68px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.45rem;
  font-weight: 900;
  color: #fff;
  box-shadow: 0 0 16px var(--aura-color), 0 0 28px -4px var(--aura-color);
}

.active-player-outside-name {
  font-size: 0.82rem;
  font-weight: 800;
  max-width: 116px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
  text-shadow: 0 0 10px var(--aura-color);
}

/* =========================================
   8. PIZARRA DE RETOS (MODAL GLASSMORPHISM)
   ========================================= */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
  animation: fadeIn 0.25s ease;
}

.glass-board {
  width: 100%;
  max-width: 400px;
  background: var(--glass-bg);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1.5px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  border-radius: 28px;
  padding: 28px 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 18px;
  animation: popUp 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.glass-board h3 {
  font-size: 1.4rem;
  font-weight: 800;
}

.glass-board p {
  font-size: 1.15rem;
  line-height: 1.5;
  padding: 16px;
  border-radius: 16px;
  background: rgba(128, 128, 128, 0.12);
}

.modal-avatar {
  width: 96px;
  height: 96px;
  border-radius: 20px;
  object-fit: cover;
  margin: 0 auto;
  border: 3px solid var(--neon-aqua);
}

/* =========================================
   9. EDITOR DE RETOS, PRENDAS Y CASTIGOS
   ========================================= */
.editor-container {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: 82dvh;
  overflow-y: auto;
}

.editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.editor-header h2 {
  font-size: 1.2rem;
  margin: 0;
}

.small-btn {
  padding: 8px 14px;
  font-size: 0.9rem;
  border-radius: 12px;
}

.tile-nav-row,
.add-punishment-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.neu-select,
.neu-input,
.neu-textarea {
  width: 100%;
  background: var(--bg-color);
  color: var(--text-main);
  border: none;
  border-radius: 14px;
  box-shadow: var(--neu-shadow-in);
  padding: 10px 12px;
  font-size: 0.95rem;
  outline: none;
}

.neu-textarea {
  resize: vertical;
  min-height: 76px;
}

.strip-toggle-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.hint-text {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.toggle-pill {
  min-width: 64px;
  padding: 10px 14px;
  font-weight: 800;
}

.toggle-pill.is-active {
  color: #141722;
  background: linear-gradient(135deg, var(--neon-yellow), #f39c12);
  box-shadow: 0 4px 12px rgba(254, 228, 64, 0.35);
}

.neu-divider {
  border: none;
  height: 2px;
  background: var(--glass-border);
  margin: 4px 0;
}

.punishments-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.punishment-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  box-shadow: var(--neu-shadow-in);
  font-size: 0.9rem;
}

.remove-punishment-btn {
  background: transparent;
  border: none;
  color: #ff5e5e;
  font-weight: 800;
  font-size: 1rem;
  cursor: pointer;
  padding: 2px 6px;
}

.danger-btn {
  width: 100%;
  color: #ff5e5e;
  margin-top: 4px;
}

/* =========================================
   10. PANEL PROGRAMADOR
   ========================================= */
.programmer-panel {
  max-width: 95vw;
  width: 900px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 20px;
  border-radius: 15px;
  text-align: center;
  background-color: var(--bg-color);
  box-shadow: var(--neu-shadow-out);
}

.programmer-hint {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 15px;
}

.programmer-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 1.1rem;
  font-weight: bold;
  margin-bottom: 20px;
  cursor: pointer;
  padding: 12px;
  border-radius: 12px;
  background: var(--bg-color);
  box-shadow: var(--neu-shadow-in);
}

.programmer-toggle input {
  width: 20px;
  height: 20px;
  accent-color: var(--neon-aqua);
}

.programmer-table-wrapper {
  overflow-x: auto;
  margin-bottom: 20px;
  border-radius: 8px;
  box-shadow: var(--neu-shadow-in);
  background: var(--bg-color);
  padding: 10px;
}

#programmer-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  min-width: 600px;
}

#programmer-table th,
#programmer-table td {
  border: 1px solid var(--glass-border);
  padding: 6px 4px;
  text-align: center;
}

#programmer-table th {
  background-color: #4A90E2;
  color: white;
  font-weight: bold;
  position: sticky;
  top: 0;
}

#programmer-table th:first-child {
  background-color: var(--bg-color);
  color: var(--text-main);
  text-align: left;
  padding-left: 10px;
  position: sticky;
  left: 0;
  z-index: 2;
}

#programmer-table td:first-child {
  text-align: left;
  padding-left: 10px;
  font-weight: bold;
  background-color: var(--bg-color);
  position: sticky;
  left: 0;
  z-index: 1;
  white-space: nowrap;
}

.turn-input {
  width: 35px;
  height: 28px;
  text-align: center;
  font-size: 0.95rem;
  font-weight: bold;
  border: 1px solid var(--glass-border);
  border-radius: 6px;
  background: transparent;
  color: var(--text-main);
}

.turn-input:focus {
  outline: 2px solid var(--neon-aqua);
  background: var(--glass-bg);
}

.programmer-actions {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 20px;
}

/* =========================================
   11. ANIMACIONES
   ========================================= */
@keyframes rollDice {
  0% { transform: rotate(0deg) scale(1); }
  25% { transform: rotate(-14deg) scale(1.12); }
  50% { transform: rotate(12deg) scale(0.95); }
  75% { transform: rotate(-8deg) scale(1.1); }
  100% { transform: rotate(0deg) scale(1); }
}

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

@keyframes popUp {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
