/* WAR SIMULATOR — war-room theme */
:root {
  --desk: #141712;
  --panel: #1d231b;
  --panel-2: #232b21;
  --edge: #2c352a;
  --phosphor: #8fe388;
  --phosphor-dim: #4e6e50;
  --amber: #e8a33d;
  --manila: #d9cca3;
  --ink: #2b2519;
  --stamp: #c24632;
  --text: #c7bd9e;
  --font-display: "Futura", "Avenir Next Condensed", "Trebuchet MS", sans-serif;
  --font-type: "American Typewriter", "Courier New", monospace;
  --font-body: "Avenir Next", "Avenir", "Helvetica Neue", Helvetica, sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  background: var(--desk);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  overflow: hidden;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}
input, select, textarea { -webkit-user-select: auto; user-select: auto; }
button {
  font-family: var(--font-type);
  background: var(--panel-2);
  color: var(--manila);
  border: 1px solid var(--edge);
  border-radius: 3px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 12.5px;
}
button:hover { border-color: var(--phosphor-dim); color: var(--phosphor); }
button:disabled { opacity: 0.4; cursor: default; }
button.primary { border-color: var(--amber); color: var(--amber); }
b { font-variant-numeric: tabular-nums; }

/* ---------- top bar ---------- */
#topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 14px;
  background: var(--panel);
  border-bottom: 2px solid var(--edge);
  flex-wrap: wrap;
}
.brand { display: flex; flex-direction: column; }
.title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 17px;
  letter-spacing: 0.12em;
  color: var(--phosphor);
}
.datebox { font-family: var(--font-type); font-size: 11.5px; color: var(--amber); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  background: var(--panel-2);
  border: 1px solid var(--edge);
  border-radius: 3px;
  padding: 3px 8px;
  font-size: 12.5px;
  white-space: nowrap;
  cursor: help;
}
.chip b { color: var(--phosphor); }
.chip.meter b { color: var(--manila); }
.chip.warn b { color: var(--stamp); }
.speedbox { margin-left: auto; display: flex; gap: 4px; }
.spd.on { border-color: var(--phosphor); color: var(--phosphor); }

/* ---------- layout ---------- */
#layout { flex: 1; display: flex; gap: 10px; padding: 10px; min-height: 0; }
#left { width: 280px; display: flex; flex-direction: column; gap: 8px; min-height: 0; }
#center { flex: 1; display: flex; flex-direction: column; gap: 8px; min-width: 0; min-height: 0; align-items: center; overflow-y: auto; }
#right { width: 260px; display: flex; flex-direction: column; gap: 6px; min-height: 0; }

