:root {
  color-scheme: dark;
  --ink: #101722;
  --ink-2: #182332;
  --ink-3: #223145;
  --paper: #f4e8cf;
  --paper-2: #dccbaa;
  --red: #e35d52;
  --red-dark: #b94641;
  --mint: #70c1a7;
  --gold: #e7b85b;
  --white: #fffaf0;
  --muted: #aab4bf;
  --danger: #ff7c73;
  --radius: 22px;
  --shadow: 0 18px 45px rgba(2, 7, 14, .24);
  --safe-bottom: max(18px, env(safe-area-inset-bottom));
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-height: 100%; background: var(--ink); }
body {
  min-width: 320px;
  min-height: 100dvh;
  margin: 0;
  background:
    radial-gradient(circle at 88% -10%, rgba(227, 93, 82, .18), transparent 36rem),
    radial-gradient(circle at -10% 40%, rgba(112, 193, 167, .1), transparent 30rem),
    var(--ink);
  color: var(--white);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
a { color: var(--paper); }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 12px; font-size: clamp(2.15rem, 10vw, 4.6rem); line-height: .94; letter-spacing: -.055em; }
h2 { margin-bottom: 10px; font-size: clamp(1.35rem, 5vw, 2rem); line-height: 1.08; letter-spacing: -.025em; }
h3 { margin-bottom: 8px; font-size: 1rem; }
p:last-child { margin-bottom: 0; }

.app-shell, .install-shell { width: min(100%, 1100px); margin: 0 auto; padding: 18px 16px calc(92px + var(--safe-bottom)); }
.install-shell { max-width: 760px; padding-top: 34px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.topbar-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.mark { display: grid; place-items: center; width: 38px; height: 38px; flex: 0 0 auto; border-radius: 12px; background: var(--red); color: white; font-weight: 900; }
.topbar-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 760; }
.topbar-meta { color: var(--muted); font-size: .78rem; }
.connection { display: inline-flex; align-items: center; gap: 7px; padding: 7px 10px; border: 1px solid rgba(255,255,255,.1); border-radius: 999px; color: var(--muted); font-size: .76rem; white-space: nowrap; }
.connection::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--mint); box-shadow: 0 0 0 4px rgba(112,193,167,.12); }
.connection.offline::before { background: var(--danger); box-shadow: 0 0 0 4px rgba(255,124,115,.13); }

.hero { padding: 18px 2px 8px; }
.eyebrow { display: inline-block; margin-bottom: 14px; color: var(--gold); font-size: .76rem; font-weight: 850; letter-spacing: .15em; text-transform: uppercase; }
.hero-copy { max-width: 32rem; color: var(--paper-2); font-size: 1.05rem; }
.hero-lockup { position: relative; padding: 30px 0 20px; }
.hero-number { position: absolute; top: -6px; right: 0; color: rgba(255,255,255,.045); font-size: min(45vw, 13rem); font-weight: 950; line-height: 1; pointer-events: none; }

