/* ============================================================
   YAHTZEE — JUEGO CLÁSICO DE DADOS · ESTILOS OFICIALES
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Bebas+Neue&family=Outfit:wght@300;400;500;600;700;800&display=swap');

:root {
  --primary-color: #d63031;
  --primary-hover: #b71540;
  --secondary-color: #0984e3;
  --accent-color: #f1c40f;
  --accent-glow: rgba(241, 196, 15, 0.4);
  --success-color: #00b894;
  --danger-color: #d63031;
  --bg-dark: #0c1022;
  --card-bg: rgba(18, 24, 48, 0.85);
  --card-border: rgba(255, 255, 255, 0.12);
  --text-main: #f5f6fa;
  --text-muted: rgba(245, 246, 250, 0.65);
  --font-display: 'Bebas Neue', sans-serif;
  --font-body: 'Outfit', 'Segoe UI', sans-serif;
}

body.theme-yahtzee {
  font-family: var(--font-body);
  color: var(--text-main);
  min-height: 100vh;
  margin: 0;
  padding: 15px;
  background:
    radial-gradient(ellipse 70% 50% at 20% 10%, rgba(214, 48, 49, 0.22) 0%, transparent 60%),
    radial-gradient(ellipse 65% 50% at 80% 85%, rgba(9, 132, 227, 0.2) 0%, transparent 60%),
    radial-gradient(ellipse 40% 40% at 50% 50%, rgba(241, 196, 15, 0.08) 0%, transparent 70%),
    linear-gradient(160deg, #090d1c 0%, #0c1022 50%, #11172f 100%) !important;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
}

/* ── HEADER ─────────────────────────────────────────── */
.app-header {
  border-radius: 18px;
  overflow: hidden;
  margin-bottom: 20px;
  min-height: 110px;
  position: relative;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.08);
  background: linear-gradient(135deg, rgba(214, 48, 49, 0.9), rgba(183, 21, 64, 0.95));
}

.header-bg-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.15;
  mix-blend-mode: overlay;
}

.header-content {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 24px;
  flex-wrap: wrap;
  gap: 15px;
}

.header-left h1 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 3rem);
  letter-spacing: 0.05em;
  margin: 0;
  color: #fff;
  text-shadow: 0 2px 10px rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-left .subtitle {
  margin: 4px 0 0 0;
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.85);
  font-weight: 400;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-header {
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 0.9rem;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
  cursor: pointer;
}

.btn-header:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-2px);
  color: #fff;
}

/* ── CONFIG SECTION ─────────────────────────────────── */
.card-section {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: 20px;
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.card-title {
  font-family: var(--font-display);
  font-size: 1.8rem;
  letter-spacing: 0.04em;
  color: var(--accent-color);
  margin: 0 0 16px 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.config-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin-bottom: 20px;
}

.config-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.config-group label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.players-count-selector {
  display: flex;
  gap: 8px;
}

.btn-player-count {
  flex: 1;
  padding: 10px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-player-count.active {
  background: var(--primary-color);
  border-color: #ff7675;
  box-shadow: 0 0 15px rgba(214, 48, 49, 0.5);
  transform: translateY(-2px);
}

.players-names-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 15px;
}

.player-name-input-group {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 6px 12px;
  gap: 10px;
}

.player-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.9rem;
  color: #fff;
}

.player-name-input {
  background: transparent;
  border: none;
  color: #fff;
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 600;
  width: 100%;
  outline: none;
}

.start-actions {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-top: 24px;
}

.btn-start {
  background: linear-gradient(135deg, #00b894, #00cec9);
  color: #fff;
  border: none;
  border-radius: 14px;
  padding: 14px 32px;
  font-family: var(--font-display);
  font-size: 1.5rem;
  letter-spacing: 0.05em;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0, 184, 148, 0.4);
  transition: all 0.25s;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.btn-start:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 10px 25px rgba(0, 184, 148, 0.6);
}

/* ── GAME PLAY AREA ─────────────────────────────────── */
.game-play-area {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

/* Status Bar */
.turn-status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--card-border);
  backdrop-filter: blur(12px);
  border-radius: 16px;
  padding: 14px 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.active-player-badge {
  display: flex;
  align-items: center;
  gap: 12px;
}

.active-player-badge .avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  font-weight: 800;
  color: #fff;
  box-shadow: 0 0 15px rgba(255, 255, 255, 0.3);
}

.active-player-badge .info {
  display: flex;
  flex-direction: column;
}

