:root {
  --green: #0f3d2e;
  --green-2: #17573f;
  --green-3: #2e7d32;
  --red: #c62828;
  --red-2: #9e1c1c;
  --gold: #d4a017;
  --cream: #fffaf0;
  --paper: #ffffff;
  --ink: #23201c;
  --muted: #6f6a62;
  --line: #ece4d4;
  --radius: 18px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .18);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, #1d6b4f 0%, transparent 60%),
    radial-gradient(900px 500px at 110% 10%, #7a1f1f 0%, transparent 55%),
    var(--green);
  min-height: 100vh;
  padding-bottom: calc(86px + env(safe-area-inset-bottom));
}
h1, h2, h3, .brand, .kicker, .t-top, .t-ups, .pot-amount { font-family: "Baloo 2", "Nunito", sans-serif; }
h2 { margin: .1em 0 .4em; font-size: 1.5rem; line-height: 1.15; color: var(--green); }
h3 { margin: 0 0 .6em; font-size: 1.2rem; color: var(--green); }
a { color: var(--red); }
code { background: #f4efe4; padding: 2px 6px; border-radius: 6px; font-size: .9em; word-break: break-all; }
img { max-width: 100%; }

/* Nieve */
.snow { position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: .55;
  background-image:
    radial-gradient(2px 2px at 20px 30px, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 120px 80px, #fff 50%, transparent 51%),
    radial-gradient(3px 3px at 220px 150px, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 300px 40px, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 80px 200px, #fff 50%, transparent 51%),
    radial-gradient(2.5px 2.5px at 170px 260px, #fff 50%, transparent 51%);
  background-size: 340px 300px;
  animation: snow 18s linear infinite;
}
@keyframes snow { to { background-position: 60px 300px; } }
@media (prefers-reduced-motion: reduce) { .snow { animation: none; } }

/* Barra superior y navegación */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 16px; background: rgba(10, 42, 32, .92); backdrop-filter: blur(6px); color: #fff;
  border-bottom: 3px solid var(--red); }
.brand { color: #fff; text-decoration: none; font-weight: 800; font-size: 1.1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.link-light { color: #ffe9b0; font-weight: 700; text-decoration: none; font-size: .9rem; }

.nav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; display: flex; justify-content: space-around;
  background: #fff; border-top: 3px solid var(--red); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  box-shadow: 0 -6px 20px rgba(0,0,0,.15); overflow-x: auto; }
.nav a { flex: 1; min-width: 58px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 2px;
  color: var(--muted); text-decoration: none; font-size: .7rem; font-weight: 800; border-radius: 12px; }
.nav a span { font-size: 1.35rem; line-height: 1; }
.nav a.on { color: var(--red); background: #fdecec; }

.wrap { position: relative; z-index: 1; max-width: 760px; margin: 0 auto; padding: 18px 14px; }
.foot { position: relative; z-index: 1; text-align: center; color: rgba(255,255,255,.6); font-size: .8rem; padding: 10px 0 20px; }

/* Tarjetas */
.card { background: var(--cream); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; box-shadow: var(--shadow);
  border: 1px solid rgba(255,255,255,.5); }
.card.slim { display: flex; flex-wrap: wrap; gap: 6px 18px; padding: 12px 16px; font-size: .92rem; }
.center { text-align: center; }
.stack { display: flex; flex-direction: column; gap: 10px; align-items: center; margin: 6px 0 20px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.row-end { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.kicker { margin: 0 0 4px; text-transform: uppercase; letter-spacing: .08em; font-size: .78rem; font-weight: 700; color: var(--red); }
.ok-text { color: var(--green-3); font-weight: 700; }

/* Boleto de bienvenida (inspirado en el papelito) */
.ticket { position: relative; background: var(--paper); border-radius: 6px; padding: 26px 20px 30px; margin: 8px auto 22px;
  max-width: 520px; text-align: center; box-shadow: 0 18px 40px rgba(0,0,0,.35); transform: rotate(-1.2deg);
  background-image:
    linear-gradient(transparent 96%, rgba(0,0,0,.035) 96%),
    linear-gradient(90deg, transparent 49.6%, rgba(0,0,0,.04) 50%, transparent 50.4%);
  background-size: 100% 34px, 100% 100%; }
.ticket::before, .ticket::after { content: ""; position: absolute; left: 0; right: 0; height: 10px;
  background: radial-gradient(circle at 6px 0, transparent 5px, var(--paper) 5.5px) repeat-x; background-size: 12px 10px; }
.ticket::before { top: -9px; transform: rotate(180deg); }
.ticket::after { bottom: -9px; }
.t-top { color: #138a3e; font-weight: 800; font-size: clamp(1.3rem, 5.5vw, 1.9rem); letter-spacing: .02em; }
.t-ups { color: var(--red); font-weight: 800; font-size: clamp(1.1rem, 4.6vw, 1.55rem); margin: 4px 0 14px; }
.t-reto { margin: 0 0 6px; font-size: 1.12rem; font-weight: 700; color: #222; }
.t-meta { margin: 0 0 16px; color: #138a3e; font-weight: 800; font-size: 1.05rem; }
.t-toca { margin: 0; color: #222; font-weight: 600; }
.t-name { margin: 8px 0 0; font-family: "Baloo 2", sans-serif; font-size: clamp(1.6rem, 7vw, 2.2rem); color: var(--red);
  font-weight: 800; border-bottom: 2px dashed #ccc; display: inline-block; padding: 0 12px; }

/* Avatares */
.av { display: inline-flex; align-items: center; gap: 8px; vertical-align: middle; }
.av-circle { display: inline-grid; place-items: center; border-radius: 50%; background: var(--avc);
  box-shadow: inset 0 0 0 3px rgba(255,255,255,.65), 0 3px 8px rgba(0,0,0,.2); line-height: 1; }
.av-sm .av-circle { width: 32px; height: 32px; font-size: 18px; }
.av-md .av-circle { width: 42px; height: 42px; font-size: 24px; }
.av-lg .av-circle { width: 60px; height: 60px; font-size: 34px; }
.av-xl { flex-direction: column; margin: 8px 0 4px; }
.av-xl .av-circle { width: 104px; height: 104px; font-size: 60px; }
.av-name { font-weight: 800; color: var(--green); }
.av-xl .av-name { font-family: "Baloo 2", sans-serif; font-size: 1.5rem; }

/* Botones */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; cursor: pointer;
  background: var(--green-2); color: #fff; font: inherit; font-weight: 800; padding: 11px 18px; border-radius: 999px;
  text-decoration: none; box-shadow: 0 4px 0 rgba(0,0,0,.2); transition: transform .08s; }
.btn:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0,0,0,.2); }
.btn-red { background: var(--red); }
.btn-green { background: var(--green-3); }
.btn-ghost { background: #fff; color: var(--green); box-shadow: inset 0 0 0 2px var(--green-2); }
.btn-lg { padding: 14px 28px; font-size: 1.08rem; min-width: 220px; }
.btn-sm { padding: 6px 12px; font-size: .85rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* Formularios */
.form { display: flex; flex-direction: column; gap: 12px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-weight: 700; font-size: .92rem; }
.form label.check { flex-direction: row; align-items: center; gap: 8px; }
input, select, textarea { font: inherit; padding: 11px 12px; border-radius: 12px; border: 2px solid var(--line); background: #fff; color: var(--ink); width: 100%; }
input[type=checkbox], input[type=radio] { width: auto; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--green-3); }
.form-inline { flex-direction: row; flex-wrap: wrap; align-items: flex-end; }
.form-inline label { flex: 1; min-width: 200px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }
.dayset { border: 2px solid var(--line); border-radius: 14px; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.dayset legend { font-weight: 800; color: var(--green); padding: 0 6px; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }

/* Avisos */
.alert { border-radius: 14px; padding: 12px 14px; margin-bottom: 14px; font-weight: 700; }
.alert-ok { background: #e7f6ea; color: #1f5f2a; }
.alert-error { background: #fdecec; color: var(--red-2); }
.alert-warn { background: #fff4d6; color: #7a5600; }
.status { border-radius: 12px; padding: 10px 12px; font-weight: 700; margin: 0; }
.status-ok { background: #e7f6ea; color: #1f5f2a; }
.status-wait { background: #fff4d6; color: #7a5600; }
.status-bad { background: #fdecec; color: var(--red-2); }

.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .75rem; font-weight: 800; background: #eee; color: #555; white-space: nowrap; }
.pill-gold { background: var(--gold); color: #3b2a00; }
.pill-futuro { background: #eceff1; color: #546e7a; }
.pill-entrega { background: #fff4d6; color: #7a5600; }
.pill-votacion { background: #fdecec; color: var(--red-2); }
.pill-cerrada { background: #e7f6ea; color: #1f5f2a; }
.pill-pending { background: #fff4d6; color: #7a5600; }
.pill-approved { background: #e7f6ea; color: #1f5f2a; }
.pill-rejected { background: #fdecec; color: var(--red-2); }

/* Bote */
.pot { text-align: center; background: linear-gradient(135deg, #fff8e1, #fffaf0); border: 2px solid #f1d27a; }
.pot-amount { margin: 0; font-size: 2.6rem; font-weight: 800; color: var(--green); line-height: 1.1; }
.pot.slim { text-align: left; }

/* Calendario */
.days { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.day a { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 14px; background: #fff; text-decoration: none; color: var(--ink); border: 2px solid var(--line); }
.day-n { flex: none; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: var(--red); color: #fff; font-weight: 800; font-family: "Baloo 2", sans-serif; font-size: 1.2rem; }
.day-cerrada .day-n { background: var(--green-3); }
.day-futuro .day-n { background: #90a4ae; }
.day-body { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.day-tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 14px; padding-bottom: 2px; }
.day-tabs a { flex: none; padding: 8px 14px; border-radius: 999px; background: rgba(255,255,255,.9); color: var(--green); font-weight: 800; text-decoration: none; font-size: .9rem; }
.day-tabs a.on { background: var(--red); color: #fff; }
.card .day-tabs a { background: #f1ebdd; }
.card .day-tabs a.on { background: var(--red); }

.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; }
.facts div { background: #fff; border-radius: 12px; padding: 8px; text-align: center; border: 2px solid var(--line); }
.facts span { display: block; font-size: .72rem; color: var(--muted); font-weight: 700; text-transform: uppercase; }
.facts strong { font-size: .92rem; }

/* Fotos y caritas */
.photo { display: block; width: 100%; max-height: 420px; object-fit: contain; background: #f4efe4; border-radius: 14px; margin-bottom: 10px; }
.file-drop { position: relative; border: 3px dashed #d9cfb9; border-radius: 16px; padding: 22px 12px; text-align: center; background: #fff; cursor: pointer; }
.file-drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.file-drop span { font-weight: 800; color: var(--green); }
.file-drop .preview { display: block; margin: 10px auto 0; max-height: 240px; border-radius: 12px; }
.caritas { border: 0; padding: 0; margin: 0; display: flex; justify-content: space-between; gap: 4px; flex-wrap: wrap; }
.caritas legend { font-weight: 800; margin-bottom: 8px; width: 100%; }
.carita-opt { flex: 1; min-width: 56px; display: flex !important; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px; border-radius: 14px; cursor: pointer; border: 3px solid transparent; font-size: .72rem !important; text-align: center; }
.carita-opt input { position: absolute; opacity: 0; pointer-events: none; }
.carita-opt:has(input:checked) { border-color: var(--red); background: #fff; }
.carita-opt:has(input:focus-visible) { outline: 2px solid var(--green-3); }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin: 12px 0; }
.gift { background: #fff; border-radius: 14px; overflow: hidden; border: 2px solid var(--line); display: flex; flex-direction: column; }
.gift img { width: 100%; aspect-ratio: 1; object-fit: cover; cursor: zoom-in; background: #f4efe4; }
.gift-foot { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 8px; }
.gift-foot select { width: 72px; padding: 6px; font-weight: 800; text-align: center; }
.gift.dup { border-color: var(--red); }
.vote-msg { min-height: 1.4em; font-weight: 700; color: var(--red-2); margin-bottom: 8px; }
.vote-summary { padding-left: 1.2em; }
.vote-summary li { margin: 3px 0; }

/* Chat */
.chat-card { display: flex; flex-direction: column; }
.chat { height: 56vh; min-height: 300px; overflow-y: auto; background: #fff; border-radius: 14px; padding: 12px; border: 2px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.msg { display: flex; gap: 8px; align-items: flex-end; max-width: 88%; }
.msg .bubble { background: #f1ebdd; padding: 8px 12px; border-radius: 16px 16px 16px 4px; }
.msg .who { font-size: .75rem; font-weight: 800; color: var(--green); }
.msg .time { font-size: .68rem; color: var(--muted); margin-left: 6px; font-weight: 600; }
.msg .text { white-space: pre-wrap; word-wrap: break-word; }
.msg.mine { align-self: flex-end; flex-direction: row-reverse; }
.msg.mine .bubble { background: #e3f2e5; border-radius: 16px 16px 4px 16px; }
.chat-form { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
.chat-form input { flex: 1; }

/* Tabla de posiciones */
.board { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.board li { display: flex; align-items: center; gap: 10px; background: #fff; border-radius: 14px; padding: 8px 12px; border: 2px solid var(--line); flex-wrap: wrap; }
.board li.me { border-color: var(--gold); background: #fffbea; }
.board .pos { width: 30px; font-family: "Baloo 2", sans-serif; font-size: 1.4rem; font-weight: 800; color: var(--red); text-align: center; }
.board li:nth-child(1) .pos { color: var(--gold); }
.board .score { margin-left: auto; font-weight: 800; color: var(--green); }
.real-name { font-weight: 800; color: var(--red); }
.real-name.big { font-family: "Baloo 2", sans-serif; font-size: 1.4rem; margin: 8px 0 2px; }

/* Revelación */
.reveal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.reveal-card { background: var(--cream); border-radius: var(--radius); padding: 18px 12px; text-align: center; box-shadow: var(--shadow); }
.reveal-card .av { flex-direction: column; }
.reveal-card p { margin: 4px 0; }
.reveal-card.is-open { background: linear-gradient(160deg, #fffaf0, #fff1c9); animation: pop .5s ease; }
@keyframes pop { 0% { transform: scale(.9); } 60% { transform: scale(1.04); } 100% { transform: scale(1); } }
.countdown { font-family: "Baloo 2", sans-serif; font-size: 1.6rem; color: var(--red); font-weight: 800; }

/* Listas y tablas */
.list { list-style: none; padding: 0; margin: 0; }
.list li { padding: 10px 0; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.list li:last-child { border-bottom: 0; }
.table-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tbl th, .tbl td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.tbl th { font-size: .75rem; text-transform: uppercase; color: var(--muted); }
.tbl .actions { display: flex; flex-wrap: wrap; gap: 4px; }
.chain { padding-left: 1.4em; }
.chain li { margin: 6px 0; }
.chain .arrow { color: var(--red); font-weight: 800; margin: 0 4px; }

.admin-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.admin-tabs a { padding: 8px 14px; border-radius: 999px; background: rgba(255,255,255,.9); color: var(--green); font-weight: 800; text-decoration: none; font-size: .88rem; }
.admin-tabs a.on { background: var(--red); color: #fff; }

/* Modales */
.modal { border: 0; border-radius: var(--radius); padding: 20px; max-width: min(92vw, 460px); background: var(--cream); box-shadow: var(--shadow); }
.modal::backdrop { background: rgba(0, 20, 10, .6); }
.modal-img { max-width: 96vw; text-align: center; }
.modal-img img { max-height: 80vh; border-radius: 12px; display: block; margin: 0 auto 10px; }

@media (min-width: 900px) {
  body { padding-bottom: 0; }
  .nav { position: sticky; top: 55px; bottom: auto; border-top: 0; border-bottom: 3px solid var(--red); justify-content: center; gap: 6px; }
  .nav a { flex: none; flex-direction: row; font-size: .9rem; padding: 8px 14px; gap: 6px; }
  .nav a span { font-size: 1.1rem; }
}

.nowrap { white-space: nowrap; }
