/* Outpost — the board is the hero; the chrome takes its colours from the board you chose. */


:root {
  --font: 'Archivo Variable', 'Archivo', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --panel: rgba(243, 249, 253, 0.9);
  --panel-solid: #f3f9fd;
  --ink: #0c2a40;
  --muted: #4b6a81;
  --line: rgba(12, 42, 64, 0.13);
  --field: rgba(12, 42, 64, 0.06);
  --accent: #0b67a3;
  --accent-ink: #ffffff;
  --accent-soft: rgba(11, 103, 163, 0.16);
  --danger: #d93d42;
  --win: #3f9c5a;
  --loss: #d4524f;
  --draw: #8f8f8f;
  --r-panel: 22px;
  --r-ctl: 10px;
  --r-tile: 14px;
  --topbar: 64px;
  --panel-w: 404px;
  --gap: 16px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  color-scheme: light;
}
:root[data-scheme='dark'] { color-scheme: dark; }

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  font-weight: 420;
  color: var(--ink);
  background: #10131a;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  overscroll-behavior: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.icon { fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tabular { font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.noscript { color: #fff; padding: 2rem; }

/* ---- stage ---------------------------------------------------------------------------------- */
#stage { position: fixed; inset: 0; }
#board3d { width: 100%; height: 100%; display: block; touch-action: none; }
#stage-ui { position: absolute; inset: 0; pointer-events: none; }
#stage-ui > * { pointer-events: auto; }

