/* La Puerta · Juegos de Ciudad — estilos base.
   Colores y tipografías tomados de lapuerta.net.
   Las variables de marca (--red, --bg, etc.) podrán sobrescribirse por cliente/evento. */
:root {
    --red: #FF2E4D;            /* color principal de La Puerta */
    --red-dim: #7A1A28;
    --orange: #FF9642;         /* acento */
    --bg: #0A0A0D;
    --bg2: #111014;
    --card: #161419;
    --card-border: #26232b;
    --ink: #EDE8E4;
    --ink-dim: #9C969F;
    --ok: #3ccf7a;
    --radius: 16px;
    --font-body: 'Manrope', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --font-head: 'Space Grotesk', 'Manrope', system-ui, sans-serif;
    --tex: url(/assets/brand/fondo-textura.jpg);
    color-scheme: dark;
}

* { box-sizing: border-box; }

html { background: var(--bg); }

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font-body);
    color: var(--ink);
    background:
        radial-gradient(120% 60% at 50% -10%, rgba(255, 46, 77, .16), transparent 60%),
        linear-gradient(rgba(10, 10, 13, .85), rgba(10, 10, 13, .95)),
        var(--tex) center top / cover fixed,
        var(--bg);
    line-height: 1.6;
    -webkit-text-size-adjust: 100%;
}

a { color: var(--red); }

h1, h2, h3 { font-family: var(--font-head); font-weight: 700; letter-spacing: -.02em; }
h1 { font-size: clamp(2rem, 8vw, 3rem); line-height: 1.08; margin: .25em 0 .5em; }
h2 { font-size: 1.2rem; margin: 2.2rem 0 .7rem; }

.accent { color: var(--red); }
.muted { color: var(--ink-dim); }

/* --- Barra superior --- */
.topbar {
    position: sticky; top: 0; z-index: 10;
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    padding: calc(.7rem + env(safe-area-inset-top, 0px)) 16px .7rem;
    background: rgba(10, 10, 13, .85);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--card-border);
}
.brand { display: flex; align-items: center; gap: .7rem; text-decoration: none; color: var(--ink); }
.brand img { height: 32px; width: auto; display: block; }
.brand-product {
    font-family: var(--font-head); font-size: .78rem; font-weight: 600;
    letter-spacing: .1em; text-transform: uppercase; color: var(--ink-dim);
    padding-left: .7rem; border-left: 1px solid var(--card-border);
}
.topbar-user { display: flex; align-items: center; gap: .6rem; margin: 0; }
.topbar-user .muted { font-size: .88rem; }
@media (max-width: 420px) {
    .topbar-user .muted { display: none; }
}

.container { max-width: 960px; margin: 0 auto; padding: 1.75rem 16px 4rem; }
.narrow { max-width: 420px; margin: 1rem auto; }
.center { text-align: center; }

/* --- Portada --- */
.hero { max-width: 480px; margin: 1.5rem auto 0; }
.eyebrow {
    display: inline-block; margin: 0;
    font-size: .8rem; font-weight: 600; color: var(--red);
}
.lead { font-size: 1.08rem; color: var(--ink-dim); margin-top: 0; }
.join-card { margin-top: 1.75rem; }
.staff-link { text-align: center; margin-top: 1.75rem; font-size: .92rem; }
.staff-link a { color: var(--ink-dim); text-decoration: none; }
.staff-link a:hover { color: var(--ink); }

/* --- Tarjetas y formularios --- */
.card {
    background: var(--card);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    padding: 1.35rem;
    box-shadow: 0 20px 50px rgba(0, 0, 0, .35);
}
.form { display: grid; gap: .35rem; }
.label { font-weight: 600; font-size: .9rem; margin-top: .5rem; display: block; }
.input {
    width: 100%; font: inherit; font-size: 1rem;
    padding: .8rem .95rem; margin: .35rem 0 .5rem;
    border: 1px solid var(--card-border); border-radius: 12px;
    background: var(--bg2); color: var(--ink);
}
.input::placeholder { color: #5d5862; }
.input:focus { outline: none; border-color: var(--red); box-shadow: 0 0 0 3px rgba(255, 46, 77, .22); }
.input:disabled { opacity: .6; }
.input-code {
    font-family: var(--font-head); font-weight: 700; font-size: 1.35rem;
    text-transform: uppercase; letter-spacing: .2em; text-align: center;
}
.input-code::placeholder { letter-spacing: .08em; text-transform: none; font-weight: 500; font-size: 1.05rem; }
.hint { font-size: .85rem; color: var(--ink-dim); margin: .7rem 0 0; text-align: center; }

.btn {
    display: inline-flex; align-items: center; justify-content: center;
    font: inherit; font-weight: 700; text-decoration: none; cursor: pointer;
    padding: .85rem 1.4rem; border-radius: 999px; border: 1px solid transparent;
    transition: transform .15s ease, box-shadow .15s ease, filter .15s ease;
}
.btn-primary {
    background: var(--red); color: #fff;
    box-shadow: 0 8px 24px rgba(255, 46, 77, .35);
}
.btn-primary:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn-primary:disabled { opacity: .4; cursor: not-allowed; box-shadow: none; transform: none; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--card-border); }
.btn-ghost:hover { border-color: var(--ink-dim); }
.btn-sm { padding: .4rem .9rem; font-size: .84rem; }
.btn-block { width: 100%; margin-top: .7rem; }

