:root {
  color-scheme: dark;
  --bg: #1b1433;
  --bg-2: #261c47;
  --panel: #2c2252;
  --line: rgba(255, 255, 255, .12);
  --text: #fbf6ff;
  --muted: #b9add6;
  --card: #fff8ec;
  --ink: #1d1530;
  --ink-muted: #6e6488;
  --yes: #1fcf86;
  --yes-ink: #0b5c3a;
  --no: #ff4f61;
  --no-ink: #7a1220;
  --sun: #ffbe2e;
  --violet: #8b6cff;
  --pink: #ff6fb5;
  --radius: 28px;
  --font: "Bricolage Grotesque", ui-rounded, system-ui, -apple-system, "Segoe UI", sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
input { font: inherit; }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }

/* background blobs */
.blobs { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
.blobs i { position: absolute; border-radius: 50%; filter: blur(60px); opacity: .45; animation: float 18s ease-in-out infinite alternate; }
.blobs i:nth-child(1) { width: 60vmax; height: 60vmax; background: #5b2bd6; left: -25vmax; top: -20vmax; }
.blobs i:nth-child(2) { width: 45vmax; height: 45vmax; background: #d6266f; right: -20vmax; bottom: -15vmax; animation-delay: -6s; opacity: .35; }
.blobs i:nth-child(3) { width: 30vmax; height: 30vmax; background: #ff9a1f; right: -5vmax; top: 20vh; animation-delay: -12s; opacity: .18; }
@keyframes float { to { transform: translate(6vmax, 4vmax) scale(1.1); } }

.screen {
  position: fixed; inset: 0; z-index: 1;
  display: flex; flex-direction: column;
  padding: calc(var(--safe-t) + 10px) 16px calc(var(--safe-b) + 14px);
  max-width: 560px; margin: 0 auto;
}

/* swiss cross logo */
.swiss { display: inline-block; width: 28px; height: 28px; border-radius: 8px; background: var(--no); position: relative; flex: none; }
.swiss::before, .swiss::after { content: ""; position: absolute; background: #fff; border-radius: 2px; left: 50%; top: 50%; transform: translate(-50%, -50%); }
.swiss::before { width: 58%; height: 18%; }
.swiss::after { width: 18%; height: 58%; }
.swiss.sm { width: 22px; height: 22px; border-radius: 6px; }

/* login */
.login { margin: auto; width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 12px; text-align: center; }
.logo-big { display: grid; place-items: center; margin-bottom: 4px; }
.logo-big .swiss { width: 76px; height: 76px; border-radius: 22px; transform: rotate(-8deg); box-shadow: 0 16px 40px rgba(255, 79, 97, .45); animation: wobble 3s ease-in-out infinite; }
@keyframes wobble { 50% { transform: rotate(8deg) scale(1.04); } }
.login h1 { font-size: 52px; line-height: .9; margin: 6px 0 14px; font-weight: 800; letter-spacing: -.03em; }
.login input {
  height: 56px; border-radius: 18px; border: 2px solid var(--line); background: rgba(255, 255, 255, .06);
  color: var(--text); padding: 0 18px; font-size: 18px; text-align: center; outline: none;
}
.login input:focus { border-color: var(--violet); background: rgba(255, 255, 255, .1); }
#login-pin { letter-spacing: .4em; }
.error { color: #ff8b97; min-height: 1.3em; margin: 0; font-weight: 600; }

.btn-primary {
  height: 56px; border-radius: 18px; background: var(--sun); color: var(--ink);
  font-size: 18px; font-weight: 800; padding: 0 22px; box-shadow: 0 6px 0 #c98a00;
  transition: transform .08s, box-shadow .08s, opacity .2s;
}
.btn-primary:active { transform: translateY(4px); box-shadow: 0 2px 0 #c98a00; }
.btn-primary:disabled { opacity: .35; cursor: default; }
.btn-primary.btn-no { background: var(--no); color: #fff; box-shadow: 0 6px 0 #b8273a; }
.btn-primary.btn-no:active { box-shadow: 0 2px 0 #b8273a; }
.btn-ghost { height: 56px; border-radius: 18px; padding: 0 20px; font-weight: 700; color: var(--ink-muted); }

/* top bar */
.top { display: flex; align-items: center; gap: 10px; height: 48px; flex: none; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 19px; letter-spacing: -.01em; }
.streak { display: flex; align-items: center; gap: 4px; margin-left: 4px; padding: 4px 10px 4px 6px; border-radius: 99px; background: rgba(255, 190, 46, .14); color: var(--sun); font-weight: 800; }
.streak svg { width: 18px; height: 18px; fill: var(--sun); stroke: none; }
.streak.bump { animation: bump .35s; }
@keyframes bump { 40% { transform: scale(1.25); } }
.icons { margin-left: auto; display: flex; gap: 4px; }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 14px; color: var(--muted); transition: background .15s, color .15s; }
.icon-btn:hover:not(:disabled) { background: rgba(255, 255, 255, .08); color: var(--text); }
.icon-btn:disabled { opacity: .3; cursor: default; }

/* deck */
.deck { position: relative; flex: 1; margin: 8px 0 16px; min-height: 0; touch-action: none; }
.waiting { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 14px; color: var(--muted); font-weight: 600; text-align: center; }
.spinner { width: 42px; height: 42px; border-radius: 50%; border: 4px solid rgba(255, 255, 255, .15); border-top-color: var(--sun); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.card {
  position: absolute; inset: 0;
  background: var(--card); color: var(--ink);
  border-radius: var(--radius);
  padding: 22px 22px 18px;
  display: flex; flex-direction: column;
  box-shadow: 0 24px 60px rgba(8, 2, 30, .5), 0 2px 0 rgba(255, 255, 255, .6) inset;
  touch-action: none; user-select: none; -webkit-user-select: none;
  will-change: transform;
  transition: transform .35s cubic-bezier(.2, .9, .3, 1.2), opacity .3s;
}
.card.dragging { transition: none; }
.card * { touch-action: none; }
.card.behind { transform: translateY(14px) scale(.94); opacity: .65; pointer-events: none; filter: saturate(.6); }
.card.behind2 { transform: translateY(28px) scale(.88); opacity: .3; pointer-events: none; }
.card.enter { animation: pop .38s cubic-bezier(.2, .9, .3, 1.3); }
@keyframes pop { from { transform: translateY(14px) scale(.94); } }

.card-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tag { font-size: 12.5px; font-weight: 700; padding: 5px 10px; border-radius: 99px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag-source { background: #efe4ff; color: #4b2aa8; }
.tag-show { background: #ffe6c7; color: #8a4600; }
.dur { margin-left: auto; font-size: 13px; font-weight: 700; color: var(--ink-muted); font-variant-numeric: tabular-nums; }

.sosg {
  flex: 1; margin: 18px 0; overflow: hidden; touch-action: none;
  display: flex; align-items: center;
  font-size: clamp(21px, 6vw, 28px); line-height: 1.32; font-weight: 600; letter-spacing: -.01em;
  overflow-wrap: anywhere;
}
.sosg.long { font-size: clamp(18px, 4.8vw, 22px); }
.sosg.xlong { font-size: clamp(16px, 4.2vw, 19px); }
.sosg span { margin: auto 0; }

.player { display: flex; align-items: center; gap: 12px; height: 56px; flex: none; }
.play { width: 52px; height: 52px; border-radius: 50%; background: var(--ink); color: var(--card); display: grid; place-items: center; flex: none; }
.play svg { width: 22px; height: 22px; fill: currentColor; stroke: none; }
.play .i-pause, .card.playing .play .i-play { display: none; }
.card.playing .play .i-pause { display: block; }
.bars { flex: 1; min-width: 0; height: 48px; display: flex; align-items: center; gap: 2px; cursor: pointer; overflow: hidden; }
.bars i { flex: 1; min-width: 1px; border-radius: 3px; background: #d9cfe8; height: var(--h, 20%); transition: background .1s; }
.bars i.on { background: var(--violet); }

.stamp {
  position: absolute; top: 34px; padding: 4px 14px; border: 5px solid; border-radius: 14px;
  font-size: 40px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em;
  opacity: 0; pointer-events: none; z-index: 2;
}
.stamp-yes { left: 24px; color: var(--yes); transform: rotate(-14deg); }
.stamp-no { right: 24px; color: var(--no); transform: rotate(14deg); }

/* action buttons */
.actions { display: flex; justify-content: center; align-items: center; gap: 26px; flex: none; }
.act { display: grid; place-items: center; border-radius: 50%; transition: transform .12s; }
.act:active { transform: scale(.88); }
.act-no, .act-yes { width: 76px; height: 76px; background: var(--bg-2); border: 3px solid; }
.act-no { color: var(--no); border-color: rgba(255, 79, 97, .5); }
.act-yes { color: var(--yes); border-color: rgba(31, 207, 134, .5); }
.act-no svg, .act-yes svg { width: 36px; height: 36px; stroke-width: 3; }
.act-yes svg { fill: var(--yes); stroke: none; }
.act-no:hover { background: rgba(255, 79, 97, .15); }
.act-yes:hover { background: rgba(31, 207, 134, .15); }
.act-replay { width: 54px; height: 54px; background: var(--bg-2); color: var(--sun); border: 2px solid rgba(255, 190, 46, .4); }
.act.hit { animation: hit .3s; }
@keyframes hit { 40% { transform: scale(1.18); } }

/* sheet */
.sheet { position: fixed; inset: 0; z-index: 20; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(10, 4, 28, .5); animation: fade .2s; }
.sheet-panel {
  position: absolute; left: 0; right: 0; bottom: 0; margin: 0 auto; max-width: 560px;
  background: var(--card); color: var(--ink);
  border-radius: 28px 28px 0 0; padding: 10px 18px calc(var(--safe-b) + 18px);
  animation: up .28s cubic-bezier(.2, .9, .3, 1.15);
}
.grab { width: 44px; height: 5px; border-radius: 9px; background: #ddd2ea; margin: 0 auto 10px; }
.sheet h2 { margin: 4px 4px 14px; font-size: 22px; font-weight: 800; }
.chips { display: flex; flex-direction: column; gap: 8px; }
.chip {
  display: flex; align-items: center; gap: 12px; text-align: left;
  min-height: 54px; padding: 10px 16px; border-radius: 16px;
  background: #f3ebde; color: var(--ink); font-weight: 700; font-size: 16.5px;
  border: 2px solid transparent; transition: background .12s, border-color .12s, transform .1s;
}
.chip:active { transform: scale(.98); }
.chip .box { width: 24px; height: 24px; border-radius: 8px; border: 2.5px solid #c8bad9; display: grid; place-items: center; flex: none; transition: all .12s; }
.chip .box svg { width: 16px; height: 16px; stroke: #fff; stroke-width: 3.5; opacity: 0; }
.chip .k { margin-left: auto; font-size: 12px; color: #a99cbd; font-weight: 700; }
.chip[aria-pressed="true"] { background: #ffe1e4; border-color: var(--no); }
.chip[aria-pressed="true"] .box { background: var(--no); border-color: var(--no); }
.chip[aria-pressed="true"] .box svg { opacity: 1; }
.sheet-row { display: flex; gap: 10px; margin-top: 16px; }
.sheet-row .btn-primary { flex: 1; }
@keyframes up { from { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }

/* guide modal */
.modal { position: fixed; inset: 0; z-index: 30; background: rgba(10, 4, 28, .65); display: grid; place-items: center; padding: 16px; animation: fade .2s; overflow-y: auto; }
.modal-panel {
  width: 100%; max-width: 520px; background: var(--card); color: var(--ink);
  border-radius: 28px; padding: 24px 20px 20px; animation: pop .35s cubic-bezier(.2, .9, .3, 1.3);
  max-height: calc(100dvh - 32px); overflow-y: auto;
}
.modal h2 { margin: 0 0 8px; font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.lead { margin: 0 0 14px; font-size: 15.5px; line-height: 1.4; color: #3c3354; }
.guide-grid { display: grid; gap: 10px; }
.guide-col { border-radius: 18px; padding: 12px 14px; }
.guide-col.yes { background: #dcf7ea; }
.guide-col.no { background: #ffe4e6; }
.guide-col h3 { margin: 0 0 6px; display: flex; align-items: center; gap: 8px; font-size: 17px; }
.guide-col.yes h3 { color: var(--yes-ink); }
.guide-col.no h3 { color: var(--no-ink); }
.guide-col.yes h3 svg { fill: var(--yes); stroke: none; width: 20px; height: 20px; }
.guide-col.no h3 svg { color: var(--no); width: 20px; height: 20px; stroke-width: 3.2; }
.guide-col ul { margin: 0; padding-left: 18px; line-height: 1.45; font-size: 14.5px; }
.guide-col dl { margin: 0; font-size: 14.5px; }
.guide-col dt { font-weight: 800; margin-top: 5px; }
.guide-col dd { margin: 0; color: #5a4f6e; line-height: 1.3; font-size: 13.5px; }
.note { margin: 12px 2px 0; font-size: 14.5px; color: #4a4062; line-height: 1.4; }
.keys { display: none; flex-wrap: wrap; gap: 6px 14px; margin: 14px 2px 0; font-size: 13px; color: var(--ink-muted); }
@media (hover: hover) and (pointer: fine) { .keys { display: flex; } }
kbd { display: inline-block; min-width: 22px; padding: 1px 6px; border-radius: 6px; background: #efe6f8; border-bottom: 2px solid #d4c6e6; font: 700 12px var(--font); text-align: center; margin-right: 2px; }
.modal .btn-primary { width: 100%; }
.modal-foot { position: sticky; bottom: -20px; margin: 16px -20px -20px; padding: 12px 20px 20px; background: linear-gradient(transparent, var(--card) 30%); }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--safe-b) + 120px); transform: translateX(-50%); z-index: 40;
  background: var(--ink); color: var(--text); padding: 10px 18px; border-radius: 99px; font-weight: 700;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .35); animation: fade .2s; white-space: nowrap;
}

/* confetti */
.confetti { position: fixed; z-index: 50; pointer-events: none; width: 10px; height: 14px; border-radius: 3px; }

/* stats */
.stats { padding-bottom: 0; }
.stats .top { gap: 4px; }
.stats .top .brand { margin-right: auto; }
.stats-body { flex: 1; overflow-y: auto; margin: 0 -16px; padding: 4px 16px calc(var(--safe-b) + 28px); -webkit-overflow-scrolling: touch; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile { background: rgba(255, 255, 255, .07); border: 1px solid var(--line); border-radius: 20px; padding: 14px; }
.tile .v { font-size: 34px; font-weight: 800; letter-spacing: -.03em; line-height: 1; font-variant-numeric: tabular-nums; }
.tile .l { font-size: 13px; color: var(--muted); font-weight: 600; margin-top: 6px; }
.tile .s { font-size: 12px; color: var(--muted); margin-top: 2px; font-variant-numeric: tabular-nums; }
.tile.good .v { color: var(--yes); }
.stats h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 26px 2px 10px; }
.panel { background: rgba(255, 255, 255, .05); border: 1px solid var(--line); border-radius: 20px; padding: 6px 14px; }

.reason { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; padding: 9px 0; }
.reason + .reason { border-top: 1px solid var(--line); }
.reason .n { font-weight: 700; font-size: 15px; }
.reason .c { color: var(--muted); font-size: 13.5px; font-variant-numeric: tabular-nums; }
.reason .track { grid-column: 1 / -1; }

.track { position: relative; height: 10px; border-radius: 99px; background: rgba(255, 255, 255, .08); }
.track .fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 99px; background: var(--no); }
.track .fill.good { background: var(--yes); }
.track .ci { position: absolute; top: 50%; height: 2px; background: var(--text); opacity: .55; transform: translateY(-50%); }
.track .ci::before, .track .ci::after { content: ""; position: absolute; top: -4px; width: 2px; height: 10px; background: inherit; }
.track .ci::before { left: 0; }
.track .ci::after { right: 0; }
.track.empty { background: repeating-linear-gradient(-45deg, rgba(255, 255, 255, .06) 0 4px, transparent 4px 8px); }

.src { border-bottom: 1px solid var(--line); }
.src:last-child { border-bottom: 0; }
.src-head { width: 100%; text-align: left; display: grid; grid-template-columns: 1fr auto; gap: 3px 10px; padding: 12px 0; }
.src-head .n { font-weight: 700; font-size: 15.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.src-head .pct { font-weight: 800; font-variant-numeric: tabular-nums; }
.src-head .meta { font-size: 12.5px; color: var(--muted); grid-column: 1 / -1; display: flex; gap: 10px; }
.src-head .meta .chev { margin-left: auto; transition: transform .2s; }
.src-head .track { grid-column: 1 / -1; margin-top: 4px; }
.src.low .src-head .pct, .src.low .fill { opacity: .5; }
.src.open .chev { transform: rotate(180deg); }
.src-shows { display: none; padding: 0 0 12px 12px; border-left: 2px solid var(--line); margin-left: 2px; }
.src.open .src-shows { display: block; }
.show { padding: 8px 0; display: grid; grid-template-columns: 1fr auto; gap: 3px 10px; }
.show .n { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.show .pct { font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }
.show .meta { grid-column: 1 / -1; font-size: 12px; color: var(--muted); }
.show .track { grid-column: 1 / -1; height: 6px; }
.src-reasons { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 0 12px; }
.src-reasons span { font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 99px; background: rgba(255, 79, 97, .14); color: #ffb3bb; }

.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin: 0 2px 8px; flex-wrap: wrap; }
.legend span { display: flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 8px; border-radius: 4px; background: var(--yes); display: inline-block; }
.legend i.ci { width: 14px; height: 2px; background: var(--text); opacity: .55; }

.users .u { display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; align-items: center; padding: 10px 0; }
.users .u + .u { border-top: 1px solid var(--line); }
.users .rank { font-weight: 800; color: var(--sun); text-align: center; }
.users .name { font-weight: 700; }
.users .num { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 14px; }
.users .num b { color: var(--text); }

.stats-foot { display: flex; gap: 10px; margin-top: 24px; }
.stats-foot a, .stats-foot button {
  flex: 1; height: 48px; border-radius: 16px; display: grid; place-items: center;
  font-weight: 700; color: var(--text); text-decoration: none; background: rgba(255, 255, 255, .08); border: 1px solid var(--line);
}
.empty-msg { color: var(--muted); text-align: center; padding: 30px 0; }

/* admin */
.user-form { padding: 14px; display: grid; gap: 10px; }
.field {
  width: 100%; height: 50px; border-radius: 14px; border: 2px solid var(--line); background: rgba(255, 255, 255, .06);
  color: var(--text); padding: 0 14px; font-size: 16px; outline: none; min-width: 0;
}
.field:focus { border-color: var(--violet); background: rgba(255, 255, 255, .1); }
.field::placeholder { color: var(--muted); opacity: .8; }
.pin-row { display: flex; gap: 10px; }
.pin-row .btn-primary { height: 50px; flex: none; font-size: 16px; padding: 0 16px; }
.user-form .error { min-height: 0; font-size: 14px; }
.user-form .error:empty { display: none; }
.cred {
  margin-top: 12px; display: flex; align-items: center; gap: 12px; padding: 14px 16px;
  border-radius: 20px; background: var(--sun); color: var(--ink); animation: pop .35s cubic-bezier(.2, .9, .3, 1.3);
}
.cred-text { display: grid; flex: 1; min-width: 0; }
.cred-name { font-weight: 700; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cred-pin { font-weight: 800; font-size: 30px; letter-spacing: .12em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.cred-copy { height: 44px; background: rgba(0, 0, 0, .1); color: var(--ink); font-size: 15px; }
.users .u.mng { grid-template-columns: 1fr auto auto; }
.users .u .sub { display: block; font-size: 12.5px; color: var(--muted); font-weight: 500; margin-top: 2px; }
.users .u .badge { font-size: 11px; font-weight: 800; color: var(--sun); background: rgba(255, 190, 46, .14); padding: 2px 8px; border-radius: 99px; margin-left: 6px; vertical-align: 2px; }
.users .u .icon-btn { width: 40px; height: 40px; }
.users .u .icon-btn.danger:hover { color: var(--no); background: rgba(255, 79, 97, .12); }

@media (max-width: 370px) {
  .bars { gap: 1.5px; }
  .brand-text { display: none; }
  .act-no, .act-yes { width: 68px; height: 68px; }
  .card { padding: 18px 18px 14px; }
}
@media (max-height: 640px) {
  .act-no, .act-yes { width: 64px; height: 64px; }
  .act-replay { width: 48px; height: 48px; }
  .deck { margin: 4px 0 10px; }
}
@media (min-height: 760px) { .sosg { font-size: clamp(22px, 6vw, 30px); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