/* ---- top bar -------------------------------------------------------------------------------- */
#topbar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--topbar); z-index: 30;
  display: flex; align-items: center; gap: 28px; padding: 0 20px 0 24px; pointer-events: none;
}
#topbar > * { pointer-events: auto; }
.brand {
  font-weight: 820; font-stretch: 125%; font-size: 22px; letter-spacing: -0.01em; text-decoration: none; color: var(--ink);
  padding: 6px 14px 7px; border-radius: 12px; background: var(--panel); backdrop-filter: blur(14px) saturate(1.3); -webkit-backdrop-filter: blur(14px) saturate(1.3);
  border: 1px solid var(--line);
}
.nav { display: flex; gap: 2px; padding: 4px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.nav a {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 9px; text-decoration: none; color: var(--muted);
  font-weight: 560; font-stretch: 104%;
}
.nav a:hover { color: var(--ink); }
.nav a.active { color: var(--ink); background: var(--field); }
.nav a .badge-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.online-pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px; border-radius: 999px; font-size: 13px; color: var(--muted);
  background: var(--panel); border: 1px solid var(--line); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); font-variant-numeric: tabular-nums;
}
.online-pill::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--win); box-shadow: 0 0 0 3px rgba(63, 156, 90, .2); }
.me-button { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--panel); padding: 3px 12px 3px 3px; border-radius: 999px; cursor: pointer; backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.me-button > span:not(.avatar) { font-weight: 600; font-stretch: 96%; }
.preview-pill { font-size: 13px; padding: 6px 11px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.menu { position: fixed; top: 60px; right: 20px; z-index: 40; min-width: 210px; padding: 6px; border-radius: 14px; background: var(--panel-solid); border: 1px solid var(--line); box-shadow: 0 24px 60px -20px rgba(0,0,0,.5); }
.menu a, .menu button { display: flex; width: 100%; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 9px; border: 0; background: none; color: var(--ink); text-decoration: none; cursor: pointer; text-align: left; }
.menu a:hover, .menu button:hover { background: var(--field); }

/* ---- side panel ----------------------------------------------------------------------------- */
#panel {
  position: fixed; z-index: 20; top: calc(var(--topbar) + 4px); right: var(--gap); bottom: var(--gap); width: var(--panel-w);
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-panel);
  backdrop-filter: blur(22px) saturate(1.25); -webkit-backdrop-filter: blur(22px) saturate(1.25);
  box-shadow: 0 40px 90px -40px rgba(0, 0, 0, .55);
  overflow-y: auto; overflow-x: hidden; scrollbar-width: thin; scrollbar-color: var(--line) transparent;
  display: flex; flex-direction: column;
}
#panel:empty { display: none; }
#panel > * { flex-shrink: 0; }
.section { padding: 20px 22px; }
.section + .section { border-top: 1px solid var(--line); }
.section.grow { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.panel-title { font-size: 21px; line-height: 1.2; font-weight: 720; font-stretch: 112%; margin: 0 0 4px; letter-spacing: -0.005em; }
.section-title { font-size: 14px; font-weight: 640; color: var(--muted); margin: 0 0 12px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.lede { margin: 0 0 16px; color: var(--muted); max-width: 60ch; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.spacer { flex: 1; }

/* ---- controls ------------------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 38px; padding: 0 14px;
  border-radius: var(--r-ctl); border: 1px solid var(--line); background: var(--field); color: var(--ink);
  font-weight: 600; font-stretch: 102%; cursor: pointer; white-space: nowrap; transition: background .15s var(--ease), border-color .15s, transform .1s;
}
.btn:hover:not(:disabled) { border-color: color-mix(in srgb, var(--ink) 28%, transparent); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn-primary:hover:not(:disabled) { border-color: transparent; filter: brightness(1.06); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover:not(:disabled) { color: var(--ink); background: var(--field); }
.btn-danger { color: var(--danger); }
.btn-danger:hover:not(:disabled) { border-color: var(--danger); }
.btn-block { width: 100%; }
a.btn { text-decoration: none; justify-content: center; }
.btn-lg { min-height: 48px; font-size: 16px; }
.btn-icon { width: 38px; padding: 0; }

input[type='text'], input[type='search'], input[type='number'], input[type='date'], input[type='datetime-local'], input:not([type]), select, textarea {
  width: 100%; min-height: 40px; padding: 8px 12px; border-radius: var(--r-ctl); border: 1px solid var(--line);
  background: var(--field); color: var(--ink); outline: none; transition: border-color .15s;
}
textarea { resize: vertical; min-height: 84px; line-height: 1.45; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
select option { background: var(--panel-solid); color: var(--ink); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 13px; font-weight: 600; color: var(--muted); }
input[type='color'] { width: 40px; height: 34px; padding: 2px; border-radius: 9px; border: 1px solid var(--line); background: var(--field); cursor: pointer; }
input[type='range'] { width: 100%; accent-color: var(--accent); }

.toggle { display: flex; align-items: center; gap: 12px; padding: 8px 0; cursor: pointer; position: relative; }
.toggle-text { flex: 1; display: flex; flex-direction: column; }
.toggle-text small { font-size: 13px; }
.toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.toggle-track { width: 40px; height: 24px; border-radius: 999px; background: var(--line); position: relative; transition: background .18s var(--ease); flex: none; }
.toggle-thumb { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--panel-solid); box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .18s var(--ease); }
.toggle input:checked + .toggle-track { background: var(--accent); }
.toggle input:checked + .toggle-track .toggle-thumb { transform: translateX(16px); }
.toggle input:focus-visible + .toggle-track { outline: 2px solid var(--accent); outline-offset: 2px; }

.segmented { display: flex; padding: 3px; gap: 3px; border-radius: 12px; background: var(--field); border: 1px solid var(--line); }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 34px; padding: 0 10px; border-radius: 9px; cursor: pointer; color: var(--muted); font-weight: 600; font-stretch: 100%; }
.segmented input:checked + label { background: var(--panel-solid); color: var(--ink); box-shadow: 0 1px 4px rgba(0,0,0,.15); }
.segmented input:focus-visible + label { outline: 2px solid var(--accent); }

.avatar { display: inline-grid; place-items: center; border-radius: 50%; overflow: hidden; flex: none; color: #fff; font-weight: 700; background: var(--line); }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--field); color: var(--muted); border: 1px solid var(--line); }
.badge.accent { background: var(--accent-soft); color: var(--ink); border-color: transparent; }
.dot-online { width: 8px; height: 8px; border-radius: 50%; background: var(--win); display: inline-block; flex: none; }

/* ---- lobby ---------------------------------------------------------------------------------- */
.grid-tc { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tc {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; min-height: 72px;
  border-radius: var(--r-tile); border: 1px solid var(--line); background: var(--field); cursor: pointer; color: var(--ink);
  transition: border-color .15s, background .15s, transform .1s;
}
.tc:hover { border-color: color-mix(in srgb, var(--accent) 60%, transparent); }
.tc:active { transform: translateY(1px); }
.tc-time { font-size: 22px; font-weight: 720; font-stretch: 88%; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; line-height: 1.1; }
.tc-label { font-size: 12.5px; color: var(--muted); font-weight: 520; }
.tc.seeking { border-color: var(--accent); background: var(--accent-soft); }
.tc.seeking .tc-label { color: var(--ink); }
.tc.seeking::after { content: ''; position: absolute; inset: -1px; border-radius: inherit; border: 2px solid var(--accent); animation: pulse 1.6s ease-in-out infinite; pointer-events: none; }
@keyframes pulse { 0%, 100% { opacity: .2; } 50% { opacity: 1; } }
.seek-bar { display: flex; align-items: center; gap: 10px; margin-top: 12px; padding: 10px 12px; border-radius: 12px; background: var(--accent-soft); }
.seek-bar .spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--accent); border-right-color: transparent; animation: spin .9s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

.list { display: flex; flex-direction: column; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 9px 0; min-height: 52px; }
.list-row + .list-row { border-top: 1px solid var(--line); }
.list-row .grow { flex: 1; min-width: 0; }
.list-row .name { font-weight: 640; font-stretch: 98%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; gap: 6px; }
.list-row .name a { color: var(--ink); text-decoration: none; }
.list-row .name a:hover { text-decoration: underline; }
.list-row .meta { font-size: 13px; color: var(--muted); }
.empty { color: var(--muted); padding: 6px 0; }

.challenge-card { border-radius: var(--r-tile); padding: 14px; background: var(--accent-soft); display: flex; flex-direction: column; gap: 10px; }
.challenge-card + .challenge-card { margin-top: 8px; }
.link-box { display: flex; gap: 8px; }
.link-box input { font-variant-numeric: tabular-nums; font-size: 13px; }
.active-game { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--r-tile); background: var(--accent); color: var(--accent-ink); text-decoration: none; font-weight: 650; }

/* ---- hero / sign-in ------------------------------------------------------------------------- */
.hero { padding-top: 6px; }
.wordmark { margin: 0; font-size: 56px; line-height: .92; font-weight: 860; font-stretch: 125%; letter-spacing: -0.035em; color: var(--ink); }
.hero-line { margin: 12px 0 0; font-size: 17px; line-height: 1.4; font-weight: 470; font-stretch: 104%; color: var(--ink); max-width: 30ch; }
body.route-login .brand, body.route-twofa .brand { display: none; }
.provider-btn { justify-content: flex-start; gap: 12px; min-height: 50px; font-size: 16px; padding: 0 14px; }
.provider-btn .pmark { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; font-weight: 800; font-stretch: 112%; font-size: 14px; background: var(--panel-solid); color: var(--ink); border: 1px solid var(--line); flex: none; }
.provider-btn .note { margin-left: auto; font-size: 12px; font-weight: 520; color: var(--muted); }
.signin-foot { font-size: 13px; color: var(--muted); }
.error-box { padding: 10px 12px; border-radius: 10px; background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--ink); border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent); }
.code-input { font-size: 26px !important; letter-spacing: .35em; text-align: center; font-variant-numeric: tabular-nums; font-weight: 650; font-stretch: 90%; }