#persona-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
.ptab {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 4px; font-size: 18px;
}
.ptab span { font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase; }
.ptab.on { border-color: var(--phosphor); background: #24301f; }
.ptab.on span { color: var(--phosphor); }

#persona-panel {
  flex: 1; overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: 4px;
  padding: 12px;
  display: flex; flex-direction: column; gap: 10px;
}
#persona-panel h3 {
  font-family: var(--font-display);
  font-size: 15px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--phosphor);
}
#persona-panel h4 {
  font-family: var(--font-type);
  font-size: 11px; letter-spacing: 0.15em; text-transform: uppercase;
  color: var(--amber); margin-top: 4px;
}
#persona-panel p { font-size: 12.5px; color: var(--text); }
.stat-row { display: flex; justify-content: space-between; font-size: 12.5px; padding: 2px 0; }
.stat-row b { color: var(--phosphor); }
.action-btn { width: 100%; text-align: left; margin-top: 4px; line-height: 1.4; }
.action-btn small { display: block; color: var(--phosphor-dim); font-size: 10.5px; }
.slider-row { display: flex; flex-direction: column; gap: 2px; font-size: 12px; }
.slider-row input[type=range] { width: 100%; accent-color: var(--phosphor); }
.policy-row { display: flex; align-items: flex-start; gap: 8px; font-size: 12px; }
.policy-row input { margin-top: 3px; accent-color: var(--phosphor); }
.bar-wrap { background: #10130f; border: 1px solid var(--edge); border-radius: 2px; height: 10px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--phosphor); transition: width 0.3s; }
.bar-fill.amber { background: var(--amber); }
.bar-fill.red { background: var(--stamp); }
.unit-row { display: flex; justify-content: space-between; align-items: center; gap: 6px; font-size: 12.5px; padding: 3px 0; border-bottom: 1px dashed #2c352a88; }
.unit-row button { padding: 2px 8px; font-size: 11px; }
.cheat-row { display: flex; flex-wrap: wrap; gap: 5px; }
.cheat-row button { font-size: 12px; padding: 6px 8px; }
.sfx-row { display: flex; align-items: center; gap: 6px; padding: 3px 0; border-bottom: 1px dashed #2c352a88; }
.sfx-label { flex: 1; font-size: 12.5px; }
.sfx-label .sfx-mine { color: var(--amber); font-family: var(--font-type); font-size: 10px; letter-spacing: 0.1em; }
.sfx-row button { padding: 4px 10px; font-size: 13px; }
.sfx-row button.rec-live { border-color: var(--stamp); color: var(--stamp); animation: recpulse 1s infinite; }
@keyframes recpulse { 50% { background: #3a201a; } }
@media (prefers-reduced-motion: reduce) { .sfx-row button.rec-live { animation: none; } }

/* ---------- city ---------- */
#city {
  background: #171f14;
  border: 2px solid var(--edge);
  border-radius: 4px;
  image-rendering: pixelated;
  max-width: 100%;
  cursor: pointer;
  flex-shrink: 0;
}
#palette-wrap { width: 100%; max-width: 672px; display: flex; flex-direction: column; gap: 6px; }
#palette { display: flex; flex-wrap: wrap; gap: 5px; }
.pal-btn {
  display: flex; flex-direction: column; align-items: center;
  min-width: 76px; padding: 5px 6px; gap: 1px; position: relative;
}
.pal-btn .em { font-size: 17px; font-family: var(--font-body); }
.pal-btn .nm { font-size: 9.5px; letter-spacing: 0.04em; text-transform: uppercase; }
.pal-btn .cost { font-size: 9px; color: var(--phosphor-dim); font-family: var(--font-body); }
.pal-btn.sel { border-color: var(--amber); background: #2d2a1a; }
.pal-btn.locked { opacity: 0.35; }
.pal-btn.cant .cost { color: var(--stamp); }
#cell-info { font-family: var(--font-type); font-size: 12px; color: var(--amber); min-height: 18px; }
#cell-info button { margin-left: 8px; padding: 1px 8px; font-size: 11px; }

/* ---------- right side ---------- */
.side-h {
  font-family: var(--font-type);
  font-size: 11px; letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--phosphor-dim);
}
#alerts { display: flex; flex-direction: column; gap: 5px; min-height: 30px; }
.alert {
  background: #2d1f16;
  border: 1px solid var(--stamp);
  border-radius: 3px;
  padding: 7px 9px;
  font-size: 12.5px;
  color: #e8c9b0;
}
.alert.info { border-color: var(--amber); background: #2b2618; color: var(--manila); }
.alert.tut { border-color: var(--phosphor); background: #1c2818; color: #c9dbc2; }
.alert.tut b { color: var(--phosphor); }
.tut-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 4px; }
.tut-head b { font-family: var(--font-type); font-size: 10.5px; letter-spacing: 0.15em; }
.tut-head span { cursor: pointer; color: var(--phosphor-dim); padding: 0 4px; font-size: 14px; }
.tut-head span:hover { color: var(--stamp); }
.tut-reward { color: var(--amber); font-size: 11.5px; font-family: var(--font-type); }
.alert b { color: var(--stamp); }
.alert.info b { color: var(--amber); }
#log {
  flex: 1;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: 4px;
  padding: 8px 10px;
  font-family: var(--font-type);
  font-size: 11.5px;
  line-height: 1.55;
  display: flex; flex-direction: column-reverse;
}
#log .ln { padding: 2px 0; border-bottom: 1px dashed #2c352a66; }
#log .ln .d { color: var(--phosphor-dim); margin-right: 6px; }
#log .ln.good { color: var(--phosphor); }
#log .ln.bad { color: #e0937f; }

/* ---------- battle ---------- */
.hidden { display: none !important; }
#battle-overlay {
  position: fixed; inset: 0;
  background: rgba(8, 10, 7, 0.92);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
}
#battle-frame {
  background: var(--panel);
  border: 2px solid var(--edge);
  border-radius: 6px;
  padding: 12px;
  display: flex; flex-direction: column; gap: 8px;
  max-width: 96vw;
}
#battle-head { display: flex; justify-content: space-between; align-items: baseline; }
#battle-title {
  font-family: var(--font-display);
  font-size: 18px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--stamp);
}
#battle-status { font-family: var(--font-type); font-size: 12px; color: var(--amber); }
#battlefield-wrap { position: relative; }
#battlefield { background: #10140e; border: 1px solid var(--edge); border-radius: 4px; max-width: 100%; display: block; touch-action: none; }

