/* ============================================================
   BATTLEFRONT CHESS: MILITARY EDITION — holographic HUD styles
   Pure CSS, system fonts only, no external resources.
   ============================================================ */

:root {
  --holo: #4ef0c8;
  --holo-hi: #b8fff0;
  --holo-dim: rgba(78, 240, 200, 0.38);
  --holo-faint: rgba(78, 240, 200, 0.13);
  --enemy: #ff5a4a;
  --enemy-dim: rgba(255, 90, 74, 0.35);
  --warn: #ffc24d;
  --ink: #dff7f0;
  --ink-dim: rgba(223, 247, 240, 0.58);
  --bg-panel: rgba(5, 13, 16, 0.74);
  --bg-panel-solid: rgba(6, 15, 18, 0.94);
  --border: rgba(78, 240, 200, 0.30);
  --cut: 10px;
  --font-hud: "Bahnschrift", "DIN Alternate", "DIN Condensed", "Segoe UI", "Roboto Condensed", system-ui, sans-serif;
  --font-mono: "Cascadia Mono", "Consolas", "SF Mono", "Menlo", "Courier New", monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: #06090b;
  font-family: var(--font-hud);
  color: var(--holo);
  -webkit-user-select: none; user-select: none;
  -webkit-font-smoothing: antialiased;
}

#stage { position: relative; width: 100%; height: 100%; }

#glcanvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

/* ============ HUD shell ============ */
#hud { position: absolute; inset: 0; pointer-events: none; z-index: 10; }

.fx-scanlines {
  position: absolute; inset: 0; pointer-events: none; opacity: 0.05;
  background: repeating-linear-gradient(0deg, rgba(0,0,0,0.9) 0 1px, transparent 1px 3px);
}
.fx-vignette {
  position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(ellipse 75% 70% at 50% 52%, transparent 58%, rgba(0,0,0,0.55) 100%),
    linear-gradient(180deg, rgba(3,8,10,0.55) 0%, transparent 16%, transparent 84%, rgba(3,8,10,0.6) 100%);
}

/* angled-corner holo panel with corner brackets */
.panel {
  position: relative;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  clip-path: polygon(0 0, calc(100% - var(--cut)) 0, 100% var(--cut), 100% 100%, var(--cut) 100%, 0 calc(100% - var(--cut)));
  box-shadow: inset 0 0 30px rgba(78, 240, 200, 0.05);
  backdrop-filter: blur(6px) saturate(1.2);
  -webkit-backdrop-filter: blur(6px) saturate(1.2);
}
.panel::before, .panel::after {
  content: ""; position: absolute; width: 12px; height: 12px; pointer-events: none;
  border-color: var(--holo); border-style: solid; opacity: 0.9;
}
.panel::before { left: -1px; top: -1px; border-width: 2px 0 0 2px; }
.panel::after  { right: -1px; bottom: -1px; border-width: 0 2px 2px 0; }

.panel-head {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 11px; font-weight: 600; letter-spacing: 2.5px; color: var(--holo);
  white-space: nowrap; gap: 8px;
  padding: 9px 12px 7px;
  border-bottom: 1px solid var(--holo-faint);
  background: linear-gradient(90deg, rgba(78,240,200,0.10), transparent 70%);
  text-shadow: 0 0 8px var(--holo-dim);
}
.head-tag {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 1px;
  padding: 1px 6px; border: 1px solid var(--holo-faint); color: var(--ink-dim);
}

/* ============ Top bar ============ */
.hud-top {
  position: absolute; top: 14px; left: 16px; right: 16px;
  display: flex; gap: 12px; align-items: stretch;
}
.title-panel { display: flex; align-items: center; gap: 12px; padding: 9px 20px 9px 14px; flex: 0 0 auto; }
.insignia { width: 30px; height: 30px; color: var(--holo); filter: drop-shadow(0 0 6px var(--holo-dim)); }
.title-main {
  font-size: 20px; font-weight: 700; letter-spacing: 5px; line-height: 1;
  color: var(--ink); text-shadow: 0 0 14px rgba(78,240,200,0.55);
}
.title-main span { color: var(--holo); }
.title-sub { font-size: 9.5px; letter-spacing: 3px; color: var(--ink-dim); margin-top: 5px; }

