:root {
  --bg: #16102a;
  --bg2: #2a1340;
  --fg: #f4eefc;
  --muted: #b7a8cf;
  --surface: rgba(255, 255, 255, 0.06);
  --surface-solid: #241a3a;
  --border: rgba(255, 255, 255, 0.12);
  --accent: #ff4d8d;
  --accent2: #ffa63d;
  --accent-grad: linear-gradient(135deg, #ff4d8d 0%, #ff7a3d 60%, #ffa63d 100%);
  --accent-soft: rgba(255, 77, 141, 0.16);
  --ok: #4ade80;
  --err: #ff6b6b;
  --note: #fff6a3;
  --note-ink: #2b2410;
  --radius: 16px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  font: 16px/1.55 ui-rounded, "SF Pro Rounded", "Nunito", "Segoe UI", system-ui, sans-serif;
  color: var(--fg);
  background:
    radial-gradient(1200px 600px at 10% -10%, #4a1d6e 0%, transparent 60%),
    radial-gradient(900px 500px at 110% 10%, #7a1f4a 0%, transparent 55%),
    radial-gradient(800px 600px at 50% 110%, #3b1f73 0%, transparent 60%),
    var(--bg);
  background-attachment: fixed;
}
a { color: var(--accent2); text-decoration-thickness: 2px; text-underline-offset: 3px; }
h1, h2, h3 { line-height: 1.15; margin: 0 0 .5rem; letter-spacing: -0.01em; }
h1 { font-size: clamp(1.8rem, 6vw, 2.4rem); font-weight: 900; }
h2 { font-size: 1.15rem; margin-top: 1.75rem; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); font-weight: 800; }
p { margin: .4rem 0; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.container { max-width: 720px; margin: 0 auto; padding: 1rem 1rem 4rem; }

/* gradient text helper */
.grad { background: var(--accent-grad); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ---------- nav ---------- */
.nav {
  position: sticky; top: 0; z-index: 10;
  display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; justify-content: space-between;
  padding: .7rem 1rem; backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  background: rgba(22, 16, 42, 0.7); border-bottom: 1px solid var(--border);
}
.nav nav { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; font-weight: 700; }
.nav nav a { color: var(--fg); text-decoration: none; opacity: .85; }
.nav nav a:hover { opacity: 1; }
.brand { font-weight: 900; font-size: 1.15rem; text-decoration: none; color: var(--fg); letter-spacing: -0.02em; }
.brand b { background: var(--accent-grad); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ---------- cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem 1.1rem; margin: .75rem 0; box-shadow: var(--shadow);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.card.highlight { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent) inset, 0 10px 40px rgba(255, 77, 141, 0.25); }
a.card { display: block; text-decoration: none; color: inherit; transition: transform .15s ease, border-color .15s ease; }
a.card:hover { transform: translateY(-2px); border-color: var(--accent); }
.row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: .75rem; }

/* ---------- forms ---------- */
form.inline { display: inline; }
label { display: block; font-weight: 700; margin: .5rem 0 .3rem; }
input[type=text], input[type=password], input[type=datetime-local], textarea, select {
  width: 100%; padding: .7rem .8rem; font: inherit; color: var(--fg);
  background: rgba(0, 0, 0, 0.3); border: 1px solid var(--border); border-radius: 12px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input::placeholder, textarea::placeholder { color: #8a7ca6; }
textarea { min-height: 7rem; resize: vertical; }
button, .btn {
  display: inline-block; padding: .65rem 1.1rem; font: inherit; font-weight: 800; cursor: pointer;
  background: var(--accent-grad); color: #1a0b14; border: 0; border-radius: 999px; text-decoration: none;
  box-shadow: 0 6px 18px rgba(255, 77, 141, 0.35); transition: transform .1s ease, box-shadow .15s ease;
}
button:hover, .btn:hover { transform: translateY(-1px); box-shadow: 0 8px 24px rgba(255, 77, 141, 0.45); }
button:active { transform: translateY(1px) scale(.98); }
button.secondary, .btn.secondary {
  background: transparent; color: var(--fg); border: 1.5px solid var(--border); box-shadow: none;
}
button.secondary:hover, .btn.secondary:hover { border-color: var(--accent); box-shadow: none; }
button.danger { background: var(--err); color: #2a0808; box-shadow: none; }
button.link { background: none; color: var(--accent2); padding: 0; font-weight: 600; text-decoration: underline; box-shadow: none; border-radius: 0; }
button.link:hover { transform: none; box-shadow: none; }
button:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }
.small button, button.small { padding: .4rem .8rem; font-size: .85rem; }
.checks label { display: flex; gap: .6rem; align-items: center; font-weight: 500; margin: .25rem 0; }
.checks input { accent-color: var(--accent); width: 1.1rem; height: 1.1rem; }

.flash { padding: .7rem .9rem; border-radius: 12px; margin-bottom: 1rem; font-weight: 600; border: 1px solid transparent; }
.flash.ok { background: rgba(74, 222, 128, 0.14); color: #c9ffd9; border-color: rgba(74, 222, 128, 0.4); }
.flash.err { background: rgba(255, 107, 107, 0.14); color: #ffd4d4; border-color: rgba(255, 107, 107, 0.4); }

/* ---------- phases ---------- */
.phase-bar { display: flex; gap: .35rem; flex-wrap: wrap; margin: .75rem 0 1.25rem; }
.phase-bar span {
  font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em;
  padding: .3rem .7rem; border-radius: 999px; border: 1px solid var(--border); color: var(--muted);
}
.phase-bar span.active { background: var(--accent-grad); color: #1a0b14; border-color: transparent; box-shadow: 0 0 18px rgba(255, 77, 141, 0.5); }
.phase-bar span.done { background: rgba(255, 255, 255, 0.12); color: var(--fg); }

.badge {
  display: inline-block; font-size: .72rem; font-weight: 800; letter-spacing: .04em;
  padding: .15rem .6rem; border-radius: 999px; background: rgba(255, 255, 255, 0.12); color: var(--fg);
}

/* ---------- ballot: sticky-note excuses ---------- */
.ballot { list-style: none; padding: 0; margin: 0; }
.ballot li { margin: .9rem 0; position: relative; }
.ballot li.card {
  background: var(--note); color: var(--note-ink); border: 0;
  border-radius: 4px 14px 4px 14px; transform: rotate(-.6deg);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.35);
}
.ballot li.card:nth-child(even) { transform: rotate(.7deg); background: #ffd6e7; }
.ballot li.card:nth-child(3n) { background: #c9f2ff; }
.ballot li.card::before {
  content: ""; position: absolute; top: -8px; left: 50%; width: 70px; height: 18px; margin-left: -35px;
  background: rgba(255, 255, 255, 0.45); transform: rotate(-2deg); border-radius: 2px;
}
.ballot .muted { color: #6a6047; }
.ballot .badge { background: rgba(0, 0, 0, 0.12); color: var(--note-ink); }
.ballot .excuse { font-size: 1.1rem; font-weight: 600; line-height: 1.4; font-family: Georgia, "Times New Roman", serif; font-style: italic; }
.ballot button { margin-top: .7rem; }

/* reveal list keeps numbering */
ol.ballot { counter-reset: rank; }
ol.ballot > li { counter-increment: rank; padding-left: 3.2rem; }
ol.ballot > li::after {
  content: counter(rank); position: absolute; left: .9rem; top: .95rem;
  width: 1.8rem; height: 1.8rem; border-radius: 50%; display: grid; place-items: center;
  font-weight: 900; background: rgba(0, 0, 0, 0.12); color: var(--note-ink);
}
.reveal-item.winner { background: var(--note) !important; outline: 3px solid var(--accent); box-shadow: 0 0 40px rgba(255, 77, 141, 0.5); transform: rotate(0) scale(1.02) !important; }
.reveal-item.masked { background: rgba(255, 255, 255, 0.08) !important; color: var(--muted); }
.reveal-item.masked .badge { background: rgba(255, 255, 255, 0.12); color: var(--fg); }
.reveal-item.masked::after { background: rgba(255, 255, 255, 0.12); color: var(--fg); }
.masked .name, .masked .excuse, .masked .badge { filter: blur(7px); user-select: none; }
.reveal-item { opacity: 0; animation: pop .55s cubic-bezier(.2, 1.4, .4, 1) forwards; }
.reveal-item.masked, .reveal-item.settled { opacity: 1; animation: none; }
@keyframes pop { 0% { opacity: 0; transform: translateY(20px) scale(.9) rotate(-3deg); } 100% { opacity: 1; transform: translateY(0) scale(1) rotate(-.6deg); } }

.dice { display: inline-block; font-size: 3rem; animation: roll 1.4s ease-in-out 2; filter: drop-shadow(0 6px 10px rgba(0,0,0,.4)); }
@keyframes roll { 0% { transform: rotate(0); } 50% { transform: rotate(540deg) scale(1.3); } 100% { transform: rotate(1080deg); } }

/* ---------- tables ---------- */
table { width: 100%; border-collapse: collapse; }
td, th { text-align: left; padding: .5rem .3rem; border-bottom: 1px solid var(--border); vertical-align: top; }

.copy-field { display: flex; gap: .4rem; margin: .4rem 0; }
.copy-field input { flex: 1; font-size: .8rem; font-family: ui-monospace, Menlo, monospace; }

/* ---------- hero (login / invite) ---------- */
.hero { text-align: center; padding: 1.5rem 0 1rem; }
.hero .emoji { font-size: 4rem; line-height: 1; display: block; margin-bottom: .5rem; filter: drop-shadow(0 8px 16px rgba(0,0,0,.4)); }
.hero h1 { font-size: clamp(2rem, 8vw, 3rem); }
.hero p { color: var(--muted); max-width: 32rem; margin: .5rem auto 0; }

/* ---------- team tiles ---------- */
.team-emoji { font-size: 1.6rem; line-height: 1; }

/* ---------- results page ---------- */
.results { text-align: center; padding-top: 1.5rem; }
.results .label { text-transform: uppercase; letter-spacing: .14em; font-size: .72rem; font-weight: 800; color: var(--muted); }
.results h1 { font-size: clamp(1.4rem, 5vw, 2rem); color: var(--muted); font-weight: 700; }
.results .winner-name {
  font-size: clamp(2.8rem, 13vw, 5.5rem); font-weight: 900; margin: .3rem 0 .6rem; cursor: pointer; line-height: 1;
  word-break: break-word; letter-spacing: -0.03em;
  background: var(--accent-grad); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 0 28px rgba(255, 77, 141, 0.45));
  animation: glow 3s ease-in-out infinite alternate;
}
@keyframes glow { to { filter: drop-shadow(0 0 44px rgba(255, 166, 61, 0.65)); } }
.results .winning-excuse {
  font-size: 1.35rem; font-weight: 600; font-style: italic; margin: 1.2rem auto; max-width: 36rem; padding: 1.3rem 1.4rem;
  background: var(--note); color: var(--note-ink); border-radius: 6px 20px 6px 20px; text-align: left;
  font-family: Georgia, "Times New Roman", serif; transform: rotate(-1deg); position: relative;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
}
.results .winning-excuse::before {
  content: ""; position: absolute; top: -10px; left: 50%; width: 90px; height: 22px; margin-left: -45px;
  background: rgba(255, 255, 255, 0.5); transform: rotate(-2deg); border-radius: 2px;
}
.results ol { text-align: left; padding: 0; max-width: 36rem; margin: 1rem auto; list-style: none; counter-reset: r 1; }
.results ol li { counter-increment: r; margin: .7rem 0; padding: .9rem 1rem .9rem 3.2rem; position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; }
.results ol li::before {
  content: counter(r); position: absolute; left: .9rem; top: .9rem; width: 1.8rem; height: 1.8rem; border-radius: 50%;
  display: grid; place-items: center; font-weight: 900; background: rgba(255, 255, 255, 0.12);
}
.results .votes { color: var(--muted); font-size: .85rem; font-weight: 700; }

@media (prefers-reduced-motion: reduce) {
  .reveal-item, .dice, .results .winner-name { animation: none; opacity: 1; }
  a.card, button { transition: none; }
}

/* ---------- Plato ---------- */
.plato {
  margin: 1.75rem auto 0; max-width: 34rem; padding: 0 1rem; text-align: center;
  font-family: Georgia, "Times New Roman", serif; font-style: italic; font-size: .95rem; line-height: 1.6; color: var(--muted);
}
.plato footer { margin-top: .4rem; font-style: normal; font-size: .8rem; letter-spacing: .06em; text-transform: uppercase; }
.plato cite { font-style: italic; text-transform: none; letter-spacing: 0; }

/* ---------- reveal finale (election page) ---------- */
[hidden] { display: none !important; }
.reveal-finale { padding-top: .5rem; margin-bottom: 1.5rem; scroll-margin-top: 5rem; animation: finale .7s cubic-bezier(.2, 1.3, .4, 1) both; }
@keyframes finale { from { opacity: 0; transform: scale(.85) translateY(20px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .reveal-finale { animation: none; } }