.panel, .brand-card, .task-card, .score-card, .candidate, .team-card, .fragment-card {
  border: 1px solid rgba(255,255,255,.095);
  border-radius: var(--radius);
  background: linear-gradient(150deg, rgba(255,255,255,.065), rgba(255,255,255,.025));
  box-shadow: var(--shadow);
}
.panel, .task-card, .team-card { padding: 20px; }
.brand-card { margin-bottom: 18px; padding: 30px 26px; background: linear-gradient(140deg, rgba(227,93,82,.22), rgba(255,255,255,.035)); }
.paper-card { border-color: transparent; background: var(--paper); color: #202530; }
.paper-card .muted { color: #62676d; }
.accent-card { background: linear-gradient(145deg, rgba(227,93,82,.22), rgba(227,93,82,.06)); }
.success-card { background: linear-gradient(145deg, rgba(112,193,167,.2), rgba(112,193,167,.04)); }
.stack > * + * { margin-top: 12px; }
.stack-lg > * + * { margin-top: 18px; }
.stack-xl > * + * { margin-top: 28px; }
.grid { display: grid; gap: 14px; }
.two-col { grid-template-columns: 1fr; }
.admin-grid { display: grid; gap: 16px; }
.muted { color: var(--muted); }
.micro { color: var(--muted); font-size: .78rem; }
.lead { color: var(--paper-2); font-size: 1.07rem; }
.kicker { margin-bottom: 8px; color: var(--gold); font-size: .72rem; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.big-number { font-size: 2.8rem; font-weight: 900; line-height: 1; letter-spacing: -.05em; }
.divider { height: 1px; margin: 18px 0; background: rgba(255,255,255,.1); }
details { border: 1px solid rgba(255,255,255,.1); border-radius: 14px; padding: 0 14px 14px; }
details:not([open]) { padding-bottom: 0; }
summary { min-height: 48px; display: flex; align-items: center; cursor: pointer; color: var(--paper); font-weight: 760; }

.button {
  position: relative;
  display: inline-flex;
  min-height: 50px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  padding: 13px 18px;
  border: 1px solid rgba(255,255,255,.13);
  border-radius: 15px;
  background: rgba(255,255,255,.07);
  color: var(--white);
  text-decoration: none;
  font-weight: 770;
  cursor: pointer;
  touch-action: manipulation;
  overflow: hidden;
}
.button:hover { background: rgba(255,255,255,.1); }
.button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 3px solid rgba(231,184,91,.6); outline-offset: 2px; }
.button:disabled { cursor: not-allowed; opacity: .46; }
.button.primary { border-color: transparent; background: var(--red); color: white; }
.button.primary:hover { background: var(--red-dark); }
.button.secondary { border-color: rgba(244,232,207,.32); color: var(--paper); }
.button.success { border-color: transparent; background: var(--mint); color: #0c211b; }
.button.danger { border-color: rgba(255,124,115,.3); color: var(--danger); }
.button.compact { min-height: 42px; width: auto; padding: 9px 13px; font-size: .85rem; }
.button.hold::before { content: ""; position: absolute; inset: 0; width: 0; background: rgba(255,255,255,.2); }
.button.hold.is-holding::before { width: 100%; transition: width 1.5s linear; }
.button span { position: relative; z-index: 1; }
.button-row { display: grid; grid-template-columns: 1fr; gap: 10px; }

label { display: grid; gap: 7px; color: var(--paper-2); font-size: .88rem; font-weight: 700; }
input, textarea, select {
  width: 100%;
  min-height: 50px;
  padding: 13px 14px;
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 14px;
  background: rgba(6,11,18,.52);
  color: var(--white);
}
textarea { min-height: 92px; resize: vertical; }
input::placeholder, textarea::placeholder { color: #718090; }
.form-grid { display: grid; grid-template-columns: 1fr; gap: 13px; }
.choice { display: flex; align-items: center; gap: 12px; padding: 13px; border: 1px solid rgba(255,255,255,.1); border-radius: 14px; }
.choice input { width: 20px; min-height: 20px; accent-color: var(--red); }
.choice span { display: grid; gap: 2px; }
.choice small { color: var(--muted); font-weight: 500; }
.tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 5px; border-radius: 15px; background: rgba(0,0,0,.18); }
.tab { min-height: 42px; border: 0; border-radius: 11px; background: transparent; color: var(--muted); font-size: .8rem; font-weight: 760; }
.tab.active { background: var(--ink-3); color: var(--white); }

.status-strip { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; margin-bottom: 18px; }
.score { color: var(--gold); font-size: .92rem; font-weight: 820; white-space: nowrap; }
.progress-wrap { display: grid; gap: 7px; }
.progress-meta { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: .75rem; }
.progress-track { height: 6px; border-radius: 99px; background: rgba(255,255,255,.09); overflow: hidden; }
.progress-bar { height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--red), var(--gold)); transition: width .35s ease; }

.task-card { position: relative; overflow: hidden; }
.task-card::after { content: attr(data-step); position: absolute; right: -3px; bottom: -34px; color: rgba(255,255,255,.04); font-size: 10rem; font-weight: 950; line-height: 1; pointer-events: none; }
.task-card > * { position: relative; z-index: 1; }
.location { display: flex; gap: 9px; align-items: flex-start; margin-bottom: 16px; color: var(--paper-2); font-size: .88rem; }
.location::before { content: "●"; color: var(--red); font-size: .7rem; margin-top: .25rem; }
.task-text { color: var(--paper); font-size: 1.15rem; line-height: 1.4; }
.format-chip, .phase-chip { display: inline-flex; width: fit-content; padding: 6px 9px; border-radius: 999px; background: rgba(231,184,91,.12); color: var(--gold); font-size: .72rem; font-weight: 750; }
.phase-chip { background: rgba(112,193,167,.12); color: var(--mint); }

.candidate-list { display: grid; gap: 10px; }
.candidate { display: grid; grid-template-columns: 24px 1fr auto; gap: 11px; align-items: center; width: 100%; padding: 14px; color: var(--white); text-align: left; cursor: pointer; }
.candidate.selected { border-color: var(--gold); background: rgba(231,184,91,.11); }
.candidate input { width: 20px; min-height: 20px; accent-color: var(--gold); }
.candidate-value { overflow-wrap: anywhere; font-weight: 760; }
.vote-badge { min-width: 34px; padding: 5px 8px; border-radius: 999px; background: rgba(255,255,255,.08); color: var(--paper-2); text-align: center; font-size: .78rem; }
.council-meter { display: flex; gap: 7px; }
.council-dot { width: 11px; height: 11px; border-radius: 50%; background: rgba(255,255,255,.13); }
.council-dot.on { background: var(--gold); }
.hint { padding: 14px; border-left: 3px solid var(--gold); border-radius: 0 12px 12px 0; background: rgba(231,184,91,.09); color: var(--paper); }

.member-list { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px; }
.member { display: flex; min-width: 0; align-items: center; gap: 8px; padding: 9px 10px; border-radius: 12px; background: rgba(255,255,255,.045); font-size: .82rem; }
.member-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.online-dot { width: 8px; height: 8px; flex: 0 0 auto; border-radius: 50%; background: #5e6874; }
.online-dot.on { background: var(--mint); }
.code-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
.code-grid article { display: grid; gap: 5px; padding: 14px; border-radius: 14px; background: rgba(255,255,255,.05); }
.code-grid code { color: var(--gold); font-size: 1.15rem; font-weight: 850; letter-spacing: .06em; }

.fragment-list { display: grid; gap: 10px; }
.fragment-card { padding: 14px 16px; }
.fragment-value { margin-top: 4px; color: var(--gold); font-size: 1.1rem; font-weight: 820; }
.route-arrow { display: grid; place-items: center; width: 84px; height: 84px; margin: 18px auto; border: 1px solid rgba(231,184,91,.25); border-radius: 50%; color: var(--gold); font-size: 2.2rem; }

.notice { padding: 13px 14px; border-radius: 13px; background: rgba(255,255,255,.07); }
.notice-error { border: 1px solid rgba(255,124,115,.25); background: rgba(255,124,115,.09); color: #ffc4c0; }
.notice-success { border: 1px solid rgba(112,193,167,.25); background: rgba(112,193,167,.09); color: #c2f1e2; }
.toast { position: fixed; z-index: 30; right: 14px; bottom: calc(18px + var(--safe-bottom)); left: 14px; max-width: 520px; margin: 0 auto; padding: 14px 16px; border: 1px solid rgba(255,255,255,.12); border-radius: 15px; background: #26364a; box-shadow: var(--shadow); animation: toast-in .2s ease-out; }
.toast.error { background: #692f32; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }
.skeleton { min-height: 120px; border-radius: var(--radius); background: linear-gradient(100deg, rgba(255,255,255,.04), rgba(255,255,255,.09), rgba(255,255,255,.04)); background-size: 220% 100%; animation: shimmer 1.4s infinite; }
@keyframes shimmer { to { background-position: -220% 0; } }
.fatal { max-width: 700px; margin: 30px auto; padding: 18px; color: var(--danger); }

.bottom-nav { position: fixed; z-index: 20; right: 0; bottom: 0; left: 0; padding: 10px 14px var(--safe-bottom); border-top: 1px solid rgba(255,255,255,.08); background: rgba(16,23,34,.93); backdrop-filter: blur(18px); }
.bottom-nav-inner { display: grid; grid-template-columns: repeat(3,1fr); gap: 6px; max-width: 520px; margin: auto; }
.nav-button { min-height: 42px; border: 0; border-radius: 11px; background: transparent; color: var(--muted); font-size: .75rem; }
.nav-button.active { background: rgba(255,255,255,.07); color: var(--white); }
.modal-backdrop { position: fixed; z-index: 40; inset: 0; display: grid; align-items: end; padding: 14px; background: rgba(2,7,14,.72); backdrop-filter: blur(8px); }
.modal { width: min(100%, 600px); max-height: 88dvh; margin: 0 auto; padding: 20px; border: 1px solid rgba(255,255,255,.12); border-radius: 24px; background: var(--ink-2); overflow: auto; }

.team-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.admin-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.admin-actions .button { width: auto; }
.attempts { width: 100%; border-collapse: collapse; font-size: .75rem; }
.attempts th, .attempts td { padding: 8px 5px; border-bottom: 1px solid rgba(255,255,255,.08); text-align: left; }
.attempts th { color: var(--muted); font-weight: 650; }
.install-page input { background: rgba(4,9,15,.45); }
.install-page textarea { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .75rem; }

@media (min-width: 620px) {
  .app-shell { padding-top: 26px; }
  .two-col, .button-row, .code-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .form-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .span-2 { grid-column: 1 / -1; }
  .member-list { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .modal-backdrop { align-items: center; }
}

@media (min-width: 900px) {
  .admin-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .hero { padding-top: 38px; }
  .bottom-nav { position: sticky; bottom: 0; width: min(520px,100%); margin: 26px auto 0; border: 1px solid rgba(255,255,255,.08); border-radius: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
