/* ============================================================
   DESIGN TOKENS — dark mode (default)
============================================================ */
:host {
  --nc-neon: #ff45c8;
  --nc-neon-soft: rgba(255, 69, 200, 0.55);
  --nc-neon-clock-bg: rgba(255, 69, 200, 0.08);
  --nc-bg: #06060d;
  --nc-surface: rgba(20, 17, 42, 0.6);
  --nc-surface-solid: rgba(10, 8, 22, 0.95);
  --nc-text: #fff;
  --nc-text-muted: rgba(255, 255, 255, 0.65);
  --nc-text-dim: rgba(255, 255, 255, 0.45);
  --nc-border: rgba(255, 255, 255, 0.08);
  --nc-border-strong: rgba(255, 255, 255, 0.15);
  --nc-warning: #ffb13a;
  --nc-warning-soft: rgba(255, 177, 58, 0.4);
  --nc-danger: #ff7a7a;
  --nc-danger-soft: rgba(255, 122, 122, 0.3);
  --nc-danger-bg: rgba(255, 122, 122, 0.08);
  --nc-success: #5ee5a1;
  --nc-clock-bg: rgba(0, 0, 0, 0.4);
  --nc-btn-bg: rgba(255, 255, 255, 0.03);
  --nc-btn-hover-bg: rgba(255, 255, 255, 0.07);
  --nc-seg-bg: rgba(0, 0, 0, 0.3);
  --nc-sans: "Space Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --nc-mono: "JetBrains Mono", ui-monospace, "SF Mono", monospace;
}

/* ============================================================
   LIGHT MODE TOKEN OVERRIDES  (sunset-gradient palette)
============================================================ */
:host-context(html:not([data-theme='dark'])) {
  --nc-neon: #ff3dbb;
  --nc-neon-soft: rgba(255, 61, 187, 0.55);
  --nc-neon-clock-bg: rgba(255, 61, 187, 0.08);
  --nc-bg: transparent;
  --nc-surface: rgba(26, 24, 56, 0.72);
  --nc-surface-solid: rgba(26, 24, 56, 0.97);
  --nc-text: #fff;
  --nc-text-muted: rgba(255, 255, 255, 0.72);
  --nc-text-dim: rgba(255, 255, 255, 0.45);
  --nc-border: rgba(255, 255, 255, 0.10);
  --nc-border-strong: rgba(255, 255, 255, 0.18);
  --nc-warning: #ffb13a;
  --nc-warning-soft: rgba(255, 177, 58, 0.40);
  --nc-danger: #ff7a7a;
  --nc-danger-soft: rgba(255, 122, 122, 0.30);
  --nc-danger-bg: rgba(255, 122, 122, 0.08);
  --nc-success: #5ee5a1;
  --nc-clock-bg: rgba(0, 0, 0, 0.30);
  --nc-btn-bg: rgba(255, 255, 255, 0.05);
  --nc-btn-hover-bg: rgba(255, 255, 255, 0.10);
  --nc-seg-bg: rgba(0, 0, 0, 0.28);
}

/* ============================================================
   SHELL & AMBIENT BG
============================================================ */
.game-shell {
  min-height: 100dvh;
  background: var(--nc-bg);
  font-family: var(--nc-sans);
  color: var(--nc-text);
  position: relative;
}

.game-shell::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 20% 100%, rgba(212, 77, 74, 0.08), transparent 60%),
    radial-gradient(ellipse 60% 40% at 90% 0%, rgba(74, 41, 98, 0.18), transparent 60%);
  pointer-events: none;
  z-index: 0;
}

:host-context(html:not([data-theme='dark'])) .game-shell::before {
  background:
    radial-gradient(ellipse 80% 50% at 20% 100%, rgba(212, 77, 74, 0.10), transparent 60%),
    radial-gradient(ellipse 60% 40% at 90% 0%, rgba(74, 41, 98, 0.22), transparent 60%);
}

/* ============================================================
   PAGE CONTAINER
============================================================ */
.page {
  position: relative;
  z-index: 1;
  max-width: 1320px;
  margin: 0 auto;
  padding: 28px 32px 60px;
}

/* ============================================================
   BREADCRUMB
============================================================ */
.crumb {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  font-family: var(--nc-mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.crumb-link {
  color: var(--nc-text-dim);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: color 0.15s;
}

.crumb-link:hover { color: var(--nc-neon); }
.crumb-sep { color: var(--nc-text-dim); opacity: 0.5; }
.crumb-current { color: var(--nc-text-muted); }

/* ============================================================
   GAME HEADER
============================================================ */
.game-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--nc-border);
}

