/* =====================================================
   SUSSED Online - estilos
   ===================================================== */

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f1729;
  --surface: #16213e;
  --surface-2: #1f2d4f;
  --primary: #ffeb3b;
  --primary-dark: #fdd835;
  --text: #eaeaea;
  --text-dim: #8892b0;
  --error: #ff5252;
  --success: #66bb6a;
  --border: #2a3a5e;
  --radius: 12px;
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  line-height: 1.5;
}

#app {
  width: 100%;
  max-width: 480px;
}

/* Pantalla de juego más ancha */
.game-screen { max-width: 960px; }
#app:has(.game-screen.active) { max-width: 960px; }

/* ----- Pantallas ----- */
.screen {
  display: none;
  background: var(--surface);
  padding: 28px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.screen.active { display: block; }

/* ----- Tipografía ----- */
h1 {
  font-size: 2.5rem;
  text-align: center;
  color: var(--primary);
  letter-spacing: 4px;
  margin-bottom: 4px;
}
h2 { margin-bottom: 16px; font-size: 1.4rem; }
h3 {
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
  margin-bottom: 10px;
}
.subtitle {
  text-align: center;
  color: var(--text-dim);
  margin-bottom: 28px;
  font-size: 0.95rem;
}
.label {
  font-size: 0.8rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
}
.hint {
  color: var(--text-dim);
  font-size: 0.85rem;
  text-align: center;
  margin-top: 8px;
}
.hint.big {
  font-size: 1rem;
  padding: 24px 8px;
}
.error {
  color: var(--error);
  text-align: center;
  min-height: 1.2em;
  margin-top: 12px;
  font-size: 0.9rem;
}

/* ----- Inputs ----- */
input[type="text"] {
  width: 100%;
  padding: 14px 16px;
  margin-bottom: 12px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.15s;
}
input[type="text"]:focus { border-color: var(--primary); }

/* ----- Botones ----- */
button {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.05s, background 0.15s, opacity 0.15s;
}
button:active:not(:disabled) { transform: scale(0.98); }
button:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary {
  background: var(--primary);
  color: #1a1a2e;
  margin-bottom: 8px;
}
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  margin-bottom: 8px;
}
.btn-secondary:hover:not(:disabled) { background: var(--border); }

.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  font-size: 0.85rem;
  padding: 6px 12px;
  width: auto;
  border: 1px solid var(--border);
}
.btn-ghost:hover { color: var(--text); }

/* ----- Divider ----- */
.divider {
  text-align: center;
  margin: 16px 0;
  color: var(--text-dim);
  font-size: 0.85rem;
  position: relative;
}
.divider::before,
.divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: calc(50% - 20px);
  height: 1px;
  background: var(--border);
}
.divider::before { left: 0; }
.divider::after  { right: 0; }

/* =====================================================
   LOBBY
   ===================================================== */

.lobby-header {
  text-align: center;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.room-code {
  font-size: 3rem;
  letter-spacing: 8px;
  color: var(--primary);
  font-weight: 700;
  margin: 4px 0 12px;
}
.lobby-section { margin-bottom: 20px; }
.count {
  background: var(--bg);
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.8rem;
  color: var(--text);
  margin-left: 4px;
}

#player-list { list-style: none; }
#player-list li {
  padding: 12px 14px;
  background: var(--bg);
  margin-bottom: 6px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.95rem;
}
#player-list li.disconnected { opacity: 0.4; }
.crown { color: var(--primary); }

/* Selector de rondas */
.rounds-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.btn-round {
  padding: 12px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  font-weight: 600;
}
.btn-round.active {
  background: var(--primary);
  color: #1a1a2e;
  border-color: var(--primary);
}

/* Visibilidad por rol */
.host-only { display: none; }
body.is-host .host-only { display: block; }
body.is-host .rounds-options { display: grid; }
body.is-host #lobby-hint { display: none; }
body.is-host #finished-hint { display: none; }

/* =====================================================
   GAME
   ===================================================== */

.game-header {
  text-align: center;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.game-meta {
  font-size: 0.85rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
}
.game-meta .separator { margin: 0 8px; }
#reader-label {
  font-size: 1.5rem;
  color: var(--primary);
  margin-bottom: 8px;
}
#phase-hint { margin-top: 4px; }

