/* Capt Maps — design tokens + base components (shared, owned by lead) */
@import url('https://fonts.googleapis.com/css2?family=Onest:wght@400;500;600;700&family=Unbounded:wght@500;600;700&display=swap');

:root {
  color-scheme: dark;

  /* surfaces */
  --bg: #0a0c0f;
  --bg-2: #0f1216;
  --surface: #14181e;
  --surface-2: #1a1f27;
  --surface-3: #222833;
  --surface-hover: #262d39;
  --line: rgba(255, 255, 255, 0.07);
  --line-2: rgba(255, 255, 255, 0.12);
  --line-3: rgba(255, 255, 255, 0.2);

  /* text */
  --text: #e9ecf1;
  --text-2: #a4acba;
  --text-3: #6c7585;
  --text-inv: #15110a;

  /* brand + semantic */
  --accent: #f2b632;
  --accent-2: #ffcb57;
  --accent-soft: rgba(242, 182, 50, 0.14);
  --accent-line: rgba(242, 182, 50, 0.45);
  --attack: #ff4b5c;
  --attack-soft: rgba(255, 75, 92, 0.14);
  --defense: #3e9bff;
  --defense-soft: rgba(62, 155, 255, 0.14);
  --ok: #35d07f;
  --ok-soft: rgba(53, 208, 127, 0.14);
  --warn: #ff9f2e;
  --warn-soft: rgba(255, 159, 46, 0.16);
  --danger: #ff4b5c;
  --danger-soft: rgba(255, 75, 92, 0.14);
  --discord: #5865f2;
  --discord-2: #6d78f5;
  --caller: #f2b632;

  /* type */
  --font: 'Onest', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Unbounded', 'Onest', system-ui, sans-serif;
  --fs-xs: 12px;
  --fs-sm: 13px;
  --fs-md: 14px;
  --fs-lg: 16px;
  --fs-xl: 20px;
  --fs-2xl: 28px;
  --fs-3xl: 40px;

  /* shape */
  --r-xs: 6px;
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 22px;
  --r-full: 999px;

  --sh-1: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 1px 2px rgba(0, 0, 0, 0.4);
  --sh-2: 0 1px 0 rgba(255, 255, 255, 0.05) inset, 0 8px 24px rgba(0, 0, 0, 0.45);
  --sh-3: 0 1px 0 rgba(255, 255, 255, 0.06) inset, 0 24px 60px rgba(0, 0, 0, 0.6);
  --ring: 0 0 0 3px rgba(242, 182, 50, 0.35);

  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --dur: 160ms;

  --header-h: 60px;
  --z-toolbar: 20;
  --z-popover: 60;
  --z-modal: 80;
  --z-toast: 100;
  --z-drag: 120;
}

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 var(--fs-md)/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
img, svg, canvas { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
p { margin: 0; }
:focus-visible { outline: none; box-shadow: var(--ring); }
::selection { background: rgba(242, 182, 50, 0.35); }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; }
.display { font-family: var(--font-display); letter-spacing: -0.01em; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background-color: var(--surface-hover); }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- icons ---------- */
.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.i--sm { width: 15px; height: 15px; }
.i--lg { width: 22px; height: 22px; }

/* ---------- buttons ---------- */
.btn {
  --btn-bg: var(--surface-2);
  --btn-fg: var(--text);
  --btn-bd: var(--line-2);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 14px;
  border-radius: var(--r-sm);
  border: 1px solid var(--btn-bd);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-weight: 600; font-size: var(--fs-md);
  white-space: nowrap; user-select: none;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), transform 80ms var(--ease), opacity var(--dur);
}
.btn:hover { background: var(--surface-hover); border-color: var(--line-3); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled='true'] { opacity: 0.45; pointer-events: none; }
.btn--primary { --btn-bg: var(--accent); --btn-fg: var(--text-inv); --btn-bd: transparent; box-shadow: 0 6px 20px rgba(242, 182, 50, 0.18); }
.btn--primary:hover { background: var(--accent-2); border-color: transparent; }
.btn--discord { --btn-bg: var(--discord); --btn-fg: #fff; --btn-bd: transparent; box-shadow: 0 8px 26px rgba(88, 101, 242, 0.35); }
.btn--discord:hover { background: var(--discord-2); border-color: transparent; }
.btn--danger { --btn-bg: var(--danger-soft); --btn-fg: #ff8390; --btn-bd: rgba(255, 75, 92, 0.3); }
.btn--danger:hover { background: rgba(255, 75, 92, 0.24); border-color: rgba(255, 75, 92, 0.5); }
.btn--ghost { --btn-bg: transparent; --btn-bd: transparent; --btn-fg: var(--text-2); }
.btn--ghost:hover { background: var(--surface-2); color: var(--text); border-color: transparent; }
.btn--sm { height: 30px; padding: 0 10px; font-size: var(--fs-sm); gap: 6px; border-radius: var(--r-xs); }
.btn--lg { height: 48px; padding: 0 22px; font-size: var(--fs-lg); border-radius: var(--r-md); }
.btn--icon { width: 38px; padding: 0; }
.btn--icon.btn--sm { width: 30px; }
.btn--block { width: 100%; }
.btn.is-active { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); }

/* ---------- inputs ---------- */
.input, .select, .textarea {
  width: 100%; height: 40px; padding: 0 12px;
  background: var(--bg-2);
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  color: var(--text);
  transition: border-color var(--dur), box-shadow var(--dur);
}
.textarea { height: auto; min-height: 84px; padding: 10px 12px; resize: vertical; }
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--line-3); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent-line); box-shadow: var(--ring); }
.field { display: grid; gap: 6px; }
.field > label, .field__label { font-size: var(--fs-sm); color: var(--text-2); font-weight: 500; }
.field__hint { font-size: var(--fs-xs); color: var(--text-3); }

