:root {
  --rojo: #C8102E;
  --amarillo: #FFCC00;
  --verde: #95A82A;
  --gris: #E8ECF0;
  --crema: #FDF6EE;
  --granate: #7A1010;
  --titulo: 'Lilita One', sans-serif;
}

html, body { margin: 0; padding: 0; background: var(--rojo); }
* { box-sizing: border-box; }
button, input { font-family: inherit; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

/* ---------- Layout común ---------- */
.page {
  min-height: 100vh; min-height: 100dvh;
  background: var(--rojo);
  padding: clamp(6px, 2vw, 14px);
  font-family: 'Nunito', sans-serif;
  color: var(--granate);
}
.frame {
  min-height: calc(100vh - clamp(12px, 4vw, 28px));
  min-height: calc(100dvh - clamp(12px, 4vw, 28px));
  border: clamp(5px, 1.6vw, 10px) solid var(--amarillo);
  background: var(--verde);
  display: flex; flex-direction: column;
}
.head { padding: clamp(14px, 4vw, 22px) clamp(12px, 4vw, 24px) 8px; text-align: center; }
.head--admin { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.title {
  margin: 0;
  font-family: var(--titulo); font-style: italic; font-weight: 400;
  font-size: clamp(30px, 6vw, 60px);
  letter-spacing: 1px; line-height: 1.05; text-transform: uppercase;
  color: var(--amarillo);
  text-shadow: 3px 3px 0 var(--rojo), -1px -1px 0 var(--rojo), 1px -1px 0 var(--rojo), -1px 1px 0 var(--rojo);
  transform: skewX(-6deg);
}
.title--admin { font-size: clamp(28px, 5.5vw, 54px); text-align: center; }
.tag {
  background: var(--granate); color: var(--amarillo);
  font-weight: 900; font-size: 13px; letter-spacing: 2px;
  padding: 4px 12px; text-transform: uppercase;
}
.main { flex: 1; display: block; padding: 12px clamp(10px, 4vw, 20px) 24px; }
.h2 { margin: 0; font-weight: 900; font-size: 20px; color: var(--amarillo); text-shadow: 1px 1px 0 var(--granate); }
.row-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.count { font-weight: 800; font-size: 14px; color: var(--crema); white-space: nowrap; }

.foot {
  display: flex; align-items: stretch; gap: 0; flex-wrap: wrap;
  margin: 0 clamp(8px, 3vw, 14px) clamp(8px, 3vw, 14px);
  background: var(--gris); font-weight: 900; font-size: 14px;
}
.foot-players { padding: 10px clamp(10px, 3vw, 18px); color: var(--granate); white-space: nowrap; }
.foot-age { margin-left: 14px; }
.foot-tagline { flex: 1; padding: 10px clamp(10px, 3vw, 18px); color: var(--rojo); font-weight: 800; border-left: 3px solid var(--verde); }
.foot-admin { padding: 10px 18px; background: var(--granate); color: var(--crema); font-weight: 800; text-decoration: none; display: flex; align-items: center; }

/* ---------- Temporizador: setup ---------- */
.setup { width: 100%; max-width: 820px; margin: 0 auto; display: flex; flex-direction: column; gap: 22px; }
.block { display: flex; flex-direction: column; gap: 12px; }
.block--tight { gap: 10px; }

.slots { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(30%, 140px), 1fr)); gap: 8px; }
.slot {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  min-height: clamp(84px, 22vw, 96px); padding: 10px 6px;
  cursor: default; text-align: center;
  background: rgba(253, 246, 238, 0.18); border: 3px dashed var(--crema);
  color: var(--crema);
  transition: background .2s, transform .2s;
}
.slot.is-next { border-color: var(--amarillo); }
.slot.is-filled {
  cursor: pointer; background: var(--amarillo); border: 3px solid var(--amarillo);
  box-shadow: 0 5px 0 var(--granate); transform: translateY(-2px);
  color: var(--rojo);
}
.slot-num {
  width: 30px; height: 30px; display: flex; align-items: center; justify-content: center;
  border-radius: 50%; font-weight: 900; font-size: 15px;
  background: transparent; color: var(--crema);
}
.slot.is-filled .slot-num { background: var(--rojo); color: var(--amarillo); }
.slot-name { font-weight: 900; font-size: clamp(13px, 3.6vw, 15px); line-height: 1.15; text-wrap: balance; }
.slot-hint { font-weight: 800; font-size: 10px; letter-spacing: .5px; text-transform: uppercase; color: var(--crema); }
.slot.is-filled .slot-hint { color: var(--granate); }