/* Layout dos columnas en desktop, apilado en móvil */
.game-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
@media (max-width: 720px) {
  .game-layout { grid-template-columns: 1fr; }
}

.card-panel,
.answers-panel {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

/* Lista de preguntas dentro de la carta */
.questions-list {
  list-style: none;
  counter-reset: q;
}
.questions-list > li {
  counter-increment: q;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.questions-list > li:last-child { border-bottom: none; }
.questions-list .question-text {
  font-weight: 600;
  margin-bottom: 8px;
}
.questions-list .question-text::before {
  content: counter(q) ". ";
  color: var(--primary);
  font-weight: 700;
  margin-right: 4px;
}
.options-list {
  list-style: none;
  padding-left: 16px;
}
.options-list li {
  padding: 4px 0;
  color: var(--text-dim);
  font-size: 0.95rem;
}
.options-list strong {
  color: var(--primary);
  display: inline-block;
  width: 18px;
}

/* ----- Tabla de respuestas ----- */
.answers-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 4px;
  margin-bottom: 16px;
}
.answers-table th,
.answers-table td {
  padding: 8px 6px;
  text-align: center;
  font-size: 0.95rem;
}
.answers-table th {
  color: var(--text-dim);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.answers-table td.qlabel,
.answers-table th:first-child {
  text-align: left;
  color: var(--text-dim);
  font-weight: 600;
  font-size: 0.85rem;
}

/* Marking: botones A/B/C */
.answers-table.marking td:not(.qlabel) {
  padding: 0;
}
.pick-btn {
  width: 100%;
  padding: 12px 0;
  background: var(--surface-2);
  color: var(--text-dim);
  border: 1px solid var(--border);
  font-weight: 700;
}
.pick-btn:hover { background: var(--border); color: var(--text); }
.pick-btn.selected {
  background: var(--primary);
  color: #1a1a2e;
  border-color: var(--primary);
}

/* Resolving: tabla con todos los picks */
.answers-table.resolving th.reader-col,
.answers-table.resolving td.reader-col,
.answers-table.resolving td.reader-pick {
  background: rgba(255, 235, 59, 0.08);
  border-radius: 6px;
}
.answers-table.resolving th.reader-col {
  color: var(--primary);
}
.tag {
  font-size: 0.65rem;
  background: var(--primary);
  color: #1a1a2e;
  padding: 1px 6px;
  border-radius: 999px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: lowercase;
}
.reader-pick {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--primary);
}

/* Celdas de adivinanza */
.guess-cell {
  background: var(--surface-2);
  border-radius: 6px;
  position: relative;
  font-weight: 600;
}
.guess-cell.clickable { cursor: pointer; transition: background 0.15s; }
.guess-cell.clickable:hover { background: var(--border); }
.guess-cell .pick { display: block; font-size: 1rem; }
.guess-cell .mark {
  display: block;
  font-size: 1.1rem;
  margin-top: 2px;
  min-height: 1.2em;
}
.guess-cell.correct {
  background: rgba(102, 187, 106, 0.2);
  border: 1px solid var(--success);
}
.guess-cell.correct .mark { color: var(--success); }
.guess-cell.incorrect {
  background: rgba(255, 82, 82, 0.15);
  border: 1px solid var(--error);
}
.guess-cell.incorrect .mark { color: var(--error); }

/* Footer de tabla con puntos */
.answers-table tfoot td {
  border-top: 1px solid var(--border);
  padding-top: 12px;
  font-weight: 700;
}

/* =====================================================
   FINISHED
   ===================================================== */

.final-scores {
  list-style: none;
  margin: 24px 0;
}
.final-scores li {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  background: var(--bg);
  border-radius: var(--radius);
  margin-bottom: 8px;
  border: 1px solid var(--border);
}
.final-scores li.winner {
  background: rgba(255, 235, 59, 0.1);
  border-color: var(--primary);
}
.final-scores .rank {
  font-weight: 700;
  color: var(--text-dim);
  width: 32px;
}
.final-scores li.winner .rank { color: var(--primary); }
.final-scores .name {
  flex: 1;
  font-weight: 600;
}
.final-scores .score {
  color: var(--primary);
  font-weight: 700;
}