/* on-screen controls for touch devices (hidden when a mouse/trackpad is primary) */
#touch-controls { display: none; }
@media (pointer: coarse) {
  #touch-controls { display: block; }
}
#joy-zone {
  position: absolute;
  left: 14px; bottom: 14px;
  width: 110px; height: 110px;
  border: 2px solid rgba(143, 227, 136, 0.35);
  border-radius: 50%;
  background: rgba(20, 25, 18, 0.5);
  touch-action: none;
}
#joy-thumb {
  position: absolute;
  left: 35px; top: 35px;
  width: 40px; height: 40px;
  border-radius: 50%;
  background: rgba(143, 227, 136, 0.45);
  border: 2px solid var(--phosphor);
  pointer-events: none;
}
#touch-btns {
  position: absolute;
  right: 14px; bottom: 14px;
  display: flex; gap: 12px; align-items: flex-end;
}
#touch-btns button {
  width: 64px; height: 64px;
  border-radius: 50%;
  font-size: 26px;
  background: rgba(20, 25, 18, 0.6);
  border: 2px solid rgba(232, 163, 61, 0.5);
  touch-action: none;
}
#tc-fire { width: 84px; height: 84px; font-size: 34px; }
#battle-orders { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
#battle-orders button { font-size: 13px; padding: 8px 14px; }
#battle-hint { font-family: var(--font-type); font-size: 11.5px; color: var(--phosphor-dim); }

/* ---------- FPS mission overlay ---------- */
#fps-overlay {
  position: fixed; inset: 0;
  background: rgba(8, 10, 7, 0.94);
  display: flex; align-items: center; justify-content: center;
  z-index: 55;
}
#fps-frame {
  background: var(--panel);
  border: 2px solid var(--edge);
  border-radius: 6px;
  padding: 10px;
  width: min(96vw, 980px);
  display: flex; flex-direction: column; gap: 8px;
}
#fps-head { display: flex; justify-content: space-between; align-items: center; }
#fps-title {
  font-family: var(--font-display);
  font-size: 17px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--amber);
}
#fps-stage { position: relative; }
#fps-canvas {
  width: 100%; display: block;
  background: #000; border: 1px solid var(--edge); border-radius: 4px;
  image-rendering: pixelated;
  touch-action: none;
  cursor: crosshair;
}
#fps-fire {
  display: none;
  position: absolute;
  right: 16px; bottom: 16px;
  width: 84px; height: 84px;
  border-radius: 50%;
  font-size: 34px;
  background: rgba(20, 25, 18, 0.6);
  border: 2px solid rgba(232, 163, 61, 0.5);
  touch-action: none;
}
@media (pointer: coarse) { #fps-fire { display: block; } }

/* ---------- modal ---------- */
#modal-overlay {
  position: fixed; inset: 0;
  background: rgba(8, 10, 7, 0.85);
  display: flex; align-items: center; justify-content: center;
  z-index: 60;
}
#modal {
  background: var(--manila);
  color: var(--ink);
  border-radius: 4px;
  padding: 24px 26px;
  max-width: 560px;
  width: 92vw;
  max-height: 84vh;
  overflow-y: auto;
  box-shadow: 0 12px 40px rgba(0,0,0,0.6);
  display: flex; flex-direction: column; gap: 12px;
}
#modal-title {
  font-family: var(--font-type);
  font-size: 17px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--stamp);
}
#modal-body { font-size: 14.5px; line-height: 1.55; }
#modal-body .score-line { display: flex; justify-content: space-between; font-family: var(--font-type); font-size: 13px; padding: 2px 0; }
#modal-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
#modal-buttons button {
  background: var(--ink); color: var(--manila); border-color: var(--ink);
  font-size: 13px; padding: 8px 16px;
}
#modal-buttons button:hover { color: var(--phosphor); }
#modal-buttons button small { display: block; font-size: 10.5px; color: #9a8f75; }

/* ---------- iPad / narrow screens: stack the war room ---------- */
@media (max-width: 1180px) {
  body { overflow: auto; height: auto; min-height: 100dvh; }
  #layout { flex-direction: column; }
  #center { order: 1; }
  #left { order: 2; width: 100%; }
  #right { order: 3; width: 100%; }
  #persona-tabs { grid-template-columns: repeat(4, 1fr); }
  #persona-panel { max-height: 420px; }
  #log { min-height: 140px; max-height: 220px; flex: none; }
  #city { width: 100%; height: auto; }
}
/* bigger tap targets on touch devices */
@media (pointer: coarse) {
  button { padding: 10px 14px; font-size: 14px; }
  .pal-btn { min-width: 88px; padding: 8px; }
  .pal-btn .em { font-size: 20px; }
  .unit-row button { padding: 8px 12px; }
  .spd { min-width: 44px; }
  .slider-row input[type=range] { height: 34px; }
  .policy-row input { width: 20px; height: 20px; }
}