.roster { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); gap: 8px; }
.char {
  display: flex; align-items: center; gap: 12px;
  width: 100%; min-height: 56px; padding: 10px 14px;
  border: none; cursor: pointer; text-align: left;
  font-size: 16px; font-weight: 800;
  background: var(--crema); color: var(--granate);
  transition: opacity .15s, background .15s;
}
.char.is-on { background: var(--granate); color: var(--amarillo); }
.char.is-blocked { opacity: .45; cursor: not-allowed; }
.char-badge {
  width: 26px; height: 26px; flex: none;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; font-size: 13px; font-weight: 900;
  background: transparent; color: var(--verde); border: 2px solid var(--verde);
}
.char.is-on .char-badge { background: var(--amarillo); color: var(--granate); border: none; }
.char-name { flex: 1; }
.char-status { font-size: 12px; font-weight: 900; white-space: nowrap; color: var(--verde); }
.char.is-on .char-status { color: var(--crema); }

.btn-start {
  position: sticky; bottom: 12px; z-index: 2;
  height: 64px; border: none;
  background: var(--amarillo); color: var(--rojo);
  font-family: var(--titulo); font-size: clamp(24px, 6vw, 30px); font-style: italic;
  letter-spacing: 1px; text-transform: uppercase;
  cursor: pointer; box-shadow: 0 6px 0 var(--granate);
}
.btn-start:disabled { opacity: .5; }

/* ---------- Temporizador: juego ---------- */
.game {
  width: 100%; max-width: 980px; margin: 0 auto;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
  gap: clamp(18px, 5vw, 28px); align-items: start;
}
.game-clock { display: flex; flex-direction: column; align-items: center; gap: clamp(12px, 3vw, 18px); min-width: 0; }
.badges { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: center; }
.badge { font-weight: 900; padding: 6px 14px; font-size: 15px; white-space: nowrap; }
.badge--round { background: var(--rojo); color: var(--amarillo); }
.badge--turn { background: var(--crema); color: var(--granate); }

.presets-wrap { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 100%; max-width: 420px; }
.presets-label { font-weight: 900; font-size: 13px; letter-spacing: 1px; text-transform: uppercase; color: var(--crema); }
.presets { display: flex; gap: 8px; width: 100%; }
.preset {
  flex: 1; height: 44px; border: none; cursor: pointer;
  font-family: var(--titulo); font-size: 20px;
  background: var(--crema); color: var(--granate);
}
.preset.is-on { background: var(--amarillo); color: var(--rojo); box-shadow: 0 4px 0 var(--granate); }
.pending { font-weight: 800; font-size: 12px; color: var(--amarillo); }

.current {
  font-family: var(--titulo); font-size: clamp(26px, 4.5vw, 40px);
  color: var(--crema); text-shadow: 2px 2px 0 var(--granate);
  text-align: center; line-height: 1.1; text-wrap: balance; max-width: 100%;
}

.ring { position: relative; width: min(100%, 340px, 52vh); min-width: 220px; aspect-ratio: 1; cursor: pointer; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); display: block; }
.ring-progress { transition: stroke-dashoffset .12s linear, stroke .3s; }
.ring-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; }
.ring-time {
  font-family: var(--titulo); font-size: clamp(52px, 15vw, 92px); line-height: 1;
  color: var(--granate); font-variant-numeric: tabular-nums;
}
.ring-time.is-low { color: var(--rojo); }
.ring-status { font-weight: 900; font-size: 14px; letter-spacing: 2px; text-transform: uppercase; color: var(--verde); white-space: nowrap; }

