:root {
  --ink: #100f0c;
  --paper: #f3ecdf;
  --muted: #8f897c;
  --line: rgba(243, 236, 223, 0.16);
  --amber: #e2a122;
  --amber-ink: #1a1406;
  --red: #ff5a4a;
  --card: #1b1914;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--ink);
  color: var(--paper);
}

body {
  width: min(100%, 32rem);
  margin: 0 auto;
  min-height: 100dvh;
  font-family: "Avenir Next", "Segoe UI", system-ui, sans-serif;
  font-size: 18px;
  line-height: 1.35;
  -webkit-tap-highlight-color: transparent;
}

main {
  width: 100%;
  min-height: 100dvh;
  margin: 0;
  padding:
    max(16px, env(safe-area-inset-top))
    16px
    max(24px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 16px;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
}

button, input { font: inherit; }

button {
  appearance: none;
  width: 100%;
  border: 0;
  background: var(--amber);
  color: var(--amber-ink);
  min-height: 56px;
  padding: 0 16px;
  border-radius: 14px;
  font-weight: 650;
  touch-action: manipulation;
}

button.secundario,
#qr-btn,
button.texto {
  background: transparent;
  color: var(--paper);
  border: 1px solid var(--line);
  font-weight: 550;
}

#qr-btn {
  min-height: 40px;
  width: auto;
}

button.texto {
  min-height: 44px;
}

button.elegido {
  background: var(--paper);
  color: var(--ink);
  border-color: transparent;
}

button:disabled { opacity: 0.45; }
button.elegido:disabled { opacity: 1; }
#listo:disabled {
  opacity: 1;
  background: var(--card);
  color: var(--paper);
}

button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 3px;
}

input {
  width: 100%;
  min-height: 56px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--paper);
  padding: 0 16px;
  font-size: 16px;
}

.marca {
  margin: 0;
  color: var(--muted);
  font-size: 0.74rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.codigo {
  margin: 4px 0 0;
  font-size: 1.05rem;
  letter-spacing: 0.14em;
}

#cuerpo {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.pila {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 100%;
  flex: 1;
}

h1, .frase, .pregunta, .resultado {
  font-family: "Iowan Old Style", Palatino, "Palatino Linotype", Georgia, serif;
  font-weight: 600;
  letter-spacing: 0;
  text-wrap: balance;
}

h1 {
  margin: 0;
  font-size: 1.7rem;
}

.frase, .pregunta {
  margin: 0;
  font-size: clamp(1.8rem, 8vw, 2.4rem);
  line-height: 1.12;
}

.resultado {
  margin: 0;
  font-size: clamp(2.2rem, 10vw, 3rem);
  line-height: 1.05;
}

.motivo, .espera, .url, .conexion, .tenue {
  color: var(--muted);
}

.motivo, .espera, .url, .conexion {
  margin: 0;
  font-size: 0.95rem;
}

.url {
  text-align: center;
  word-break: break-all;
}

.nota {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.qr {
  width: min(100%, 17rem);
  margin-inline: auto;
  background: var(--paper);
  border-radius: 18px;
  padding: 12px;
}

.qr img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 8px;
}

.aviso {
  background: #2a2218;
  border-radius: 14px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.aviso p { margin: 0; }

.aviso-suave {
  margin: 0;
  color: var(--amber);
  text-align: center;
  font-size: 0.95rem;
}

.jugadores, .emitidos {
  list-style: none;
  padding: 0;
  margin: 0;
}

.jugadores li, .emitidos li {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  border-bottom: 1px solid var(--line);
}

.emitidos li {
  color: var(--muted);
  font-size: 0.95rem;
}

.jugadores .quien { flex: 1; }
.jugadores .cuenta {
  font-variant-numeric: tabular-nums;
  font-size: 1.35rem;
}

.espia {
  color: var(--red);
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.16em;
}

li.fila-espia {
  background: rgba(255, 90, 74, 0.1);
  margin: 0 -12px;
  padding: 0 12px;
  border-radius: 12px;
  border-bottom-color: transparent;
}

.palabra {
  background: var(--paper);
  color: var(--ink);
  min-height: 22dvh;
  border-radius: 18px;
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
}

body[data-etapa="revelacion"] .palabra { min-height: 26dvh; }

.palabra strong {
  font-family: "Iowan Old Style", Palatino, "Palatino Linotype", Georgia, serif;
  font-size: clamp(1.8rem, 9vw, 4.2rem);
  font-weight: 600;
  line-height: 0.95;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}

.palabra.oculta {
  background: transparent;
  color: var(--muted);
  border: 1px dashed var(--line);
}

.palabra.oculta::before {
  content: "●   ●   ●";
  letter-spacing: 0.35em;
  font-size: 1rem;
}

.reloj {
  margin: 0;
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-size: clamp(4rem, 22vw, 5.5rem);
  letter-spacing: -0.05em;
  line-height: 0.9;
  font-weight: 600;
}

.acciones {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.error {
  margin: 0;
  color: var(--red);
  min-height: 1.2em;
}

.tu-nombre {
  margin: 0;
  font-size: 1.25rem;
}