.turn-panel {
  flex: 1; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 14px;
}
.turn-center { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.turn-line { display: flex; align-items: center; gap: 10px; font-size: 16px; font-weight: 600; letter-spacing: 5px; color: var(--ink); }
.turn-dot {
  width: 11px; height: 11px; transform: rotate(45deg);
  box-shadow: 0 0 12px currentColor;
}
.turn-dot.friendly { color: var(--holo); background: var(--holo); }
.turn-dot.enemy    { color: var(--enemy); background: var(--enemy); animation: pulse 0.9s ease-in-out infinite; }

.faction {
  display: flex; align-items: center; gap: 8px;
  font-size: 11px; font-weight: 600; letter-spacing: 3px;
  padding: 5px 12px; border: 1px solid transparent;
  color: var(--ink-dim); opacity: 0.55; transition: all 0.3s ease;
}
.faction i { width: 9px; height: 9px; display: inline-block; transform: rotate(45deg); }
.faction.allied i { background: #c9cfa8; box-shadow: 0 0 0 2px rgba(78,240,200,0.5); }
.faction.hostile i { background: #2a2420; box-shadow: 0 0 0 2px rgba(255,90,74,0.6); }
.faction.active { opacity: 1; }
.faction.allied.active { color: var(--holo); border-color: var(--holo-dim); background: rgba(78,240,200,0.10); box-shadow: 0 0 16px rgba(78,240,200,0.18); }
.faction.hostile.active { color: var(--enemy); border-color: var(--enemy-dim); background: rgba(255,90,74,0.10); box-shadow: 0 0 16px rgba(255,90,74,0.18); }

.check-badge {
  font-size: 10.5px; font-weight: 700; letter-spacing: 2.5px; color: #1a0c06;
  background: var(--warn); padding: 2px 10px;
  clip-path: polygon(6px 0, 100% 0, calc(100% - 6px) 100%, 0 100%);
  animation: blink 0.7s steps(2, start) infinite;
}
@keyframes blink { 50% { opacity: 0.4; } }

.clock-panel { padding: 8px 18px; text-align: center; min-width: 90px; display: flex; flex-direction: column; justify-content: center; }
.clock-panel .label { font-size: 10px; letter-spacing: 3px; color: var(--ink-dim); }
#moveCount { font-family: var(--font-mono); font-size: 24px; font-weight: bold; color: var(--ink); text-shadow: 0 0 10px var(--holo-dim); line-height: 1.1; }

/* ============ Move list ============ */
.hud-left {
  position: absolute; left: 16px; top: 96px; bottom: 64px;
  width: 200px; display: flex; flex-direction: column; overflow: hidden;
}
.move-list { flex: 1; overflow-y: auto; padding: 6px 6px 10px; font-family: var(--font-mono); font-size: 12.5px; }
.move-empty { color: var(--ink-dim); font-style: italic; padding: 8px 6px; font-size: 11.5px; }
.move-row {
  display: grid; grid-template-columns: 28px 1fr 1fr; gap: 4px;
  padding: 3px 6px; border-bottom: 1px solid rgba(78,240,200,0.06);
  animation: rowIn 0.35s ease-out;
}
.move-row:nth-child(odd) { background: rgba(78,240,200,0.025); }
.move-row .num { color: var(--ink-dim); opacity: 0.7; }
.move-row .white { color: #e6fff8; }
.move-row .black { color: #ff9d8f; }
.move-row .cap { font-weight: 700; }
.move-row .chk { text-decoration: underline; text-decoration-color: var(--warn); text-underline-offset: 3px; }
.move-row.latest { background: rgba(78,240,200,0.10); box-shadow: inset 2px 0 0 var(--holo); }
.move-row.latest .white, .move-row.latest .black { text-shadow: 0 0 8px currentColor; }
@keyframes rowIn { from { opacity: 0; transform: translateX(-8px); } to { opacity: 1; transform: none; } }

.move-list::-webkit-scrollbar { width: 5px; }
.move-list::-webkit-scrollbar-thumb { background: var(--holo-dim); }

/* ============ Right column ============ */
.hud-right {
  position: absolute; right: 16px; top: 96px;
  width: 214px; display: flex; flex-direction: column; gap: 12px;
}
.hud-controls { pointer-events: auto; }
.btn-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 10px; }
.btn-grid .wide, .btn-grid #btnSound { grid-column: span 2; }

.holo-btn {
  position: relative;
  font-family: var(--font-hud); font-weight: 600;
  font-size: 12px; letter-spacing: 2px;
  color: var(--holo);
  background: rgba(8, 26, 30, 0.85);
  border: 1px solid var(--border);
  padding: 9px 8px;
  cursor: pointer;
  clip-path: polygon(0 0, calc(100% - 7px) 0, 100% 7px, 100% 100%, 7px 100%, 0 calc(100% - 7px));
  transition: background 0.15s, color 0.15s, box-shadow 0.15s, transform 0.06s;
}
.holo-btn b {
  font-family: var(--font-mono); font-size: 9.5px; font-weight: 400; letter-spacing: 0;
  color: var(--ink-dim); border: 1px solid var(--holo-faint);
  padding: 0 4px; margin-right: 7px; vertical-align: 1px;
}
.holo-btn:hover:not(:disabled) {
  background: rgba(78, 240, 200, 0.18); color: var(--holo-hi);
  box-shadow: inset 0 0 18px rgba(78, 240, 200, 0.25);
}
.holo-btn:active:not(:disabled) { transform: translateY(1px); }
.holo-btn:disabled { opacity: 0.3; cursor: default; }
.holo-btn:focus-visible { outline: 1px solid var(--holo-hi); outline-offset: 2px; }
.holo-btn.primary { background: rgba(78, 240, 200, 0.20); border-color: var(--holo); color: var(--holo-hi); }
.holo-btn.primary:hover { background: rgba(78, 240, 200, 0.32); }

/* forces / casualties */
.forces-panel { padding-bottom: 10px; }
.balance {
  position: relative; height: 6px; margin: 12px 12px 10px;
  background: linear-gradient(90deg, rgba(78,240,200,0.18), rgba(255,90,74,0.18));
}
.balance::after { content: ""; position: absolute; left: 50%; top: -3px; bottom: -3px; width: 1px; background: var(--ink-dim); }
.balance-fill {
  position: absolute; top: 0; bottom: 0; left: 50%; width: 0;
  transition: all 0.5s cubic-bezier(.2,.8,.2,1);
}
.balance-fill.pos { background: var(--holo); box-shadow: 0 0 10px var(--holo); }
.balance-fill.neg { background: var(--enemy); box-shadow: 0 0 10px var(--enemy); }
.force-row { padding: 4px 12px; }
.force-label { font-size: 9.5px; letter-spacing: 2.5px; color: var(--ink-dim); margin-bottom: 3px; }
.casualties { min-height: 24px; display: flex; flex-wrap: wrap; gap: 1px; font-size: 19px; line-height: 1.2;
  font-family: "Segoe UI Symbol", "Noto Sans Symbols 2", "DejaVu Sans", sans-serif; }
.casualties .none { font-size: 12px; color: var(--ink-dim); opacity: 0.5; line-height: 24px; }
.force-row.allied .casualties span:not(.none) { color: #d8dcc0; text-shadow: 0 0 6px rgba(78,240,200,0.55); }
.force-row.hostile .casualties span:not(.none) { color: #ff7a6a; text-shadow: 0 0 6px rgba(255,90,74,0.6); }
.casualties span.pop { animation: pop 0.45s cubic-bezier(.2,1.6,.4,1); }
@keyframes pop { from { transform: scale(2.2); opacity: 0; } to { transform: none; opacity: 1; } }
#materialTag.pos { color: var(--holo); border-color: var(--holo-dim); }
#materialTag.neg { color: var(--enemy); border-color: var(--enemy-dim); }

/* ============ Thinking indicator ============ */
.thinking {
  position: absolute; left: 50%; transform: translateX(-50%);
  top: 84px;
  font-size: 12.5px; font-weight: 600; letter-spacing: 3px; color: var(--enemy);
  background: var(--bg-panel-solid); border: 1px solid var(--enemy-dim);
  padding: 8px 20px 10px;
  clip-path: polygon(8px 0, calc(100% - 8px) 0, 100% 50%, calc(100% - 8px) 100%, 8px 100%, 0 50%);
  overflow: hidden;
}
.think-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: rgba(255,90,74,0.15); }
.think-bar i { position: absolute; top: 0; bottom: 0; width: 30%; background: var(--enemy); box-shadow: 0 0 8px var(--enemy); animation: scan 1.1s ease-in-out infinite alternate; }
@keyframes scan { from { left: -30%; } to { left: 100%; } }
.pulse-dot {
  display: inline-block; width: 8px; height: 8px; transform: rotate(45deg);
  background: var(--enemy); margin-right: 8px; vertical-align: 1px;
  box-shadow: 0 0 10px var(--enemy);
  animation: pulse 0.9s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: 0.35; } }
.dots { animation: blink 1.2s steps(3, start) infinite; }

/* ============ Toast ============ */
.toast {
  position: absolute; left: 50%; top: 128px;
  font-size: 13px; font-weight: 600; letter-spacing: 2.5px; text-align: center;
  background: var(--bg-panel-solid);
  border: 1px solid currentColor; border-left-width: 3px;
  color: var(--warn);
  padding: 10px 26px;
  box-shadow: 0 0 24px rgba(0,0,0,0.5);
  transform: translateX(-50%);
  animation: toastIn 0.28s cubic-bezier(.2,.9,.3,1.2);
}
.toast.alert { color: var(--enemy); }
.toast.info { color: var(--holo); }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, -10px) scale(0.96); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ============ Bottom bar ============ */
.hud-bottom {
  position: absolute; left: 16px; right: 16px; bottom: 12px;
  display: flex; gap: 18px; align-items: center;
  font-size: 11px; letter-spacing: 1px; color: var(--ink-dim);
}
.intel { --cut: 7px; display: flex; align-items: center; gap: 10px; padding: 6px 14px 6px 8px; min-width: 260px; }
.intel::before, .intel::after { width: 8px; height: 8px; }
.intel-sq {
  font-family: var(--font-mono); font-size: 12px; font-weight: 700; color: #06120f;
  background: var(--holo); padding: 1px 6px; min-width: 30px; text-align: center;
}
.intel-txt { font-size: 11.5px; letter-spacing: 2px; color: var(--ink); white-space: nowrap; }
.intel.hostile .intel-sq { background: var(--enemy); }
.intel.hostile .intel-txt { color: #ffb0a6; }
.intel.empty .intel-sq { background: rgba(78,240,200,0.25); color: var(--ink); }
.intel.empty .intel-txt { color: var(--ink-dim); }
.legend { display: flex; gap: 16px; flex-wrap: wrap; }
.legend b { color: var(--ink); font-weight: 600; letter-spacing: 1.5px; }
.depth-info { margin-left: auto; font-family: var(--font-mono); color: var(--warn); letter-spacing: 1px; opacity: 0.85; }

/* ============ Modals ============ */
.modal {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, rgba(4,12,14,0.55), rgba(2,6,8,0.85));
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  pointer-events: auto; z-index: 30;
  animation: fadeIn 0.25s ease-out;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-box { width: 440px; max-width: 92vw; padding: 0 0 18px; background: var(--bg-panel-solid); animation: boxIn 0.3s cubic-bezier(.2,.9,.3,1.1); }
@keyframes boxIn { from { opacity: 0; transform: translateY(12px) scale(0.97); } to { opacity: 1; transform: none; } }
.settings-group { margin: 16px 18px 0; }
.settings-label { font-size: 10.5px; letter-spacing: 3px; color: var(--ink-dim); margin-bottom: 7px; }
.seg { display: flex; gap: 6px; }
.seg label { flex: 1; cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 12.5px; font-weight: 600; letter-spacing: 2px; color: var(--ink-dim);
  padding: 9px 4px 8px; border: 1px solid var(--holo-faint); background: rgba(78,240,200,0.03);
  transition: all 0.15s;
}
.seg small { font-size: 9.5px; font-weight: 400; letter-spacing: 1px; opacity: 0.75; }
.seg label:hover span { border-color: var(--border); color: var(--ink); }
.seg input:checked + span {
  color: var(--holo-hi); border-color: var(--holo);
  background: rgba(78,240,200,0.16); box-shadow: inset 0 0 14px rgba(78,240,200,0.2);
}
.seg input:focus-visible + span { outline: 1px solid var(--holo-hi); }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin: 20px 18px 0; }
.modal-actions .holo-btn { min-width: 110px; }

.result-box { text-align: center; width: 480px; padding: 26px 0 22px; overflow: hidden; }
.result-kicker { font-family: var(--font-mono); font-size: 11px; letter-spacing: 3px; color: var(--ink-dim); }
.result-title {
  font-size: 54px; font-weight: 700; letter-spacing: 14px; margin: 8px 0 8px; padding-left: 14px;
  text-shadow: 0 0 28px currentColor; color: var(--warn);
  animation: titleIn 0.8s cubic-bezier(.2,.9,.3,1);
}
@keyframes titleIn { from { letter-spacing: 40px; opacity: 0; filter: blur(6px); } to { letter-spacing: 14px; opacity: 1; filter: none; } }
.result-title.victory { color: var(--holo); }
.result-title.defeat  { color: var(--enemy); }
.result-modal.victory .result-box { border-color: var(--holo); box-shadow: 0 0 60px rgba(78,240,200,0.15), inset 0 0 40px rgba(78,240,200,0.08); }
.result-modal.defeat .result-box { border-color: var(--enemy); box-shadow: 0 0 60px rgba(255,90,74,0.15), inset 0 0 40px rgba(255,90,74,0.08); }
.result-modal.defeat .result-box::before, .result-modal.defeat .result-box::after { border-color: var(--enemy); }
.result-text { font-size: 15px; color: var(--ink); margin: 0 28px 18px; letter-spacing: 1px; }
.result-stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(84px, 1fr)); gap: 1px;
  margin: 0 22px; background: var(--holo-faint); border: 1px solid var(--holo-faint);
}
.result-stats div { background: var(--bg-panel-solid); padding: 9px 4px; }
.result-stats b { display: block; font-family: var(--font-mono); font-size: 18px; color: var(--ink); }
.result-stats small { font-size: 9px; letter-spacing: 2px; color: var(--ink-dim); }
.result-box .modal-actions { justify-content: center; }

/* ============ Loading ============ */
.loading {
  position: absolute; inset: 0; z-index: 50;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px;
  background:
    linear-gradient(rgba(78,240,200,0.035) 1px, transparent 1px) 0 0 / 40px 40px,
    linear-gradient(90deg, rgba(78,240,200,0.035) 1px, transparent 1px) 0 0 / 40px 40px,
    radial-gradient(ellipse at center, #0a1a1e, #030608 75%);
  transition: opacity 0.8s ease;
  pointer-events: auto;
}
.loading.done { opacity: 0; pointer-events: none; }
.loading-insignia { width: 64px; height: 64px; color: var(--holo); filter: drop-shadow(0 0 14px var(--holo-dim)); animation: pulse 1.6s ease-in-out infinite; margin-bottom: 6px; }
.loading-title { font-size: 26px; font-weight: 700; letter-spacing: 9px; color: var(--ink); text-shadow: 0 0 18px var(--holo); padding-left: 9px; }
.loading-sub { font-size: 11px; letter-spacing: 6px; color: var(--ink-dim); margin-bottom: 14px; padding-left: 6px; }
.loading-bar {
  width: 340px; max-width: 70vw; height: 4px;
  background: rgba(78,240,200,0.12); overflow: hidden;
}
.loading-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, rgba(78,240,200,0.4), var(--holo-hi));
  box-shadow: 0 0 12px var(--holo);
  transition: width 0.25s ease;
}
.loading-text { font-family: var(--font-mono); font-size: 11px; letter-spacing: 2px; color: var(--ink-dim); }

