:root {
  --bg: #141a21;
  --panel: #1c2530;
  --panel-line: #2c3947;
  --text: #d8e2ec;
  --muted: #7d8da0;
  --accent: #4aa3ff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Menlo", "Consolas", monospace;
}

header {
  padding: 14px 22px 4px;
}

header h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: 4px;
}

.muted { color: var(--muted); }

header p { margin: 2px 0 0; font-size: 11px; letter-spacing: 1px; }

#app {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding: 12px 22px 22px;
  align-items: flex-start;
}

#board-wrap {
  position: relative;
  flex: 0 1 auto;
  min-width: 0;
}

#board {
  display: block;
  max-width: 100%;
  height: auto;
  background: radial-gradient(ellipse at center, #1a222c 0%, #10151c 100%);
  border: 1px solid var(--panel-line);
  border-radius: 8px;
}

#panel {
  flex: 1 1 300px;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: 8px;
  padding: 14px;
  font-size: 15px;
}

#turn-banner {
  font-size: 20px;
  font-weight: bold;
  letter-spacing: 1px;
}

#phase-hint {
  margin: 4px 0 12px;
  font-size: 14px;
  min-height: 16px;
}

button {
  background: #2a3644;
  color: var(--text);
  border: 1px solid var(--panel-line);
  border-radius: 5px;
  padding: 8px 12px;
  font-family: inherit;
  font-size: 14px;
  letter-spacing: 1px;
  cursor: pointer;
}

button:hover { background: #354456; border-color: var(--accent); }
button:active { background: #22303e; }

/* Primary action — big and prominent so it's easy to hit every turn. */
.big-btn {
  display: block;
  width: 100%;
  padding: 16px;
  font-size: 20px;
  font-weight: bold;
  letter-spacing: 2px;
  background: #2f5c86;
  border-color: #3f79ad;
}
.big-btn:hover { background: #3a6f9f; border-color: var(--accent); }

.hidden { display: none !important; }

.undo-btn {
  display: block;
  width: 100%;
  margin-top: 8px;
  font-size: 13px;
  color: #ffe14d;
  border-color: #4a4630;
}

.mode-btn {
  display: block;
  width: 100%;
  margin-top: 8px;
  font-size: 12px;
  color: var(--accent);
}

/* --- online lobby --- */

.online-btn { color: #8ef0a8; border-color: #2f5c3f; }

#lobby-banner {
  font-size: 20px;
  font-weight: bold;
  letter-spacing: 2px;
  color: #8ef0a8;
}

#lobby-status { font-size: 13px; margin: 4px 0 12px; min-height: 16px; }

.lobby-name-form { display: flex; flex-direction: column; gap: 8px; }

#lobby-name {
  background: #10151c;
  color: var(--text);
  border: 1px solid var(--panel-line);
  border-radius: 5px;
  padding: 10px;
  font-family: inherit;
  font-size: 16px;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.lobby-hint { font-size: 12px; margin: 0 0 8px; }

#lobby-roster { display: flex; flex-direction: column; gap: 6px; }

.roster-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #222c38;
  border: 1px solid var(--panel-line);
  border-radius: 5px;
  padding: 8px 10px;
  font-size: 14px;
}

.roster-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.roster-tag { font-size: 11px; letter-spacing: 1px; color: var(--muted); }
.roster-row.busy { opacity: 0.55; }
.roster-row button { padding: 5px 10px; font-size: 12px; }
.roster-row .accept { color: #8ef0a8; border-color: #2f5c3f; }
.roster-row .decline { color: #ff9078; }

.roster-empty {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
  border: 1px dashed var(--panel-line);
  border-radius: 6px;
  padding: 12px;
  text-align: center;
}

#code-display {
  margin-top: 10px;
  text-align: center;
  font-size: 26px;
  letter-spacing: 6px;
  color: #ffe14d;
  background: #10151c;
  border: 1px solid var(--panel-line);
  border-radius: 6px;
  padding: 10px;
}

#editor-banner {
  font-size: 20px;
  font-weight: bold;
  letter-spacing: 2px;
  color: #ffe14d;
}

.editor-hint { margin: 4px 0 12px; font-size: 13px; }

#bench-row { display: flex; flex-wrap: wrap; gap: 6px; }

#bench-row button {
  font-size: 12px;
  color: #ffe14d;
  border-color: #4a4630;
}

.panel-section { margin-top: 14px; }

.panel-section h2 {
  margin: 0 0 7px;
  font-size: 13px;
  letter-spacing: 2px;
  color: var(--muted);
  border-bottom: 1px solid var(--panel-line);
  padding-bottom: 4px;
}

/* Surrender / New Game — tucked at the bottom, away from End Turn, so they
   don't get hit by accident when ending a turn. */
.end-actions { margin-top: 22px; }
.end-actions-row { display: flex; gap: 8px; }
.end-actions-row button { flex: 1; font-size: 12px; color: var(--muted); }

.facing-compass {
  display: grid;
  grid-template-columns: 84px 84px;
  gap: 6px;
  width: max-content;
}
.facing-compass button { width: 84px; }

.blurb {
  margin: 4px 0 10px;
  font-size: 14px;
  line-height: 1.55;
  color: #c3d2e0;
  border-left: 2px solid var(--panel-line);
  padding-left: 9px;
}

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(74, 163, 255, 0); border-color: var(--panel-line); }
  50% { box-shadow: 0 0 10px 2px rgba(74, 163, 255, 0.55); border-color: var(--accent); }
}
button.pulse { animation: pulse-glow 1.1s ease-in-out infinite; }

.stat-grid {
  display: grid;
  grid-template-columns: 112px 1fr;
  gap: 3px 8px;
  font-size: 14px;
}

.stat-grid span { color: var(--muted); }

#selected-card h3 {
  margin: 0;
  font-size: 16px;
  letter-spacing: 1px;
}

.unit-top {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 8px;
}

.unit-portrait {
  height: 96px;
  width: auto;
  flex: 0 0 auto;
  image-rendering: auto;
  filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.5));
}

.unit-top-info { min-width: 0; }
.unit-role { font-size: 11px; letter-spacing: 1px; margin: 2px 0 6px; }
.unit-hp { font-size: 15px; }
.unit-hp b { color: var(--text); }

.help {
  margin: 0;
  padding-left: 16px;
  font-size: 12px;
  line-height: 1.7;
  color: var(--muted);
}

#game-over {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 14, 20, 0.7);
  border-radius: 8px;
}

#game-over.hidden { display: none; }

#game-over-box {
  background: var(--panel);
  border: 1px solid var(--accent);
  border-radius: 10px;
  padding: 30px 50px;
  text-align: center;
}

#game-over-text {
  font-size: 26px;
  font-weight: bold;
  letter-spacing: 3px;
  margin-bottom: 14px;
}

.dmg-title {
  font-size: 12px;
  letter-spacing: 2px;
  color: var(--muted);
  margin-bottom: 8px;
}

.dmg-cols {
  display: flex;
  gap: 28px;
  justify-content: center;
  margin-bottom: 20px;
  font-size: 13px;
}

.dmg-col { min-width: 150px; text-align: left; }
.dmg-col h4 { margin: 0 0 6px; font-size: 13px; letter-spacing: 1px; }

.dmg-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  line-height: 1.7;
}
.dmg-row b { color: #ffe14d; }