.active-player-badge .name {
  font-size: 1.3rem;
  font-weight: 800;
  color: #fff;
}

.active-player-badge .meta {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.turn-counters {
  display: flex;
  align-items: center;
  gap: 18px;
}

.counter-pill {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 8px 16px;
  text-align: center;
}

.counter-pill .label {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  display: block;
}

.counter-pill .val {
  font-family: var(--font-display);
  font-size: 1.6rem;
  color: var(--accent-color);
  line-height: 1.1;
}

/* ── DADOS (DICE TABLE) ─────────────────────────────── */
.dice-board {
  background: radial-gradient(circle at 50% 50%, rgba(20, 60, 40, 0.8) 0%, rgba(10, 30, 20, 0.95) 100%);
  border: 4px solid #5a3d28;
  border-radius: 24px;
  padding: 24px 16px;
  box-shadow: inset 0 0 40px rgba(0,0,0,0.8), 0 12px 36px rgba(0,0,0,0.6);
  text-align: center;
  position: relative;
}

.dice-board-hint {
  font-size: 0.88rem;
  color: rgba(255, 255, 255, 0.7);
  margin-bottom: 18px;
}

.dice-container {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  min-height: 100px;
  margin-bottom: 24px;
}

/* ── DIE ITEM ───────────────────────────────────────── */
.die {
  width: 76px;
  height: 76px;
  background: linear-gradient(145deg, #ffffff, #e6e6e6);
  border-radius: 16px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  padding: 8px;
  box-shadow:
    0 8px 20px rgba(0, 0, 0, 0.45),
    inset 0 3px 2px rgba(255, 255, 255, 0.9),
    inset 0 -3px 4px rgba(0, 0, 0, 0.15);
  cursor: pointer;
  position: relative;
  transition: transform 0.22s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.22s, border-color 0.22s;
  border: 3px solid #dcdde1;
  user-select: none;
}

.die:hover:not(.disabled) {
  transform: translateY(-4px) scale(1.05);
}

.die.held {
  border-color: #f1c40f;
  background: linear-gradient(145deg, #fffef0, #fcf3cf);
  box-shadow:
    0 0 20px rgba(241, 196, 15, 0.7),
    0 10px 24px rgba(0, 0, 0, 0.45);
  transform: translateY(-8px);
}

.die.held::after {
  content: 'FIJADO';
  position: absolute;
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
  background: #f1c40f;
  color: #111;
  font-size: 0.65rem;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.05em;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}

/* PIPS */
.pip {
  width: 13px;
  height: 13px;
  background-color: #2d3436;
  border-radius: 50%;
  box-shadow: inset 0 2px 2px rgba(0, 0, 0, 0.7);
  justify-self: center;
  align-self: center;
}

.pip.pip-tl { grid-column: 1; grid-row: 1; }
.pip.pip-tr { grid-column: 3; grid-row: 1; }
.pip.pip-ml { grid-column: 1; grid-row: 2; }
.pip.pip-mc { grid-column: 2; grid-row: 2; }
.pip.pip-mr { grid-column: 3; grid-row: 2; }
.pip.pip-bl { grid-column: 1; grid-row: 3; }
.pip.pip-br { grid-column: 3; grid-row: 3; }

/* Centro rojo para el 1 */
.die[data-value="1"] .pip {
  width: 18px;
  height: 18px;
  background-color: #d63031;
}

/* Animación de rodar dados */
@keyframes diceRollAnimation {
  0%   { transform: rotate(0deg) scale(0.9); }
  25%  { transform: rotate(-25deg) scale(1.18); }
  50%  { transform: rotate(20deg) scale(0.92); }
  75%  { transform: rotate(-10deg) scale(1.06); }
  100% { transform: rotate(0deg) scale(1); }
}

.die.rolling {
  animation: diceRollAnimation 0.5s ease-out;
}

/* Botones de acción de dados */
.dice-actions {
  display: flex;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
}

.btn-roll {
  background: linear-gradient(135deg, #d63031, #b71540);
  color: #fff;
  border: none;
  border-radius: 14px;
  padding: 14px 32px;
  font-family: var(--font-display);
  font-size: 1.5rem;
  letter-spacing: 0.05em;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(214, 48, 49, 0.45);
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.btn-roll:hover:not(:disabled) {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 8px 25px rgba(214, 48, 49, 0.6);
}

.btn-roll:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.btn-secondary-action {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  padding: 10px 18px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-secondary-action:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.2);
}

/* ── SCORECARD TABLE ────────────────────────────────── */
.scorecard-wrapper {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: 20px;
  padding: 20px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  overflow-x: auto;
}

.scorecard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 10px;
}

.scorecard-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 450px;
}

.scorecard-table th,
.scorecard-table td {
  padding: 10px 14px;
  text-align: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.scorecard-table th:first-child,
.scorecard-table td:first-child {
  text-align: left;
  position: sticky;
  left: 0;
  background: rgba(18, 24, 48, 0.95);
  z-index: 2;
  font-weight: 600;
  min-width: 180px;
}

.scorecard-table th {
  font-family: var(--font-display);
  font-size: 1.25rem;
  letter-spacing: 0.04em;
  color: #fff;
  background: rgba(0, 0, 0, 0.35);
  border-bottom: 2px solid rgba(255, 255, 255, 0.15);
}

.scorecard-table th.active-player-col {
  background: rgba(214, 48, 49, 0.25);
  color: var(--accent-color);
  border-bottom: 2px solid var(--accent-color);
}

.scorecard-table td.active-player-col {
  background: rgba(214, 48, 49, 0.08);
}

/* Filas de sección */
.section-row td {
  background: rgba(255, 255, 255, 0.05);
  font-family: var(--font-display);
  font-size: 1.15rem;
  color: var(--accent-color);
  letter-spacing: 0.05em;
  padding: 12px 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
}

.subtotal-row td,
.bonus-row td,
.total-row td {
  font-weight: 700;
  background: rgba(255, 255, 255, 0.03);
}

.grand-total-row td {
  font-family: var(--font-display);
  font-size: 1.5rem;
  color: #fff;
  background: linear-gradient(90deg, rgba(214, 48, 49, 0.3), rgba(241, 196, 15, 0.3));
  border-top: 2px solid var(--accent-color);
  border-bottom: 2px solid var(--accent-color);
  padding: 14px;
}

/* Casillas de puntuación */
.score-cell {
  position: relative;
  font-weight: 700;
  font-size: 1.05rem;
  transition: all 0.2s;
}

.score-cell.scored {
  color: #fff;
}

.score-cell.zero {
  color: rgba(255, 255, 255, 0.35);
}

/* Casilla disponible para anotar */
.score-cell.selectable {
  cursor: pointer;
  background: rgba(46, 204, 113, 0.15) !important;
  color: #2ecc71;
  font-weight: 800;
  border: 1px dashed rgba(46, 204, 113, 0.4);
  border-radius: 8px;
}

.score-cell.selectable:hover {
  background: rgba(46, 204, 113, 0.35) !important;
  color: #fff;
  transform: scale(1.05);
  box-shadow: 0 0 12px rgba(46, 204, 113, 0.5);
}

.score-cell.selectable.potential-zero {
  color: rgba(241, 196, 15, 0.7);
  background: rgba(241, 196, 15, 0.1) !important;
  border-color: rgba(241, 196, 15, 0.3);
}

.category-desc {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 400;
  margin-top: 2px;
}

/* ── MODAL WINNER / PODIUM ──────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-content {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 24px;
  padding: 30px;
  max-width: 500px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7);
  animation: modalPop 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes modalPop {
  0% { transform: scale(0.8); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.winner-crown {
  font-size: 3.5rem;
  color: var(--accent-color);
  margin-bottom: 10px;
  animation: bounce 1.5s infinite;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.winner-name {
  font-family: var(--font-display);
  font-size: 2.5rem;
  color: #fff;
  margin: 0;
  text-shadow: 0 0 20px var(--accent-glow);
}

.podium-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 24px 0;
}

.podium-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.05);
  padding: 12px 18px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.podium-item.first {
  background: linear-gradient(90deg, rgba(241, 196, 15, 0.2), rgba(255, 255, 255, 0.05));
  border-color: #f1c40f;
}

.podium-item .rank {
  font-weight: 800;
  font-size: 1.2rem;
  width: 30px;
}

.podium-item .name {
  font-weight: 600;
  flex: 1;
  text-align: left;
  margin-left: 10px;
}

.podium-item .score {
  font-family: var(--font-display);
  font-size: 1.5rem;
  color: var(--accent-color);
}

/* Responsividad */
@media (max-width: 768px) {
  .die {
    width: 60px;
    height: 60px;
    padding: 6px;
  }
  .pip {
    width: 10px;
    height: 10px;
  }
  .die[data-value="1"] .pip {
    width: 14px;
    height: 14px;
  }
  .header-content {
    flex-direction: column;
    text-align: center;
  }
}