.actions { display: flex; gap: 10px; width: 100%; max-width: 420px; }
.btn-big {
  flex: 1; min-width: 0; height: 64px; border: none; cursor: pointer;
  font-family: var(--titulo); font-size: 24px;
  box-shadow: 0 5px 0 var(--granate);
}
.btn-big--run { background: var(--amarillo); color: var(--rojo); }
.btn-big--next { background: var(--rojo); color: var(--amarillo); }
.btn-ghost {
  flex: 1; height: 44px; border: 2px solid var(--crema);
  background: transparent; color: var(--crema);
  font-weight: 900; font-size: 14px; cursor: pointer;
}
.kbd { font-size: 12px; font-weight: 800; color: var(--crema); opacity: .85; }
@media (pointer: coarse) { .kbd { display: none; } }

.game-turns { display: flex; flex-direction: column; gap: 10px; min-width: 0; padding-right: 6px; }
.turn-list { display: flex; flex-direction: column; gap: 10px; }
.turn {
  display: flex; align-items: center; gap: 12px;
  min-height: 54px; padding: 8px 16px;
  border: none; cursor: pointer; text-align: left;
  background: var(--gris); color: var(--granate);
  transition: transform .2s, background .2s;
}
.turn:nth-child(even) { background: var(--crema); }
.turn.is-current { background: var(--amarillo); color: var(--rojo); transform: translateX(6px); }
.turn-num {
  width: 28px; height: 28px; flex: none;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; font-weight: 900; font-size: 14px;
  background: var(--verde); color: var(--crema);
}
.turn.is-current .turn-num { background: var(--rojo); color: var(--amarillo); }
.turn-name { flex: 1; font-weight: 900; font-size: 17px; }
.turn-used { font-weight: 800; font-size: 13px; font-variant-numeric: tabular-nums; }
.btn-back {
  margin-top: 8px; align-self: flex-start;
  height: 40px; padding: 0 16px; border: none;
  background: var(--granate); color: var(--crema);
  font-weight: 800; font-size: 14px; cursor: pointer;
}

/* ---------- Admin ---------- */
.admin { width: 100%; max-width: 860px; margin: 0 auto; display: flex; flex-direction: column; gap: 26px; }
.chars { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr)); gap: 8px; }
.char-row { display: flex; align-items: center; gap: 10px; min-height: 56px; padding: 8px; background: var(--gris); }
.char-row:nth-child(even) { background: var(--crema); }
.char-row.is-hidden { opacity: .6; }
.char-row-num {
  width: 28px; height: 28px; flex: none;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; font-weight: 900; font-size: 14px;
  background: var(--rojo); color: var(--amarillo);
}
.char-row input {
  flex: 1; min-width: 0; height: 40px; padding: 0 10px;
  border: 2px solid var(--gris); border-radius: 0; background: #FFFFFF; color: var(--granate);
  font-size: 16px; font-weight: 800; outline: none;
}
.char-row input:focus { border-color: var(--amarillo); }
.char-toggle {
  flex: none; width: 88px; height: 40px; border: none; cursor: pointer;
  font-weight: 900; font-size: 13px;
  background: var(--verde); color: var(--crema);
}
.char-row.is-hidden .char-toggle { background: var(--granate); color: var(--gris); }

.steppers { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: 10px; }
.stepper { display: flex; flex-direction: column; gap: 8px; background: var(--crema); padding: 14px; }
.stepper-label { font-weight: 900; font-size: 14px; text-transform: uppercase; letter-spacing: 1px; color: var(--verde); }
.stepper-row { display: flex; align-items: center; gap: 10px; }
.stepper-btn { width: 44px; height: 44px; border: none; background: var(--rojo); color: var(--amarillo); font-size: 24px; font-weight: 900; cursor: pointer; }
.stepper-value { flex: 1; text-align: center; font-family: var(--titulo); font-size: 34px; color: var(--granate); font-variant-numeric: tabular-nums; }

.admin-actions { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.btn-go {
  flex: 2; min-width: 220px; height: 60px;
  display: flex; align-items: center; justify-content: center;
  background: var(--amarillo); color: var(--rojo);
  font-family: var(--titulo); font-size: 24px; text-decoration: none;
  box-shadow: 0 5px 0 var(--granate);
}
.btn-restore {
  flex: 1; min-width: 180px; height: 60px;
  border: 2px solid var(--crema); background: transparent; color: var(--crema);
  font-weight: 900; font-size: 15px; cursor: pointer;
}
.saved { font-size: 13px; font-weight: 800; color: var(--crema); }