/* ============ Utility ============ */
.hidden { display: none !important; }

/* ============ Responsive ============ */
@media (max-width: 1100px) {
  .legend { display: none; }
  .hud-left { width: 170px; }
  .hud-right { width: 190px; }
}
@media (max-width: 820px) {
  .hud-top { top: 8px; left: 8px; right: 8px; gap: 6px; flex-wrap: wrap; }
  .title-panel { padding: 6px 12px 6px 8px; }
  .insignia { width: 22px; height: 22px; }
  .title-main { font-size: 13px; letter-spacing: 2px; }
  .title-sub { display: none; }
  .turn-panel { order: 3; flex-basis: 100%; padding: 5px 8px; }
  .faction { padding: 3px 7px; font-size: 9.5px; letter-spacing: 1.5px; }
  .turn-line { font-size: 13px; letter-spacing: 3px; }
  .clock-panel { flex: 1; min-width: 0; padding: 4px 10px; }
  #moveCount { font-size: 18px; }
  .hud-left { display: none; }
  .hud-right { top: auto; bottom: 52px; right: 8px; left: 8px; width: auto; flex-direction: row; }
  .hud-right .panel-head { display: none; }
  .hud-controls { flex: 1; }
  .btn-grid { grid-template-columns: repeat(5, 1fr); padding: 6px; gap: 4px; }
  .btn-grid .wide, .btn-grid #btnSound { grid-column: auto; }
  .holo-btn { font-size: 10px; letter-spacing: 1px; padding: 8px 2px; }
  .holo-btn b { display: none; }
  .forces-panel { display: none; }
  .thinking { top: 96px; font-size: 11px; }
  .toast { top: 138px; font-size: 11.5px; padding: 8px 14px; max-width: 92vw; }
  .hud-bottom { left: 8px; right: 8px; bottom: 8px; }
  .intel { min-width: 0; flex: 1; }
  .depth-info { display: none; }
  .result-title { font-size: 36px; letter-spacing: 8px; }
  .loading-title { font-size: 18px; letter-spacing: 5px; padding-left: 5px; white-space: nowrap; }
}