.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch__track { width: 38px; height: 22px; border-radius: var(--r-full); background: var(--surface-3); border: 1px solid var(--line-2); position: relative; transition: background var(--dur); flex: none; }
.switch__track::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--text-2); transition: transform var(--dur) var(--ease), background var(--dur); }
.switch input:checked + .switch__track { background: var(--accent); border-color: transparent; }
.switch input:checked + .switch__track::after { transform: translateX(16px); background: var(--text-inv); }
.switch input:focus-visible + .switch__track { box-shadow: var(--ring); }

/* segmented control */
.seg { display: inline-flex; padding: 3px; gap: 3px; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--r-md); }
.seg > button { height: 32px; padding: 0 14px; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--text-2); font-weight: 600; font-size: var(--fs-sm); display: inline-flex; align-items: center; gap: 6px; transition: background var(--dur), color var(--dur); }
.seg > button:hover { color: var(--text); }
.seg > button[aria-pressed='true'] { background: var(--surface-3); color: var(--text); box-shadow: var(--sh-1); }

/* stepper */
.stepper { display: inline-flex; align-items: center; height: 30px; border: 1px solid var(--line-2); border-radius: var(--r-sm); background: var(--bg-2); overflow: hidden; }
.stepper > button { width: 28px; height: 100%; border: 0; background: transparent; color: var(--text-2); font-size: 16px; line-height: 1; display: grid; place-items: center; }
.stepper > button:hover { background: var(--surface-3); color: var(--text); }
.stepper > button:disabled { opacity: 0.35; pointer-events: none; }
.stepper > output, .stepper > span { min-width: 28px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; font-size: var(--fs-sm); }

/* ---------- cards & surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--sh-1); }
.card--hover { transition: border-color var(--dur), transform var(--dur) var(--ease), box-shadow var(--dur); }
.card--hover:hover { border-color: var(--line-3); transform: translateY(-2px); box-shadow: var(--sh-2); }
.divider { height: 1px; background: var(--line); border: 0; margin: 0; }
.panel-title { font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-3); }

/* ---------- badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: var(--r-full); font-size: var(--fs-xs); font-weight: 700; letter-spacing: 0.01em; background: var(--surface-3); color: var(--text-2); white-space: nowrap; }
.badge .i { width: 13px; height: 13px; }
.badge--attack { background: var(--attack-soft); color: #ff7c89; }
.badge--defense { background: var(--defense-soft); color: #74b6ff; }
.badge--caller { background: var(--accent-soft); color: var(--accent); }
.badge--ok { background: var(--ok-soft); color: var(--ok); }
.badge--warn { background: var(--warn-soft); color: var(--warn); }
.badge--muted { background: transparent; border: 1px solid var(--line-2); color: var(--text-3); }

.pill-status { display: inline-flex; align-items: center; gap: 7px; height: 26px; padding: 0 10px 0 9px; border-radius: var(--r-full); font-size: var(--fs-sm); font-weight: 600; border: 1px solid var(--line-2); background: var(--surface-2); }
.pill-status::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 22%, transparent); }
.pill-status--open { color: var(--ok); }
.pill-status--locked { color: var(--accent); }
.pill-status--final { color: #b57bff; }
.pill-status > span { color: var(--text); }

/* ---------- avatar & user chip ---------- */
.avatar { --size: 32px; width: var(--size); height: var(--size); border-radius: 50%; flex: none; object-fit: cover; background: var(--surface-3); box-shadow: 0 0 0 1px var(--line-2); display: grid; place-items: center; font-weight: 700; font-size: calc(var(--size) * 0.4); color: var(--text-2); overflow: hidden; }
.avatar--xs { --size: 20px; }
.avatar--sm { --size: 26px; }
.avatar--lg { --size: 44px; }
.avatar--xl { --size: 64px; }
.avatar.is-caller { box-shadow: 0 0 0 2px var(--caller); }