/* ---- game ----------------------------------------------------------------------------------- */
.plate {
  position: absolute; left: clamp(12px, 2vw, 24px); display: flex; align-items: center; gap: 12px; padding: 8px 8px 8px 10px;
  border-radius: 16px; background: var(--panel); border: 1px solid var(--line); backdrop-filter: blur(16px) saturate(1.2); -webkit-backdrop-filter: blur(16px) saturate(1.2);
  max-width: min(420px, calc(100% - 24px)); box-shadow: 0 18px 40px -24px rgba(0,0,0,.6); transition: box-shadow .2s, border-color .2s;
}
.plate.top { top: calc(var(--topbar) + 8px); }
.plate.bottom { bottom: clamp(12px, 2vw, 24px); }
.plate-who { display: flex; flex-direction: column; min-width: 0; }
.plate-name { font-weight: 680; font-stretch: 98%; display: flex; align-items: center; gap: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.plate-name a { color: var(--ink); text-decoration: none; }
.plate-sub { font-size: 13px; color: var(--muted); display: flex; gap: 8px; align-items: center; font-variant-numeric: tabular-nums; min-height: 18px; }
.plate-sub .captured { letter-spacing: -0.12em; font-size: 15px; line-height: 1; }
.clock {
  margin-left: 6px; min-width: 104px; padding: 6px 12px; border-radius: 11px; text-align: right;
  font-size: 30px; line-height: 1.1; font-weight: 720; font-stretch: 78%; font-variant-numeric: tabular-nums; letter-spacing: -0.01em;
  background: var(--field); color: var(--muted); border: 1px solid var(--line);
}
.clock.running { background: var(--ink); color: var(--panel-solid); border-color: transparent; }
.clock.low.running { background: var(--danger); color: #fff; }
.plate.to-move { border-color: color-mix(in srgb, var(--accent) 55%, transparent); }
.first-move { position: absolute; left: 50%; top: calc(var(--topbar) + 14px); transform: translateX(-50%); padding: 8px 14px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); font-size: 14px; backdrop-filter: blur(12px); white-space: nowrap; }

.game-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.game-head .tc-big { font-size: 21px; font-weight: 720; font-stretch: 92%; font-variant-numeric: tabular-nums; }
.moves { display: grid; grid-template-columns: 44px 1fr 1fr; align-content: start; font-variant-numeric: tabular-nums; font-stretch: 92%; min-height: 96px; max-height: 34vh; overflow-y: auto; border-radius: 12px; background: var(--field); border: 1px solid var(--line); scrollbar-width: thin; }
.move-num { padding: 5px 0 5px 12px; color: var(--muted); font-size: 13px; line-height: 22px; }
.mv { padding: 5px 10px; border: 0; background: none; text-align: left; cursor: pointer; border-radius: 6px; font-weight: 560; line-height: 22px; color: var(--ink); }
.mv:hover { background: var(--line); }
.mv.current { background: var(--accent); color: var(--accent-ink); }
.moves-empty { grid-column: 1 / -1; padding: 14px; color: var(--muted); font-size: 14px; }
.nav-buttons { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 8px; }
.game-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.game-actions .btn { flex: 1; }
.banner { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 12px; border-radius: 12px; background: var(--accent-soft); margin-bottom: 12px; }
.banner .grow { flex: 1; min-width: 140px; }

.chat { display: flex; flex-direction: column; gap: 10px; min-height: 0; flex: 1; }
.chat-log { flex: 1; min-height: 120px; max-height: 30vh; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; border-radius: 12px; background: var(--field); border: 1px solid var(--line); scrollbar-width: thin; }
.chat-line { font-size: 14px; line-height: 1.4; overflow-wrap: anywhere; }
.chat-line b { font-weight: 680; margin-right: 6px; }
.chat-line.system { color: var(--muted); font-style: italic; font-size: 13px; }
.chat-form { display: flex; gap: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: transparent; color: var(--ink); border-radius: 999px; padding: 4px 11px; font-size: 13px; cursor: pointer; }
.chip:hover { background: var(--field); }

.promo { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0,0,0,.25); }
.promo-card { display: flex; gap: 8px; padding: 10px; border-radius: 18px; background: var(--panel-solid); border: 1px solid var(--line); box-shadow: 0 30px 60px -20px rgba(0,0,0,.6); }
.promo-card button { width: 72px; height: 72px; border-radius: 14px; border: 1px solid var(--line); background: var(--field); font-size: 46px; line-height: 1; cursor: pointer; color: var(--ink); }
.promo-card button:hover, .promo-card button:focus-visible { background: var(--accent); color: var(--accent-ink); }

