:root {
  --bg: #140b24;
  --bg2: #1e1236;
  --card: #241645;
  --card2: #2d1c55;
  --line: #3b2a66;
  --text: #f6f1ff;
  --muted: #b3a6d6;
  --pink: #ff3d9a;
  --orange: #ffb02e;
  --teal: #2ee6c9;
  --red: #ff5a5a;
  --grad: linear-gradient(135deg, #ff3d9a 0%, #ff7a3d 55%, #ffb02e 100%);
  --radius: 18px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: radial-gradient(1200px 600px at 50% -200px, #3a1a6b 0%, var(--bg) 60%) fixed, var(--bg);
  color: var(--text);
  font-family: "Nunito", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  font-size: 17px;
  line-height: 1.45;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--teal); }
h1, h2, h3 { font-family: "Fredoka", "Nunito", sans-serif; font-weight: 600; line-height: 1.15; margin: 0 0 .4em; }
h1 { font-size: 2rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }
p { margin: .3em 0 .8em; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.center { text-align: center; }

.topbar {
  position: sticky; top: 0; z-index: 10;
  padding: 12px 18px calc(12px) 18px;
  padding-top: calc(12px + env(safe-area-inset-top));
  background: rgba(20, 11, 36, .85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { font-family: "Fredoka", sans-serif; font-weight: 700; font-size: 1.25rem; color: var(--text); text-decoration: none; }
.brand .mic { display: inline-block; transform: rotate(-15deg); }

.wrap { max-width: 640px; margin: 0 auto; padding: 18px 16px 80px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin: 14px 0;
}
.card.glow { border-color: transparent; background: linear-gradient(var(--card), var(--card)) padding-box, var(--grad) border-box; border: 2px solid transparent; }

.hero { text-align: center; padding: 24px 0 8px; }
.hero .big-mic { font-size: 64px; display: inline-block; transform: rotate(-15deg); }
.hero h1 { font-size: 2.4rem; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }

label { display: block; font-weight: 700; margin: 10px 0 6px; }
input[type=text], input[type=url], select {
  width: 100%; padding: 13px 14px; font-size: 17px; font-family: inherit;
  background: var(--bg2); color: var(--text);
  border: 1px solid var(--line); border-radius: 12px; outline: none;
}
input:focus { border-color: var(--pink); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px 20px; border-radius: 999px; border: 0; cursor: pointer;
  font-family: "Fredoka", sans-serif; font-weight: 600; font-size: 1.05rem;
  background: var(--card2); color: var(--text); text-decoration: none;
  transition: transform .08s ease, opacity .2s;
  user-select: none; -webkit-user-select: none;
}
.btn:active { transform: scale(.97); }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn.primary { background: var(--grad); color: #1a0b2e; }
.btn.teal { background: var(--teal); color: #08241f; }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.danger { background: transparent; border: 1px solid var(--red); color: var(--red); }
.btn.block { display: flex; width: 100%; }
.btn.sm { padding: 8px 14px; font-size: .92rem; }
.btn.huge { padding: 22px; font-size: 1.5rem; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.spread { justify-content: space-between; }
.stack > * + * { margin-top: 10px; }

.list { list-style: none; margin: 0; padding: 0; }
.list li {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
.list li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .title { font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list a.rowlink { color: inherit; text-decoration: none; display: flex; gap: 12px; align-items: center; flex: 1; min-width: 0; }

.chip {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  background: var(--card2); color: var(--muted); font-size: .82rem; font-weight: 700; margin: 2px 4px 2px 0;
}
.chip.hot { background: rgba(255, 61, 154, .18); color: var(--pink); }
.chip.ok { background: rgba(46, 230, 201, .15); color: var(--teal); }

.choice { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choice input { display: none; }
.choice label {
  margin: 0; padding: 14px 10px; text-align: center; border-radius: 14px; cursor: pointer;
  background: var(--bg2); border: 2px solid var(--line); font-weight: 700;
}
.choice label small { display: block; font-weight: 600; color: var(--muted); font-size: .8rem; }
.choice input:checked + label { border-color: var(--pink); background: rgba(255, 61, 154, .12); }

.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; cursor: pointer; }
.switch input { width: 52px; height: 30px; appearance: none; -webkit-appearance: none; background: var(--line); border-radius: 999px; position: relative; cursor: pointer; transition: background .2s; flex: none; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: left .2s; }
.switch input:checked { background: var(--teal); }
.switch input:checked::after { left: 25px; }

.check { display: flex; gap: 12px; align-items: center; font-weight: 700; cursor: pointer; padding: 10px 0; }
.check input { width: 26px; height: 26px; accent-color: var(--pink); flex: none; }

/* video */
.video { position: relative; width: 100%; aspect-ratio: 16 / 9; background: #000; border-radius: 14px; overflow: hidden; }
.video > div, .video iframe { position: absolute; inset: 0; width: 100% !important; height: 100% !important; }

/* sing stage */
.stage-banner {
  margin: 12px 0; padding: 16px; border-radius: 16px; text-align: center;
  background: var(--card); border: 2px solid var(--line);
  font-family: "Fredoka", sans-serif; transition: background .2s, border-color .2s;
}
.stage-banner .label { font-size: 1.3rem; font-weight: 600; }
.stage-banner .count { font-size: 3.2rem; font-weight: 700; line-height: 1; margin-top: 6px; }
.stage-banner.warm { border-color: var(--orange); }
.stage-banner.sing { background: var(--grad); color: #1a0b2e; border-color: transparent; animation: pulse 1s ease-in-out infinite; }
.stage-banner.done { border-color: var(--teal); }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.02); } }
.bar { height: 10px; background: var(--bg2); border-radius: 999px; overflow: hidden; margin-top: 10px; }
.bar > i { display: block; height: 100%; width: 0%; background: var(--grad); }
.stage-banner.sing .bar { background: rgba(0,0,0,.2); }
.stage-banner.sing .bar > i { background: #1a0b2e; }
.hint { background: rgba(255, 176, 46, .15); border: 1px solid var(--orange); color: var(--orange); padding: 10px 14px; border-radius: 12px; font-weight: 700; margin: 10px 0; }
.err { background: rgba(255, 90, 90, .12); border: 1px solid var(--red); color: #ffc2c2; padding: 10px 14px; border-radius: 12px; margin: 10px 0; }

.youre-up { text-align: center; }
.youre-up .big { font-family: "Fredoka", sans-serif; font-size: 2.2rem; font-weight: 700; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }

.now-singing { text-align: center; padding: 18px; }
.now-singing .who { font-family: "Fredoka", sans-serif; font-size: 2.4rem; font-weight: 700; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; min-height: 1.2em; }

.progress { display: flex; gap: 3px; flex-wrap: wrap; margin: 8px 0; }
.progress span { flex: 1 0 8px; max-width: 26px; height: 10px; border-radius: 4px; background: var(--bg2); }
.progress span.done { background: var(--teal); }
.progress span.now { background: var(--pink); animation: pulse 1s infinite; }

/* mark tool */
.tap-btn {
  width: 100%; padding: 30px 10px; font-size: 1.6rem; border-radius: 22px;
  font-family: "Fredoka", sans-serif; font-weight: 700; border: 0; cursor: pointer;
  background: var(--grad); color: #1a0b2e; margin: 12px 0;
  user-select: none; -webkit-user-select: none; touch-action: manipulation;
}
.tap-btn:active { transform: scale(.98); filter: brightness(1.1); }
.marks { max-height: 320px; overflow-y: auto; }
.marks li { padding: 6px 0; gap: 6px; }
.marks .t { font-variant-numeric: tabular-nums; font-weight: 800; width: 74px; }
.marks .n { color: var(--muted); width: 30px; }
.iconbtn { background: var(--card2); color: var(--text); border: 0; border-radius: 10px; padding: 7px 10px; font-size: .9rem; cursor: pointer; font-weight: 800; }

input[type=range] { width: 100%; accent-color: var(--pink); }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 12px 20px; border-radius: 999px; font-weight: 800;
  box-shadow: 0 8px 30px rgba(0,0,0,.4); z-index: 100; max-width: 90vw; text-align: center;
}
.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  background: var(--bg2); border: 1px solid var(--line); border-radius: 22px 22px 0 0;
  width: 100%; max-width: 640px; padding: 20px 18px calc(24px + env(safe-area-inset-bottom));
  max-height: 92vh; overflow-y: auto; animation: up .2s ease-out;
}
@keyframes up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.spinner { display: inline-block; width: 22px; height: 22px; border: 3px solid var(--line); border-top-color: var(--pink); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { text-align: center; padding: 18px; color: var(--muted); }