.chip-user { display: inline-flex; align-items: center; gap: 8px; min-width: 0; height: 34px; padding: 0 10px 0 4px; border-radius: var(--r-full); background: var(--surface-2); border: 1px solid var(--line); max-width: 100%; }
.chip-user__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; font-size: var(--fs-sm); }
.chip-user__crown { color: var(--caller); display: inline-flex; }
.chip-user.is-me { border-color: var(--accent-line); background: var(--accent-soft); }
/* lists stay vertically scrollable; a 260ms hold starts the drag (dnd.js). Inside the map container touch-action is none. */
body.cm-dnd-on [data-drag-user] { touch-action: pan-y; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
body.cm-dnd-on [data-drag-user] { cursor: grab; }
body.cm-dragging, body.cm-dragging * { cursor: grabbing !important; user-select: none !important; }

/* drag ghost + drop target highlight (used by dnd.js) */
.dnd-ghost { position: fixed; left: 0; top: 0; z-index: var(--z-drag); pointer-events: none; transform: translate(-50%, -50%); box-shadow: var(--sh-3); opacity: 0.95; }
.dnd-source { opacity: 0.35; }
.is-drop-target { outline: 2px dashed var(--accent) !important; outline-offset: 3px; }
.is-drop-over { outline: 2px solid var(--accent) !important; outline-offset: 3px; background-color: var(--accent-soft) !important; }

/* ---------- progress ---------- */
.progress { height: 6px; border-radius: var(--r-full); background: var(--surface-3); overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width 300ms var(--ease); }
.progress.is-full > i { background: var(--ok); }
.progress.is-over > i { background: var(--warn); }

/* ---------- modal ---------- */
.modal-backdrop { position: fixed; inset: 0; z-index: var(--z-modal); background: rgba(5, 6, 8, 0.72); backdrop-filter: blur(6px); display: grid; place-items: center; padding: 20px; animation: fade-in 140ms var(--ease); }
.modal { width: min(520px, 100%); max-height: calc(100dvh - 40px); display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-xl); box-shadow: var(--sh-3); animation: pop-in 180ms var(--ease); }
.modal--wide { width: min(860px, 100%); }
.modal__head { display: flex; align-items: center; gap: 12px; padding: 18px 20px 12px; }
.modal__title { font-family: var(--font-display); font-size: var(--fs-lg); font-weight: 600; flex: 1; }
.modal__body { padding: 4px 20px 16px; overflow: auto; display: grid; gap: 14px; }
.modal__foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px 18px; border-top: 1px solid var(--line); }

/* ---------- popover ---------- */
.popover { position: fixed; z-index: var(--z-popover); min-width: 220px; max-width: min(340px, calc(100vw - 16px)); background: var(--surface-2); border: 1px solid var(--line-2); border-radius: var(--r-md); box-shadow: var(--sh-3); padding: 10px; animation: pop-in 140ms var(--ease); }
.menu { display: grid; gap: 2px; }
.menu > button { display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 10px; border: 0; border-radius: var(--r-sm); background: transparent; text-align: left; font-weight: 500; color: var(--text); }
.menu > button:hover { background: var(--surface-3); }
.menu > button.is-danger { color: #ff8390; }

/* ---------- toast ---------- */
.toasts { position: fixed; z-index: var(--z-toast); right: 16px; bottom: 16px; display: grid; gap: 8px; width: min(380px, calc(100vw - 32px)); }
.toast { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: var(--r-md); background: var(--surface-3); border: 1px solid var(--line-2); box-shadow: var(--sh-3); animation: toast-in 220ms var(--ease); font-weight: 500; }
.toast .i { margin-top: 1px; }
.toast--ok .i { color: var(--ok); }
.toast--warn .i { color: var(--warn); }
.toast--error .i { color: var(--danger); }
.toast--info .i { color: var(--accent); }
.toast.is-leaving { animation: toast-out 180ms var(--ease) forwards; }

/* ---------- brand ---------- */
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none !important; }
.brand__logo { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: var(--accent); color: var(--text-inv); box-shadow: 0 6px 18px rgba(242, 182, 50, 0.25); }
.brand__logo .i { width: 19px; height: 19px; stroke-width: 2.4; }
.brand__name { font-family: var(--font-display); font-weight: 700; font-size: 15px; letter-spacing: 0.04em; }
.brand__name b { color: var(--accent); font-weight: 700; margin-left: 4px; }

/* ---------- misc ---------- */
.empty { display: grid; justify-items: center; text-align: center; gap: 10px; padding: 40px 20px; color: var(--text-2); }
.empty__icon { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--line); color: var(--text-3); }
.empty__title { font-weight: 700; color: var(--text); font-size: var(--fs-lg); }
.skeleton { background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-3) 50%, var(--surface-2) 100%); background-size: 200% 100%; animation: shimmer 1.3s linear infinite; border-radius: var(--r-sm); }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line-3); border-top-color: var(--accent); animation: spin 700ms linear infinite; }
.kbd { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 5px; background: var(--surface-3); border: 1px solid var(--line-2); border-bottom-width: 2px; font-size: 11px; font-weight: 700; color: var(--text-2); }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.swatch { width: 24px; height: 24px; border-radius: 50%; border: 2px solid transparent; box-shadow: 0 0 0 1px var(--line-2) inset; cursor: pointer; padding: 0; }
.swatch[aria-pressed='true'] { border-color: var(--text); }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(6px) scale(0.98); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(10px); } }

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