/* RushChess GUI — dark glass aesthetic */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg0: #0b0e14;
  --bg1: #11151f;
  --glass: rgba(255, 255, 255, 0.045);
  --glass-hi: rgba(255, 255, 255, 0.09);
  --stroke: rgba(255, 255, 255, 0.08);
  --text: #e8ecf4;
  --text-dim: #94a3b8;
  --accent: #6c8cff;
  --accent2: #9f6cff;
  --good: #4ade80;
  --bad: #f87171;
  /* board theme (JS overrides these) */
  --sq-light: #e8e0cf;
  --sq-dark: #9c8465;
  --sq-hl: rgba(255, 213, 79, 0.45);
  --sq-hl-strong: rgba(255, 213, 79, 0.75);
  --board-glow: rgba(108, 140, 255, 0.18);
}

html, body { height: 100%; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background:
    radial-gradient(1200px 800px at 15% -10%, #1a2138 0%, transparent 55%),
    radial-gradient(1000px 700px at 110% 110%, #241a38 0%, transparent 55%),
    linear-gradient(160deg, var(--bg0), var(--bg1));
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

.bg-glow { position: fixed; border-radius: 50%; filter: blur(120px); opacity: .35; pointer-events: none; z-index: 0; }
.bg-glow-1 { width: 480px; height: 480px; background: #2b3a6e; top: -140px; left: -120px; animation: drift 18s ease-in-out infinite alternate; }
.bg-glow-2 { width: 420px; height: 420px; background: #4a2b6e; bottom: -160px; right: -100px; animation: drift 22s ease-in-out infinite alternate-reverse; }
@keyframes drift { from { transform: translate(0, 0) } to { transform: translate(60px, 40px) } }

/* ===== top bar ===== */
.topbar {
  position: relative; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 26px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 44px; height: 44px; border-radius: 13px;
  display: grid; place-items: center; font-size: 26px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  box-shadow: 0 6px 24px rgba(108, 140, 255, .35);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-size: 20px; font-weight: 700; letter-spacing: .3px; }
.brand-name em { font-style: normal; background: linear-gradient(90deg, var(--accent), var(--accent2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.brand-sub { font-size: 11.5px; color: var(--text-dim); }
.topbar-actions { display: flex; align-items: center; gap: 12px; }

.theme-dots { display: flex; gap: 8px; padding: 8px 10px; border-radius: 12px; background: var(--glass); border: 1px solid var(--stroke); }
.theme-dot { width: 20px; height: 20px; border-radius: 7px; cursor: pointer; border: 2px solid transparent; transition: transform .15s, border-color .15s; }
.theme-dot:hover { transform: scale(1.15); }
.theme-dot.active { border-color: #fff; }

/* ===== layout ===== */
.layout {
  position: relative; z-index: 2;
  display: flex; justify-content: center; align-items: flex-start;
  gap: 26px; padding: 6px 26px 32px;
  flex-wrap: wrap;
}

/* ===== board column ===== */
.board-col { display: flex; flex-direction: column; gap: 10px; }

.player-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 14px; border-radius: 14px;
  background: var(--glass); border: 1px solid var(--stroke);
  backdrop-filter: blur(10px);
  min-height: 52px;
}
.player-bar.active-turn { border-color: rgba(108, 140, 255, .55); box-shadow: 0 0 0 1px rgba(108,140,255,.25), 0 4px 18px rgba(108,140,255,.12); }
.avatar {
  width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center;
  font-size: 21px; background: var(--glass-hi); border: 1px solid var(--stroke);
}
.player-meta { display: flex; flex-direction: column; gap: 1px; flex: 1; min-width: 0; }
.player-name { font-weight: 600; font-size: 14.5px; }
.captured { font-size: 15px; letter-spacing: 1px; color: var(--text-dim); min-height: 18px; white-space: nowrap; overflow: hidden; }
.captured .mat-diff { color: var(--good); font-size: 12px; font-weight: 700; margin-left: 6px; }

.clock {
  font-variant-numeric: tabular-nums; font-weight: 800; font-size: 19px;
  padding: 5px 12px; border-radius: 10px;
  background: rgba(0, 0, 0, .3); border: 1px solid var(--stroke);
  letter-spacing: .5px;
}
.clock.running { border-color: rgba(108, 140, 255, .55); color: #fff; box-shadow: 0 0 14px rgba(108, 140, 255, .18); }
.clock.low { color: #f87171; border-color: rgba(248, 113, 113, .5); animation: lowtime 1s ease-in-out infinite; }
@keyframes lowtime { 0%, 100% { background: rgba(0,0,0,.3) } 50% { background: rgba(248,113,113,.18) } }

.think-indicator { display: none; gap: 4px; }
.think-indicator.on { display: flex; }
.think-indicator span { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); animation: pulse 1s ease-in-out infinite; }
.think-indicator span:nth-child(2) { animation-delay: .18s; }
.think-indicator span:nth-child(3) { animation-delay: .36s; }
@keyframes pulse { 0%, 100% { opacity: .25; transform: scale(.8) } 50% { opacity: 1; transform: scale(1.15) } }

/* ===== board + eval ===== */
.board-frame { display: flex; gap: 14px; align-items: stretch; }

.eval-wrap { display: flex; flex-direction: column; align-items: center; gap: 8px; width: 26px; }
.eval-bar {
  flex: 1; width: 14px; border-radius: 8px; overflow: hidden;
  background: linear-gradient(180deg, #23262e, #16181f);
  border: 1px solid var(--stroke); position: relative;
  display: flex; flex-direction: column; justify-content: flex-end;
}
.eval-white {
  width: 100%; height: 50%;
  background: linear-gradient(180deg, #ffffff, #cfd6e4);
  transition: height .6s cubic-bezier(.2, .8, .2, 1);
  border-radius: 0 0 7px 7px;
}
.eval-label { font-size: 10.5px; font-weight: 700; color: var(--text-dim); font-variant-numeric: tabular-nums; }

.board-outer {
  padding: 12px; border-radius: 20px;
  background: linear-gradient(145deg, rgba(255,255,255,.07), rgba(255,255,255,.02));
  border: 1px solid var(--stroke);
  box-shadow: 0 30px 70px rgba(0, 0, 0, .5), 0 0 90px var(--board-glow);
  backdrop-filter: blur(8px);
}
.board {
  position: relative;
  width: min(76vh, 82vw, 640px);
  aspect-ratio: 1;
  border-radius: 10px; overflow: hidden;
  user-select: none; touch-action: none;
}
.board-squares, .board-hl, .board-pieces, .board-hints { position: absolute; inset: 0; }
.board-arrows { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 6; }

.sqr { position: absolute; width: 12.5%; height: 12.5%; }
.sqr.light { background: var(--sq-light); }
.sqr.dark { background: var(--sq-dark); }

.hl { position: absolute; width: 12.5%; height: 12.5%; pointer-events: none; }
.hl-last { background: var(--sq-hl); }
.hl-sel { background: var(--sq-hl-strong); }
.hl-check {
  background: radial-gradient(circle, rgba(248, 90, 90, .85) 0%, rgba(248, 90, 90, .35) 55%, transparent 75%);
  animation: checkpulse 1.1s ease-in-out infinite;
}
@keyframes checkpulse { 0%, 100% { opacity: .75 } 50% { opacity: 1 } }

.hint { position: absolute; width: 12.5%; height: 12.5%; display: grid; place-items: center; cursor: pointer; z-index: 5; }
.hint::after { content: ''; width: 30%; height: 30%; border-radius: 50%; background: rgba(20, 24, 34, .35); transition: transform .12s; }
.hint.capture::after { width: 84%; height: 84%; background: transparent; border: 5px solid rgba(20, 24, 34, .35); }
.hint:hover::after { transform: scale(1.25); }

.piece {
  position: absolute; width: 12.5%; height: 12.5%;
  display: grid; place-items: center;
  cursor: grab; z-index: 3;
  transition: transform .22s cubic-bezier(.25, .9, .3, 1.15);
  will-change: transform;
}
.piece.dragging { transition: none; z-index: 20; cursor: grabbing; }
.piece.no-anim { transition: none; }
.piece-svg { width: 92%; height: 92%; filter: drop-shadow(0 4px 5px rgba(0, 0, 0, .45)); pointer-events: none; }

/* piece colors */
.piece-w .pc-body { fill: url(#pgw); }
.piece-w .pc-line { stroke: #3a4150; stroke-width: 3.2; stroke-linejoin: round; stroke-linecap: round; }
.piece-w .pc-cut { stroke: #3a4150; stroke-width: 4.5; stroke-linecap: round; }
.piece-w .pc-gleam { fill: rgba(255, 255, 255, .85); }
.piece-w .pc-gleamline { stroke: rgba(255, 255, 255, .8); stroke-width: 3; stroke-linecap: round; }
.piece-w .pc-dot { fill: #3a4150; }
.piece-b .pc-body { fill: url(#pgb); }
.piece-b .pc-line { stroke: #05070c; stroke-width: 3.2; stroke-linejoin: round; stroke-linecap: round; }
.piece-b .pc-cut { stroke: #cfd6e4; stroke-width: 4.5; stroke-linecap: round; }
.piece-b .pc-gleam { fill: rgba(255, 255, 255, .28); }
.piece-b .pc-gleamline { stroke: rgba(255, 255, 255, .35); stroke-width: 3; stroke-linecap: round; }
.piece-b .pc-dot { fill: #e8ecf4; }

/* coordinates */
.coords { position: absolute; pointer-events: none; font-size: 11px; font-weight: 700; z-index: 4; }
.coords span { position: absolute; opacity: .75; }
.coords-files { inset: auto 0 2px 0; height: 14px; }
.coords-files span { bottom: 0; width: 12.5%; text-align: right; padding-right: 5px; }
.coords-ranks { inset: 0 auto 0 3px; width: 12px; }
.coords-ranks span { height: 12.5%; left: 0; padding-top: 3px; }

/* promotion picker */
.promo-picker {
  position: absolute; z-index: 30; width: 12.5%;
  display: flex; flex-direction: column;
  background: #1a1f2c; border: 1px solid var(--stroke); border-radius: 10px;
  box-shadow: 0 16px 50px rgba(0, 0, 0, .6); overflow: hidden;
}
.promo-opt { aspect-ratio: 1; display: grid; place-items: center; cursor: pointer; }
.promo-opt:hover { background: var(--glass-hi); }
.promo-opt svg { width: 86%; height: 86%; }

/* arrows */
.arrow-hint { fill: rgba(108, 220, 130, .75); }

/* ===== side panel ===== */
.panel {
  width: 340px; display: flex; flex-direction: column; gap: 14px;
  padding: 18px; border-radius: 20px;
  background: var(--glass); border: 1px solid var(--stroke);
  backdrop-filter: blur(14px);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .35);
  align-self: stretch;
  max-height: calc(min(76vh, 82vw, 640px) + 148px);
}

.status-card {
  padding: 12px 16px; border-radius: 14px;
  background: linear-gradient(135deg, rgba(108, 140, 255, .14), rgba(159, 108, 255, .1));
  border: 1px solid rgba(108, 140, 255, .28);
}
.status-main { font-weight: 700; font-size: 15.5px; }
.status-sub { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.status-open { font-size: 12px; margin-top: 4px; color: #b9c6ff; font-weight: 600; }
.status-open:empty { display: none; }

.panel-tabs { display: flex; gap: 6px; }
.tab {
  flex: 1; padding: 8px 4px; border: none; border-radius: 10px; cursor: pointer;
  background: transparent; color: var(--text-dim); font-weight: 600; font-size: 13px;
  font-family: inherit; transition: background .15s, color .15s;
}
.tab:hover { background: var(--glass-hi); color: var(--text); }
.tab.active { background: var(--glass-hi); color: var(--text); box-shadow: inset 0 0 0 1px var(--stroke); }

.tab-page { display: flex; flex-direction: column; gap: 12px; flex: 1; min-height: 0; }
.hidden { display: none !important; }

/* move list */
.move-list {
  flex: 1; min-height: 120px; overflow-y: auto;
  border-radius: 12px; background: rgba(0, 0, 0, .22); border: 1px solid var(--stroke);
  padding: 8px; font-size: 13.5px;
  display: grid; grid-template-columns: 34px 1fr 1fr; align-content: start; gap: 2px 4px;
}
.move-empty { grid-column: 1 / -1; color: var(--text-dim); font-size: 12.5px; padding: 10px; text-align: center; }
.mv-no { color: var(--text-dim); text-align: right; padding: 3px 4px; font-variant-numeric: tabular-nums; }
.mv {
  padding: 3px 8px; border-radius: 7px; cursor: pointer; font-weight: 600;
  transition: background .12s;
  white-space: nowrap;
}
.mv:hover { background: var(--glass-hi); }
.mv.current { background: linear-gradient(90deg, rgba(108, 140, 255, .35), rgba(159, 108, 255, .25)); }

.move-list::-webkit-scrollbar { width: 8px; }
.move-list::-webkit-scrollbar-thumb { background: var(--glass-hi); border-radius: 4px; }

.nav-row { display: flex; gap: 6px; }
.nav-btn { flex: 1; font-size: 13px; padding: 7px 0; }

.action-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* buttons */
.btn {
  padding: 9px 14px; border-radius: 11px; border: 1px solid var(--stroke);
  background: var(--glass-hi); color: var(--text); font-weight: 600; font-size: 13.5px;
  cursor: pointer; font-family: inherit;
  transition: transform .12s, background .15s, box-shadow .15s;
}
.btn:hover { background: rgba(255, 255, 255, .14); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .4; cursor: default; transform: none; }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--glass-hi); }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border: none; box-shadow: 0 8px 24px rgba(108, 140, 255, .35);
}
.btn-primary:hover { background: linear-gradient(135deg, #7d9aff, #ad7fff); box-shadow: 0 10px 30px rgba(108, 140, 255, .5); }
.btn-big { padding: 13px; font-size: 15px; }

/* engine tab */
.engine-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat {
  padding: 10px 12px; border-radius: 12px;
  background: rgba(0, 0, 0, .22); border: 1px solid var(--stroke);
  display: flex; flex-direction: column; gap: 2px;
}
.stat-label { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .8px; }
.stat-value { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }
.pv-title { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .8px; margin-top: 2px; }
.pv-lines { display: flex; flex-direction: column; gap: 6px; }
.pv-line {
  padding: 9px 12px; border-radius: 12px; background: rgba(0, 0, 0, .22);
  border: 1px solid var(--stroke); font-size: 12.5px; line-height: 1.55;
  color: var(--text); word-spacing: 2px;
  display: flex; align-items: baseline; gap: 8px;
}
.pv-eval {
  flex-shrink: 0; font-weight: 800; font-variant-numeric: tabular-nums; font-size: 12px;
  padding: 1px 7px; border-radius: 7px; background: rgba(108, 140, 255, .18);
  color: #b9c6ff;
}
.pv-moves { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toggle-row { display: flex; align-items: center; gap: 10px; font-size: 13.5px; cursor: pointer; padding: 4px 2px; }
.toggle-row input { accent-color: var(--accent); width: 16px; height: 16px; }
.engine-note { font-size: 12px; color: var(--text-dim); line-height: 1.5; }

/* setup tab */
.setup-group { display: flex; flex-direction: column; gap: 8px; }
.setup-label { font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .8px; font-weight: 700; }
.seg { display: flex; gap: 6px; }
.seg-btn {
  flex: 1; padding: 9px 6px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--stroke); background: transparent; color: var(--text-dim);
  font-weight: 600; font-size: 12.5px; font-family: inherit; transition: all .15s;
}
.seg-btn:hover { background: var(--glass-hi); color: var(--text); }
.seg-btn.active { background: linear-gradient(135deg, rgba(108, 140, 255, .3), rgba(159, 108, 255, .22)); color: var(--text); border-color: rgba(108, 140, 255, .5); }

.slider { width: 100%; accent-color: var(--accent); height: 4px; cursor: pointer; }
.level-scale { display: flex; justify-content: space-between; font-size: 11px; color: var(--text-dim); }

/* modal */
.modal-veil {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(5, 7, 12, .65); backdrop-filter: blur(6px);
  display: grid; place-items: center;
  animation: fadein .25s ease;
}
@keyframes fadein { from { opacity: 0 } to { opacity: 1 } }
.modal {
  width: min(380px, 88vw); padding: 34px 30px 26px; border-radius: 24px; text-align: center;
  background: linear-gradient(160deg, #1c2230, #141824);
  border: 1px solid var(--stroke);
  box-shadow: 0 40px 100px rgba(0, 0, 0, .6);
  animation: pop .35s cubic-bezier(.2, 1.4, .4, 1);
}
@keyframes pop { from { transform: scale(.85); opacity: 0 } to { transform: scale(1); opacity: 1 } }
.modal-icon {
  width: 72px; height: 72px; margin: 0 auto 14px; border-radius: 22px;
  display: grid; place-items: center; font-size: 40px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  box-shadow: 0 12px 40px rgba(108, 140, 255, .4);
}
.modal-title { font-size: 26px; font-weight: 800; }
.modal-sub { color: var(--text-dim); margin-top: 6px; font-size: 14.5px; }
.modal-actions { display: flex; gap: 10px; margin-top: 24px; }
.modal-actions .btn { flex: 1; padding: 12px; }

/* import modal */
.modal-wide { width: min(560px, 92vw); text-align: left; }
.modal-wide .modal-title { font-size: 20px; }
.import-text {
  width: 100%; height: 180px; margin-top: 14px; resize: vertical;
  padding: 12px; border-radius: 12px; border: 1px solid var(--stroke);
  background: rgba(0, 0, 0, .3); color: var(--text);
  font-family: Consolas, monospace; font-size: 12.5px; line-height: 1.5;
  outline: none;
}
.import-text:focus { border-color: rgba(108, 140, 255, .5); }

/* toast */
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translate(-50%, 20px);
  padding: 11px 20px; border-radius: 12px; z-index: 120;
  background: #1c2230; border: 1px solid var(--stroke); font-size: 13.5px; font-weight: 600;
  box-shadow: 0 14px 40px rgba(0, 0, 0, .5);
  opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* responsive */
@media (max-width: 1080px) {
  .layout { flex-direction: column; align-items: center; }
  .panel { width: min(680px, 94vw); max-height: none; }
  .board { width: min(94vw, 70vh, 640px); }
}
