:root {
  --bg: #f6f3ff;
  --card: #ffffff;
  --text: #2a2346;
  --muted: #6d6690;
  --accent: #7c5cff;
  --accent-2: #ff7ab6;
  --accent-text: #ffffff;
  --border: #e3dcff;
  --soft: #efeaff;
  --error: #d6336c;
  --shadow: 0 8px 24px rgba(76, 52, 180, 0.12);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17142a;
    --card: #221e3b;
    --text: #f2efff;
    --muted: #aaa3cc;
    --accent: #9b82ff;
    --accent-2: #ff8cc2;
    --border: #3a3360;
    --soft: #2c2750;
    --error: #ff7aa8;
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 500 17px/1.45 Nunito, system-ui, -apple-system, sans-serif;
  min-height: 100dvh;
}
main {
  max-width: 520px;
  margin: 0 auto;
  padding: max(24px, env(safe-area-inset-top)) 16px max(32px, env(safe-area-inset-bottom));
}
header { text-align: center; margin-bottom: 20px; }
h1 { font-size: 44px; font-weight: 900; margin: 0; letter-spacing: -0.5px; }
header p { margin: 4px 0 0; color: var(--muted); }

.tabs {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
  background: var(--soft); padding: 6px; border-radius: 18px; margin-bottom: 16px;
}
.tabs button {
  border: 0; background: transparent; color: var(--muted);
  font: inherit; font-weight: 900; font-size: 19px;
  padding: 12px; border-radius: 14px; cursor: pointer;
}
.tabs button[aria-selected="true"] { background: var(--card); color: var(--text); box-shadow: var(--shadow); }

.card > * { min-width: 0; }
.card {
  background: var(--card); border-radius: 24px; padding: 20px;
  box-shadow: var(--shadow); display: grid; gap: 16px;
}

.field { display: grid; gap: 6px; font-weight: 700; }
input {
  font: inherit; font-size: 18px; color: var(--text);
  background: var(--bg); border: 2px solid var(--border); border-radius: 14px;
  padding: 12px 14px; width: 100%; min-width: 0;
}
input:focus { outline: none; border-color: var(--accent); }

.dropzone {
  display: grid; justify-items: center; gap: 6px; text-align: center;
  border: 3px dashed var(--border); border-radius: 20px; padding: 28px 16px;
  cursor: pointer; transition: border-color .15s, background .15s;
  font-weight: 700; word-break: break-word;
}
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--soft); }
.dropzone.has-file { border-style: solid; border-color: var(--accent); }
.dz-icon { font-size: 44px; line-height: 1; }
.dropzone small { color: var(--muted); font-weight: 500; }

.choices { border: 0; padding: 0; margin: 0; }
.choices legend { font-weight: 700; margin-bottom: 6px; padding: 0; }
#download-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
#download-options label {
  position: relative;
  text-align: center; padding: 10px 4px; font-size: 16px; white-space: nowrap; border-radius: 14px; cursor: pointer;
  border: 2px solid var(--border); font-weight: 700;
}
#download-options input { position: absolute; opacity: 0; pointer-events: none; }
#download-options label:has(input:checked) { border-color: var(--accent); background: var(--soft); }
#download-options label:has(input:focus-visible) { outline: 2px solid var(--accent); }

/* Turnstile only appears when Cloudflare wants an extra check. */
/* Stays in the page (Turnstile can't run in a display:none box) but takes no space until shown. */
.human-check { display: grid; justify-items: center; text-align: center; margin-top: -16px; }
.human-check p { display: none; margin: 0; font-weight: 700; }
.human-check.show {
  gap: 10px; margin-top: 0; padding: 14px;
  background: var(--soft); border: 2px solid var(--border); border-radius: 20px;
}
.human-check.show p { display: block; }
.turnstile { display: flex; justify-content: center; width: 100%; }
.turnstile > div { border-radius: 12px; overflow: hidden; max-width: 100%; }

button, .button { font: inherit; cursor: pointer; }
.big {
  border: 0; border-radius: 18px; padding: 16px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--accent-text); font-size: 21px; font-weight: 900;
  text-align: center; text-decoration: none; display: block;
}
.big:disabled { opacity: .45; cursor: not-allowed; }

.progress { height: 12px; border-radius: 99px; background: var(--soft); overflow: hidden; }
.progress div { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .2s; }

.error { color: var(--error); font-weight: 700; margin: 0; min-height: 0; }
.error:empty { display: none; }

.result { text-align: center; }
.label { margin: 0; font-weight: 700; color: var(--muted); }
.phrase {
  display: grid; justify-items: center; gap: 4px;
  font-size: clamp(34px, 11vw, 52px); font-weight: 900; line-height: 1.1; word-break: break-word;
}
.phrase .emoji { font-size: 1.6em; }
.phrase.small { font-size: 30px; }
.meta { margin: 0; color: var(--muted); font-weight: 700; }
.countdown { color: var(--accent); font-variant-numeric: tabular-nums; }
.filename { margin: 0; font-size: 20px; font-weight: 900; word-break: break-word; }

.row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.row button {
  border: 2px solid var(--border); background: var(--bg); color: var(--text);
  border-radius: 14px; padding: 10px 14px; font-weight: 700;
}
.qr { display: flex; justify-content: center; }
.qr svg { background: #fff; border-radius: 12px; width: 220px; height: auto; }
.link { border: 0; background: none; color: var(--accent); font-weight: 700; text-decoration: underline; }

.words { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.words input { text-align: center; font-weight: 700; font-size: 20px; }

section { display: grid; gap: 16px; }

/* ---------- Admin ---------- */
.admin main { max-width: 720px; }
.admin h2 { font-size: 22px; font-weight: 900; margin: 28px 0 12px; }
.muted { color: var(--muted); }
.stack { display: grid; gap: 12px; }
.summary { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.summary .link { margin-left: auto; }
.pill {
  display: inline-block; padding: 4px 12px; border-radius: 99px;
  background: var(--soft); font-weight: 900; font-size: 15px; white-space: nowrap;
}
.pill.live { background: #d9f7e4; color: #116336; }
.pill.done { background: #dde8ff; color: #23439a; }
.pill.expired { background: #eee; color: #666; }
@media (prefers-color-scheme: dark) {
  .pill.live { background: #173d28; color: #8de7b0; }
  .pill.done { background: #1d2a52; color: #a9c1ff; }
  .pill.expired { background: #2f2f3a; color: #b3b3c2; }
}
.drop { gap: 6px; }
.drop p { margin: 0; }
.drop-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.drop-phrase { font-size: 24px; font-weight: 900; }
.downloads { margin: 0; padding-left: 4px; list-style: none; color: var(--muted); font-size: 15px; }
.drop-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.danger {
  border: 2px solid var(--error); background: transparent; color: var(--error);
  border-radius: 12px; padding: 8px 14px; font-weight: 700;
}
.danger:disabled { opacity: .5; }
.empty { text-align: center; color: var(--muted); font-weight: 700; margin: 0; }
.activity { list-style: none; margin: 0; padding: 8px 20px; gap: 0; }
.activity li {
  display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: baseline;
  padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 15px;
}
.activity li:last-child { border-bottom: 0; }
.event-text { word-break: break-word; }
.event-when { white-space: nowrap; font-size: 14px; }