.result-head { font-size: 28px; line-height: 1.15; font-weight: 780; font-stretch: 112%; margin: 0; }
.result-sub { color: var(--muted); margin: 6px 0 0; }
.rating-change { font-variant-numeric: tabular-nums; font-weight: 700; }
.rating-change.up { color: var(--win); }
.rating-change.down { color: var(--loss); }
.pgn-box { width: 100%; min-height: 150px; font-size: 12.5px; line-height: 1.45; font-family: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace; white-space: pre; }
.pgn-help { font-size: 14px; color: var(--muted); }
.pgn-help ol { margin: 6px 0 0; padding-left: 20px; }
.pgn-help li { margin: 3px 0; }

/* ---- profile -------------------------------------------------------------------------------- */
.profile-head { display: flex; gap: 16px; align-items: center; }
.profile-name { font-size: 28px; line-height: 1.1; font-weight: 780; font-stretch: 112%; margin: 0; overflow-wrap: anywhere; }
.profile-meta { color: var(--muted); font-size: 14px; display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 4px; }
.bio { white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; }
.ratings { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.rating-tile { padding: 10px; border-radius: 12px; background: var(--field); border: 1px solid var(--line); }
.rating-tile .v { font-size: 22px; font-weight: 720; font-stretch: 88%; font-variant-numeric: tabular-nums; line-height: 1.1; }
.rating-tile .l { font-size: 13px; font-weight: 600; }
.rating-tile .n { font-size: 12.5px; color: var(--muted); }
.wld { display: flex; height: 8px; border-radius: 999px; overflow: hidden; background: var(--field); margin-top: 8px; }
.wld i { display: block; }
.res { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; font-weight: 760; font-size: 13px; color: #fff; flex: none; }
.res.w { background: var(--win); } .res.l { background: var(--loss); } .res.d { background: var(--draw); }

/* ---- settings ------------------------------------------------------------------------------- */
.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; padding: 14px 18px 0; }
.tab { border: 0; background: none; padding: 8px 10px; border-radius: 10px; color: var(--muted); font-weight: 600; cursor: pointer; white-space: nowrap; }
.tab:hover { color: var(--ink); }
.tab.active { background: var(--field); color: var(--ink); }
.theme-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.preset { display: flex; flex-direction: column; gap: 8px; padding: 8px; border-radius: var(--r-tile); border: 1px solid var(--line); background: var(--field); cursor: pointer; text-align: left; color: var(--ink); }
.preset:hover { border-color: color-mix(in srgb, var(--accent) 60%, transparent); }
.preset.active { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.preset-swatch { display: grid; grid-template-columns: repeat(4, 1fr); height: 46px; border-radius: 9px; overflow: hidden; position: relative; }
.preset-swatch i { display: block; }
.preset-swatch .pcs { position: absolute; right: 6px; bottom: 6px; display: flex; gap: 4px; }
.preset-swatch .pcs b { width: 14px; height: 14px; border-radius: 50%; border: 1px solid rgba(0,0,0,.25); }
.preset-name { font-size: 13px; font-weight: 620; line-height: 1.25; }
.piece-sets { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.piece-set { gap: 6px; }
.piece-set-strip { display: grid; grid-template-columns: repeat(6, 1fr); border-radius: 9px; overflow: hidden; }
.piece-set-strip > span { aspect-ratio: 1; display: block; }
.piece-set-strip canvas { display: block; width: 100%; height: 100%; }
.piece-set-name { display: flex; align-items: center; gap: 8px; }
.set-default { font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 999px; background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--ink); }
.editor-group { display: flex; flex-direction: column; gap: 10px; padding: 12px; border-radius: var(--r-tile); background: var(--field); border: 1px solid var(--line); }
.editor-group h4 { margin: 0; font-size: 14px; font-weight: 680; }
.color-row { display: flex; align-items: center; gap: 8px; }
.color-row select { flex: 1; min-width: 0; }
.image-row { display: flex; align-items: center; gap: 8px; }
.image-thumb { width: 44px; height: 44px; border-radius: 8px; background: var(--line) center/cover no-repeat; flex: none; border: 1px solid var(--line); }
.sticky-actions { position: sticky; bottom: 0; padding: 14px 22px; background: var(--panel-solid); border-top: 1px solid var(--line); display: flex; gap: 8px; z-index: 2; margin-top: auto; }
.qr { width: 200px; height: 200px; border-radius: 12px; background: #fff; padding: 8px; display: block; }
.codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 14px; padding: 12px; border-radius: 12px; background: var(--field); border: 1px solid var(--line); }
.secret { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; word-break: break-all; }
.preview-card { display: flex; gap: 12px; align-items: center; padding: 12px; border-radius: var(--r-tile); background: var(--field); border: 1px solid var(--line); }
.checks { display: flex; flex-direction: column; gap: 6px; }
.checks label { display: flex; gap: 10px; align-items: center; cursor: pointer; }
.checks input { width: 18px; height: 18px; accent-color: var(--accent); }
.danger-zone { border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent); border-radius: var(--r-tile); padding: 14px; }

/* ---- modal & toasts ------------------------------------------------------------------------- */
.modal-wrap { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 20px; background: rgba(5, 8, 12, .45); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); animation: fade .16s var(--ease); }
.modal { width: min(460px, 100%); max-height: calc(100vh - 40px); overflow-y: auto; padding: 22px; border-radius: 20px; background: var(--panel-solid); color: var(--ink); border: 1px solid var(--line); box-shadow: 0 40px 100px -30px rgba(0,0,0,.6); animation: rise .2s var(--ease); }
.modal-wide { width: min(620px, 100%); }
.modal-title { margin: 0 0 12px; font-size: 21px; font-weight: 720; font-stretch: 112%; }
.modal-body { display: flex; flex-direction: column; gap: 12px; }
.modal-body p { margin: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.modal-wrap.leaving { opacity: 0; transition: opacity .16s; }
#toast-root { position: fixed; z-index: 70; left: 50%; bottom: 22px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; width: min(460px, calc(100vw - 24px)); pointer-events: none; }
.toast { pointer-events: auto; width: 100%; display: flex; flex-direction: column; gap: 10px; padding: 12px 14px; border-radius: 14px; background: var(--panel-solid); color: var(--ink); border: 1px solid var(--line); box-shadow: 0 20px 50px -20px rgba(0,0,0,.55); animation: rise .2s var(--ease); }
.toast-error { border-color: color-mix(in srgb, var(--danger) 60%, transparent); }
.toast-actions { display: flex; gap: 8px; justify-content: flex-end; }
.toast.leaving { opacity: 0; transform: translateY(6px); transition: all .18s; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

/* ---- responsive ----------------------------------------------------------------------------- */
@media (max-width: 900px) {
  :root { --topbar: 56px; --gap: 0px; }
  body { overflow: auto; }
  #stage { position: fixed; top: 0; left: 0; right: 0; bottom: auto; height: 58svh; }
  #panel { top: 58svh; left: 0; right: 0; bottom: 0; width: auto; border-radius: 20px 20px 0 0; border-bottom: 0; }
  #topbar { gap: 10px; padding: 0 10px; }
  .brand { font-size: 18px; padding: 4px 10px 5px; }
  .nav a span { display: none; }
  .nav a { padding: 7px 9px; }
  .online-pill { display: none; }
  .me-button > span:not(.avatar) { display: none; }
  .me-button { padding: 3px; }
  .wordmark { font-size: 44px; }
  .hero-line { font-size: 15px; }
  .plate { padding: 5px 6px 5px 8px; gap: 8px; border-radius: 13px; }
  .plate.top { top: calc(var(--topbar) + 4px); }
  .plate.bottom { bottom: 8px; }
  .plate .avatar { width: 30px !important; height: 30px !important; }
  .clock { font-size: 22px; min-width: 78px; padding: 4px 9px; }
  .moves { max-height: 22vh; }
  body.route-login #panel, body.route-twofa #panel { top: 52svh; }
  body.route-login #stage, body.route-twofa #stage { height: 52svh; }
}

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

/* ---- names, ranks and titles ------------------------------------------------------------------- */

.name-tag { display: inline-flex; align-items: center; gap: 5px; min-width: 0; max-width: 100%; vertical-align: middle; }
.name-tag .name-link, .name-tag .name-text { color: inherit; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.name-tag .name-link:hover { text-decoration: underline; }

.rank {
  --rank-a: #8a8f98; --rank-b: #5f646c; --rank-ink: #fff; --rank-glow: rgba(255, 255, 255, .55);
  position: relative; overflow: hidden; flex: none; display: inline-flex; align-items: center;
  height: 1.45em; padding: 0 .5em; border-radius: 6px;
  font-size: max(11px, .62em); font-weight: 760; font-stretch: 108%; letter-spacing: .02em; line-height: 1;
  color: var(--rank-ink); background: linear-gradient(160deg, var(--rank-a), var(--rank-b));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .28), 0 1px 2px rgba(0, 0, 0, .25);
  cursor: default; user-select: none;
}
/* The shine: a bright band that sweeps across once each time you hover. */
.rank::after {
  content: ''; position: absolute; inset: -40% auto -40% -60%; width: 45%;
  background: linear-gradient(100deg, transparent, var(--rank-glow), transparent);
  transform: translateX(0) skewX(-18deg); opacity: 0; pointer-events: none;
}
.rank:hover::after, .name-tag:hover .rank::after { animation: rank-shine .75s var(--ease) both; }
@keyframes rank-shine { 0% { transform: translateX(0) skewX(-18deg); opacity: 1; } 100% { transform: translateX(420%) skewX(-18deg); opacity: 1; } }

.rank-owner { --rank-a: #ff4b4b; --rank-b: #b3121a; --rank-glow: rgba(255, 236, 236, .9); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), 0 0 0 1px rgba(120, 0, 8, .35), 0 2px 8px rgba(220, 30, 40, .35); }
.rank-admin { --rank-a: #ff9640; --rank-b: #c2520c; }
.rank-helper { --rank-a: #2fbf8f; --rank-b: #12785a; }
.rank-media { --rank-a: #b45cff; --rank-b: #6b23c4; }
.rank-cool { --rank-a: #2dd4f0; --rank-b: #3b5bf5; background: linear-gradient(120deg, #2dd4f0, #6a7cff 45%, #d16bff 75%, #2dd4f0); background-size: 220% 100%; }
.rank-cool:hover { animation: rank-cool 2.4s linear infinite; }
@keyframes rank-cool { to { background-position: -220% 0; } }

.title-tag {
  flex: none; display: inline-flex; align-items: center; height: 1.45em; padding: 0 .38em; border-radius: 5px;
  font-size: max(11px, .62em); font-weight: 800; font-stretch: 104%; letter-spacing: .03em; line-height: 1; cursor: default; user-select: none;
  position: relative; overflow: hidden;
}
.title-tag::after {
  content: ''; position: absolute; inset: -40% auto -40% -60%; width: 45%; opacity: 0; pointer-events: none;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .85), transparent); transform: skewX(-18deg);
}
.title-tag:hover::after { animation: rank-shine .75s var(--ease) both; }
/* GM: shining gold. The slow sheen runs on its own; hover adds the sweep. */
.title-gold {
  color: #3d2600;
  background: linear-gradient(115deg, #a8741a 0%, #f6d77a 22%, #fff3c4 32%, #e0aa3e 46%, #b9832a 62%, #f3cf6a 82%, #a8741a 100%);
  background-size: 260% 100%; animation: title-sheen 4.5s linear infinite;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .6), 0 0 0 1px rgba(120, 80, 10, .35), 0 1px 6px rgba(230, 170, 50, .35);
}
@keyframes title-sheen { to { background-position: -260% 0; } }
.title-silver { color: #1f2a33; background: linear-gradient(135deg, #f4f7fa, #b7c2cc 55%, #e8edf2); box-shadow: inset 0 1px 0 #fff, 0 0 0 1px rgba(60, 75, 90, .3); }
.title-bronze { color: #fff7ef; background: linear-gradient(135deg, #e0a06a, #a35a25 60%, #c9824b); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), 0 0 0 1px rgba(100, 50, 15, .35); }
.title-steel { color: #eef4fb; background: linear-gradient(135deg, #7d93ab, #3f5368 65%, #6a8099); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .3), 0 0 0 1px rgba(25, 40, 60, .35); }
.title-custom { color: var(--ink); background: var(--field); box-shadow: inset 0 0 0 1px var(--line); }

@media (prefers-reduced-motion: reduce) {
  .rank::after, .title-tag::after { animation: none !important; opacity: 0; }
  .title-gold, .rank-cool:hover { animation: none; }
}

.profile-name { display: flex; align-items: center; }
.profile-name .name-tag { gap: 8px; }
.me-button .name-tag { font-weight: 600; }
.chat-line .name-tag { margin-right: 6px; font-weight: 680; }

/* ---- moderation & appeals ---------------------------------------------------------------------- */

.ban-banner { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r-tile); background: rgba(217, 61, 66, .12); border: 1px solid rgba(217, 61, 66, .35); color: var(--ink); margin-top: 12px; }
.ban-banner b { color: var(--danger); }
.ban-banner .small { color: var(--muted); }
.mod-grid { display: grid; gap: 14px; }
.mod-card { border: 1px solid var(--line); border-radius: var(--r-tile); padding: 14px; background: var(--field); }
.mod-card h3 { margin: 0 0 10px; font-size: 15px; font-weight: 720; display: flex; align-items: center; gap: 8px; }
.mod-card .row { gap: 8px; }
.mod-ratings { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.mod-ratings input { width: 100%; }
.mod-status { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.mod-log { max-height: 180px; overflow: auto; font-size: 13px; color: var(--muted); display: grid; gap: 4px; }
.mod-log b { color: var(--ink); font-weight: 640; }
.appeal-card { border: 1px solid var(--line); border-radius: var(--r-tile); padding: 14px; display: grid; gap: 8px; background: var(--field); }
.appeal-card blockquote { margin: 0; padding: 10px 12px; border-left: 3px solid var(--accent); background: var(--panel-solid); border-radius: 8px; white-space: pre-wrap; overflow-wrap: anywhere; }
.appeal-card .meta { font-size: 13px; color: var(--muted); }
.status-pill { display: inline-flex; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 680; background: var(--field); border: 1px solid var(--line); }
.status-accepted { color: var(--win); border-color: currentColor; }
.status-reduced { color: #b7791f; border-color: currentColor; }
.status-denied { color: var(--danger); border-color: currentColor; }
.status-open { color: var(--accent); border-color: currentColor; }
.warning-modal .warn-reason { padding: 12px 14px; border-radius: var(--r-tile); background: rgba(217, 140, 30, .14); border: 1px solid rgba(217, 140, 30, .4); white-space: pre-wrap; overflow-wrap: anywhere; }
@media (max-width: 560px) { .mod-ratings { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
/* Profile header: badges on one line, the full name below when space runs out. */
.profile-name .name-tag { flex-wrap: wrap; row-gap: 6px; }
.profile-name .rank, .profile-name .title-tag { font-size: 14px; }
.profile-name .name-text { white-space: normal; overflow: visible; overflow-wrap: anywhere; flex-basis: auto; }
/* Player cards: the flag and rating always show in full after the name; a long name shortens with an
   ellipsis instead of running over them. Rank and title badges never shrink. */
.plate-name .name-tag { flex: 0 1 auto; min-width: 0; max-width: none; overflow: hidden; padding-block: 2px; }
.plate-name .name-tag > :not(.name-link):not(.name-text) { flex: none; }
.plate-name .name-tag .name-link, .plate-name .name-tag .name-text { flex: 0 1 auto; min-width: 0; max-width: 11em; }
.plate-name > :not(.name-tag) { flex: none; }
.owner-shield { display: flex; gap: 12px; align-items: flex-start; padding: 14px; border-radius: var(--r-tile); margin-top: 12px;
  background: linear-gradient(135deg, rgba(255, 75, 75, .14), rgba(179, 18, 26, .08)); border: 1px solid rgba(220, 40, 50, .35); }
.owner-shield > svg { color: #d11f29; flex: none; margin-top: 2px; }
.owner-shield b { color: #c0151f; }
.notice { display: flex; gap: 12px; align-items: flex-start; padding: 12px 4px; border-bottom: 1px solid var(--line); }
.notice:last-child { border-bottom: 0; }
.notice > svg { flex: none; margin-top: 3px; color: var(--muted); }
.notice.unread > svg { color: var(--accent); }
.notice .notice-title { font-weight: 640; }
.notice.unread .notice-title::after { content: ''; display: inline-block; width: 7px; height: 7px; margin-left: 7px; border-radius: 50%; background: var(--accent); vertical-align: middle; }
.notice .meta { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
details summary { cursor: pointer; color: var(--muted); }
/* ---- player search ------------------------------------------------------------------------------ */
.search-box { display: flex; align-items: center; gap: 8px; padding: 0 12px; border-radius: var(--r-field, 10px); background: var(--field); border: 1px solid var(--line); margin-top: 6px; }
.search-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.search-box > svg { color: var(--muted); flex: none; }
.search-box input[type='search'] { border: 0; background: transparent; box-shadow: none; padding: 11px 0; flex: 1; min-width: 0; }
.search-box input[type='search']:focus { outline: none; box-shadow: none; }
a.player-row { display: flex; align-items: center; gap: 12px; padding: 10px 6px; border-radius: 10px; color: inherit; text-decoration: none; }
a.player-row:hover, a.player-row:focus-visible { background: var(--field); }
a.player-row + a.player-row { border-top: 1px solid var(--line); }
.player-rating { display: grid; justify-items: end; line-height: 1.2; }
.player-rating b { font-size: 16px; font-variant-numeric: tabular-nums; }
.grow { flex: 1; min-width: 0; }
.online-pill { white-space: nowrap; }
/* Collapse nav labels to icons before the top bar runs out of room (hover shows the name). */
@media (max-width: 1420px) {
  .nav.crowded a span { display: none; }
  .nav.crowded a { padding: 7px 10px; }
}
@media (max-width: 1120px) {
  #topbar { gap: 14px; }
  .nav a span { display: none; }
  .nav a { padding: 7px 10px; }
}
.mod-record { grid-template-columns: repeat(3, minmax(0, 1fr)); }
/* ---- level picker ---------------------------------------------------------------------------- */
.level-grid { display: grid; gap: 6px; }
button.level { display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto; column-gap: 12px; align-items: center; text-align: left;
  padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--field); color: var(--ink); cursor: pointer; font: inherit; }
button.level:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); }
button.level.active { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 30%, transparent); }
button.level b { grid-column: 1; font-weight: 680; }
button.level .small { grid-column: 1; }
button.level .level-r { grid-column: 2; grid-row: 1 / span 2; font-weight: 760; font-variant-numeric: tabular-nums; color: var(--muted); }
button.level.active .level-r { color: var(--accent); }

/* ---- homepage ------------------------------------------------------------------------------------ */
/* The wordmark sits on the board itself, bottom left, like a title card over the scene. */
.home-hero {
  position: absolute; left: 28px; bottom: 34px; max-width: min(56vw, 780px); pointer-events: none !important;
  color: #fff; animation: rise .6s var(--ease) both;
}
.home-hero::before {
  content: ''; position: absolute; inset: -60px -80px -40px -60px; z-index: -1; pointer-events: none;
  background: radial-gradient(ellipse at 25% 70%, rgba(6, 12, 24, .42), rgba(6, 12, 24, 0) 68%);
}
.home-wordmark {
  margin: 0; font-size: clamp(64px, 10.5vw, 156px); line-height: .86; font-weight: 870; font-stretch: 125%;
  letter-spacing: -0.04em; text-shadow: 0 2px 30px rgba(0, 0, 0, .28);
}
/* Once the 3D glass letters are drawn over it, the HTML wordmark stays for layout and screen readers. */
.home-wordmark { width: fit-content; }
.home-wordmark.is-glass { color: transparent; text-shadow: none; pointer-events: auto; user-select: none; -webkit-user-select: none; }
.home-line { margin: 16px 0 0; font-size: 19px; line-height: 1.42; font-weight: 500; font-stretch: 102%; max-width: 38ch; text-shadow: 0 1px 12px rgba(0, 0, 0, .45); }
.home-hello { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.home-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
a.home-card {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px; border-radius: 12px; text-decoration: none; color: var(--ink);
  background: var(--field); border: 1px solid var(--line); transition: border-color .15s, transform .15s;
}
a.home-card:hover, a.home-card:focus-visible { border-color: var(--accent); }
a.home-card:active { transform: translateY(1px); }
a.home-card > svg { flex: none; color: var(--accent); margin-top: 1px; }
.home-card-text { display: grid; gap: 2px; min-width: 0; }
.home-card-text b { font-weight: 680; }
.home-card-text span { font-size: 13px; line-height: 1.35; color: var(--muted); }
.home-notes { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.home-notes li { display: grid; gap: 2px; font-size: 14px; line-height: 1.4; }
.home-notes li span { color: var(--muted); }
@media (max-width: 900px) {
  .home-hero { left: 16px; bottom: 18px; max-width: calc(100vw - 32px); }
  .home-wordmark { font-size: 58px; }
  .home-line { font-size: 14.5px; margin-top: 8px; }
}
@media (max-width: 420px) { .home-grid { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) { .home-hero { animation: none; } }
