:root {
  --bg: #120d18;
  --surface: #1e1628;
  --surface-2: #2a1f38;
  --line: #3a2d4c;
  --text: #f4ecff;
  --muted: #a898bd;
  --accent: #ff7a1a;
  --accent-ink: #1a0d00;
  --good: #7be38f;
  --bad: #ff6b6b;
  --radius: 18px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { margin: 0; }

body {
  min-height: 100dvh;
  background:
    radial-gradient(120% 60% at 50% -10%, #3b1d52 0%, transparent 60%),
    var(--bg);
  color: var(--text);
  font: 16px/1.45 'Inter', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: 560px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

.wrap.wide { max-width: 1100px; }

h1 {
  font-family: 'Creepster', 'Inter', cursive;
  font-weight: 400;
  font-size: clamp(2.4rem, 11vw, 3.6rem);
  line-height: 1;
  letter-spacing: 0.02em;
  color: var(--accent);
  margin: 8px 0 6px;
  text-shadow: 0 0 24px rgb(255 122 26 / 0.35);
}

.lead { color: var(--muted); margin: 0 0 24px; }

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

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 54px;
  padding: 14px 20px;
  border: 0;
  border-radius: 14px;
  background: var(--accent);
  color: var(--accent-ink);
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.1;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.08s ease, opacity 0.2s;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.ghost {
  background: transparent;
  color: var(--text);
  border: 1.5px solid var(--line);
}
.btn + .btn { margin-top: 12px; }

label.field { display: block; margin-bottom: 18px; }
label.field > span { display: block; font-weight: 600; margin-bottom: 8px; }

input[type='text'] {
  width: 100%;
  min-height: 54px;
  padding: 14px 16px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 1.05rem;
}
input[type='text']:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }

.photo-pick {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 4 / 5;
  max-height: 46dvh;
  width: 100%;
  margin: 0 auto;
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
  text-align: center;
  overflow: hidden;
  cursor: pointer;
}
.photo-pick img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.photo-pick .hint { font-size: 3rem; line-height: 1; }
.photo-pick input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.msg { min-height: 1.5em; margin: 12px 0; font-weight: 600; }
.msg.error { color: var(--bad); }

.done { text-align: center; padding-top: 32px; }
.done .big { font-size: 4.5rem; line-height: 1; }

/* Votación */
.bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 -16px 16px;
  padding: 12px 16px;
  background: rgb(18 13 24 / 0.86);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  font-size: 0.95rem;
}
.bar strong { color: var(--accent); }

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
@media (min-width: 640px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; } }
@media (min-width: 960px) { .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  border-radius: var(--radius);
  background: var(--surface);
  border: 2px solid transparent;
  overflow: hidden;
  transition: border-color 0.2s, transform 0.2s;
}
.card.mine { border-color: var(--accent); box-shadow: 0 0 0 4px rgb(255 122 26 / 0.18); }
.card img {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  background: var(--surface-2);
  cursor: zoom-in;
}
.card .body { padding: 10px 10px 12px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.card .name { font-weight: 700; overflow-wrap: anywhere; }
.card .btn { min-height: 44px; padding: 10px; font-size: 0.95rem; margin-top: auto; }
.card.mine .btn { background: var(--good); }
.card .count {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgb(0 0 0 / 0.7);
  font-weight: 800;
  font-size: 0.9rem;
}
.card .rank {
  position: absolute;
  top: 8px;
  left: 8px;
  font-size: 1.8rem;
  line-height: 1;
  filter: drop-shadow(0 2px 4px rgb(0 0 0 / 0.6));
}
.card .del {
  appearance: none;
  border: 1px solid var(--bad);
  background: transparent;
  color: var(--bad);
  border-radius: 10px;
  padding: 6px;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

.empty { text-align: center; color: var(--muted); padding: 48px 8px; }
.empty .big { font-size: 3.5rem; }

.admin {
  margin: 0 0 16px;
  padding: 12px;
  border: 1px dashed var(--accent);
  border-radius: 14px;
  display: grid;
  gap: 8px;
}

.lightbox[open] { display: grid; }
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 20;
  place-items: center;
  padding: 16px;
  background: rgb(0 0 0 / 0.9);
  border: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
}
.lightbox img { max-width: 100%; max-height: 85dvh; border-radius: 12px; }
.lightbox p { color: #fff; font-weight: 700; text-align: center; margin: 12px 0 0; }

.toast {
  position: fixed;
  left: 50%;
  bottom: max(20px, env(safe-area-inset-bottom));
  transform: translate(-50%, 140%);
  z-index: 30;
  padding: 12px 18px;
  border-radius: 999px;
  background: var(--text);
  color: var(--bg);
  font-weight: 700;
  transition: transform 0.25s ease;
  white-space: nowrap;
}
.toast.show { transform: translate(-50%, 0); }

/* Home */
.home { display: grid; gap: 12px; margin-top: 24px; }
