/* ===== Amigo Secreto · estilo navideño, pensado primero para celular ===== */
:root {
    --rojo: #9f1d2b;
    --rojo-oscuro: #6e1220;
    --verde: #1d5c3f;
    --verde-claro: #e6f2ea;
    --dorado: #e8b54a;
    --dorado-oscuro: #b8861f;
    --crema: #fff8ee;
    --texto: #2b1d1a;
    --texto-suave: #6b5a55;
    --borde: #ead9c6;
    --error: #b42318;
    --error-fondo: #fdecea;
    --advertencia-fondo: #fff4d6;
    --radio: 18px;
    --sombra: 0 10px 30px rgba(110, 18, 32, .12);
    color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 1.0625rem;
    line-height: 1.55;
    color: var(--texto);
    background:
        radial-gradient(circle at 20% 0%, rgba(232, 181, 74, .18), transparent 45%),
        radial-gradient(circle at 100% 30%, rgba(29, 92, 63, .12), transparent 40%),
        linear-gradient(180deg, var(--rojo-oscuro) 0, var(--rojo) 220px, var(--crema) 220px);
}

/* Nieve decorativa (solo CSS) */
.nieve {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    background-image:
        radial-gradient(2px 2px at 20px 30px, #fff, transparent),
        radial-gradient(2px 2px at 80px 120px, rgba(255,255,255,.8), transparent),
        radial-gradient(3px 3px at 150px 60px, rgba(255,255,255,.7), transparent),
        radial-gradient(2px 2px at 220px 160px, #fff, transparent),
        radial-gradient(3px 3px at 280px 20px, rgba(255,255,255,.6), transparent);
    background-size: 300px 200px;
    animation: nevar 18s linear infinite;
    opacity: .55;
}
@keyframes nevar { from { background-position: 0 0; } to { background-position: 60px 400px; } }

.encabezado, .contenido, .pie { position: relative; z-index: 1; }

.encabezado {
    padding: 1.1rem 1rem .5rem;
    display: flex;
    justify-content: center;
}
.marca {
    display: flex;
    align-items: center;
    gap: .6rem;
    color: #fff;
    text-decoration: none;
}
.marca-icono { font-size: 2rem; filter: drop-shadow(0 2px 4px rgba(0,0,0,.3)); }
.marca strong { display: block; font-size: 1.35rem; letter-spacing: .02em; }
.marca small { display: block; color: var(--dorado); font-weight: 600; font-size: .85rem; text-transform: uppercase; letter-spacing: .08em; }

.contenido {
    flex: 1;
    width: 100%;
    max-width: 640px;
    margin: 0 auto;
    padding: .75rem .9rem 2rem;
}

.pie {
    text-align: center;
    padding: 1.25rem;
    color: var(--texto-suave);
    font-size: .9rem;
}

/* ----- Tarjetas ----- */
.tarjeta {
    background: #fff;
    border-radius: var(--radio);
    box-shadow: var(--sombra);
    padding: 1.4rem 1.2rem;
    margin-bottom: 1.1rem;
    border-top: 6px solid var(--verde);
    position: relative;
}
.tarjeta::before { /* listón dorado */
    content: "";
    position: absolute;
    top: -6px; left: 50%;
    width: 46px; height: 6px;
    transform: translateX(-50%);
    background: var(--dorado);
}
.tarjeta-angosta { max-width: 460px; margin-left: auto; margin-right: auto; }
.tarjeta-exito { text-align: center; border-top-color: var(--dorado); }
.centrado { text-align: center; }

h1 { font-size: 1.6rem; line-height: 1.2; margin: 0 0 .5rem; color: var(--rojo-oscuro); }
h2 { font-size: 1.25rem; margin: 0 0 .75rem; color: var(--verde); }
.lead { color: var(--texto-suave); margin-top: 0; }
.ayuda { color: var(--texto-suave); font-size: .9rem; margin: .75rem 0 0; }

.portada { text-align: center; }
.portada-adorno { font-size: 2.6rem; letter-spacing: .3rem; margin-bottom: .25rem; }

.pasos ol { padding-left: 1.3rem; margin: 0; }
.pasos li { margin-bottom: .5rem; }
.pasos li::marker { color: var(--rojo); font-weight: 700; }

/* ----- Botones ----- */
.acciones { display: flex; flex-direction: column; gap: .65rem; margin-top: 1.1rem; }
.acciones-centro { align-items: center; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    min-height: 48px;
    padding: .7rem 1.2rem;
    border: 2px solid transparent;
    border-radius: 999px;
    font: inherit;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    transition: transform .12s ease, box-shadow .12s ease, background-color .12s ease;
    -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.97); }
.btn:focus-visible, input:focus-visible { outline: 3px solid var(--dorado); outline-offset: 2px; }

.btn-primario { background: var(--rojo); color: #fff; box-shadow: 0 6px 16px rgba(159, 29, 43, .35); }
.btn-primario:hover { background: var(--rojo-oscuro); }
.btn-secundario { background: var(--verde-claro); color: var(--verde); border-color: #bcd9c7; }
.btn-secundario:hover { background: #d4eadb; }
.btn-dorado { background: var(--dorado); color: #3d2a05; }
.btn-dorado:hover { background: var(--dorado-oscuro); color: #fff; }
.btn-peligro { background: #fff; color: var(--error); border-color: #f1b8b2; }
.btn-peligro:hover { background: var(--error-fondo); }
.btn-enlace { background: none; color: var(--rojo); min-height: 40px; padding: .4rem .6rem; text-decoration: underline; }
.btn-grande { font-size: 1.1rem; min-height: 54px; }
.btn-bloque { width: 100%; }
.btn-chico { min-height: 38px; padding: .35rem .8rem; font-size: .9rem; }

/* ----- Formularios ----- */
.formulario { margin-top: 1rem; }
.campo { margin: 0 0 1.1rem; border: 0; padding: 0; }
.campo label, .campo legend { display: block; font-weight: 700; margin-bottom: .35rem; }

input[type="text"], input[type="password"], input:not([type]) {
    width: 100%;
    min-height: 50px;
    padding: .7rem .9rem;
    font: inherit;
    font-size: 1rem; /* ≥16px evita el zoom automático en iOS */
    color: var(--texto);
    background: #fffdf9;
    border: 2px solid var(--borde);
    border-radius: 12px;
    transition: border-color .12s ease;
}
input:focus { border-color: var(--verde); }
input.invalid { border-color: var(--error); }
input.valid.modified { border-color: #7fb594; }

.entrada-codigo {
    text-transform: uppercase;
    text-align: center;
    font-size: 1.6rem !important;
    letter-spacing: .4em;
    font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
    font-weight: 700;
}

.opciones { display: grid; gap: .55rem; }
.opcion {
    display: flex !important;
    align-items: center;
    gap: .65rem;
    padding: .8rem .9rem;
    border: 2px solid var(--borde);
    border-radius: 12px;
    font-weight: 600 !important;
    cursor: pointer;
    background: #fffdf9;
}
.opcion:has(input:checked) { border-color: var(--verde); background: var(--verde-claro); }
.opcion input { width: 1.3rem; height: 1.3rem; accent-color: var(--verde); margin: 0; }

.error-campo, .validation-message { color: var(--error); font-size: .9rem; font-weight: 600; margin-top: .3rem; }

/* ----- Avisos ----- */
.aviso { border-radius: 12px; padding: .85rem 1rem; margin: .75rem 0; font-weight: 600; }
.aviso p { margin: .25rem 0; }
.aviso-error { background: var(--error-fondo); color: var(--error); border-left: 5px solid var(--error); }
.aviso-exito { background: var(--verde-claro); color: var(--verde); border-left: 5px solid var(--verde); }
.aviso-advertencia { background: var(--advertencia-fondo); color: #6b4a00; border-left: 5px solid var(--dorado); font-weight: 500; }

/* ----- Código personal ----- */
.codigo-tarjeta {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .6rem;
    margin: 1.2rem 0 .5rem;
    padding: 1.2rem 1rem;
    border: 3px dashed var(--dorado);
    border-radius: var(--radio);
    background: #fffaf0;
}
.codigo-etiqueta { text-transform: uppercase; letter-spacing: .1em; font-size: .8rem; font-weight: 700; color: var(--texto-suave); }
.codigo-valor {
    display: block;
    font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
    font-size: 2.4rem;
    font-weight: 800;
    letter-spacing: .3em;
    padding-left: .3em; /* compensa el letter-spacing para centrar */
    color: var(--rojo-oscuro);
    user-select: all;
}
.codigo-valor-chico { font-size: 1.6rem; }

/* ----- Regalo animado ----- */
.tarjeta-regalo { text-align: center; overflow: hidden; }
.regalo-escena { padding: 1.2rem 0 .4rem; transition: opacity .4s ease; }
.regalo-escena.oculto { display: none; }
.regalo-indicacion { color: var(--texto-suave); font-weight: 600; margin-top: 1rem; }

.regalo {
    position: relative;
    width: 170px;
    height: 170px;
    margin: 1.4rem auto 0;
    display: block;
    border: 0;
    background: none;
    cursor: pointer;
    animation: sacudir 2.4s ease-in-out infinite;
    -webkit-tap-highlight-color: transparent;
}
.regalo-caja, .regalo-tapa { position: absolute; left: 50%; transform: translateX(-50%); border-radius: 8px; }
.regalo-caja {
    bottom: 0;
    width: 150px;
    height: 112px;
    background:
        linear-gradient(90deg, transparent 43%, var(--dorado) 43%, var(--dorado) 57%, transparent 57%),
        linear-gradient(135deg, #c42a3b, var(--rojo));
    box-shadow: inset 0 -10px 0 rgba(0,0,0,.12), 0 12px 24px rgba(110,18,32,.3);
}
.regalo-tapa {
    bottom: 104px;
    width: 170px;
    height: 34px;
    z-index: 2;
    background:
        linear-gradient(90deg, transparent 43%, var(--dorado) 43%, var(--dorado) 57%, transparent 57%),
        linear-gradient(135deg, #d43446, #b02232);
    box-shadow: 0 4px 0 rgba(0,0,0,.12);
    transition: transform .7s cubic-bezier(.3,1.6,.6,1), opacity .7s ease;
}
.regalo-tapa::before, .regalo-tapa::after { /* moño */
    content: "";
    position: absolute;
    bottom: 30px;
    width: 46px;
    height: 34px;
    border: 9px solid var(--dorado);
    border-radius: 50% 50% 10% 50%;
}
.regalo-tapa::before { left: 38px; transform: rotate(-25deg); }
.regalo-tapa::after { right: 38px; transform: rotate(25deg) scaleX(-1); }

.regalo.abierto { animation: none; }
.regalo.abierto .regalo-tapa { transform: translate(-50%, -120px) rotate(-28deg); opacity: 0; }
.regalo.abierto .regalo-caja { animation: rebotar .5s ease; }

@keyframes sacudir {
    0%, 70%, 100% { transform: rotate(0); }
    75% { transform: rotate(-6deg); }
    80% { transform: rotate(6deg); }
    85% { transform: rotate(-4deg); }
    90% { transform: rotate(4deg); }
}
@keyframes rebotar { 50% { transform: translateX(-50%) scale(1.06, .94); } }

.revelacion { animation: aparecer .6s cubic-bezier(.2,1.4,.5,1); outline: none; }
.revelacion-titulo { font-weight: 700; color: var(--texto-suave); text-transform: uppercase; letter-spacing: .1em; font-size: .9rem; margin: 1rem 0 .2rem; }
.revelacion-nombre { font-size: 2.1rem; font-weight: 800; color: var(--rojo); margin: 0 0 1rem; line-height: 1.15; }
.revelacion-datos { display: grid; gap: .7rem; margin: 0; text-align: left; }
.revelacion-datos > div { background: #fffaf0; border: 2px solid var(--borde); border-radius: 14px; padding: .8rem 1rem; }
.revelacion-datos dt { font-size: .85rem; font-weight: 700; color: var(--texto-suave); }
.revelacion-datos dd { margin: .15rem 0 0; font-size: 1.15rem; font-weight: 700; overflow-wrap: anywhere; }
@keyframes aparecer { from { opacity: 0; transform: scale(.85) translateY(20px); } }

#confeti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 50; }

/* ----- Gestión ----- */
.titulo-con-accion { display: flex; justify-content: space-between; align-items: flex-start; gap: .5rem; flex-wrap: wrap; }
.estadisticas { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; margin: 1rem 0; }
.estadistica {
    background: var(--crema);
    border: 2px solid var(--borde);
    border-radius: 14px;
    padding: .7rem .4rem;
    text-align: center;
    font-size: .85rem;
    font-weight: 600;
    color: var(--texto-suave);
}
.estadistica .numero { display: block; font-size: 1.8rem; font-weight: 800; color: var(--rojo-oscuro); line-height: 1.1; }
.estado-sorteo { background: var(--advertencia-fondo); border-radius: 12px; padding: .2rem 1rem; }
.estado-sorteo.realizado { background: var(--verde-claro); }

.lista-participantes { list-style: none; margin: 0; padding: 0; }
.lista-participantes li {
    display: flex;
    flex-direction: column;
    gap: .5rem;
    padding: .85rem 0;
    border-bottom: 1px solid var(--borde);
}
.lista-participantes li:last-child { border-bottom: 0; }
.participante-info { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .6rem; }
.participante-info strong { overflow-wrap: anywhere; }
.participante-info small { flex-basis: 100%; color: var(--texto-suave); }
.participante-acciones { display: flex; gap: .5rem; flex-wrap: wrap; }
.etiqueta { font-size: .75rem; font-weight: 700; padding: .15rem .55rem; border-radius: 999px; }
.etiqueta-si { background: var(--verde-claro); color: var(--verde); }
.etiqueta-no { background: #f1ece8; color: var(--texto-suave); }

code { background: #f6efe6; padding: .1rem .35rem; border-radius: 6px; }

/* ----- Pantallas más grandes ----- */
@media (min-width: 600px) {
    .contenido { padding-top: 1.5rem; }
    .tarjeta { padding: 2rem 2rem; }
    h1 { font-size: 1.9rem; }
    .acciones { flex-direction: row; flex-wrap: wrap; }
    .portada .acciones, .tarjeta-exito .acciones, .acciones-centro { justify-content: center; }
    .lista-participantes li { flex-direction: row; justify-content: space-between; align-items: center; }
    .participante-acciones { flex-shrink: 0; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
    .nieve { display: none; }
}
