@font-face {
  font-family: 'RetroConnect Sans';
  src: url('/fonts/source-sans-3-latin-wght-normal.woff2') format('woff2');
  font-style: normal;
  font-weight: 200 900;
  font-display: swap;
}

:root {
  color-scheme: dark;
  font-family: 'RetroConnect Sans', sans-serif;
  --canvas: oklch(0.175 0.018 170);
  --surface: oklch(0.215 0.021 170);
  --surface-raised: oklch(0.25 0.023 170);
  --line: oklch(0.33 0.024 170);
  --text: oklch(0.94 0.014 155);
  --muted: oklch(0.7 0.026 165);
  --accent: oklch(0.82 0.14 155);
  --accent-hover: oklch(0.87 0.15 155);
  --accent-ink: oklch(0.22 0.055 160);
  --danger: oklch(0.72 0.15 25);
  --warning: oklch(0.8 0.13 85);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--canvas); color: var(--text); }
button, input { font: inherit; }
button, a, input { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: 0.55; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { letter-spacing: -0.025em; }
h1 { margin-bottom: 12px; font-size: clamp(2rem, 4vw, 3.25rem); line-height: 1.02; }
h2 { margin-bottom: 0; font-size: 1.5rem; }
h3 { margin-bottom: 0; font-size: 1rem; }
code { font-family: ui-monospace, monospace; }
.muted { color: var(--muted); line-height: 1.6; }
.eyebrow { margin-bottom: 8px; color: var(--accent); font-size: 0.72rem; font-weight: 750; letter-spacing: 0.16em; text-transform: uppercase; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.gate { width: min(480px, calc(100% - 48px)); margin: 12vh auto 48px; }
.gate h1 { font-size: 2.4rem; }
.gate .brand-mark { margin-bottom: 32px; }
.gate-form { display: grid; gap: 12px; margin-top: 24px; }
.brand-mark { display: grid; place-items: center; width: 44px; height: 44px; border: 1px solid var(--accent); border-radius: 10px; color: var(--accent); font-size: 0.9rem; font-weight: 850; letter-spacing: -0.04em; }

.topbar { position: sticky; top: 0; z-index: 10; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 24px; min-height: 76px; padding: 12px 32px; border-bottom: 1px solid var(--line); background: var(--canvas); }
.brand { display: inline-flex; align-items: center; gap: 12px; width: max-content; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 1.05rem; letter-spacing: -0.01em; }
.brand small { color: var(--muted); font-size: 0.75rem; }
.system-status { display: flex; gap: 8px; }
.status-pill { display: inline-flex; align-items: center; gap: 8px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 0.78rem; font-weight: 650; white-space: nowrap; }
.status-dot { width: 7px; height: 7px; flex: none; border-radius: 50%; background: currentColor; }
.status-pill.online { border-color: oklch(0.43 0.07 155); color: var(--accent); }
.status-pill.offline { border-color: oklch(0.39 0.06 25); color: var(--danger); }
.status-pill.warning { color: var(--warning); }
.header-actions { display: flex; justify-content: flex-end; align-items: center; gap: 8px; }
.icon-button { display: grid; place-items: center; width: 36px; height: 36px; padding: 0; border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--muted); }
.icon-button:hover { border-color: var(--line); color: var(--text); }
.icon-button svg { width: 18px; height: 18px; }

.connection-error { padding: 12px 32px; border-bottom: 1px solid oklch(0.42 0.08 25); background: oklch(0.24 0.045 25); color: oklch(0.88 0.08 25); }
main { width: min(1440px, 100%); margin: 0 auto; padding: 48px 32px 64px; }
.page-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 40px; }
.page-heading p:not(.eyebrow):not(.last-updated) { max-width: 600px; margin-bottom: 0; color: var(--muted); font-size: 1.05rem; }
.last-updated { flex: none; margin-bottom: 4px; color: var(--muted); font-size: 0.78rem; }
.live-deck { display: grid; grid-template-columns: 1.25fr 1fr auto; gap: 32px; align-items: center; margin-bottom: 40px; padding: 24px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.live-deck h2 { font-size: 1.15rem; }
.live-deck .eyebrow { margin-bottom: 6px; }
.live-deck p:last-child { margin-bottom: 0; }
.timer-row { display: flex; align-items: center; gap: 16px; margin-top: 12px; }
.timer-value { color: var(--accent); font-size: clamp(1.75rem, 3vw, 2.5rem); font-variant-numeric: tabular-nums; letter-spacing: -0.035em; }
.peek-panel { padding-left: 32px; border-left: 1px solid var(--line); }
.peek-panel .muted { margin-top: 8px; font-size: 0.8rem; }
.overlay-links { display: flex; flex-wrap: wrap; gap: 8px; }
.overlay-links .eyebrow { flex-basis: 100%; }
.workspace { display: grid; grid-template-columns: minmax(0, 1.75fr) minmax(280px, 0.75fr); gap: 48px; align-items: start; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.count { color: var(--muted); font-size: 0.85rem; }

.game-composer { margin-bottom: 24px; padding: 20px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.composer-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.composer-grid { display: grid; grid-template-columns: minmax(140px, 1fr) minmax(110px, 0.65fr); gap: 16px 12px; }
.aliases-field { grid-column: 1 / -1; }
.composer-submit { grid-column: 1 / -1; justify-self: start; }
.field { margin-bottom: 16px; }
.field label, .gate-form label { display: block; margin-bottom: 7px; font-size: 0.8rem; font-weight: 700; }
.field label span { color: var(--muted); font-weight: 500; }
.field small { display: block; margin-top: 6px; color: var(--muted); font-size: 0.76rem; line-height: 1.4; }
.connector-option { grid-column: 1 / -1; }
.connector-option label { display: flex; align-items: center; gap: 8px; font-size: 0.84rem; font-weight: 700; cursor: pointer; }
.connector-option input { width: 17px; min-height: 17px; margin: 0; accent-color: var(--accent); }
.connector-option small { display: block; margin: 6px 0 0 25px; color: var(--muted); font-size: 0.76rem; line-height: 1.4; }
.art-editor { grid-column: 1 / -1; display: flex; align-items: center; gap: 16px; }
.art-preview { display: grid; place-items: center; width: 72px; height: 96px; flex: none; overflow: hidden; border: 1px dashed var(--line); border-radius: 8px; background: var(--canvas); color: var(--muted); text-align: center; font-size: 0.72rem; }
.art-preview img { width: 100%; height: 100%; object-fit: contain; }
.art-label { display: block; margin-bottom: 4px; font-size: 0.8rem; font-weight: 700; }
.art-help { max-width: 420px; margin-bottom: 10px; color: var(--muted); font-size: 0.76rem; line-height: 1.4; }
.art-actions { display: flex; flex-wrap: wrap; gap: 8px; }
input { width: 100%; min-height: 42px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; outline: none; background: var(--canvas); color: var(--text); }
input::placeholder { color: oklch(0.57 0.024 165); }
input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px oklch(0.82 0.14 155 / 0.13); }
input[type='number'] { font-variant-numeric: tabular-nums; }

.button { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 9px 16px; border: 1px solid transparent; border-radius: 8px; font-weight: 750; line-height: 1; transition: background 120ms ease, border-color 120ms ease; }
.button.primary { background: var(--accent); color: var(--accent-ink); }
.button.primary:hover { background: var(--accent-hover); }
.button.secondary { border-color: var(--line); background: var(--surface-raised); color: var(--text); }
.button.secondary:hover, .button.subtle:hover { border-color: var(--muted); }
.button.subtle { border-color: var(--line); background: transparent; color: var(--text); }
.button.danger-text { background: transparent; color: var(--danger); }
.button.danger-text:hover { background: oklch(0.26 0.04 25); }
.button.small { min-height: 34px; padding: 7px 11px; font-size: 0.78rem; }
.full-width { width: 100%; }
.text-button { padding: 0; border: 0; background: transparent; color: var(--accent); font-size: 0.8rem; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.library-toolbar { display: flex; align-items: center; gap: 16px; margin-bottom: 12px; }
.search { position: relative; display: block; width: min(360px, 100%); flex: none; }
.search svg { position: absolute; top: 50%; left: 11px; width: 17px; height: 17px; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search input { min-height: 38px; padding-left: 36px; font-size: 0.86rem; }
.feedback { min-height: 1.2em; margin: 0; color: var(--accent); font-size: 0.82rem; line-height: 1.4; }
.feedback.error { color: var(--danger); }
.game-table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th { padding: 10px 12px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 0.7rem; letter-spacing: 0.1em; text-transform: uppercase; }
th:last-child { width: 220px; }
td { padding: 16px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:hover { background: oklch(0.21 0.018 170 / 0.55); }
.game-name { font-weight: 700; }
.game-aliases { margin-top: 3px; color: var(--muted); font-size: 0.77rem; }
.game-playtime { color: var(--text); font-size: 0.88rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.codename { display: inline-block; padding: 4px 7px; border: 1px solid var(--line); border-radius: 6px; color: var(--accent); font-size: 0.78rem; overflow-wrap: anywhere; }
.row-actions { display: flex; justify-content: flex-end; gap: 4px; }
.empty-state { padding: 40px 24px; border: 1px dashed var(--line); border-radius: 12px; text-align: center; color: var(--muted); }
.empty-state h3 { margin-bottom: 8px; color: var(--text); }
.empty-state p { margin-bottom: 0; }
.empty-state.compact { padding: 24px; }

.sidebar { padding-left: 32px; border-left: 1px solid var(--line); }
.settings-section { margin-bottom: 40px; }
.section-copy { margin: 12px 0 24px; color: var(--muted); font-size: 0.88rem; line-height: 1.55; }
.rule-note { margin: 20px 0; padding-left: 12px; border-left: 2px solid var(--accent); }
.rule-note strong { font-size: 0.82rem; }
.rule-note p { margin: 5px 0 0; color: var(--muted); font-size: 0.78rem; line-height: 1.5; }
.rule-note code { font-size: 0.75rem; }
#settingsFeedback { margin-top: 10px; }
.connection-section { padding-top: 32px; border-top: 1px solid var(--line); }
.endpoint { display: block; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--accent); font-size: 0.74rem; overflow-wrap: anywhere; }
.connection-detail { margin: 12px 0 0; color: var(--muted); font-size: 0.78rem; line-height: 1.5; }

.activity-section { margin-top: 56px; padding-top: 32px; border-top: 1px solid var(--line); }
.activity-list { margin: 0; padding: 0; list-style: none; }
.activity-item { display: grid; grid-template-columns: 12px 1fr; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.activity-item p { margin: 0 0 3px; font-size: 0.9rem; }
.activity-item small { color: var(--muted); font-size: 0.75rem; text-transform: capitalize; }
.activity-marker { width: 7px; height: 7px; margin-top: 7px; border-radius: 50%; background: var(--muted); }
.activity-item.sent .activity-marker, .activity-item.rolled .activity-marker { background: var(--accent); }
.activity-item.failed .activity-marker { background: var(--danger); }
.activity-item.ignored .activity-marker, .activity-item.queued .activity-marker { background: var(--warning); }

@media (min-width: 1100px) {
  .composer-grid { grid-template-columns: minmax(160px, 1fr) minmax(110px, 0.55fr) minmax(170px, 1fr) auto; align-items: start; }
  .aliases-field { grid-column: auto; }
  .composer-submit { grid-column: 1 / -1; margin-top: 0; }
  .game-composer .field { margin-bottom: 0; }
}

@media (max-width: 980px) {
  .topbar { grid-template-columns: 1fr auto; }
  .system-status { grid-column: 1 / -1; grid-row: 2; }
  .live-deck { grid-template-columns: 1fr 1fr; }
  .overlay-links { grid-column: 1 / -1; }
  .workspace { grid-template-columns: 1fr; gap: 40px; }
  .sidebar { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; padding-left: 0; border-left: 0; }
  .settings-section { margin-bottom: 0; }
  .connection-section { padding: 0 0 0 32px; border-top: 0; border-left: 1px solid var(--line); }
}

@media (max-width: 680px) {
  .topbar { gap: 12px; padding: 12px 16px; }
  .brand-mark { width: 38px; height: 38px; }
  .system-status { flex-wrap: wrap; }
  .status-pill { font-size: 0.72rem; }
  #lockButton { display: none; }
  main { padding: 32px 16px 48px; }
  .page-heading { display: block; margin-bottom: 32px; }
  .live-deck { grid-template-columns: 1fr; gap: 24px; }
  .peek-panel { padding: 24px 0 0; border-top: 1px solid var(--line); border-left: 0; }
  .overlay-links { grid-column: auto; }
  .last-updated { margin-top: 16px; }
  .workspace { gap: 32px; }
  .game-composer { padding: 16px; }
  .composer-grid { grid-template-columns: 1fr; }
  .aliases-field, .composer-submit { grid-column: auto; }
  .library-toolbar { align-items: flex-start; flex-direction: column; gap: 8px; }
  .search { width: 100%; }
  th:nth-child(2), td:nth-child(2) { display: none; }
  th:last-child { width: 180px; }
  td { padding: 14px 4px; }
  .row-actions { gap: 2px; }
  .button.small { padding: 7px 9px; }
  .sidebar { display: block; }
  .settings-section { margin-bottom: 32px; }
  .connection-section { padding: 32px 0 0; border-top: 1px solid var(--line); border-left: 0; }
  .activity-section { margin-top: 40px; }
}