.game-title {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.game-title h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--nc-text);
  display: inline-flex;
  align-items: center;
  gap: 14px;
}

.tag-rated {
  font-family: var(--nc-mono);
  font-size: 10px;
  letter-spacing: 0.22em;
  color: var(--nc-neon);
  border: 1px solid var(--nc-neon-soft);
  padding: 4px 10px;
  text-transform: uppercase;
}

.game-meta-strip {
  display: flex;
  align-items: center;
  gap: 14px;
  font-family: var(--nc-mono);
  font-size: 11px;
  color: var(--nc-text-dim);
  letter-spacing: 0.06em;
}

.game-id {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--nc-text-muted);
}

.game-id strong { color: var(--nc-text); font-weight: 500; }

.meta-dot {
  width: 3px;
  height: 3px;
  background: var(--nc-text-dim);
  border-radius: 50%;
  flex-shrink: 0;
}

.copy-btn {
  background: transparent;
  border: none;
  color: var(--nc-text-dim);
  cursor: pointer;
  padding: 2px 4px;
  display: inline-flex;
  transition: color 0.15s;
}

.copy-btn:hover { color: var(--nc-neon); }

.header-actions { display: flex; gap: 8px; align-items: center; }

/* ============================================================
   BUTTONS
============================================================ */
.btn {
  font-family: var(--nc-sans);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 600;
  padding: 9px 14px;
  cursor: pointer;
  border: 1px solid var(--nc-border-strong);
  background: var(--nc-btn-bg);
  color: var(--nc-text);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s, border-color 0.15s;
}

.btn:hover {
  background: var(--nc-btn-hover-bg);
  border-color: var(--nc-text-muted);
}

.btn-primary {
  background: var(--nc-neon) !important;
  color: #fff !important;
  border-color: var(--nc-neon) !important;
  box-shadow: 0 0 14px rgba(255, 69, 200, 0.3);
  font-weight: 700;
  padding: 9px 14px;
  flex-shrink: 0;
}

.btn-primary:hover { box-shadow: 0 0 20px rgba(255, 69, 200, 0.5); }

.btn-ghost {
  background: transparent;
  border: none;
  color: var(--nc-text-muted);
  padding: 8px 12px;
  font-size: 12px;
  letter-spacing: 0.04em;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--nc-sans);
  transition: color 0.15s;
}

.btn-ghost:hover { color: var(--nc-neon); }

/* ============================================================
   STATE MESSAGES (loading / error)
============================================================ */
.state-message {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px;
  font-family: var(--nc-mono);
  font-size: 13px;
  color: var(--nc-text-muted);
  letter-spacing: 0.06em;
}

.state-error {
  color: var(--nc-danger);
  background: var(--nc-danger-bg);
  border: 1px solid var(--nc-danger-soft);
}

/* ============================================================
   COMPLETION BANNER
============================================================ */
.completion-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  margin-bottom: 24px;
  background: rgba(255, 69, 200, 0.06);
  border: 1px solid var(--nc-neon-soft);
  animation: slideIn 0.35s ease-out;
}

.completion-banner--timeout {
  background: rgba(255, 177, 58, 0.06);
  border-color: var(--nc-warning-soft);
}

.completion-banner--timeout .completion-title {
  color: var(--nc-warning);
}

.completion-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.completion-icon {
  font-size: 22px;
  opacity: 0.7;
}

.completion-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.completion-new {
  font-size: 11px !important;
  padding: 8px 14px !important;
  text-decoration: none;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.completion-title { font-size: 15px; font-weight: 700; color: var(--nc-neon); }

.completion-sub {
  font-family: var(--nc-mono);
  font-size: 10px;
  color: var(--nc-text-dim);
  letter-spacing: 0.08em;
  margin-top: 2px;
}

.completion-link {
  font-family: var(--nc-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--nc-text-muted);
  text-decoration: none;
  border-bottom: 1px solid var(--nc-border-strong);
  padding-bottom: 2px;
  transition: color 0.15s, border-color 0.15s;
  flex-shrink: 0;
}

.completion-link:hover { color: var(--nc-neon); border-color: var(--nc-neon-soft); }

/* ============================================================
   MAIN GRID
============================================================ */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 28px;
  align-items: start;
}

/* ============================================================
   BOARD COLUMN
============================================================ */
.board-col {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 520px;
  width: 100%;
  margin: 0 auto;
}

.status-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: rgba(255, 69, 200, 0.05);
  border: 1px solid rgba(255, 69, 200, 0.15);
  font-size: 12px;
}

