/* ---------------------------------------------------------------- tokens */
:root {
  --bg: #120e1c;
  --bg-2: #1b1430;
  --surface: rgba(255, 255, 255, 0.055);
  --surface-2: rgba(255, 255, 255, 0.09);
  --line: rgba(255, 255, 255, 0.12);
  --text: #f6f2ea;
  --muted: rgba(246, 242, 234, 0.58);
  --accent: #ff9f43;
  --accent-2: #ff5f7e;
  --good: #4ade80;
  --warn: #fbbf24;
  --bad: #fb7185;
  --radius: 18px;
  --shadow: 0 18px 40px -18px rgba(0, 0, 0, 0.75);
  --font: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, "Segoe UI",
    Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  overscroll-behavior-y: none;
}

body {
  background:
    radial-gradient(1200px 700px at 12% -8%, rgba(255, 95, 126, 0.20), transparent 60%),
    radial-gradient(1000px 640px at 92% 4%, rgba(255, 159, 67, 0.18), transparent 62%),
    radial-gradient(900px 700px at 50% 108%, rgba(120, 90, 255, 0.20), transparent 60%),
    var(--bg);
  min-height: 100dvh;
}

.app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom);
}

.screen { animation: fade 0.28s ease both; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------------------------------------------------------------- layout */
.pad { padding: 16px 16px 40px; display: flex; flex-direction: column; gap: 14px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hint { color: var(--muted); font-size: 13px; margin: 6px 0 12px; }
.err { color: var(--bad); font-size: 14px; min-height: 20px; margin: 10px 0 0; }

/* ------------------------------------------------------------------- hero */
.home { padding: 42px 22px calc(34px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 26px; }
.hero { text-align: center; }
.hero-mark {
  font-size: 54px; line-height: 1;
  filter: drop-shadow(0 8px 20px rgba(255, 159, 67, 0.35));
  animation: bob 3.4s ease-in-out infinite;
}
@keyframes bob { 0%, 100% { transform: translateY(0) rotate(-3deg); } 50% { transform: translateY(-8px) rotate(3deg); } }
.hero h1 {
  font-size: 40px; margin: 12px 0 6px; letter-spacing: -0.02em;
  background: linear-gradient(92deg, #ffd79a, #ff8fa3 55%, #b79cff);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.tagline { color: var(--muted); margin: 0; font-size: 15px; }

/* ----------------------------------------------------------------- header */
.bar {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(18, 14, 28, 0.72);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  position: sticky; top: 0; z-index: 20;
  padding-top: calc(14px + env(safe-area-inset-top));
}
.bar-sticky { position: sticky; }
.bar h2 { font-size: 17px; margin: 0; flex: 1; }
.bar-title { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.bar-title strong { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn-icon {
  background: var(--surface); border: 1px solid var(--line); color: var(--text);
  width: 38px; height: 38px; border-radius: 12px; font-size: 18px; line-height: 1;
  cursor: pointer; flex: none;
}
.btn-icon:active { transform: scale(0.94); }

/* ------------------------------------------------------------------ cards */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.card h3 { margin: 0 0 10px; font-size: 15px; letter-spacing: 0.01em; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }

/* ---------------------------------------------------------------- buttons */
.btn {
  appearance: none; border: 1px solid var(--line); border-radius: 14px;
  background: var(--surface-2); color: var(--text);
  font-family: inherit; font-size: 15px; font-weight: 600;
  padding: 13px 16px; cursor: pointer; transition: transform 0.12s ease, opacity 0.15s ease;
  text-align: center;
}
.btn:active { transform: scale(0.975); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-block { width: 100%; }
.btn-lg { font-size: 17px; padding: 16px; }
.btn-primary {
  background: linear-gradient(96deg, var(--accent), var(--accent-2));
  border-color: transparent; color: #1a1020; font-weight: 800;
  box-shadow: 0 12px 28px -12px rgba(255, 95, 126, 0.75);
}
.btn-ghost { background: var(--surface-2); }
.btn-quiet { background: transparent; border-style: dashed; color: var(--muted); font-weight: 600; }
.btn-quiet.danger { color: var(--bad); }

/* ----------------------------------------------------------------- inputs */
.input {
  width: 100%; background: rgba(0, 0, 0, 0.28); border: 1px solid var(--line);
  color: var(--text); border-radius: 13px; padding: 13px 14px; font-family: inherit; font-size: 16px;
}
.input:focus { outline: 2px solid rgba(255, 159, 67, 0.55); outline-offset: 1px; }
.input::placeholder { color: rgba(246, 242, 234, 0.32); }
.input-code { font-size: 28px; letter-spacing: 0.34em; text-align: center; font-weight: 800; text-transform: uppercase; }
.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 16px; }
.field > span { font-size: 13px; color: var(--muted); font-weight: 600; }

/* ------------------------------------------------------------------ chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chip {
  border: 1px solid var(--line); background: var(--surface); color: var(--muted);
  padding: 9px 13px; border-radius: 999px; font-size: 14px; font-weight: 600; cursor: pointer;
  font-family: inherit;
}
.chip.active { background: linear-gradient(96deg, var(--accent), var(--accent-2)); color: #1a1020; border-color: transparent; }
.chip.mini { padding: 5px 9px; font-size: 12px; border-radius: 8px; }
.chip .x { margin-left: 6px; opacity: 0.6; }

/* ------------------------------------------------------------------ items */
.items { display: flex; flex-direction: column; gap: 12px; }
.item-row {
  display: grid; grid-template-columns: 74px 1fr; gap: 12px;
  background: rgba(0, 0, 0, 0.22); border: 1px solid var(--line); border-radius: 14px; padding: 12px;
}
.item-thumb {
  width: 74px; height: 74px; border-radius: 12px; background: var(--surface-2);
  border: 1px dashed var(--line); display: flex; align-items: center; justify-content: center;
  font-size: 24px; cursor: pointer; overflow: hidden; color: var(--muted);
}
.item-thumb img { width: 100%; height: 100%; object-fit: cover; }
.item-fields { display: flex; flex-direction: column; gap: 8px; }
.item-label { font-size: 12px; font-weight: 700; color: var(--accent); letter-spacing: 0.06em; text-transform: uppercase; }
.row-actions { display: flex; gap: 8px; align-items: center; }

/* -------------------------------------------------------------- criteria */
.crits { display: flex; flex-direction: column; gap: 10px; }
.crit-row {
  display: grid; grid-template-columns: 42px 1fr auto auto; gap: 10px; align-items: center;
  background: rgba(0, 0, 0, 0.22); border: 1px solid var(--line); border-radius: 14px; padding: 9px 11px;
}
.emoji-pick {
  width: 42px; height: 42px; border-radius: 11px; background: var(--surface-2); border: 1px solid var(--line);
  font-size: 20px; cursor: pointer; color: var(--text);
}
.stars { display: flex; gap: 2px; }
.star { background: none; border: 0; color: rgba(255, 255, 255, 0.22); font-size: 17px; cursor: pointer; padding: 2px; }
.star.on { color: var(--accent); }
.icon-x { background: none; border: 0; color: var(--muted); font-size: 18px; cursor: pointer; padding: 6px; }

/* --------------------------------------------------------------- switch */
.switch-row { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; cursor: pointer; }
.switch-row input { display: none; }
.switch {
  width: 46px; height: 28px; border-radius: 999px; background: rgba(255, 255, 255, 0.14);
  position: relative; transition: background 0.2s ease; flex: none;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px;
  border-radius: 50%; background: #fff; transition: transform 0.2s ease;
}
.switch-row input:checked + .switch { background: linear-gradient(96deg, var(--accent), var(--accent-2)); }
.switch-row input:checked + .switch::after { transform: translateX(18px); }
.switch-label { display: flex; flex-direction: column; font-size: 14px; font-weight: 600; }
.switch-label small { color: var(--muted); font-weight: 400; font-size: 12px; }

/* ----------------------------------------------------------------- roster */
.roster { display: flex; flex-direction: column; gap: 8px; }
.person {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  background: rgba(0, 0, 0, 0.22); border: 1px solid var(--line); border-radius: 12px;
}
.person .name { flex: 1; font-weight: 600; font-size: 14px; }
.person .state { font-size: 12px; color: var(--muted); }
.person.done .state { color: var(--good); }
.person .tick { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; background: var(--surface-2); }
.person.done .tick { background: rgba(74, 222, 128, 0.2); color: var(--good); }

/* ------------------------------------------------------------- code + qr */
.code {
  font-size: 42px; font-weight: 900; letter-spacing: 0.22em; margin: 8px 0 14px;
  background: linear-gradient(92deg, #ffd79a, #ff8fa3);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  text-indent: 0.22em;
}
.qr-wrap { margin: 18px auto 6px; display: grid; place-items: center; }
.qr { width: 220px; height: 220px; background: #fff; border-radius: 16px; padding: 10px; }

/* -------------------------------------------------------------- progress */
.progress-wrap { display: flex; align-items: center; gap: 10px; padding: 12px 16px 0; }
.progress { flex: 1; height: 7px; background: rgba(255, 255, 255, 0.1); border-radius: 999px; overflow: hidden; }
.progress-bar { height: 100%; width: 0%; border-radius: 999px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width 0.45s cubic-bezier(0.2, 0.8, 0.2, 1); }

/* ------------------------------------------------------------------ votes */
.vote-card { display: flex; flex-direction: column; gap: 12px; }
.sample-head { display: flex; gap: 14px; align-items: center; }
.sample-photo {
  width: 92px; height: 92px; border-radius: 14px; object-fit: cover; background: var(--surface-2);
  border: 1px solid var(--line); flex: none;
}
.sample-photo.empty { display: grid; place-items: center; font-size: 30px; }
.sample-name { font-size: 22px; font-weight: 800; letter-spacing: -0.01em; }
.sample-note { color: var(--muted); font-size: 13px; }
.crit-block { background: rgba(0, 0, 0, 0.24); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.crit-top { display: flex; align-items: center; gap: 9px; margin-bottom: 10px; }
.crit-top .name { font-weight: 700; font-size: 15px; flex: 1; }
.crit-top .wt { font-size: 11px; color: var(--accent); font-weight: 700; letter-spacing: 0.05em; }
.scale { display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; }
.scale button {
  aspect-ratio: 1 / 1.15; border-radius: 8px; border: 1px solid var(--line); background: var(--surface);
  color: var(--muted); font-size: 12px; font-weight: 700; cursor: pointer; padding: 0; font-family: inherit;
  display: grid; place-items: center;
}
.scale button.on { background: linear-gradient(160deg, var(--accent), var(--accent-2)); color: #1a1020; border-color: transparent; }
.scale button:active { transform: scale(0.92); }
.scale-foot { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 6px; }
.crit-tools { display: flex; gap: 8px; margin-top: 9px; align-items: center; }
.skip-toggle {
  font-size: 12px; color: var(--muted); background: none; border: 1px dashed var(--line);
  padding: 5px 9px; border-radius: 8px; cursor: pointer; font-family: inherit;
}
.skip-toggle.on { color: var(--warn); border-color: var(--warn); }
.note-input { flex: 1; background: rgba(0, 0, 0, 0.3); border: 1px solid var(--line); color: var(--text); border-radius: 9px; padding: 7px 10px; font-size: 13px; font-family: inherit; min-width: 0; }

/* ------------------------------------------------------------ waiting room */
.waiting { text-align: center; padding: 26px 16px; display: flex; flex-direction: column; gap: 16px; align-items: center; }
.waiting h3 { margin: 0; font-size: 20px; }
.spinner {
  width: 52px; height: 52px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, 0.14);
  border-top-color: var(--accent); animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.pulse { animation: pulse 1.8s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.04); } }

/* --------------------------------------------------------------- results */
.results { padding-bottom: 60px; }
.podium { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; align-items: end; margin: 8px 0 4px; }
.podium .col { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.podium .medal { font-size: 34px; animation: drop 0.7s cubic-bezier(0.2, 1.3, 0.4, 1) both; }
.podium .medal.d1 { animation-delay: 0.1s; }
.podium .medal.d2 { animation-delay: 0.25s; }
.podium .medal.d3 { animation-delay: 0.4s; }
@keyframes drop { from { transform: translateY(-26px) scale(0.7); opacity: 0; } to { transform: none; opacity: 1; } }
.podium .plate {
  width: 100%; border-radius: 14px 14px 8px 8px; padding: 12px 8px; text-align: center;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.04));
  border: 1px solid var(--line);
}
.podium .col.d1 .plate { padding-top: 22px; background: linear-gradient(180deg, rgba(255, 199, 122, 0.42), rgba(255, 159, 67, 0.12)); border-color: rgba(255, 199, 122, 0.5); }
.podium .col.d2 .plate { background: linear-gradient(180deg, rgba(220, 225, 235, 0.3), rgba(255, 255, 255, 0.05)); }
.podium .col.d3 .plate { background: linear-gradient(180deg, rgba(205, 127, 50, 0.34), rgba(255, 255, 255, 0.04)); }
.podium .nm { font-weight: 800; font-size: 14px; line-height: 1.2; word-break: break-word; }
.podium .sc { font-size: 12px; color: var(--muted); margin-top: 4px; }
.reveal-name { font-weight: 800; background: linear-gradient(92deg, #ffd79a, #ff8fa3); -webkit-background-clip: text; background-clip: text; color: transparent; }

.awards { display: flex; flex-direction: column; gap: 10px; }
.award { display: flex; gap: 12px; align-items: center; background: rgba(0, 0, 0, 0.22); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; }
.award .ico { font-size: 24px; flex: none; }
.award .ttl { font-size: 13px; font-weight: 800; color: var(--accent); letter-spacing: 0.02em; }
.award .who { font-size: 14px; font-weight: 600; }
.award .why { font-size: 12px; color: var(--muted); }

.bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 1fr; gap: 5px; }
.bar-top { display: flex; justify-content: space-between; font-size: 13px; }
.bar-top .lbl { font-weight: 700; }
.bar-top .val { color: var(--muted); font-variant-numeric: tabular-nums; }
.bar-track { height: 10px; background: rgba(255, 255, 255, 0.08); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width 0.8s cubic-bezier(0.2, 0.8, 0.2, 1); }
.bar-row.dim .bar-fill { background: linear-gradient(90deg, #6b7280, #4b5563); }

.note-list { display: flex; flex-direction: column; gap: 8px; }
.note-item { background: rgba(0, 0, 0, 0.2); border-left: 3px solid var(--accent-2); border-radius: 0 12px 12px 0; padding: 9px 12px; font-size: 13px; }
.note-item .who { font-weight: 700; font-size: 12px; color: var(--muted); margin-bottom: 3px; }

.legend { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.legend .li { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.legend .sw { width: 10px; height: 10px; border-radius: 3px; }

.chart { display: grid; place-items: center; }
.chart svg { width: 100%; height: auto; overflow: visible; }

/* -------------------------------------------------------------- confetti */
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 50; }
.confetti i {
  position: absolute; top: -14px; width: 9px; height: 14px; border-radius: 2px;
  animation: fall linear forwards;
}
@keyframes fall {
  0% { transform: translateY(-20px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(105vh) rotate(720deg); opacity: 0.15; }
}

/* ----------------------------------------------------------------- misc */
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.on { background: var(--good); box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.18); }
.dot.off { background: var(--bad); }

.conn { margin-top: auto; text-align: center; font-size: 12px; color: var(--muted); }
.conn b { color: var(--text); font-weight: 700; }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translate(-50%, 24px); opacity: 0; pointer-events: none;
  background: rgba(20, 16, 32, 0.96); border: 1px solid var(--line); color: var(--text);
  padding: 12px 18px; border-radius: 14px; font-size: 14px; font-weight: 600;
  box-shadow: var(--shadow); transition: opacity 0.25s ease, transform 0.25s ease; z-index: 100;
  max-width: calc(100vw - 40px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.banner {
  border-radius: 14px; padding: 12px 14px; font-size: 13px;
  background: rgba(251, 191, 36, 0.12); border: 1px solid rgba(251, 191, 36, 0.35); color: #fde68a;
}
.banner.info { background: rgba(96, 165, 250, 0.12); border-color: rgba(96, 165, 250, 0.35); color: #bfdbfe; }

table.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
table.grid th, table.grid td { padding: 8px 6px; text-align: right; border-bottom: 1px solid var(--line); }
table.grid th:first-child, table.grid td:first-child { text-align: left; }
table.grid th { color: var(--muted); font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; }
table.grid td { font-variant-numeric: tabular-nums; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

@media (min-width: 640px) {
  .app { padding: 24px 0; }
  .screen { background: rgba(255, 255, 255, 0.028); border: 1px solid var(--line); border-radius: 26px; overflow: hidden; box-shadow: var(--shadow); }
}
