/* ================= Task Force ================= */

:root {
  --bg: #070b1e;
  --bg2: #111a4a;
  --card: rgba(20, 28, 72, 0.78);
  --card-hi: rgba(36, 48, 112, 0.9);
  --line: rgba(255, 255, 255, 0.13);
  --text: #f3f5ff;
  --muted: #aeb7e6;
  --yellow: #ffd23f;
  --yellow-d: #c99400;
  --red: #ff4057;
  --red-d: #b3112c;
  --blue: #3ec7ff;
  --blue-d: #1679b0;
  --green: #5ef08a;
  --green-d: #1fa34d;
  --orange: #ff8a3d;
  --orange-d: #b9541a;
  --purple: #a35cff;
  --purple-d: #6227b8;
  --gray: #5d6795;
  --gray-d: #353d66;
  --radius: 22px;
  --font: 'Fredoka', 'Arial Rounded MT Bold', 'Trebuchet MS', system-ui, sans-serif;
  color-scheme: dark;
}

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

html, body { margin: 0; min-height: 100%; }

body {
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.35;
  color: var(--text);
  background:
    radial-gradient(ellipse 80% 50% at 15% 0%, rgba(120, 60, 255, 0.35), transparent 60%),
    radial-gradient(ellipse 70% 50% at 100% 30%, rgba(30, 160, 255, 0.22), transparent 60%),
    radial-gradient(ellipse 90% 60% at 50% 110%, rgba(255, 60, 140, 0.2), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

input, textarea, select { user-select: text; -webkit-user-select: text; }

h1, h2, h3 { margin: 0; line-height: 1.1; font-weight: 700; }
h2 { font-size: 22px; }
h3 { font-size: 19px; }
p { margin: 0; }
b { font-weight: 700; }

/* ---------- starfield ---------- */

.sky { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.stars {
  position: absolute; inset: -100% 0 0 0;
  background-repeat: repeat;
  animation: starfall linear infinite;
}
.s1 {
  background-image:
    radial-gradient(1.4px 1.4px at 23px 41px, #fff, transparent),
    radial-gradient(1px 1px at 120px 80px, #cfe3ff, transparent),
    radial-gradient(1.2px 1.2px at 200px 160px, #fff, transparent),
    radial-gradient(1px 1px at 60px 220px, #ffe9c4, transparent),
    radial-gradient(1.3px 1.3px at 260px 30px, #fff, transparent),
    radial-gradient(1px 1px at 170px 260px, #fff, transparent);
  background-size: 300px 300px;
  animation-duration: 160s;
  opacity: 0.8;
}
.s2 {
  background-image:
    radial-gradient(2px 2px at 50px 90px, #fff, transparent),
    radial-gradient(1.6px 1.6px at 330px 210px, #bfe8ff, transparent),
    radial-gradient(1.8px 1.8px at 210px 380px, #fff, transparent);
  background-size: 420px 420px;
  animation-duration: 90s;
  opacity: 0.7;
}
.s3 {
  background-image:
    radial-gradient(2.6px 2.6px at 140px 120px, #fff, transparent),
    radial-gradient(2.2px 2.2px at 480px 400px, #ffd9f5, transparent);
  background-size: 600px 600px;
  animation-duration: 50s;
  opacity: 0.55;
}
@keyframes starfall { to { transform: translateY(50%); } }

/* ---------- layout ---------- */

#app { min-height: 100dvh; }

.screen {
  max-width: 520px;
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) 16px max(28px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 100dvh;
  animation: screen-in 0.35s ease-out;
}
.screen.center { justify-content: center; align-items: center; }
@keyframes screen-in { from { opacity: 0; transform: translateY(12px); } }

.card {
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.card h2 { display: flex; align-items: center; gap: 10px; }

.pill {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 34px; height: 28px; padding: 0 10px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.12); font-size: 16px; font-weight: 600;
}

.hint { color: var(--muted); font-size: 15px; }
.hint.center, .center { text-align: center; }
.hint.warn { color: var(--yellow); }
.big-text { font-size: 20px; text-align: center; }
.imp-text { color: var(--red); }

/* ---------- top bar & brand ---------- */

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 44px; }
.topbar-r { display: flex; align-items: center; gap: 8px; }
.brand { display: flex; align-items: center; gap: 6px; font-weight: 700; font-size: 20px; letter-spacing: 0.06em; }
.brand-mark { display: block; width: 28px; height: 28px; border-radius: 7px; flex: none; }
.logo-mark { display: block; width: 64px; height: 64px; margin: 0 auto 14px; border-radius: 16px; }
.brand span:first-of-type { color: var(--yellow); }
.brand span:last-child { color: var(--blue); }

.me-chip {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 12px 4px 6px; border-radius: 999px;
  background: var(--card); border: 2px solid var(--line); font-weight: 600;
}
.me-chip .crew { width: 26px; }

.icon-btn {
  font: inherit; font-size: 20px; width: 44px; height: 44px; border-radius: 50%;
  border: 2px solid var(--line); background: var(--card); color: var(--text); cursor: pointer;
}

/* ---------- crewmate ---------- */

.crew { display: block; width: 100%; height: auto; overflow: visible; filter: drop-shadow(0 6px 6px rgba(0, 0, 0, 0.35)); }
.crew.bob { animation: bob 1.6s ease-in-out infinite; }
.crew.float { animation: float 3s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-5px) rotate(-2deg); } }
@keyframes float { 0%, 100% { transform: translateY(0) rotate(-6deg); } 50% { transform: translateY(-16px) rotate(6deg); } }

.loading { width: 140px; text-align: center; color: var(--muted); }
.loading p { margin-top: 18px; font-size: 18px; }

/* ---------- buttons ---------- */

.btn {
  font: inherit; font-weight: 700; font-size: 18px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px 20px; min-height: 52px;
  border: 0; border-radius: 18px; cursor: pointer; text-decoration: none; text-align: center;
  color: #18122b; background: var(--yellow);
  box-shadow: 0 5px 0 var(--yellow-d), 0 10px 22px rgba(0, 0, 0, 0.3);
  transition: transform 0.08s, box-shadow 0.08s, filter 0.2s;
}
.btn:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 1px 0 var(--yellow-d), 0 4px 10px rgba(0, 0, 0, 0.3); }
.btn:disabled { opacity: 0.45; filter: grayscale(0.7); cursor: not-allowed; }
.btn.big { width: 100%; font-size: 20px; min-height: 58px; }
.btn.huge { width: 100%; font-size: 24px; min-height: 68px; border-radius: 22px; letter-spacing: 0.03em; }
.btn.small { font-size: 15px; min-height: 40px; padding: 8px 14px; border-radius: 14px; }
.btn.red { background: var(--red); color: #fff; box-shadow: 0 5px 0 var(--red-d), 0 10px 22px rgba(0, 0, 0, 0.3); }
.btn.red:active:not(:disabled) { box-shadow: 0 1px 0 var(--red-d); }
.btn.blue { background: var(--blue); color: #08203a; box-shadow: 0 5px 0 var(--blue-d), 0 10px 22px rgba(0, 0, 0, 0.3); }
.btn.blue:active:not(:disabled) { box-shadow: 0 1px 0 var(--blue-d); }
.btn.orange { background: var(--orange); color: #2a1200; box-shadow: 0 5px 0 var(--orange-d), 0 10px 22px rgba(0, 0, 0, 0.3); }
.btn.orange:active:not(:disabled) { box-shadow: 0 1px 0 var(--orange-d); }
.btn.ghost { background: rgba(255, 255, 255, 0.08); color: var(--text); border: 2px solid var(--line); box-shadow: 0 4px 0 rgba(0, 0, 0, 0.35); }
.btn.ghost:active:not(:disabled) { box-shadow: 0 0 0 rgba(0, 0, 0, 0.35); }
.btn-row { display: flex; gap: 10px; }
.btn-row > * { flex: 1; }

.link-btn { font: inherit; background: none; border: 0; color: var(--muted); text-decoration: underline; padding: 10px; cursor: pointer; }

.start-btn:not(:disabled) { animation: pulse-glow 1.8s ease-in-out infinite; }
@keyframes pulse-glow {
  50% { box-shadow: 0 5px 0 var(--yellow-d), 0 0 34px rgba(255, 210, 63, 0.65); }
}

/* ---------- inputs ---------- */

.lbl { font-weight: 600; font-size: 17px; color: var(--muted); }
.text-in {
  font: inherit; font-size: 22px; font-weight: 600; color: var(--text);
  width: 100%; padding: 14px 16px; border-radius: 16px;
  background: rgba(5, 8, 30, 0.6); border: 2px solid var(--line); outline: none;
}
.text-in:focus { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(62, 199, 255, 0.2); }
.text-in.small { font-size: 17px; padding: 10px 12px; border-radius: 12px; }
textarea.text-in { resize: none; }
select.text-in { appearance: none; -webkit-appearance: none; }

.switch { position: relative; width: 58px; height: 34px; flex: none; }
.switch input { opacity: 0; width: 100%; height: 100%; margin: 0; position: absolute; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--gray-d); transition: background 0.2s; }
.switch span::after {
  content: ''; position: absolute; top: 4px; left: 4px; width: 26px; height: 26px; border-radius: 50%;
  background: #fff; transition: transform 0.2s; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}
.switch input:checked + span { background: var(--green-d); }
.switch input:checked + span::after { transform: translateX(24px); }

/* ---------- join ---------- */

.join { justify-content: center; }
.hero { text-align: center; padding: 10px 0 4px; }
.parade { display: flex; justify-content: center; gap: 4px; margin-bottom: 6px; }
.parade-one { width: 54px; animation: parade 1.4s ease-in-out infinite; animation-delay: calc(var(--i) * -0.28s); }
.parade-one:nth-child(3) { width: 70px; }
@keyframes parade { 50% { transform: translateY(-10px) rotate(4deg); } }

.logo { display: flex; flex-direction: column; font-size: clamp(56px, 18vw, 84px); line-height: 0.92; letter-spacing: 0.04em; }
.logo span {
  background: linear-gradient(180deg, #fff3b0 0%, var(--yellow) 45%, #ff9d2e 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 4px 0 #b4560c) drop-shadow(0 10px 18px rgba(0, 0, 0, 0.5));
}
.logo span:last-child {
  background: linear-gradient(180deg, #d8f6ff 0%, var(--blue) 45%, #5a6bff 100%);
  -webkit-background-clip: text; background-clip: text;
  filter: drop-shadow(0 4px 0 #2a2f9e) drop-shadow(0 10px 18px rgba(0, 0, 0, 0.5));
}
.tagline { margin-top: 10px; color: var(--muted); font-size: 18px; font-weight: 500; }

.colors { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.color-pick {
  aspect-ratio: 1; padding: 6px 8px; border-radius: 16px; cursor: pointer;
  background: rgba(255, 255, 255, 0.06); border: 3px solid transparent;
  transition: transform 0.12s, border-color 0.12s;
}
.color-pick.sel { border-color: var(--yellow); background: rgba(255, 210, 63, 0.16); transform: scale(1.08); }
.color-pick:disabled { opacity: 0.2; cursor: not-allowed; }
.color-pick .crew { filter: none; }

/* ---------- lobby ---------- */

.notice { background: rgba(62, 199, 255, 0.15); border-color: rgba(62, 199, 255, 0.4); font-weight: 600; }

.crew-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 10px; }
.crew-slot {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 10px 6px 8px; border-radius: 16px; background: rgba(255, 255, 255, 0.05);
  animation: pop-in 0.35s cubic-bezier(.3, 1.6, .5, 1);
}
.crew-slot .crew { width: 48px; }
.crew-slot.me { background: rgba(255, 210, 63, 0.12); outline: 2px solid rgba(255, 210, 63, 0.5); }
.crew-slot.away { opacity: 0.35; }
.crew-name { font-weight: 600; font-size: 15px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crown { position: absolute; top: -8px; font-size: 20px; z-index: 1; }
.kick {
  position: absolute; top: 2px; right: 2px; width: 26px; height: 26px; border-radius: 50%;
  border: 0; background: rgba(0, 0, 0, 0.35); color: #fff; font-size: 13px; cursor: pointer;
}
@keyframes pop-in { from { transform: scale(0.4); opacity: 0; } }

.invite { flex-direction: row; align-items: center; gap: 14px; }
.invite img { width: 112px; height: 112px; border-radius: 14px; background: #fff; padding: 6px; flex: none; }
.invite p { color: var(--muted); font-size: 15px; margin: 4px 0; }
.invite code { font-family: inherit; font-weight: 600; font-size: 15px; color: var(--yellow); word-break: break-all; }

.waiting-host { flex-direction: row; align-items: center; gap: 14px; font-size: 18px; }
.waiting-host .crew { width: 52px; flex: none; }

.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; }
.set-label { font-weight: 600; flex: 1; display: flex; align-items: center; gap: 4px; min-width: 0; }
.set-row .text-in.small { max-width: 52%; }
.setting-help-btn {
  font: inherit; font-size: 14px; font-weight: 600; color: var(--muted); cursor: pointer;
  width: 36px; height: 36px; flex: none; border: 0; border-radius: 50%; background: none;
}
.setting-help-btn:hover, .setting-help-btn[aria-expanded="true"] { background: rgba(255, 255, 255, 0.08); color: var(--blue); }
.setting-help-btn:focus-visible, .guide-link:focus-visible, .guide-icon:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.setting-help { color: var(--muted); font-size: 15px; line-height: 1.5; padding: 8px 12px; margin-top: 4px; border-left: 2px solid var(--blue); background: rgba(62, 199, 255, 0.05); }
.guide-icon { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; color: var(--muted); }
.guide-link { display: block; text-align: center; font-size: 15px; }
.guide-link .hint { display: block; font-size: 12px; text-decoration: none; }
.topbar { flex-wrap: wrap; }
.topbar-r { margin-left: auto; }
.guide { max-width: 720px; gap: 20px; user-select: text; -webkit-user-select: text; }
.guide-header { display: flex; flex-direction: column; gap: 16px; padding: 12px 0; }
.guide-header .brand { text-decoration: none; align-self: flex-start; }
.guide h1 { font-size: 36px; }
.guide p, .guide li, .guide dd { line-height: 1.6; }
.guide-nav a, .guide-section a { color: var(--blue); }
.guide-section { scroll-margin-top: 16px; }
.guide-section ol, .guide-section ul { margin: 0; padding-left: 24px; }
.guide-section li + li { margin-top: 10px; }
.guide-section h3 { margin-top: 4px; }
.guide-settings { margin: 0; }
.guide-settings dt { font-weight: 700; margin-top: 16px; }
.guide-settings dt:first-child { margin-top: 0; }
.guide-settings dd { margin: 4px 0 0; color: var(--muted); }
.guide-section details { border-top: 1px solid var(--line); padding-top: 12px; }
.guide-section summary { cursor: pointer; font-weight: 600; padding: 4px 0; }
.guide-section details p { margin-top: 8px; color: var(--muted); }
.stepper { display: flex; align-items: center; gap: 4px; }
.stepper b { min-width: 52px; text-align: center; font-size: 20px; }
.stepper button {
  font: inherit; font-size: 24px; font-weight: 700; width: 44px; height: 44px; border-radius: 50%;
  border: 0; cursor: pointer; color: #18122b; background: var(--blue); box-shadow: 0 3px 0 var(--blue-d);
}
.stepper button:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--blue-d); }

.howto { padding: 0; gap: 0; overflow: hidden; }
.howto-toggle {
  font: inherit; font-weight: 700; font-size: 19px; color: var(--text);
  display: flex; justify-content: space-between; width: 100%; padding: 16px; background: none; border: 0; cursor: pointer;
}
.howto-list { list-style: none; margin: 0; padding: 0 16px 16px; display: flex; flex-direction: column; gap: 12px; }
.howto-list li { display: flex; gap: 12px; align-items: flex-start; }
.howto-icon { font-size: 28px; width: 40px; flex: none; text-align: center; }
.howto-list p { color: var(--muted); font-size: 16px; margin-top: 2px; }

/* ---------- station editor ---------- */

.station-edit { gap: 10px; }
.station-edit.off { opacity: 0.5; }
.se-top, .se-bot { display: flex; align-items: center; gap: 8px; }
.emoji-in {
  font: inherit; font-size: 26px; width: 54px; height: 50px; text-align: center; border-radius: 12px;
  background: rgba(5, 8, 30, 0.6); border: 2px solid var(--line); color: var(--text); flex: none;
}
.se-bot select { flex: 1; }
.code-tag {
  font-weight: 700; letter-spacing: 0.12em; padding: 6px 10px; border-radius: 10px;
  background: rgba(255, 210, 63, 0.15); color: var(--yellow);
}
.sticky-bottom {
  position: sticky; bottom: 0; padding: 14px 0 max(4px, env(safe-area-inset-bottom));
  background: linear-gradient(transparent, var(--bg) 40%);
}

/* ---------- playing ---------- */

.taskbar {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: 18px; background: var(--card); border: 2px solid var(--line);
  position: sticky; top: 8px; z-index: 5;
}
.tb-label { font-weight: 700; font-size: 14px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.tb-track { height: 22px; border-radius: 999px; background: rgba(0, 0, 0, 0.45); overflow: hidden; border: 2px solid rgba(255, 255, 255, 0.1); }
.tb-fill {
  height: 100%; border-radius: 999px; transition: width 0.8s cubic-bezier(.3, 1.3, .5, 1);
  background: repeating-linear-gradient(-45deg, var(--green) 0 12px, #3fd673 12px 24px);
  background-size: 34px 34px; animation: stripes 1s linear infinite;
  box-shadow: 0 0 16px rgba(94, 240, 138, 0.6);
}
@keyframes stripes { to { background-position: 34px 0; } }
.tb-pct { font-weight: 700; font-size: 18px; min-width: 46px; text-align: right; color: var(--green); }

.task-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.task {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 16px;
  background: rgba(255, 255, 255, 0.06); border: 2px solid transparent; transition: all 0.3s;
}
.t-emoji { font-size: 32px; width: 42px; text-align: center; flex: none; }
.t-text { flex: 1; display: flex; flex-direction: column; }
.t-text b { font-size: 18px; }
.t-text small { color: var(--muted); font-size: 15px; }
.t-check {
  width: 34px; height: 34px; border-radius: 50%; flex: none; border: 3px solid rgba(255, 255, 255, 0.2);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 20px;
}
.task.done { background: rgba(94, 240, 138, 0.1); border-color: rgba(94, 240, 138, 0.3); }
.task.done .t-text b { text-decoration: line-through; text-decoration-thickness: 3px; opacity: 0.7; }
.task.done .t-check { background: var(--green); border-color: var(--green); color: #063018; animation: pop-in 0.4s cubic-bezier(.3, 1.8, .5, 1); }

.scan-btn { font-size: 26px; }

.actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.act-btn {
  font: inherit; color: #fff; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 12px 4px 10px; border: 0; border-radius: 18px; font-weight: 700; font-size: 15px; line-height: 1.1;
  background: var(--c); box-shadow: 0 5px 0 var(--cd), 0 8px 18px rgba(0, 0, 0, 0.3);
}
.act-btn span:last-child { display: flex; flex-direction: column; align-items: center; }
.act-btn small { font-size: 13px; font-weight: 500; opacity: 0.85; }
.act-btn:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 1px 0 var(--cd); }
.act-btn:disabled { opacity: 0.4; filter: grayscale(0.7); }
.ab-icon { font-size: 30px; }
.act-btn.red { --c: var(--red); --cd: var(--red-d); }
.act-btn.orange { --c: var(--orange); --cd: var(--orange-d); }
.act-btn.gray { --c: var(--gray); --cd: var(--gray-d); }
.act-btn.purple { --c: var(--purple); --cd: var(--purple-d); }
.is-ghost .actions { grid-template-columns: 1fr; }

.is-ghost { position: relative; }
.is-ghost::before {
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: -1;
  background: radial-gradient(circle at 50% 40%, rgba(160, 200, 255, 0.18), transparent 70%);
}
.ghost-note { background: rgba(170, 200, 255, 0.15); border-color: rgba(200, 220, 255, 0.35); font-weight: 600; text-align: center; }

.sab-banner {
  border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 8px;
  background: rgba(255, 30, 60, 0.25); border: 3px solid var(--red);
  animation: alarm-flash 0.9s steps(2) infinite;
}
@keyframes alarm-flash { 50% { background: rgba(255, 30, 60, 0.5); box-shadow: 0 0 40px rgba(255, 40, 70, 0.7); } }
.sab-top { display: flex; justify-content: space-between; align-items: center; font-weight: 700; font-size: 20px; text-transform: uppercase; }
.sab-time { font-size: 32px; min-width: 50px; text-align: right; }
.sab-spots { display: flex; gap: 8px; flex-wrap: wrap; }
.sab-spot { padding: 8px 14px; border-radius: 999px; background: rgba(0, 0, 0, 0.35); font-weight: 600; }
.sab-spot.fixed { background: var(--green-d); }

.tagged { justify-content: center; text-align: center; }
.tagged h1 { font-size: 40px; color: var(--red); }
.tagged-art { width: 150px; margin: 0 auto; animation: wobble 2.4s ease-in-out infinite; }
@keyframes wobble { 50% { transform: rotate(-6deg) scale(1.04); } }

/* ---------- modal sheets ---------- */

.modal {
  position: fixed; inset: 0; z-index: 40; display: flex; align-items: flex-end; justify-content: center;
  background: rgba(3, 5, 20, 0.7); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  animation: fade-in 0.2s ease-out;
}
@keyframes fade-in { from { opacity: 0; } }

.sheet {
  position: relative; width: 100%; max-width: 520px; max-height: 92dvh; overflow-y: auto;
  padding: 26px 18px max(22px, env(safe-area-inset-bottom));
  background: linear-gradient(180deg, #1c2766, #121a4a);
  border: 2px solid var(--line); border-bottom: 0; border-radius: 28px 28px 0 0;
  display: flex; flex-direction: column; gap: 14px;
  animation: sheet-up 0.35s cubic-bezier(.2, 1.2, .4, 1);
  box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.5);
}
@keyframes sheet-up { from { transform: translateY(100%); } }
.sheet-x {
  position: absolute; top: 14px; right: 14px; width: 40px; height: 40px; border-radius: 50%;
  border: 0; background: rgba(255, 255, 255, 0.12); color: var(--text); font-size: 18px; cursor: pointer; z-index: 2;
}

.code-sheet { text-align: center; }
.code-sheet h2 { font-size: 26px; }
.or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 15px; }
.or::before, .or::after { content: ''; flex: 1; height: 2px; background: var(--line); }
.code-in {
  font: inherit; font-size: 44px; font-weight: 700; letter-spacing: 0.3em; text-align: center; text-transform: uppercase;
  padding: 14px 10px 14px calc(10px + 0.3em); width: 100%; border-radius: 20px; color: var(--yellow);
  background: rgba(5, 8, 30, 0.7); border: 3px solid var(--line); outline: none;
}
.code-in:focus { border-color: var(--yellow); }
.code-in::placeholder { color: rgba(255, 255, 255, 0.15); }

.confirm-sheet { text-align: center; }
.confirm-sheet h2 { font-size: 26px; }
.confirm-sheet p { color: var(--muted); font-size: 18px; }

.you-are { text-align: center; color: var(--muted); font-size: 18px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.1em; }
.role-name { text-align: center; font-size: clamp(48px, 15vw, 72px); letter-spacing: 0.02em; }
.secret.crew .role-name, .ov-reveal.crew .role-name { color: var(--blue); text-shadow: 0 0 30px rgba(62, 199, 255, 0.7); }
.secret.imp .role-name, .ov-reveal.imp .role-name { color: var(--red); text-shadow: 0 0 30px rgba(255, 64, 87, 0.8); }
.secret > p { text-align: center; }
.sab-box { background: rgba(255, 64, 87, 0.14); border: 2px solid rgba(255, 64, 87, 0.45); border-radius: 18px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.sab-box p { color: var(--muted); }

/* ---------- full-screen overlays ---------- */

#overlay .ov { position: fixed; inset: 0; z-index: 50; }

.ov-station { display: flex; align-items: flex-end; justify-content: center; background: rgba(3, 5, 20, 0.75); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.station-sheet { min-height: 60dvh; }
.st-head { display: flex; align-items: center; gap: 14px; padding-right: 44px; }
.st-emoji { font-size: 52px; }
.st-head small { color: var(--muted); font-size: 14px; text-transform: uppercase; letter-spacing: 0.1em; font-weight: 600; }
.st-head h2 { font-size: 30px; }
.st-body { display: flex; flex-direction: column; gap: 14px; flex: 1; }
.irl { background: rgba(255, 210, 63, 0.12); border: 2px dashed rgba(255, 210, 63, 0.55); border-radius: 18px; padding: 16px; }
.irl-label { font-size: 13px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--yellow); font-weight: 700; }
.irl-task { font-size: 24px; font-weight: 600; margin-top: 6px; }
.st-msg { text-align: center; display: flex; flex-direction: column; gap: 10px; align-items: center; padding: 20px 0; }
.st-msg-icon { font-size: 70px; }
.st-msg h3 { font-size: 26px; }
.st-msg p { color: var(--muted); font-size: 18px; margin-bottom: 10px; }
.alert-box { text-align: center; font-weight: 700; font-size: 20px; padding: 12px; border-radius: 16px; background: rgba(255, 30, 60, 0.3); animation: alarm-flash 0.9s steps(2) infinite; }

.success { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 30px 0; }
.success h2 { font-size: 36px; color: var(--green); }
.success p { color: var(--muted); font-size: 18px; }
.big-check {
  width: 120px; height: 120px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 70px; font-weight: 700; color: #063018; background: var(--green);
  box-shadow: 0 0 0 10px rgba(94, 240, 138, 0.2), 0 0 60px rgba(94, 240, 138, 0.6);
  animation: pop-in 0.5s cubic-bezier(.3, 1.8, .5, 1);
}

.ov-reveal {
  display: flex; align-items: center; justify-content: center; padding: 24px;
  background: radial-gradient(circle at 50% 40%, #1b1f4f, #04050f 75%);
}
.ov-reveal.crew { background: radial-gradient(circle at 50% 45%, #0f4c8a, #04050f 75%); }
.ov-reveal.imp { background: radial-gradient(circle at 50% 45%, #7a0f22, #04050f 75%); }
.reveal-hide, .reveal-role { max-width: 440px; width: 100%; text-align: center; display: flex; flex-direction: column; gap: 16px; align-items: center; animation: screen-in 0.4s ease-out; }
.shh { font-size: 96px; animation: wobble 2s ease-in-out infinite; }
.reveal-hide h1 { font-size: 56px; }
.reveal-hide p { font-size: 22px; color: var(--muted); }
.reveal-role .role-name { animation: role-slam 0.6s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes role-slam { from { transform: scale(2.4); opacity: 0; letter-spacing: 0.4em; } }
.reveal-lineup { display: flex; justify-content: center; gap: 18px; }
.lineup-one { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 90px; font-weight: 600; animation: pop-in 0.5s cubic-bezier(.3, 1.6, .5, 1) backwards; animation-delay: calc(var(--i, 0) * 0.1s + 0.2s); }
.reveal-lineup .lineup-one:first-child { width: 120px; }
.role-tip { font-size: 20px; }

.splash {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; padding: 24px; text-align: center; overflow: hidden;
}
.splash::before {
  content: ''; position: absolute; inset: -50%;
  background: repeating-conic-gradient(from 0deg, rgba(255, 255, 255, 0.07) 0 10deg, transparent 10deg 20deg);
  animation: spin 14s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.splash > * { position: relative; }
.splash.emergency { background: radial-gradient(circle, #d81b3c, #4a0010 80%); }
.splash.body { background: radial-gradient(circle, #8f1f5f, #2a0520 80%); }
.splash.sabotage { background: radial-gradient(circle, #ff2a2a, #3b0000 80%); animation: alarm-bg 0.6s steps(2) infinite; }
@keyframes alarm-bg { 50% { filter: brightness(0.6); } }
.splash h1 {
  font-size: clamp(40px, 12vw, 72px); text-transform: uppercase; line-height: 0.95;
  text-shadow: 0 6px 0 rgba(0, 0, 0, 0.35), 0 0 40px rgba(255, 255, 255, 0.3);
  animation: role-slam 0.55s cubic-bezier(.2, 1.6, .4, 1);
}
.splash p { font-size: 22px; font-weight: 600; }
.splash-art { font-size: 100px; width: 150px; line-height: 1; animation: wobble 1s ease-in-out infinite; }
.splash-go {
  display: flex; flex-direction: column; gap: 4px; font-size: 20px;
  background: rgba(0, 0, 0, 0.35); padding: 14px 24px; border-radius: 20px;
}
.splash-go b { font-size: 30px; color: var(--yellow); }
.splash-tap { position: absolute !important; bottom: max(20px, env(safe-area-inset-bottom)); font-size: 15px !important; opacity: 0.6; }

.ov-eject { background: #03040c; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.ov-eject::before {
  content: ''; position: absolute; inset: 0;
  background-image: radial-gradient(1.5px 1.5px at 20px 30px, #fff, transparent), radial-gradient(1px 1px at 140px 90px, #fff, transparent), radial-gradient(2px 2px at 90px 170px, #fff, transparent);
  background-size: 200px 200px; animation: star-rush 1.2s linear infinite;
}
@keyframes star-rush { to { background-position: -200px 0; } }
.eject { position: relative; width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 24px; text-align: center; }
.eject-crew { position: absolute; top: 28%; left: 0; width: 90px; animation: eject-drift 6.5s linear forwards; }
@keyframes eject-drift {
  from { transform: translateX(-120px) rotate(0); }
  to { transform: translateX(calc(100vw + 120px)) rotate(720deg); }
}
.eject-text { font-size: clamp(26px, 7.5vw, 36px); font-weight: 600; min-height: 2.6em; margin-top: 30vh; }
.eject-sub { font-size: 20px; color: var(--muted); opacity: 0; transition: opacity 0.6s; }
.ov-eject.typed .eject-sub { opacity: 1; }

/* ---------- meeting ---------- */

.meeting { background: none; }
.meet-head { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px; padding-top: 6px; }
.meet-kind { font-weight: 600; color: var(--muted); font-size: 16px; }
.meet-head h1 { font-size: 34px; }
.meet-spot { color: var(--muted); }
.big-timer {
  font-size: 54px; font-weight: 700; line-height: 1; min-width: 120px; padding: 6px 20px; border-radius: 22px;
  background: rgba(0, 0, 0, 0.35); border: 3px solid var(--line); font-variant-numeric: tabular-nums;
}
.big-timer.urgent { color: var(--red); border-color: var(--red); animation: pulse 0.5s ease-in-out infinite alternate; }
@keyframes pulse { to { transform: scale(1.06); } }

.bodies { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px; font-weight: 600; }
.body-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px 4px 6px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.1); font-weight: 600;
}
.body-chip .crew { width: 30px; }
.body-chip.imp { background: rgba(255, 64, 87, 0.25); font-size: 20px; padding: 6px 16px 6px 8px; }
.body-chip.imp .crew { width: 40px; }

.vote-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.vote-card {
  font: inherit; color: var(--text); position: relative; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 12px 6px 10px; border-radius: 18px; background: var(--card); border: 3px solid var(--line);
  transition: transform 0.15s, border-color 0.15s, background 0.15s;
}
.vote-card .crew { width: 58px; }
.vote-card:disabled { cursor: default; }
.vote.meeting .vote-card:not(:disabled):active { transform: scale(0.95); }
.vote-card.sel { border-color: var(--yellow); background: rgba(255, 210, 63, 0.18); transform: scale(1.05); }
.vote-card.dead { opacity: 0.45; }
.vote-card.me { border-style: dashed; }
.vote-card.out { border-color: var(--red); background: rgba(255, 64, 87, 0.2); }
.vc-name { font-weight: 600; font-size: 15px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.voted-badge {
  position: absolute; top: 8px; right: -6px; transform: rotate(14deg);
  background: var(--green); color: #063018; font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 8px;
  animation: pop-in 0.3s cubic-bezier(.3, 1.8, .5, 1);
}
.vc-votes { display: flex; flex-wrap: wrap; gap: 3px; justify-content: center; min-height: 14px; }
.vc-votes i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid #0a0d20; animation: pop-in 0.3s backwards; }

.meet-foot { display: flex; flex-direction: column; gap: 10px; margin-top: auto; }
.vote-msg { text-align: center; font-size: 19px; font-weight: 600; padding: 14px; border-radius: 18px; background: var(--card); }
.vote-confirm {
  display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: 20px;
  background: var(--card-hi); border: 2px solid var(--yellow); animation: sheet-up 0.25s ease-out;
}
.vote-confirm span { flex: 1; font-size: 18px; }

/* ---------- end ---------- */

.end { text-align: center; justify-content: center; }
.end-title { font-size: clamp(64px, 20vw, 100px); text-transform: uppercase; animation: role-slam 0.7s cubic-bezier(.2, 1.6, .4, 1); }
.end-title.win { color: var(--blue); text-shadow: 0 0 40px rgba(62, 199, 255, 0.8), 0 6px 0 #1a3d9e; }
.imp-won .end-title.win { color: var(--red); text-shadow: 0 0 40px rgba(255, 64, 87, 0.8), 0 6px 0 #7a0f22; }
.end-title.lose { color: #c5cbe8; text-shadow: 0 6px 0 #2b3160; }
.end-sub { font-size: 20px; }
.lineup { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px 10px; padding: 10px 0; }
.lineup .lineup-one { width: 72px; }
.imp-reveal { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; }

/* ---------- mini-games ---------- */

.mg { display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 4px 0 8px; }
.mg-title { text-align: center; font-weight: 700; font-size: 24px; }
.mg-hint { text-align: center; font-size: 19px; }
.mg-count { color: var(--yellow); font-weight: 700; }

.battery {
  position: relative; width: 88%; max-width: 340px; height: 64px; border-radius: 16px;
  border: 5px solid #e8ecff; padding: 5px; background: rgba(0, 0, 0, 0.4);
}
.battery::after { content: ''; position: absolute; right: -16px; top: 16px; width: 10px; height: 22px; border-radius: 0 6px 6px 0; background: #e8ecff; }
.battery-fill { height: 100%; width: 0; border-radius: 9px; background: linear-gradient(90deg, #5ef08a, #b4ff5e); box-shadow: 0 0 20px rgba(94, 240, 138, 0.7); }
.battery-pct { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 22px; text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6); }
.hold-btn {
  font: inherit; font-weight: 700; font-size: 32px; color: #fff; cursor: pointer; touch-action: none;
  width: 150px; height: 150px; border-radius: 50%; border: 6px solid rgba(255, 255, 255, 0.5);
  background: radial-gradient(circle at 35% 30%, #ff7a8a, var(--red) 55%, var(--red-d));
  box-shadow: 0 10px 0 #7a0a1d, 0 18px 40px rgba(0, 0, 0, 0.5);
  transition: transform 0.08s, box-shadow 0.08s;
}
.hold-btn.held { transform: translateY(8px) scale(0.97); box-shadow: 0 2px 0 #7a0a1d, 0 0 50px rgba(255, 64, 87, 0.8); }

.tank {
  position: relative; width: 120px; height: 180px; border-radius: 24px; overflow: hidden;
  border: 5px solid #e8ecff; background: rgba(0, 0, 0, 0.45);
}
.tank-fill {
  position: absolute; left: 0; right: 0; bottom: 0; height: 0;
  background: linear-gradient(180deg, #ffd23f, #ff8a3d); transition: height 0.2s cubic-bezier(.3, 1.6, .5, 1);
  box-shadow: 0 0 24px rgba(255, 170, 60, 0.7);
}
.tank-count { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 26px; text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6); }
.pump-btn {
  font: inherit; font-weight: 700; font-size: 30px; color: #18122b; cursor: pointer; touch-action: manipulation;
  padding: 22px 40px; border-radius: 26px; border: 0; background: var(--yellow); box-shadow: 0 8px 0 var(--yellow-d);
}
.pump-btn.bump { animation: bump 0.15s; }
@keyframes bump { 50% { transform: translateY(6px) scale(0.96); box-shadow: 0 2px 0 var(--yellow-d); } }

.space-box {
  position: relative; width: 100%; height: 330px; border-radius: 20px; overflow: hidden; touch-action: none;
  border: 3px solid var(--line);
  background: radial-gradient(1.5px 1.5px at 30px 40px, #fff, transparent), radial-gradient(1px 1px at 120px 150px, #fff, transparent), radial-gradient(1.5px 1.5px at 220px 60px, #fff, transparent), radial-gradient(1px 1px at 80px 260px, #fff, transparent), #050818;
  background-size: 260px 300px;
}
.rock {
  position: absolute; top: 0; left: 0; width: 64px; height: 64px; font-size: 46px; line-height: 64px;
  padding: 0; border: 0; background: none; cursor: pointer; will-change: transform;
}
.rock.boom { animation: boom 0.35s ease-out forwards; }
@keyframes boom { to { opacity: 0; scale: 1.8; } }

.wires { position: relative; width: 100%; display: flex; justify-content: space-between; padding: 6px 4px; }
.wire-lines { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.wire-lines line { stroke-width: 12; stroke-linecap: round; filter: drop-shadow(0 0 6px rgba(255, 255, 255, 0.4)); }
.wire-col { display: flex; flex-direction: column; gap: 18px; position: relative; z-index: 1; }
.plug {
  font: inherit; width: 72px; height: 60px; font-size: 28px; color: #0a0d20; cursor: pointer;
  background: var(--c); border: 4px solid rgba(0, 0, 0, 0.35); box-shadow: 0 5px 0 rgba(0, 0, 0, 0.4);
}
.plug.left { border-radius: 14px 30px 30px 14px; }
.plug.right { border-radius: 30px 14px 14px 30px; }
.plug.sel { outline: 4px solid #fff; outline-offset: 3px; animation: pulse 0.5s ease-in-out infinite alternate; }
.plug.linked { opacity: 0.55; box-shadow: none; transform: translateY(4px); }
.plug.shake { animation: shake 0.35s; }
@keyframes shake { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }

.simon { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; width: 100%; max-width: 320px; }
.pad {
  font: inherit; aspect-ratio: 1; border-radius: 26px; border: 0; cursor: pointer; font-size: 44px; color: rgba(0, 0, 0, 0.45);
  background: var(--c); opacity: 0.35; box-shadow: 0 6px 0 rgba(0, 0, 0, 0.45); transition: opacity 0.1s, transform 0.1s;
}
.pad.lit { opacity: 1; transform: scale(1.05); box-shadow: 0 0 40px var(--c), 0 6px 0 rgba(0, 0, 0, 0.45); }
.simon-dots { display: flex; gap: 10px; }
.simon-dots i { width: 18px; height: 18px; border-radius: 50%; background: rgba(255, 255, 255, 0.15); transition: background 0.2s; }
.simon-dots i.on { background: var(--green); box-shadow: 0 0 12px var(--green); }

/* ---------- confetti, toast, offline ---------- */

.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 80; overflow: hidden; }
.confetti i {
  position: absolute; top: -20px; left: var(--x); width: 10px; height: 16px; border-radius: 3px; background: var(--c);
  animation: confetti-fall var(--d) ease-in var(--delay) forwards;
}
@keyframes confetti-fall { to { transform: translate(var(--drift), 105vh) rotate(var(--r)); } }

#toast {
  position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); z-index: 90;
  transform: translate(-50%, 140%); max-width: calc(100% - 32px); width: max-content;
  padding: 14px 22px; border-radius: 18px; font-weight: 600; font-size: 17px; text-align: center;
  background: #fff; color: #18122b; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  transition: transform 0.3s cubic-bezier(.2, 1.4, .4, 1), visibility 0.3s; pointer-events: none; visibility: hidden;
}
#toast.show { transform: translate(-50%, 0); visibility: visible; }

.offline {
  position: fixed; top: 0; left: 0; right: 0; z-index: 95; text-align: center; font-weight: 700;
  padding: max(8px, env(safe-area-inset-top)) 16px 8px; background: var(--orange); color: #2a1200;
}

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