@font-face {
    font-family: "Rock Salt";
    src: url("/fonts/rock-salt.woff2") format("woff2");
    font-display: swap;
}

@font-face {
    font-family: "Bebas Neue";
    src: url("/fonts/bebas-neue.woff2") format("woff2");
    font-display: swap;
}

:root {
    --bg: #111;
    --panel: #1c1c1c;
    --line: #2e2e2e;
    --text: #f2f2f2;
    --muted: #a0a0a0;
    --accent: #ffd400;
    --accent-ink: #111;
    --danger: #ff5a5a;
    --radius: 14px;
    --display: "Rock Salt", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 16px;
    line-height: 1.45;
}

a { color: var(--accent); }
h1 { font-family: var(--display); font-weight: 400; font-size: 2rem; margin: .4rem 0 .6rem; letter-spacing: .02em; }
h2 { font-size: 1.1rem; margin: 1.6rem 0 .6rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
img { max-width: 100%; display: block; }

.muted { color: var(--muted); }
.small { font-size: .875rem; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Barra superior y menú */
.topbar {
    position: sticky; top: 0; z-index: 1100; /* sobre los controles del mapa (1000) */
    display: flex; align-items: center; justify-content: space-between;
    padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
    background: var(--bg); border-bottom: 1px solid var(--line);
}
.topbar { gap: 12px; }
/* El logo ocupa todo el ancho libre junto al menú, con un tope para pantallas grandes */
.logo { display: block; line-height: 0; flex: 1 1 auto; min-width: 0; max-width: 202px; }
.logo img { display: block; width: 100%; height: auto; }
.burger { width: 44px; height: 44px; display: grid; place-content: center; gap: 5px; background: none; border: 0; cursor: pointer; }
.burger span { display: block; width: 26px; height: 3px; background: var(--text); border-radius: 2px; transition: transform .2s, opacity .2s; }
.menu-open .burger span:nth-child(1) { transform: translateY(8px) rotate(45deg); }
.menu-open .burger span:nth-child(2) { opacity: 0; }
.menu-open .burger span:nth-child(3) { transform: translateY(-8px) rotate(-45deg); }

.menu {
    position: fixed; z-index: 1050; top: 0; right: 0; bottom: 0;
    width: min(80vw, 320px);
    padding: calc(env(safe-area-inset-top) + 100px) 24px 24px;
    background: var(--panel); border-left: 1px solid var(--line);
    display: flex; flex-direction: column; gap: 4px;
}
.menu[hidden] { display: none; }
.menu a, .menu button {
    font: inherit; font-size: 1.25rem; font-weight: 700; text-align: left;
    color: var(--text); text-decoration: none; background: none; border: 0;
    padding: 12px 0; border-bottom: 1px solid var(--line); cursor: pointer; width: 100%;
}

.page { max-width: 720px; margin: 0 auto; padding: 16px 16px calc(env(safe-area-inset-bottom) + 40px); }

.flash { background: var(--accent); color: var(--accent-ink); padding: 10px 14px; border-radius: var(--radius); font-weight: 600; }
.errors { background: rgba(255, 90, 90, .12); border: 1px solid var(--danger); border-radius: var(--radius); padding: 4px 14px; margin-bottom: 12px; }
.errors p { margin: 8px 0; color: #ffb3b3; }

/* Inicio */
.home { display: flex; flex-direction: column; gap: 14px; padding-top: 8px; }
.tagline { color: var(--muted); margin: 0 0 6px; }
.home-buttons { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.home-button {
    display: flex; align-items: center; justify-content: center; padding: 9px 4px 7px;
    border-radius: 0; background: var(--panel); border: 1px solid var(--line);
    color: var(--text); text-decoration: none; text-align: center;
    font-family: "Bebas Neue", system-ui, sans-serif; font-size: clamp(1rem, 5vw, 1.2rem); line-height: 1; letter-spacing: .02em; white-space: nowrap; text-transform: uppercase;
}
.home-button.accent { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.more { text-align: center; margin-top: 16px; }
.photo-full { margin: 0 -16px; }
.photo-full img { width: 100%; max-height: 75vh; object-fit: contain; background: #000; }
.photo-full figcaption { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 10px 16px 0; }
.photo-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 12px; }
.photo-actions > * { white-space: nowrap; }
.photo-delete { margin-left: auto; }
/* King (corona) */
.votes { display: flex; gap: 8px; }
.vote {
    display: inline-flex; align-items: center; gap: 6px; font: inherit; font-weight: 700;
    color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 999px;
    padding: 8px 14px; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.vote .crown { width: 1.2em; height: 1.2em; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
.vote .crown rect { fill: currentColor; stroke: none; }
.vote .vote-label { text-transform: uppercase; letter-spacing: .03em; }
.vote.king.on { border-color: var(--accent); color: var(--accent); }
.vote.king.on .crown { fill: currentColor; }
.votes.compact { gap: 3px; padding: 3px 0 6px; }
.votes.compact form { flex: 1; }
.votes.compact .vote { width: 100%; justify-content: center; gap: 3px; padding: 4px 2px; font-size: .72rem; border-radius: 6px; }
.votes.compact > a.vote { flex: 1; }
.votes.compact .vote-label { display: none; }
.comment { padding: 8px 0; border-bottom: 1px solid var(--line); }
.comment p { margin: 2px 0; word-break: break-word; }
.comment-form { margin: 12px 0 20px; }
form.inline { display: inline; }
.link-button { font: inherit; background: none; border: 0; padding: 0 0 0 8px; color: var(--muted); text-decoration: underline; cursor: pointer; }
.photo-tag { font-family: var(--display); font-size: 1.6rem; color: var(--text); text-decoration: none; }
.big-button {
    display: block; padding: 26px 22px; border-radius: var(--radius);
    background: var(--panel); border: 1px solid var(--line);
    color: var(--text); text-decoration: none;
}
.big-button strong { display: block; font-family: var(--display); font-weight: 400; font-size: 1.6rem; text-transform: uppercase; letter-spacing: .03em; }
.big-button span { color: var(--muted); }
.big-button.accent { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.big-button.accent span { color: #3a3300; }

/* Formularios */
.form { display: flex; flex-direction: column; gap: 14px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; }
input:not([type=file]), textarea {
    font: inherit; color: var(--text); background: var(--panel);
    border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; width: 100%;
}
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
input[readonly] { opacity: .7; }
textarea { resize: vertical; }
.button {
    display: inline-flex; justify-content: center; align-items: center;
    font: inherit; font-weight: 800; text-transform: uppercase; letter-spacing: .04em;
    background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 10px;
    padding: 14px 18px; cursor: pointer; text-decoration: none;
}
.button.danger { background: var(--danger); color: #fff; }
.button.small-button { padding: 8px 12px; font-size: .8rem; }
.button.secondary { background: var(--panel); color: var(--text); border: 1px solid var(--line); }
.button:disabled { opacity: .4; cursor: not-allowed; }
.photo-input { display: flex; flex-direction: column; gap: 10px; }
.photo-preview { border-radius: var(--radius); max-height: 50vh; object-fit: contain; background: #000; }

.search-form { display: flex; gap: 8px; margin-bottom: 8px; }
.search-form input { flex: 1; }

/* Perfil y ranking */
.profile-head { display: flex; gap: 16px; align-items: center; }
.avatar { width: 96px; height: 96px; border-radius: var(--radius); object-fit: cover; }

.rank-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 16px; }
.rank-card {
    display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px;
    background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
    color: var(--text); text-decoration: none; text-align: center; font-weight: 700; word-break: break-word;
}
.rank-card img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; }
.rank-card.current { border-color: var(--accent); justify-content: center; }
.pos { color: var(--accent); font-weight: 900; }

.ranking-row {
    display: flex; align-items: center; gap: 12px; padding: 10px 4px;
    border-bottom: 1px solid var(--line); color: var(--text); text-decoration: none;
}
.ranking-row img { width: 52px; height: 52px; object-fit: cover; border-radius: 8px; }
.ranking-row .pos { width: 2.6em; }
.ranking-row .name { flex: 1; min-width: 0; font-weight: 800; font-size: 1.1rem; }
.ranking-row .count { color: var(--muted); }
/* King recibidos por un tag (perfil y ranking) */
.tag-votes { display: flex; gap: 12px; margin: 4px 0 0; font-size: .875rem; font-weight: 700; color: var(--muted); }
.tag-votes > span { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.tag-votes .crown { width: 1.2em; height: 1.2em; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
.tag-votes .crown rect { fill: currentColor; stroke: none; }
.tag-votes.crowned .tag-kings { color: var(--accent); }
.tag-votes.crowned .crown { fill: currentColor; }
.ranking-row .tag-votes { font-size: .78rem; margin-top: 2px; }

.feed { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 3px; }
.feed-item { position: relative; }
.feed-item form { position: absolute; top: 4px; right: 4px; }
.feed-delete { font: inherit; font-size: .75rem; font-weight: 800; background: var(--danger); color: #fff; border: 0; border-radius: 6px; padding: 4px 8px; cursor: pointer; }
.feed a:not(.vote, .rank-chip) { position: relative; display: block; color: var(--text); text-decoration: none; }
.feed img { width: 100%; aspect-ratio: 1; object-fit: cover; }
/* Franja con el nombre y el puesto: el nombre largo se corta con "…" para que el puesto quede dentro de la foto. */
.feed a:not(.vote, .rank-chip) > span { position: absolute; left: 0; right: 0; bottom: 0; display: flex; gap: 4px; padding: 4px 6px; font-size: .75rem; background: rgba(0, 0, 0, .6); }
.feed a:not(.vote, .rank-chip) > span > .tag-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-chip { flex: none; display: inline-flex; align-items: center; justify-content: center; min-width: 2.6em; padding: 4px 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--accent); font-size: .78rem; font-weight: 900; text-decoration: none; }
.photo-rank { display: block; color: var(--accent); font-weight: 800; text-decoration: none; margin-top: 2px; }
.feed.carousel { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.feed.carousel::-webkit-scrollbar { display: none; }
.feed.carousel a { flex: 0 0 calc((100% - 6px) / 3); scroll-snap-align: start; }

/* Mapas */
.map { height: 280px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); }
.map.tall { height: 60vh; }
.tag-pin img { width: 44px; height: 44px; object-fit: cover; border: 3px solid var(--accent); border-radius: 50%; box-shadow: 0 2px 6px rgba(0, 0, 0, .5); }
.leaflet-popup-content a { color: #111; text-decoration: none; text-align: center; display: block; }

/* Administración */
.admin-nav { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.admin-nav a { padding: 8px 12px; border-radius: 999px; border: 1px solid var(--line); color: var(--text); text-decoration: none; font-weight: 700; font-size: .9rem; }
.admin-nav a.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px; }
.stats div { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 6px; text-align: center; }
.stats strong { display: block; font-size: 1.5rem; }
.stats span { color: var(--muted); font-size: .8rem; }
.admin-item { padding: 12px 0; border-bottom: 1px solid var(--line); }
.admin-item p { margin: 4px 0; }
.admin-item.unread { border-left: 3px solid var(--accent); padding-left: 10px; }
.admin-title { font-weight: 800; font-size: 1.1rem; color: var(--text); text-decoration: none; }
.message-body { white-space: pre-line; word-break: break-word; }
.admin-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.badge { font-size: .7rem; background: var(--accent); color: var(--accent-ink); padding: 2px 6px; border-radius: 6px; vertical-align: middle; }
.pager { display: flex; justify-content: space-between; align-items: center; margin-top: 16px; }

/* Ayuda (manual de uso). La misma página se imprime como PDF. */
.manual-cover { display: none; }
.manual-download { margin: 16px 0; }
.manual-index { display: flex; flex-direction: column; margin: 8px 0 8px; border-top: 1px solid var(--line); }
.manual-index a { padding: 10px 2px; border-bottom: 1px solid var(--line); color: var(--text); text-decoration: none; font-weight: 700; }
.manual-index b, .manual-step h2 b { color: var(--accent); font-family: var(--display); font-weight: 400; margin-right: 8px; }
.manual-step { padding: 8px 0 4px; scroll-margin-top: 100px; }
.manual-step h2 { font-family: var(--display); font-weight: 400; font-size: 1.5rem; text-transform: none; letter-spacing: .02em; color: var(--text); margin: 1.6rem 0 .4rem; }
.manual-step ol, .manual-step ul { padding-left: 1.3em; }
.manual-step li { margin: 6px 0; }
.manual-step li::marker { color: var(--accent); font-weight: 800; }
.manual-key { display: inline-block; padding: 1px 8px; border: 1px solid var(--line); background: var(--panel); font-family: "Bebas Neue", system-ui, sans-serif; font-size: 1.1em; line-height: 1.3; letter-spacing: .02em; text-transform: uppercase; }
.manual-key.accent { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.manual-tip { background: var(--panel); border-left: 3px solid var(--accent); border-radius: 0 var(--radius) var(--radius) 0; padding: 10px 14px; }
.manual-step h3 { font-size: 1rem; margin: 1.2rem 0 .5rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.manual-flow { display: grid; grid-template-columns: 1fr auto 1fr auto 1fr; align-items: stretch; gap: 6px; }
.manual-flow div { background: var(--panel); border: 1px solid var(--line); padding: 10px; }
.manual-flow strong { display: block; font-family: "Bebas Neue", system-ui, sans-serif; font-weight: 400; font-size: 1.5rem; line-height: 1; color: var(--accent); margin-bottom: 4px; }
.manual-flow span { font-size: .85rem; color: var(--muted); }
.manual-flow i { align-self: center; font-style: normal; font-weight: 900; color: var(--accent); }
.manual-roles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.manual-roles div { background: var(--panel); border: 1px solid var(--line); border-top: 3px solid var(--accent); padding: 10px 12px; }
.manual-roles strong { font-family: var(--display); font-weight: 400; font-size: 1.1rem; }
.manual-roles p { margin: 6px 0 0; font-size: .9rem; color: var(--muted); }
@media (max-width: 480px) {
    .manual-flow { grid-template-columns: 1fr; }
    .manual-flow i { transform: rotate(90deg); justify-self: center; }
    .manual-roles { grid-template-columns: 1fr; }
}
.manual-shots { display: flex; justify-content: center; gap: 10px; margin: 12px 0 0; }
.manual-shots img { width: min(100%, 260px); height: auto; border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 6px 20px rgba(0, 0, 0, .5); }
.manual-step.two .manual-shots img { width: calc(50% - 5px); }
@media (min-width: 640px) {
    .manual-step.has-shot { display: grid; grid-template-columns: 1fr 240px; gap: 24px; align-items: start; }
    .manual-step.has-shot.two { grid-template-columns: 1fr; }
    .manual-step.has-shot .manual-shots { margin-top: 1.6rem; }
    .manual-step.has-shot.two .manual-shots { margin-top: 0; }
    .manual-step.two .manual-shots img { width: 240px; }
}
.manual-note { margin-top: 24px; }
.manual-faq dt { font-weight: 800; margin-top: 14px; }
.manual-faq dd { margin: 4px 0 0; color: var(--muted); }

@media print {
    @page { size: A4; margin: 0; }
    html, body { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .topbar, .menu, .manual-download, .manual-index, .flash { display: none !important; }
    /* Sin margen de hoja para que el fondo oscuro llegue al borde; el aire lo da el relleno, repetido en cada hoja. */
    .page { max-width: none; padding: 16mm 16mm; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
    .manual-cover { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; height: 265mm; text-align: center; break-after: page; }
    .manual-cover img { width: 70mm; height: auto; }
    .manual-cover-title { font-family: var(--display); font-size: 2.6rem; color: var(--accent); margin: 18px 0 0; }
    .manual-qr { margin-top: 18mm; display: flex; flex-direction: column; align-items: center; gap: 8px; }
    .manual-qr img { width: 42mm; height: 42mm; border: 3px solid var(--accent); border-radius: 10px; }
    .manual-qr p { margin: 0; color: var(--muted); }
    .manual-qr strong { color: var(--accent); font-size: 1.2rem; }
    .manual-step { break-inside: avoid; }
    .manual-intro { break-after: page; }
    .manual-step.has-shot { display: grid; grid-template-columns: 1fr 58mm; gap: 8mm; align-items: start; }
    .manual-step.has-shot.two { grid-template-columns: 1fr 98mm; }
    .manual-step.has-shot .manual-shots { margin-top: 1.6rem; }
    .manual-step.two .manual-shots img, .manual-shots img { width: 100%; min-width: 0; box-shadow: none; }
    .manual-step.two .manual-shots img { width: calc(50% - 2mm); }
    a { color: var(--text); text-decoration: none; }
}

/* Spotting: sugerencias de tags cercanos y lectura con IA */
.tag-suggest { margin: -4px 0 4px; }
.tag-suggest p { margin: 0 0 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font: inherit; font-weight: 700; background: transparent; color: var(--text); border: 1px solid var(--accent); border-radius: 999px; padding: 6px 12px; cursor: pointer; }
.chip.selected { background: var(--accent); color: var(--accent-ink); }
.tag-reader { margin: 0; }
.tag-reader strong { color: var(--accent); }

/* Mis mensajes y avisos de King */
.burger { position: relative; }
.burger-dot { position: absolute; top: 8px; right: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); border: 2px solid var(--bg); }
.count-badge { display: inline-block; min-width: 1.5em; margin-left: 6px; padding: 1px 6px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-size: .8rem; font-weight: 800; text-align: center; }
.inbox-write { margin-bottom: 14px; }
.inbox-write summary { display: inline-block; list-style: none; cursor: pointer; }
.inbox-write summary::-webkit-details-marker { display: none; }
.inbox-write[open] summary { margin-bottom: 10px; }
.inbox { display: flex; flex-direction: column; gap: 8px; }
.inbox-item { display: block; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; color: var(--text); text-decoration: none; }
.inbox-item p { margin: 2px 0; }
.inbox-item.new { border-color: var(--accent); }
.inbox-item.message.mine { margin-left: 15%; background: transparent; }
.inbox-item.notice { display: flex; align-items: center; gap: 12px; }
.notice-icon { flex: none; display: grid; place-content: center; width: 40px; height: 40px; border-radius: 50%; border: 2px solid currentColor; font-weight: 900; text-transform: uppercase; font-size: .75rem; }
.notice.king .notice-icon { color: var(--accent); }
.notice.king .crown { width: 22px; height: 22px; fill: currentColor; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
.notice-text { flex: 1; min-width: 0; line-height: 1.35; }
.notice-text .muted { display: block; }
.notice.king b { color: var(--accent); }
.tag-name { font-family: var(--display); }
.notice-thumb { flex: none; width: 52px; height: 52px; object-fit: cover; border-radius: 8px; }
.conversation-row { display: block; color: var(--text); text-decoration: none; }
.conversation-row .muted { display: block; margin-top: 4px; }
.chat { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.chat-bubble { max-width: 85%; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 12px; }
.chat-bubble p { margin: 2px 0; }
.chat-bubble.mine { align-self: flex-end; border-color: var(--accent); }

/* Reportar, bloquear, mi cuenta y privacidad */
.photo-safety { margin: 10px 0 0; }
details.report { display: inline; }
details.report > summary { display: inline; list-style: none; }
details.report > summary::-webkit-details-marker { display: none; }
details.report[open] { display: block; }
.report-form { margin: 10px 0; padding: 12px 14px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); gap: 8px; color: var(--text); }
.report-form p { margin: 0; }
.form label.radio, .form label.check { flex-direction: row; align-items: center; gap: 10px; font-weight: 400; }
.form label.radio input, .form label.check input { width: auto; accent-color: var(--accent); }
.blocked-note { padding: 18px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.blocked-note p { margin: 0 0 10px; }
.blocked-list { list-style: none; padding: 0; margin: 0; }
.blocked-list li { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.danger-zone { margin-top: 28px; padding: 16px; border: 1px solid var(--danger); border-radius: var(--radius); }
.danger-zone h2 { margin-top: 0; color: var(--danger); }
.prose p, .prose li { line-height: 1.55; }
.prose h2 { margin-top: 1.8rem; }
.report-thumb { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; vertical-align: middle; margin-right: 8px; }
.admin-item.resolved { opacity: .55; }