/* --- Mensajes --- */
.alert { padding: .85rem 1rem; border-radius: 12px; margin-bottom: 1rem; border: 1px solid; font-weight: 500; }
.alert-error   { background: rgba(255, 46, 77, .10); border-color: rgba(255, 46, 77, .4); color: #ff8a9b; }
.alert-info    { background: rgba(255, 150, 66, .10); border-color: rgba(255, 150, 66, .35); color: #ffc08f; }
.alert-success { background: rgba(60, 207, 122, .10); border-color: rgba(60, 207, 122, .35); color: #8fe6b2; }

/* --- Panel --- */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: .75rem; margin-top: 1.25rem; }
@media (min-width: 720px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat {
    background: var(--card); border: 1px solid var(--card-border); border-radius: var(--radius);
    padding: 1.1rem; display: flex; flex-direction: column;
    border-left: 3px solid var(--red);
}
.stat:nth-child(2) { border-left-color: var(--orange); }
.stat-value { font-family: var(--font-head); font-size: 2.1rem; font-weight: 700; line-height: 1; }
.stat-label { color: var(--ink-dim); font-size: .86rem; margin-top: .4rem; }
.roadmap { color: var(--ink-dim); padding-left: 1.2rem; }
.roadmap li::marker { color: var(--red); }

/* =====================  Panel de administración  ===================== */
.subnav {
    display: flex; gap: .25rem; overflow-x: auto; scrollbar-width: none;
    padding: .5rem 12px; border-bottom: 1px solid var(--card-border);
    background: rgba(10, 10, 13, .7);
}
.subnav::-webkit-scrollbar { display: none; }
.subnav a {
    flex: 0 0 auto; padding: .45rem .9rem; border-radius: 999px;
    color: var(--ink-dim); text-decoration: none; font-weight: 600; font-size: .9rem;
}
.subnav a:hover { color: var(--ink); }
.subnav a.active { background: rgba(255, 46, 77, .14); color: var(--ink); box-shadow: inset 0 0 0 1px rgba(255, 46, 77, .45); }
@media (min-width: 720px) { .subnav { justify-content: center; } }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.page-head h1 { margin: .1em 0 0; font-size: clamp(1.6rem, 6vw, 2.2rem); }
.page-head .actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.back { display: inline-block; color: var(--ink-dim); text-decoration: none; font-size: .9rem; margin-bottom: .4rem; }
.back:hover { color: var(--ink); }

/* Listas tipo tarjeta */
.list { display: grid; gap: .6rem; padding: 0; margin: 0; list-style: none; }
.row {
    display: flex; align-items: center; gap: .9rem;
    background: var(--card); border: 1px solid var(--card-border); border-radius: 14px;
    padding: .85rem 1rem; text-decoration: none; color: var(--ink);
}
a.row:hover { border-color: #3a3540; }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 700; display: block; overflow: hidden; text-overflow: ellipsis; }
.row-sub { color: var(--ink-dim); font-size: .86rem; display: block; }
.row-side { display: flex; gap: .4rem; align-items: center; flex-shrink: 0; }
.row-num {
    width: 2rem; height: 2rem; border-radius: 50%; flex-shrink: 0;
    display: grid; place-items: center; font-family: var(--font-head); font-weight: 700;
    background: rgba(255, 46, 77, .14); color: var(--red);
}
.empty { text-align: center; padding: 2.2rem 1rem; color: var(--ink-dim); border: 1px dashed var(--card-border); border-radius: var(--radius); }
.empty p { margin: 0 0 1rem; }

.badge {
    display: inline-block; padding: .15rem .6rem; border-radius: 999px; font-size: .74rem; font-weight: 700;
    background: #221f27; color: var(--ink-dim); white-space: nowrap;
}
.badge-red { background: rgba(255, 46, 77, .15); color: #ff8a9b; }
.badge-orange { background: rgba(255, 150, 66, .15); color: #ffc08f; }
.badge-green { background: rgba(60, 207, 122, .14); color: #8fe6b2; }

/* Formularios del panel */
.form-card { max-width: 720px; }
.grid-2 { display: grid; gap: 0 1rem; }
@media (min-width: 640px) { .grid-2 { grid-template-columns: 1fr 1fr; } }
.field { margin-bottom: .4rem; }
.field-help { font-size: .82rem; color: var(--ink-dim); margin: -.2rem 0 .5rem; }
.field-error { font-size: .84rem; color: #ff8a9b; margin: -.2rem 0 .5rem; }
.input-invalid { border-color: var(--red) !important; }
textarea.input { min-height: 6rem; resize: vertical; line-height: 1.5; }
select.input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--ink-dim) 50%), linear-gradient(135deg, var(--ink-dim) 50%, transparent 50%); background-position: calc(100% - 18px) 55%, calc(100% - 13px) 55%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 2.2rem; }
input[type=file].input { padding: .6rem; }
.color-field { display: flex; align-items: center; gap: .6rem; }
.color-field input[type=color] { width: 3rem; height: 2.8rem; padding: 0; border: 1px solid var(--card-border); border-radius: 10px; background: none; cursor: pointer; }
.color-field .input { margin: 0; }
.check { display: flex; gap: .6rem; align-items: flex-start; margin: .7rem 0; cursor: pointer; }
.check input { width: 1.15rem; height: 1.15rem; margin-top: .2rem; accent-color: var(--red); flex-shrink: 0; }
.fieldset { border: 0; padding: 0; margin: 1.6rem 0 0; }
.fieldset legend { font-family: var(--font-head); font-weight: 700; font-size: 1.05rem; padding: 0; margin-bottom: .3rem; }
.form-actions { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: 1.4rem; }
.btn-danger { background: transparent; color: #ff8a9b; border-color: rgba(255, 46, 77, .45); }
.btn-danger:hover { background: rgba(255, 46, 77, .1); }
.btn-icon { padding: .35rem .6rem; font-size: .85rem; line-height: 1; }
.inline { display: inline; margin: 0; }
.danger-zone { margin-top: 2.5rem; padding-top: 1.25rem; border-top: 1px solid var(--card-border); }

/* Marca: logo y muestras de color */
.logo-thumb { width: 52px; height: 52px; border-radius: 12px; object-fit: contain; background: #000; border: 1px solid var(--card-border); flex-shrink: 0; padding: 4px; }
.logo-thumb.placeholder { display: grid; place-items: center; font-family: var(--font-head); font-weight: 700; color: var(--ink-dim); }
.swatches { display: flex; gap: .3rem; }
.swatch { width: 18px; height: 18px; border-radius: 50%; border: 1px solid rgba(255, 255, 255, .2); }
.logo-preview { max-width: 220px; max-height: 90px; display: block; margin: .3rem 0 .6rem; padding: .5rem; background: #000; border-radius: 10px; border: 1px solid var(--card-border); }
.brand-preview { border-radius: 14px; padding: 1rem; border: 1px solid var(--card-border); margin-top: .5rem; }
.brand-preview .bp-btn { display: inline-block; margin-top: .6rem; padding: .45rem 1rem; border-radius: 999px; font-weight: 700; font-size: .85rem; }

/* Secciones de detalle */
.section { margin-top: 2rem; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: .8rem; }
.section-head h2 { margin: 0; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .45rem 1rem; margin: 0; }
.kv dt { color: var(--ink-dim); font-size: .9rem; }
.kv dd { margin: 0; font-weight: 600; }
.code { font-family: var(--font-head); font-weight: 700; letter-spacing: .12em; color: var(--orange); }
.type-help { font-size: .86rem; color: var(--ink-dim); background: var(--bg2); border: 1px solid var(--card-border); border-radius: 10px; padding: .6rem .8rem; margin: .2rem 0 .8rem; }
.cfg[hidden] { display: none; }
.event-row-status { min-width: 5.5rem; text-align: right; }

/* Ajustes móviles */
@media (max-width: 480px) {
    .subnav { gap: 0; padding: .45rem 8px; }
    .subnav a { padding: .4rem .62rem; font-size: .85rem; }
}
[id] { scroll-margin-top: 80px; } /* que la barra fija no tape el destino de un ancla */
.event-controls { display: flex; align-items: center; justify-content: space-between; gap: .8rem; flex-wrap: wrap; margin-bottom: 1rem; padding: .9rem 1rem; }
.event-controls .actions { display: flex; gap: .5rem; }

/* =====================  Panel en vivo  ===================== */
.container-wide { max-width: 1240px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.small { font-size: .85rem; }
.input-sm { padding: .5rem .7rem; margin: 0; font-size: .92rem; border-radius: 10px; }
.live-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.2rem; }
.live-head h1 { margin: .1em 0 .3em; font-size: clamp(1.5rem, 5vw, 2.1rem); }
.live-head .actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.live-meta { display: flex; align-items: center; gap: .7rem; flex-wrap: wrap; }
.live-clock { font-family: var(--font-head); font-weight: 700; font-size: 1.2rem; font-variant-numeric: tabular-nums; }
.live-grid { display: grid; gap: 1.5rem; }
@media (min-width: 960px) { .live-grid { grid-template-columns: 1.5fr 1fr; align-items: start; } }
.live-section { margin-bottom: 1.8rem; }
.live-section h2 { margin: 0 0 .7rem; display: flex; align-items: center; gap: .5rem; }
.count { background: var(--red); color: #fff; border-radius: 999px; font-size: .8rem; padding: .1rem .55rem; }
.empty-sm { border: 1px dashed var(--card-border); border-radius: 12px; padding: .9rem 1rem; margin: 0; font-size: .92rem; }

.review { margin-bottom: .9rem; padding: 1rem; }
.review-head { display: flex; justify-content: space-between; gap: .6rem; flex-wrap: wrap; font-size: .95rem; }
.review-task { color: var(--ink-dim); font-size: .88rem; margin: .4rem 0 .7rem; }
.review-media { display: grid; gap: .6rem; margin: .6rem 0; }
.review-media.compare { grid-template-columns: 1fr 1fr; }
.review-media figure { margin: 0; }
.review-media img, .review-media video { width: 100%; max-height: 420px; object-fit: contain; background: #000; border-radius: 10px; display: block; }
.review-media audio { width: 100%; }
.review-media figcaption { font-size: .78rem; color: var(--ink-dim); margin-top: .25rem; text-align: center; }
.review-note { margin: .2rem 0 .6rem; }
.review-actions { display: grid; gap: .5rem; }
.review-approve, .review-reject, .inline-form { display: flex; gap: .4rem; align-items: center; margin: 0; }
.review-approve .input { max-width: 6.5rem; }
.review-reject .input, .inline-form .input { flex: 1; min-width: 0; }

.team-live details { background: var(--card); border: 1px solid var(--card-border); border-radius: 14px; }
.team-live details[open] { border-color: #3a3540; }
.team-live summary { list-style: none; cursor: pointer; border: 0; background: none; }
.team-live summary::-webkit-details-marker { display: none; }
.team-score { font-family: var(--font-head); font-weight: 700; font-size: 1.3rem; text-align: right; }
.team-score small { display: block; font-size: .7rem; color: var(--ink-dim); font-weight: 500; }
.team-actions { padding: 0 1rem 1rem; display: grid; gap: .55rem; }
.team-actions p { margin: 0; }
.btn-row { display: flex; gap: .4rem; flex-wrap: wrap; }

.msg-form { display: grid; gap: .5rem; padding: .9rem; }
.msg-form .input { margin: 0; min-height: 3.5rem; }
.msg-form .btn { justify-self: end; }
.feed { list-style: none; padding: 0; margin: .8rem 0 0; display: grid; gap: .35rem; }
.feed li { font-size: .9rem; padding: .5rem .75rem; border-radius: 10px; background: var(--card); border: 1px solid var(--card-border); }
.feed small { display: block; color: var(--ink-dim); font-size: .74rem; }
.feed-team_finished, .feed-submission_sent { border-left: 3px solid var(--orange) !important; }
.feed-answer_correct, .feed-submission_approved { border-left: 3px solid var(--ok) !important; }
.feed-event_start, .feed-event_pause, .feed-event_resume, .feed-event_finish { border-left: 3px solid var(--red) !important; }
.news { position: fixed; left: 16px; right: 16px; bottom: calc(1.2rem + env(safe-area-inset-bottom, 0px)); z-index: 30; text-align: center; }
.news .btn { box-shadow: 0 10px 30px rgba(0,0,0,.45); }

/* =====================  Mapa  ===================== */
.minimap { position: relative; overflow: hidden; background: #d9d4cc; border-radius: 14px; border: 1px solid var(--card-border); user-select: none; -webkit-user-select: none; cursor: grab; height: 320px; }
.minimap.mm-dragging { cursor: grabbing; }
.mm-pane, .mm-tiles, .mm-overlay { position: absolute; inset: 0; }
.mm-tile { position: absolute; left: 0; top: 0; width: 256px; height: 256px; max-width: none; pointer-events: none; }
.mm-overlay { pointer-events: none; }
.mm-marker { position: absolute; left: 0; top: 0; pointer-events: auto; will-change: transform; }
.mm-circle { position: absolute; left: 0; top: 0; border-radius: 50%; background: rgba(255, 46, 77, .16); border: 2px solid rgba(255, 46, 77, .8); pointer-events: none; }
.mm-zoom { position: absolute; top: 10px; right: 10px; display: flex; flex-direction: column; border-radius: 10px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,.3); z-index: 2; }
.mm-zoom button { width: 36px; height: 36px; border: 0; background: #fff; color: #222; font-size: 1.25rem; font-weight: 700; cursor: pointer; }
.mm-zoom button + button { border-top: 1px solid #ddd; }
.mm-attr { position: absolute; right: 0; bottom: 0; font-size: 10px; background: rgba(255,255,255,.8); color: #333; padding: 1px 6px; border-top-left-radius: 6px; z-index: 2; }
.mm-attr a { color: #0645ad; }

/* Pin con número (pruebas) */
.mm-pin { width: 0; height: 0; }
.mm-pin > span {
    position: absolute; left: -15px; top: -38px; width: 30px; height: 30px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg);
    background: var(--red); border: 2px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.4); display: grid; place-items: center;
}
.mm-pin > span > b { transform: rotate(45deg); color: #fff; font: 700 .8rem var(--font-head); }
/* Equipo en vivo */
.mm-team { width: 0; height: 0; }
.mm-team > span {
    position: absolute; transform: translate(-50%, -50%); white-space: nowrap; display: flex; align-items: center; gap: .35rem;
    background: #fff; color: #111; border-radius: 999px; padding: .2rem .6rem .2rem .25rem; font: 700 .78rem var(--font-body);
    box-shadow: 0 2px 8px rgba(0,0,0,.35); cursor: pointer;
}
.mm-team > span::before { content: ""; width: 14px; height: 14px; border-radius: 50%; background: var(--ok); border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.2); }
.mm-team.stale > span { opacity: .65; }
.mm-team.stale > span::before { background: #f0b429; }
.mm-team.lost > span::before { background: #999; }
.mm-me > span::before { background: #2f80ed; }

.map-tools { display: flex; gap: .5rem; flex-wrap: wrap; margin: .5rem 0; }
.map-tools .input { flex: 1; min-width: 12rem; margin: 0; }
.map-results { list-style: none; padding: 0; margin: 0 0 .5rem; border: 1px solid var(--card-border); border-radius: 10px; overflow: hidden; }
.map-results button { width: 100%; text-align: left; background: var(--bg2); color: var(--ink); border: 0; border-bottom: 1px solid var(--card-border); padding: .55rem .8rem; font: inherit; font-size: .88rem; cursor: pointer; }
.map-results button:hover { background: var(--card); }
.map-legend { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .8rem; color: var(--ink-dim); margin-top: .4rem; }
.map-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: .3rem; vertical-align: middle; }
.row-side { flex-wrap: wrap; justify-content: flex-end; }
.table-wrap { overflow-x: auto; border: 1px solid var(--card-border); border-radius: 14px; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { padding: .65rem .8rem; text-align: left; border-bottom: 1px solid var(--card-border); white-space: nowrap; }
.table th { color: var(--ink-dim); font-weight: 600; font-size: .8rem; background: var(--bg2); }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.checklist { list-style: none; padding: 0; margin: .6rem 0 0; display: grid; gap: .3rem; font-size: .92rem; }
.checklist .ok { color: #8fe6b2; }
.checklist .bad { color: #ff8a9b; font-weight: 600; }
.checklist .warn { color: #ffc08f; }
