* { margin:0; padding:0; box-sizing:border-box; }
body { background:#111; color:#ccc; font-family:'Courier New',monospace; overflow:hidden; user-select:none; }
#gameContainer { position:relative; width:100vw; height:100vh; display:none; }

#settingsScreen {
  position:fixed; top:0; left:0; width:100vw; height:100vh; z-index:1000;
  background:radial-gradient(circle at 50% 30%,#1a1330,#05050a 75%);
  overflow-y:auto;
  /* NOT display:flex + align-items:center here on purpose: centering an
     overflowing child with flex clips whatever's above the centered
     position, so scrolling up could never actually reach the real top of
     the panel — worse the taller the settings panel or the shorter the
     viewport, hence "half the time" depending on how tall the window is.
     Block layout + auto side margins on #settingsPanel below centers it
     horizontally the same way, but leaves the full height scrollable. */
}
#settingsPanel {
  background:rgba(15,10,25,0.92); border:1px solid #4a2a6a; border-radius:6px;
  padding:26px 32px; width:1400px; max-width:96vw; margin:20px auto;
  box-shadow:0 0 40px rgba(0,0,0,0.6);
}
#settingsPanel h1 { color:#b57fff; font-size:20px; margin-bottom:4px; letter-spacing:1px; }
#settingsPanel .sub { color:#9a8fc9; font-size:11px; margin-bottom:18px; line-height:1.5; }
.settingsRow { margin-bottom:14px; }
.settingsRow label { display:block; color:#c9b8ff; font-size:11px; margin-bottom:4px; }
.settingsRow input[type=number], .settingsRow select {
  width:100%; background:#000; color:#e0d0ff; border:1px solid #4a2a6a; border-radius:3px;
  padding:7px 8px; font-family:inherit; font-size:13px;
}
.settingsRow .desc { color:#6a5a8a; font-size:10px; margin-top:3px; line-height:1.4; }
.settingsGridTwo { display:grid; grid-template-columns:repeat(auto-fit, minmax(190px, 1fr)); gap:14px 18px; }
#startGameBtn {
  width:100%; margin-top:8px; padding:11px; font-size:14px; font-weight:bold;
  background:linear-gradient(#3a1a5a,#20102d); border:1px solid #b57fff; color:#e0d0ff;
  border-radius:4px; cursor:pointer; letter-spacing:1px;
}
#startGameBtn:hover { background:linear-gradient(#4a2570,#2a1740); }
#settingsNote { color:#8a7ab5; font-size:10px; margin-top:12px; text-align:center; }
#threeHost { position:absolute; top:96px; left:0; right:0; bottom:0; }
#threeHost canvas { display:block; }
#ui { position:absolute; top:0; left:0; width:100%; height:100%; pointer-events:none; }

#topBar {
  position:absolute; top:0; left:0; right:0; height:36px;
  background:linear-gradient(#241a30,#140d1a);
  border-bottom:2px solid #4a2a6a;
  display:flex; align-items:center; gap:12px; padding:0 10px;
  pointer-events:all; flex-wrap:nowrap; overflow:hidden;
}
.resource { color:#c9adff; font-size:12px; white-space:nowrap; }
.resource span { color:#0ff; font-weight:bold; }
#playerSwitch {
  padding:4px 10px;
  background:#2a1a5a; border:1px solid #8a5aff; color:#c9adff;
  cursor:pointer; font-family:inherit; font-size:11px;
  border-radius:3px;
}
#playerSwitch:hover { background:#3a2a7a; }
#currentPlayer { color:#fa0; font-size:12px; font-weight:bold; white-space:nowrap; }
#capacityDisplay, #capacityDisplay2 { color:#e0b8ff; font-size:11px; white-space:nowrap; }
#mapControls { margin-left:auto; display:flex; align-items:center; gap:5px; }
#mapControls button {
  background:#1a0d2a; border:1px solid #4a2a6a; color:#c9adff; font-size:10px;
  padding:3px 6px; cursor:pointer; border-radius:2px;
}
#mapControls button:hover { background:#2a1a4a; }
#econBar {
  position:absolute; top:36px; left:0; right:0; height:60px;
  background:#150a20; border-bottom:1px solid #3a1a5a;
  display:flex; flex-direction:column; justify-content:center; gap:2px; padding:4px 10px;
  font-size:10px; color:#a88ac9; pointer-events:all; overflow:hidden;
}
.econRow { display:flex; align-items:center; gap:16px; height:18px; white-space:nowrap; }
.econStat { color:#a88ac9; }
.econStat span { color:#d0b0ff; }
#timeDisplay { color:#9df; font-size:12px; white-space:nowrap; }
#speedControl { display:flex; align-items:center; gap:4px; }
#speedControl label { color:#9df; font-size:10px; }
#speedControl input {
  width:34px; background:#0a1622; color:#9df; border:1px solid #345;
  text-align:center; font-size:11px; border-radius:2px;
}

/* "Errors waiting" readout — placed to the RIGHT of #creditBar (which
   sits at top:128px;left:10px;max-width:420px in index.html), so its
   left edge starts just past that panel's right edge — same row,
   side-by-side, never overlapping it. Lists every active
   dictionary-game wrong-answer ban (see dictActiveBans in
   10-dictgame.js) with moments left, ONE PER ROW. Hidden entirely
   (collapses to nothing) when there's nothing banned; grows downward to
   fit however many rows there are — no truncation, no scrolling. */
#dictBanPanel {
  position:absolute; top:128px; left:440px; z-index:80;
  display:none; flex-direction:column; gap:1px;
  background:rgba(25,5,10,0.85); border:1px solid #6a2a2a;
  border-radius:4px; padding:4px 8px; pointer-events:all; max-width:360px;
}
#dictBanPanel.show { display:flex; }
.dictBanRow { color:#ff9977; font-size:11px; white-space:nowrap; line-height:1.5; }

#bottomPanel {
  position:absolute; bottom:0; left:160px; right:0; height:120px;
  background:linear-gradient(#140d1a,#241a30);
  border-top:2px solid #4a2a6a;
  display:flex; pointer-events:all;
}

#infoWindow {
  flex:1; padding:6px 10px; overflow-y:auto; font-size:11px;
  border-right:1px solid #4a2a6a; pointer-events:all;
}
#infoWindow h3 { color:#b57fff; font-size:12px; margin-bottom:4px; }
.unitInfo { color:#aaa; line-height:1.5; }

#buildMenu {
  width:280px; padding:4px 8px; overflow-y:auto;
  border-right:1px solid #4a2a6a;
}
#buildMenu h3 { color:#b57fff; font-size:11px; margin-bottom:3px; }
.buildGrid { display:grid; grid-template-columns:repeat(4,1fr); gap:3px; }
.buildBtn {
  background:#1a0d2a; border:1px solid #4a2a6a; color:#c9adff;
  font-size:10px; padding:3px 2px; cursor:pointer; text-align:center;
  border-radius:2px; line-height:1.3;
}
.buildBtn:hover { background:#2a1a4a; border-color:#8a5aff; }
.buildBtn .cost { color:#0ff; font-size:9px; }
.buildBtn .name { color:#cfc; font-size:9px; }

#cmdButtons { width:140px; padding:4px; display:grid; grid-template-columns:repeat(3,1fr); gap:2px; align-content:start; }
.cmdBtn {
  background:#120a1a; border:1px solid #3a1a5a; color:#a88ac9;
  font-size:10px; padding:4px 2px; cursor:pointer; text-align:center;
  border-radius:2px;
}
.cmdBtn:hover { background:#241a30; border-color:#8a5aff; }
.cmdBtn.active { background:#2a1a4a; border-color:#b57fff; color:#d0b0ff; }

#minimap {
  position:absolute; bottom:0; left:0; width:160px; height:160px;
  background:#0a0512; border-right:1px solid #4a2a6a; border-top:2px solid #4a2a6a;
  pointer-events:all; cursor:pointer;
}
#minimapCanvas { width:160px; height:160px; }

#alert {
  position:absolute; top:104px; left:50%; transform:translateX(-50%);
  background:#2a1a00; border:1px solid #fa0; color:#fc8;
  padding:4px 14px; font-size:12px; border-radius:3px;
  display:none; z-index:100;
}

#queueDisplay {
  position:absolute; bottom:122px; left:162px;
  display:flex; gap:4px; pointer-events:none;
  background:rgba(10,0,20,0.7); padding:3px 6px; border-radius:3px;
  border:1px solid #3a1a5a; min-height:36px; align-items:center;
}
.queueLabel { color:#b57fff; font-size:10px; margin-right:4px; }
.queueItem {
  width:32px; height:32px; background:#1a0d2a;
  border:1px solid #4a2a6a; border-radius:3px;
  display:flex; align-items:center; justify-content:center;
  font-size:13px; color:#b57fff; position:relative; flex-shrink:0;
}
.queueProgress {
  position:absolute; bottom:0; left:0; height:3px;
  background:#b57fff; transition:width 0.15s; border-radius:0 0 2px 2px;
}

#selectedIndicator {
  position:absolute; top:104px; left:10px;
  color:#b57fff; font-size:11px; pointer-events:none;
  background:rgba(10,0,20,0.5); padding:2px 6px; border-radius:3px;
}
#hint3d {
  position:absolute; top:130px; left:10px; color:#6a5a8a; font-size:10px;
  pointer-events:none; max-width:360px; line-height:1.4;
  background:rgba(10,0,20,0.4); padding:3px 6px; border-radius:3px;
}
#selectBox {
  position:absolute; border:1px solid #b57fff; background:rgba(181,127,255,0.15);
  display:none; pointer-events:none; z-index:50;
}

#attackTargetPanel {
  position:absolute; top:220px; left:10px; z-index:60; width:230px;
  background:rgba(20,0,0,0.92); border:1px solid #ff4422; border-radius:4px;
  padding:6px 8px; pointer-events:all;
}
.attackTargetHeader { color:#ff8866; font-size:11px; margin-bottom:5px; font-weight:bold; }
.attackTargetList { max-height:160px; overflow-y:auto; border:1px solid #4a2020; border-radius:3px; background:rgba(0,0,0,0.25); }
.attackTargetItem {
  display:flex; justify-content:space-between; gap:6px; font-size:11px;
  padding:4px 6px; cursor:pointer;
}
.attackTargetItem:hover { background:rgba(255,68,34,0.2); }
.teamHeader { color:#b57fff; font-size:11px; margin-bottom:4px; font-weight:bold; }
.teamRow { color:#cfc; font-size:11px; line-height:1.6; display:flex; justify-content:space-between; gap:6px; }
.teamRow .tcount { color:#0ff; }
.teamListWrap { margin-top:4px; }
.teamListHint { color:#6a5a8a; font-size:9px; margin-bottom:3px; }
.teamList { max-height:78px; overflow-y:auto; border:1px solid #2a1a4a; border-radius:3px; background:rgba(0,0,0,0.25); }
.teamListItem {
  display:flex; justify-content:space-between; gap:6px; font-size:10px;
  padding:2px 6px; cursor:pointer; pointer-events:all;
}
.teamListItem:hover { background:rgba(181,127,255,0.18); }

#groupBar {
  position:absolute; top:100px; right:8px; display:flex; gap:3px; align-items:center;
  background:rgba(10,0,20,0.6); padding:4px 6px; border-radius:4px;
  pointer-events:all; border:1px solid #4a2a6a;
}
.groupLabel { color:#8a7ab5; font-size:10px; margin-right:2px; }
.groupBtn {
  width:22px; height:22px; background:#1a0d2a; border:1px solid #4a2a6a; color:#c9adff;
  font-size:11px; cursor:pointer; border-radius:3px; font-family:inherit;
}
.groupBtn:hover { background:#2a1a4a; border-color:#8a5aff; }
.groupBtn.armed { background:#3a2a0d; border-color:#fa0; color:#fc8; }
.groupBtn.bound { border-color:#b57fff; color:#b57fff; }

#dragModeBar {
  position:absolute; top:136px; right:8px; display:flex; gap:3px; align-items:center;
  background:rgba(10,0,20,0.6); padding:4px 6px; border-radius:4px;
  pointer-events:all; border:1px solid #4a2a6a;
}
.dragModeBtn { width:auto; padding:0 8px; }
.dragModeBtn.active { background:#2a1a5a; border-color:#5f9; color:#5f9; }

/* 4D rotation control panel — the genuinely "4D" part of the view.
   #rot4dWrap reserves space above #bottomPanel (120px + 2px border) so
   the rotation controls can never overlap the Move/Attack/Stop buttons,
   and scrolls internally if the content is taller than the viewport. */
#rot4dWrap {
  position:absolute; top:172px; right:8px; bottom:130px;
  display:flex; flex-direction:column; gap:6px;
  overflow-y:auto; pointer-events:none; width:190px;
}
#rot4dBar, #advRotBar {
  display:flex; flex-direction:column; gap:3px; align-items:stretch;
  background:rgba(10,0,20,0.6); padding:6px; border-radius:4px;
  pointer-events:all; border:1px solid #4a2a6a; width:100%; flex-shrink:0;
}
#rot4dBar .rot4dTitle, #advRotBar .rot4dTitle { color:#8a7ab5; font-size:10px; margin:4px 0 2px; text-align:center; }
#rot4dBar .rot4dRow, #advRotBar .rot4dRow { display:flex; gap:3px; align-items:center; }
#rot4dBar button, #advRotBar button {
  flex:1; background:#1a0d2a; border:1px solid #4a2a6a; color:#c9adff;
  font-size:10px; padding:3px 2px; cursor:pointer; border-radius:2px; font-family:inherit;
}
#rot4dBar button:hover, #advRotBar button:hover { background:#2a1a4a; border-color:#8a5aff; }
#rot4dBar button.spinning, #advRotBar button.spinning { border-color:#5f9; color:#5f9; }

/* Dictionary Set mini-game — in-page panel (10-dictgame.js), same window
   as every other RTS panel, never a popup. Hidden by default; the whole
   game is frozen (see loop() in 06-draw.js) whenever it's visible. */
#dictGamePanel {
  display:none; position:fixed; top:50%; left:50%; transform:translate(-50%,-50%);
  z-index:2500; width:640px; max-width:92vw; max-height:88vh; overflow-y:auto;
  background:rgba(12,6,22,0.97); border:1px solid #b57fff; border-radius:6px;
  padding:16px 20px; pointer-events:all; box-shadow:0 0 50px rgba(0,0,0,0.7);
  font-family:'Courier New',monospace;
}
#dictGamePanel.show { display:block; }
#dgHeader { display:flex; justify-content:space-between; align-items:center; color:#b57fff; font-size:13px; letter-spacing:1px; border-bottom:1px solid #4a2a6a; padding-bottom:8px; }
#dgScoreRow { color:#8a7ab5; font-size:11px; margin-top:8px; }
#dgScoreRow span { color:#0ff; }
.dg-grid-row { display:flex; justify-content:center; align-items:center; min-height:44px; margin:18px 0 20px; flex-wrap:wrap; gap:2px; }
.dg-word-row { display:flex; align-items:center; gap:2px; flex-wrap:wrap; justify-content:center; }
.dg-word-row img, .dg-word-row span { color:#e0d0ff; }
.dg-dict-grid { display:grid; gap:8px; margin-bottom:6px; }
.dg-dict-cell {
  background:#1a0d2a; border:1px solid #4a2a6a; border-radius:6px; padding:8px 10px;
  cursor:pointer; display:flex; align-items:center; justify-content:center; gap:1px; flex-wrap:wrap;
}
.dg-dict-cell:hover { background:#2a1a4a; border-color:#8a5aff; }
#dgButtonRow { display:flex; gap:10px; margin-top:12px; }
#dgButtonRow button {
  flex:1; background:#1a0d2a; border:1px solid #4a2a6a; color:#c9adff; font-size:13px;
  padding:9px 6px; cursor:pointer; border-radius:4px; font-family:inherit;
}
#dgButtonRow button:hover { background:#2a1a4a; border-color:#8a5aff; }
#dgButtonRow button.dg-btn-hint { border-color:#5f9; color:#5f9; }
#dgErrorInfo { color:#ff6666; font-size:11px; margin-top:10px; min-height:14px; }
#dgInfo { color:#5f9; font-size:11px; min-height:14px; }
