/* La Mesa Electoral: papel oficial, azul institucional y sello rojo */
@font-face { font-family: 'Oswald'; src: url('../fonts/oswald-latin.woff2') format('woff2'); font-weight: 400 700; font-display: swap; }
@font-face { font-family: 'Spectral'; src: url('../fonts/spectral-400.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Spectral'; src: url('../fonts/spectral-600.woff2') format('woff2'); font-weight: 600; font-display: swap; }

:root {
    --azul: #17335c;
    --azul-2: #234a80;
    --papel: #faf6ea;
    --papel-2: #efe8d5;
    --tinta: #22262e;
    --rojo: #a81e2d;
    --verde: #1f7a4d;
    --ambar: #b77a10;
    --titular: 'Oswald', 'Arial Narrow', sans-serif;
    --texto: 'Spectral', Georgia, serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
    background: #10141d;
    background-image: radial-gradient(ellipse at 50% 0, #2a3852, #10141d 70%);
    color: var(--tinta);
    font-family: var(--texto);
    font-size: 17px;
    line-height: 1.42;
}
h1, h2, h3 { font-family: var(--titular); margin: 0; }
button { font: inherit; cursor: pointer; }
a { color: var(--azul-2); }

/* ---- La carta de designación ---- */
#start-screen { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 18px 16px 30px; }
.carta {
    position: relative; width: 100%; max-width: 640px; padding: 30px 32px 22px;
    background: var(--papel);
    background-image: linear-gradient(transparent 96%, rgba(23,51,92,0.03) 96%);
    background-size: 100% 28px;
    box-shadow: 0 24px 60px rgba(0,0,0,0.55);
    transform: rotate(-0.4deg);
    animation: cae 0.55s cubic-bezier(.2,.9,.3,1.2);
}
@keyframes cae { from { opacity: 0; transform: translateY(-34px) rotate(-3deg); } }
.carta-org { font-family: var(--titular); letter-spacing: 3px; color: var(--azul); font-size: 14px; margin: 0 0 8px; }
.carta h1 { font-size: clamp(38px, 8vw, 58px); color: var(--azul); line-height: 1.04; text-transform: uppercase; font-weight: 700; }
.carta-sub { font-style: italic; color: #5d5b52; margin: 6px 0 16px; border-bottom: 2px solid var(--azul); padding-bottom: 10px; font-size: 15px; }
.carta p { margin: 0 0 10px; }
.carta-sello {
    position: absolute; top: 28px; right: 22px; padding: 4px 11px;
    font-family: var(--titular); font-weight: 700; font-size: 19px; letter-spacing: 2px;
    color: var(--rojo); border: 3px solid var(--rojo); border-radius: 5px;
    transform: rotate(9deg); opacity: 0.8;
    animation: sellar 0.45s 0.55s both cubic-bezier(.3,1.6,.5,1);
}
@keyframes sellar { from { opacity: 0; transform: rotate(9deg) scale(2.6); } }
.modos { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 16px 0 12px; }
.btn-modo {
    text-align: left; padding: 13px 14px; color: #fff; border: 0; border-radius: 8px;
    box-shadow: 0 4px 0 rgba(0,0,0,0.3); transition: transform 0.1s, box-shadow 0.1s;
}
.btn-modo:hover { transform: translateY(-2px); box-shadow: 0 6px 0 rgba(0,0,0,0.3); }
.btn-modo:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0,0,0,0.3); }
.btn-modo strong { display: block; font-family: var(--titular); font-size: 21px; margin-bottom: 4px; }
.btn-modo span { font-size: 14px; line-height: 1.3; display: block; opacity: 0.93; }
.btn-modo.realista { background: linear-gradient(160deg, var(--azul-2), var(--azul)); }
.btn-modo.directo { background: linear-gradient(160deg, #8a2c35, #6e1c27); }
.btn-modo.completa { grid-column: 1 / -1; background: linear-gradient(160deg, #24404f, #122631); }
.cola-dice { margin: 8px 0 0; font-size: 15px; color: #5c4631; font-style: italic; }
.cola-dice strong { font-style: normal; }
.ranking-pestanas { display: flex; gap: 8px; margin-bottom: 10px; }
.ranking-pestanas .activa { background: var(--azul); color: #fff; }
.btn-continuar { display: block; width: 100%; background: var(--verde); font-family: var(--titular); font-size: 19px; margin-top: 8px; text-align: center; }
.carta-acciones { display: flex; flex-wrap: wrap; gap: 8px; }
.btn-sec { background: var(--papel-2); border: 1px solid #c6bea6; border-radius: 6px; padding: 7px 12px; font-family: var(--titular); font-size: 15px; color: var(--azul); }
.btn-sec:hover { background: #e7dec6; }
.excusa-resp { margin-top: 10px !important; padding: 8px 12px; background: #fbeaea; border-left: 4px solid var(--rojo); font-size: 15px; }
.carta-pie { margin-top: 14px !important; font-size: 14px; }
.enlace { background: none; border: 0; padding: 0; color: var(--azul-2); text-decoration: underline; }
.carta-nota { color: #6e6b60; font-size: 14px; font-style: italic; margin: 6px 0 0; }

/* ---- El juego ---- */
#game-container { height: 100dvh; max-width: 1200px; margin: 0 auto; display: flex; flex-direction: column; background: #10141d; }
#hud { flex: none; display: flex; align-items: center; gap: 12px; padding: 7px 10px; background: var(--azul); color: #fff; font-family: var(--titular); }
.btn-icono { flex: none; width: 36px; height: 36px; border-radius: 7px; border: 0; background: rgba(255,255,255,0.14); color: #fff; font-size: 18px; }
.hud-reloj { flex: none; display: flex; flex-direction: column; line-height: 1; min-width: 92px; }
.hud-reloj strong { font-size: 25px; font-variant-numeric: tabular-nums; }
.hud-reloj small { font-size: 12px; opacity: 0.8; margin-top: 3px; white-space: nowrap; }
.medidores { flex: 1; min-width: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px 10px; }
.medidor { display: flex; align-items: center; gap: 5px; font-size: 15px; }
.barra { flex: 1; min-width: 20px; height: 9px; border-radius: 5px; background: rgba(0,0,0,0.38); overflow: hidden; }
.barra div { height: 100%; transition: width 0.5s cubic-bezier(.3,1,.4,1); border-radius: 5px; }
.barra .bueno { background: linear-gradient(90deg, #40bf7c, #7fe0a8); }
.barra .malo { background: linear-gradient(90deg, #e9b13c, #f0d06a); }
.medidor.peligro .barra div { background: linear-gradient(90deg, #d6394a, #ff6c6c); animation: late 0.8s infinite alternate; }
@keyframes late { to { opacity: 0.55; } }
.hud-votos { flex: none; display: flex; flex-direction: column; align-items: flex-end; line-height: 1.05; }
.hud-votos small { font-size: 12px; opacity: 0.8; }
.hud-votos strong { font-size: 16px; font-variant-numeric: tabular-nums; white-space: nowrap; }

#escenario { position: relative; flex: 1 1 auto; min-height: 0; background: #1b2230; overflow: hidden; }
#escena { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.modo-realista.con-manos #escena { touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none; }
.nota-papeleta {
    position: absolute; left: 50%; bottom: 6px; transform: translateX(-50%); width: min(94%, 560px);
    background: rgba(250,246,234,0.95); padding: 6px 12px; border-radius: 7px; font-size: 14px; pointer-events: none;
    box-shadow: 0 3px 12px rgba(0,0,0,0.4);
}
.nota-papeleta p { margin: 0 0 3px; }

.panel, .guia { flex: none; background: var(--papel); }
.panel { max-height: 47dvh; overflow-y: auto; padding: 11px 16px 14px; box-shadow: 0 -5px 18px rgba(0,0,0,0.45); animation: sube 0.22s ease-out; }
@keyframes sube { from { transform: translateY(14px); opacity: 0.4; } }
.guia { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: var(--azul); color: #fff; font-family: var(--titular); font-size: 19px; line-height: 1.2; }
.guia p { margin: 0; }
.guia-n { flex: none; background: #ffd24a; color: var(--azul); border-radius: 14px; padding: 2px 10px; font-weight: 700; font-size: 15px; }
.caso-cab { display: flex; align-items: baseline; gap: 9px; margin-bottom: 4px; }
.caso-cab h2 { font-size: 23px; color: var(--azul); font-weight: 600; line-height: 1.15; }
.caso-hora { flex: none; font-family: var(--titular); font-weight: 600; background: var(--azul); color: #fff; font-size: 14px; padding: 1px 7px; border-radius: 4px; font-variant-numeric: tabular-nums; }
.dice { margin: 0 0 9px; font-size: 16.5px; }
.dice-falta { visibility: hidden; }
.solo-lector { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.susurro { margin: 0 0 9px; color: #5c4631; font-size: 15px; background: var(--papel-2); padding: 5px 10px; border-left: 3px solid var(--ambar); }
.opciones { display: flex; flex-direction: column; gap: 7px; }
.btn-op {
    display: block; text-align: left; text-decoration: none; padding: 10px 14px; background: #fff; color: var(--tinta);
    border: 2px solid var(--azul); border-radius: 7px; font-family: var(--texto); font-size: 16px; font-weight: 600; line-height: 1.22;
    box-shadow: 0 2px 0 var(--azul); transition: transform 0.08s, background 0.12s;
}
.btn-op:hover { background: #e7eefa; transform: translateY(-1px); }
.btn-op:active { transform: translateY(2px); box-shadow: none; }
.btn-seguir { display: block; width: 100%; margin-top: 8px; padding: 11px; background: var(--azul); color: #fff; border: 0; border-radius: 7px; font-family: var(--titular); font-size: 19px; font-weight: 600; }
.btn-seguir:hover { background: var(--azul-2); }
.resultado { position: relative; padding: 2px 0 0; }
.resultado p { margin: 0 0 8px; }
.sello {
    display: inline-block; margin-bottom: 7px; padding: 1px 10px; font-family: var(--titular); font-weight: 700; font-size: 19px;
    letter-spacing: 1.5px; border: 3px solid; border-radius: 4px; transform: rotate(-2deg);
    animation: sellar2 0.28s cubic-bezier(.3,1.7,.5,1);
}
@keyframes sellar2 { from { opacity: 0; transform: rotate(-2deg) scale(2.3); } }
.resultado.bien .sello { color: var(--verde); }
.resultado.mal .sello { color: var(--rojo); }
.resultado.regular .sello { color: var(--ambar); }
.resultado .racha { font-family: var(--titular); font-weight: 600; color: var(--verde); }
.resultado .racha.rota { color: var(--rojo); }
.regla { font-size: 15px; padding: 7px 11px; background: #e9eef6; border-left: 4px solid var(--azul); }
.regla span { font-family: var(--titular); font-weight: 600; color: var(--azul); margin-right: 5px; text-transform: uppercase; font-size: 13px; }
.aviso { font-weight: 600; color: var(--rojo); }

/* ---- Modales ---- */
.modal { display: none; position: fixed; inset: 0; z-index: 30; align-items: center; justify-content: center; padding: 16px; background: rgba(8,10,16,0.72); }
.modal.active { display: flex; }
.modal-content { width: 100%; max-width: 520px; max-height: 92dvh; overflow-y: auto; padding: 20px 22px; background: var(--papel); border-radius: 6px; box-shadow: 0 20px 50px rgba(0,0,0,0.6); }
.modal-content h3 { color: var(--azul); font-size: 27px; margin-bottom: 8px; }
.modal-content p { margin: 0 0 9px; }
.lista-ayuda { padding-left: 18px; margin: 6px 0 10px; }
.fin { text-align: center; }
.fin-emoji { font-size: 56px; line-height: 1.1; }
.fin-puntos { font-family: var(--titular); color: var(--azul); margin: 6px 0 0; }
.fin-puntos strong { font-size: 54px; line-height: 1; }
.fin-puntos span { font-size: 18px; }
.fin-rango { font-style: italic; font-weight: 600; color: var(--rojo); }
.fin-stats { list-style: none; padding: 0; margin: 0 0 10px; text-align: left; font-size: 15px; }
.fin-stats li { padding: 3px 0; border-bottom: 1px dotted #c8c0aa; }
.acta-tabla { width: 100%; border-collapse: collapse; margin: 8px 0 10px; font-size: 14.5px; text-align: left; background: #fff; }
.acta-tabla th { background: var(--azul); color: #fff; padding: 5px 8px; font-family: var(--titular); font-weight: 600; letter-spacing: 1px; }
.acta-tabla td { padding: 3px 8px; border-bottom: 1px solid #e3ddcb; }
.acta-tabla td:last-child { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.fin-texto { margin-top: 12px !important; text-align: left; font-size: 15.5px; }
.fin-plegable { text-align: left; margin-bottom: 10px; }
.fin-plegable summary { padding: 8px 10px; background: var(--papel-2); border-radius: 5px; font-family: var(--titular); font-size: 16px; color: var(--azul); cursor: pointer; }
.repaso-limpio { font-family: var(--titular); color: var(--verde); }
.repaso-linea { padding: 9px 2px; border-bottom: 1px dotted #c8c0aa; font-size: 15px; }
.repaso-linea p { margin: 3px 0 0; }
.repaso-mal { color: var(--rojo); }
.repaso-bien { color: var(--verde); font-weight: 600; }
.repaso-linea .regla { margin-top: 5px; font-size: 14px; }
.fin .opciones { margin-top: 7px; text-align: center; }
.fin .btn-op { text-align: center; }
.fin-reto { margin: 6px 0 4px; font-size: 14.5px; font-style: italic; color: var(--azul); }
.kofi-fin { margin: 8px 0; padding: 9px 12px; background: var(--papel-2); border-radius: 7px; font-size: 14.5px; }
.kofi-fin p { margin: 0 0 4px; }
.kofi-fin a { display: inline-block; padding: 8px 4px; font-weight: 700; color: var(--rojo); }
#nickname-input { width: 100%; padding: 10px; font-size: 17px; border: 2px solid var(--azul); border-radius: 6px; margin-bottom: 8px; }
.ranking-list { margin-bottom: 10px; }
.ranking-row { display: grid; grid-template-columns: 42px 1fr auto auto; gap: 8px; padding: 5px 7px; border-bottom: 1px solid #e3ddcb; font-size: 15px; }
.ranking-row.is-me { background: #fff2c6; font-weight: 600; }
.ranking-row.is-top1 .ranking-rank { color: #b58a00; font-weight: 700; }
.ranking-score { font-weight: 600; }
.ranking-time { color: #77725f; }
.ranking-loading, .ranking-empty, .ranking-error { text-align: center; color: #6e6b60; padding: 16px 0; }

/* ---- Retención: saltar gestos, tramo y hito ---- */
.btn-saltar { display: none; flex: none; margin-left: auto; min-height: 44px; padding: 0 14px; background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.6); border-radius: 22px; font: inherit; font-size: 15px; cursor: pointer; }
.con-saltable .btn-saltar { display: block; }
.hud-votos small#hud-tramo { margin-top: 2px; }
.aviso-hito { position: fixed; left: 50%; top: 64px; transform: translate(-50%, -12px); opacity: 0; pointer-events: none; z-index: 40; background: var(--azul); color: #fff; padding: 8px 16px; border-radius: 20px; font-family: var(--titular); font-size: 17px; transition: opacity .3s, transform .3s; }
.aviso-hito.visible { opacity: 1; transform: translate(-50%, 0); }
.btn-modo .corto, .btn-modo .solo-movil { display: none; }
@media (max-width: 600px) {
    .btn-modo.realista .largo { display: none; }
    .btn-modo.realista .corto, .btn-modo.realista .solo-movil { display: block; }
    .btn-modo.realista .solo-movil { margin-top: 4px; font-size: 13.5px; opacity: .85; }
}

/* ---- Móvil ---- */
@media (max-width: 720px) {
    body { font-size: 16px; }
    .carta { padding: 22px 18px 16px; transform: none; }
    .carta-sello { top: 12px; right: 10px; font-size: 14px; }
    .modos { grid-template-columns: 1fr; }
    #hud { flex-wrap: wrap; gap: 5px 8px; padding: 5px 8px; }
    .btn-icono { width: 32px; height: 32px; }
    .hud-reloj { min-width: 0; flex: 1; }
    .hud-reloj strong { font-size: 21px; }
    .medidores { order: 5; flex: 0 0 100%; }
    .medidor { font-size: 13px; }
    .panel { max-height: 54dvh; padding: 8px 12px 11px; }
    .caso-cab h2 { font-size: 20px; }
    .dice { font-size: 15.5px; margin-bottom: 7px; }
    .btn-op { font-size: 15px; padding: 8px 11px; }
    .guia { font-size: 17px; padding: 9px 12px; }
    /* Con los gestos, el visor guarda proporción: si crece a lo alto, los puntos de agarre se salen por los lados. */
    .con-manos #escenario { flex: 0 0 auto; width: 100%; aspect-ratio: 440 / 540; }
    .con-manos .guia { flex: 1 1 auto; font-size: 20px; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}
