:root {
  --bg: #0d0f14;
  --bg-2: #141821;
  --card: #1a1f2b;
  --card-2: #222836;
  --line: #2c3444;
  --txt: #eef1f7;
  --muted: #98a2b7;
  --accent: #ffcc4d;
  --accent-2: #ff8a3d;
  --yes: #35d07f;
  --no: #ff5a6a;
  --radius: 18px;
  --shadow: 0 12px 40px rgba(0, 0, 0, .45);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--txt);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-size: 16px;
  overscroll-behavior-y: none;
}

body {
  background-image:
    radial-gradient(900px 500px at 15% -10%, rgba(255, 204, 77, .10), transparent 60%),
    radial-gradient(700px 500px at 100% 0%, rgba(255, 90, 106, .10), transparent 55%);
  background-attachment: fixed;
}

a { color: var(--accent); }
img { max-width: 100%; display: block; }

.app { max-width: 780px; margin: 0 auto; padding: 0 16px calc(32px + var(--safe-b)); }

/* ---------- topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 10px;
  padding: 14px 0 12px;
  background: linear-gradient(var(--bg) 72%, transparent);
}
.brand { display: flex; align-items: baseline; gap: 8px; min-width: 0; flex: 1; }
.brand h1 {
  margin: 0; font-size: 19px; font-weight: 800; letter-spacing: -.3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.brand .dot { color: var(--accent); }
.chip {
  border: 1px solid var(--line); background: var(--card);
  color: var(--muted); border-radius: 999px; padding: 6px 12px;
  font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.chip:active { transform: scale(.96); }
.chip.solid { background: var(--accent); color: #241c00; border-color: transparent; }

/* ---------- fases ---------- */
.phasebar {
  display: flex; gap: 6px; margin: 0 0 18px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 999px; padding: 5px;
}
.phasebar div {
  flex: 1; text-align: center; font-size: 12.5px; font-weight: 700;
  padding: 8px 4px; border-radius: 999px; color: var(--muted);
}
.phasebar div.on { background: var(--accent); color: #241c00; }
.phasebar div.done { color: var(--yes); }

/* ---------- bloques ---------- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px; margin-bottom: 16px;
}
.card h2 { margin: 0 0 6px; font-size: 20px; letter-spacing: -.3px; }
.card p.sub { margin: 0 0 18px; color: var(--muted); font-size: 14.5px; line-height: 1.5; }
.hero { text-align: center; padding: 28px 20px; }
.hero .big { font-size: 46px; line-height: 1; margin-bottom: 12px; }

label { display: block; font-size: 13px; font-weight: 700; color: var(--muted); margin: 14px 0 6px; }
input[type=text], input[type=password], input[type=number], select {
  width: 100%; padding: 14px 14px; font-size: 16px;
  background: var(--bg-2); border: 1px solid var(--line); color: var(--txt);
  border-radius: 12px; outline: none;
}
input:focus, select:focus { border-color: var(--accent); }

.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 15px 18px; font-size: 16px; font-weight: 700;
  border: none; border-radius: 14px; cursor: pointer;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #2a1d00; margin-top: 18px;
}
.btn:active { transform: scale(.985); }
.btn[disabled] { opacity: .55; }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--txt); }
.btn.danger { background: transparent; border: 1px solid var(--no); color: var(--no); }
.btn.small { width: auto; padding: 10px 16px; font-size: 14px; margin-top: 0; }

.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.switchrow { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.switchrow:last-child { border-bottom: none; }
.switchrow span { font-size: 14.5px; }
.switchrow small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 2px; }

.msg { padding: 12px 14px; border-radius: 12px; font-size: 14px; margin-top: 14px; }
.msg.err { background: rgba(255, 90, 106, .12); color: #ffb3bb; border: 1px solid rgba(255, 90, 106, .3); }
.msg.ok { background: rgba(53, 208, 127, .12); color: #9ff0c4; border: 1px solid rgba(53, 208, 127, .3); }

.tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.tabs button {
  flex: 1; padding: 11px; font-size: 14px; font-weight: 700; cursor: pointer;
  background: var(--card); border: 1px solid var(--line); color: var(--muted); border-radius: 12px;
}
.tabs button.on { background: var(--card-2); color: var(--txt); border-color: var(--accent); }

/* ---------- galeria ---------- */
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 560px) { .grid { grid-template-columns: repeat(3, 1fr); } }
.tile {
  position: relative; aspect-ratio: 1; border-radius: 14px; overflow: hidden;
  background: var(--bg-2); border: 1px solid var(--line);
}
.tile img { width: 100%; height: 100%; object-fit: cover; }
.tile .del {
  position: absolute; top: 6px; right: 6px; width: 30px; height: 30px;
  border-radius: 50%; border: none; background: rgba(0, 0, 0, .6); color: #fff;
  font-size: 16px; line-height: 1; cursor: pointer;
}
.tile .cap {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 16px 8px 6px;
  font-size: 11.5px; background: linear-gradient(transparent, rgba(0, 0, 0, .8));
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.uploading { position: relative; }
.uploading::after {
  content: ''; position: absolute; inset: 0; background: rgba(13, 15, 20, .6);
}

/* ---------- swipe ---------- */
.deck {
  position: relative; height: min(66vh, 520px); margin: 6px 0 14px;
  touch-action: none; user-select: none;
}
.swipecard {
  position: absolute; inset: 0; border-radius: 22px; overflow: hidden;
  background: var(--card-2); box-shadow: var(--shadow); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  will-change: transform;
}
.swipecard img { width: 100%; height: 100%; object-fit: contain; background: #05070b; pointer-events: none; }
.swipecard .title {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 26px 16px 14px;
  background: linear-gradient(transparent, rgba(0, 0, 0, .85)); font-size: 14px;
}
.stamp {
  position: absolute; top: 22px; font-size: 26px; font-weight: 900; letter-spacing: 2px;
  padding: 8px 16px; border-radius: 12px; border: 4px solid; opacity: 0; transform: rotate(-14deg);
}
.stamp.yes { left: 18px; color: var(--yes); border-color: var(--yes); }
.stamp.no { right: 18px; color: var(--no); border-color: var(--no); transform: rotate(14deg); }

.deckactions { display: flex; align-items: center; justify-content: center; gap: 18px; }
.circle {
  width: 68px; height: 68px; border-radius: 50%; border: 2px solid var(--line);
  background: var(--card); font-size: 27px; cursor: pointer; color: var(--txt);
  display: flex; align-items: center; justify-content: center;
}
.circle:active { transform: scale(.92); }
.circle[disabled] { opacity: .3; }
.circle.no { color: var(--no); border-color: rgba(255, 90, 106, .45); }
.circle.yes { color: var(--yes); border-color: rgba(53, 208, 127, .45); }
.circle.mini { width: 46px; height: 46px; font-size: 18px; color: var(--muted); }

.progress { height: 6px; background: var(--card); border-radius: 99px; overflow: hidden; margin-bottom: 12px; }
.progress i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .25s; }
.counter { text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 10px; }

/* ---------- resultados ---------- */
.podium { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; align-items: end; margin-bottom: 22px; }
.pod { text-align: center; }
.pod .ph { border-radius: 14px; overflow: hidden; border: 2px solid var(--line); aspect-ratio: 1; background: var(--bg-2); }
.pod .ph img { width: 100%; height: 100%; object-fit: cover; }
.pod.p1 .ph { border-color: var(--accent); }
.pod.p2 .ph { border-color: #c9d2e3; }
.pod.p3 .ph { border-color: #d08a4d; }
.pod .medal { font-size: 22px; margin-top: 6px; }
.pod .who { font-size: 12.5px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pod .pts { font-size: 12px; color: var(--accent); font-weight: 700; }

.rankrow { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.rankrow:last-child { border-bottom: none; }
.rankrow .pos { width: 26px; text-align: center; font-weight: 800; color: var(--muted); font-size: 14px; }
.rankrow .th { width: 54px; height: 54px; border-radius: 10px; overflow: hidden; flex: none; background: var(--bg-2); }
.rankrow .th img { width: 100%; height: 100%; object-fit: cover; }
.rankrow .info { flex: 1; min-width: 0; }
.rankrow .info b { display: block; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rankrow .info span { font-size: 12.5px; color: var(--muted); }
.rankrow .score { font-weight: 800; color: var(--accent); font-size: 17px; }

/* ---------- lightbox ---------- */
.lightbox {
  position: fixed; inset: 0; z-index: 100; background: rgba(5, 7, 11, .95);
  display: flex; align-items: center; justify-content: center; padding: 16px; flex-direction: column; gap: 12px;
}
.lightbox img { max-height: 78vh; object-fit: contain; border-radius: 12px; }
.lightbox .meta { text-align: center; font-size: 14px; color: var(--muted); }

/* ---------- misc ---------- */
.empty { text-align: center; color: var(--muted); padding: 34px 10px; font-size: 14.5px; line-height: 1.55; }
.empty .big { font-size: 42px; margin-bottom: 10px; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
@media (min-width: 520px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; text-align: center; }
.stat b { display: block; font-size: 24px; font-weight: 800; }
.stat span { font-size: 12px; color: var(--muted); }
.spinner {
  width: 22px; height: 22px; border: 3px solid rgba(255, 255, 255, .2);
  border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; margin: 24px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }
.hidden { display: none !important; }
.footnote { text-align: center; color: var(--muted); font-size: 12px; padding: 18px 0 6px; }