:host-context(html:not([data-theme='dark'])) .status-strip {
  background: rgba(255, 61, 187, 0.06);
  border-color: rgba(255, 61, 187, 0.20);
}

.status-left { display: inline-flex; align-items: center; gap: 10px; }

.status-pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--nc-neon);
  box-shadow: 0 0 6px var(--nc-neon);
  animation: pulse 1.8s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.35; transform: scale(0.7); }
}

.status-text { font-weight: 500; color: var(--nc-text); letter-spacing: 0.02em; }

.status-side {
  font-family: var(--nc-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--nc-text-dim);
}

/* container-type + aspect-ratio give cqw/cqh a defined size for the chess-board component */
.board-wrap {
  container-type: size;
  aspect-ratio: 1 / 1;
  padding: 10px;
  background: var(--nc-surface);
  border: 1px solid var(--nc-border);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 69, 200, 0.06);
}

:host-context(html:not([data-theme='dark'])) .board-wrap {
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(255, 61, 187, 0.08);
}

.board-wrap.reviewing {
  border-color: var(--nc-warning-soft);
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 177, 58, 0.18);
}

/* ============================================================
   SIDE COLUMN
============================================================ */
.side { display: flex; flex-direction: column; gap: 12px; }

.side-card {
  background: var(--nc-surface);
  border: 1px solid var(--nc-border);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.side-card-summary {
  list-style: none;
  cursor: pointer;
  padding: 13px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
}

.side-card-summary::-webkit-details-marker { display: none; }

.side-card-title {
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--nc-text-muted);
  font-weight: 600;
  flex: 1;
}

.side-card-meta {
  font-family: var(--nc-mono);
  font-size: 10px;
  color: var(--nc-text-dim);
  letter-spacing: 0.08em;
}

.chev { color: var(--nc-text-dim); flex-shrink: 0; transition: transform 0.2s; }
.side-card[open] .chev { transform: rotate(180deg); }
.side-card[open] .side-card-summary { border-bottom: 1px solid var(--nc-border); }

.side-card-body {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ============================================================
   UCI INPUT
============================================================ */
.uci-row { display: flex; gap: 6px; }

.uci-input {
  flex: 1;
  background: var(--nc-clock-bg);
  border: 1px solid var(--nc-border);
  color: var(--nc-text);
  font-family: var(--nc-mono);
  font-size: 13px;
  padding: 9px 12px;
  letter-spacing: 0.04em;
  outline: none;
  transition: border-color 0.15s;
}

.uci-input:focus { border-color: var(--nc-neon-soft); }
.uci-input::placeholder { color: var(--nc-text-dim); }

.uci-hint { margin: 0; font-size: 11px; color: var(--nc-text-dim); line-height: 1.4; }

/* ============================================================
   BOARD DESIGN SEGMENTED CONTROL
============================================================ */
.seg {
  display: flex;
  border: 1px solid var(--nc-border);
  padding: 2px;
  background: var(--nc-seg-bg);
}

.seg-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--nc-text-muted);
  padding: 7px 10px;
  font-size: 11px;
  font-family: var(--nc-sans);
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.seg-btn.active { background: var(--nc-neon); color: #fff; font-weight: 700; }

/* ============================================================
   RESIGN CONFIRM OVERLAY
============================================================ */
.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 600;
}

.confirm-box {
  background: var(--nc-surface-solid);
  border: 1px solid var(--nc-danger-soft);
  padding: 28px 32px;
  min-width: 300px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.confirm-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--nc-text);
}

.confirm-sub {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--nc-text-muted);
}

.confirm-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.btn-danger-solid {
  background: var(--nc-danger) !important;
  color: #fff !important;
  border-color: var(--nc-danger) !important;
  font-weight: 700;
}

.btn-danger-solid:hover { opacity: 0.88; }

/* ============================================================
   TOAST
============================================================ */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--nc-surface-solid);
  border: 1px solid var(--nc-neon-soft);
  color: var(--nc-text);
  padding: 10px 18px;
  font-size: 12px;
  font-family: var(--nc-mono);
  letter-spacing: 0.08em;
  z-index: 500;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ============================================================
   RESPONSIVE
============================================================ */
@media (max-width: 1100px) {
  .layout { grid-template-columns: 1fr; }
  .board-col { max-width: 560px; margin: 0 auto; }
}

@media (max-width: 640px) {
  .page { padding: 16px 16px 48px; }
  .game-header { flex-direction: column; align-items: flex-start; gap: 12px; }
  .game-title h1 { font-size: 20px; }
}
