* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: #0a0a0a;
  color: #e8e8e8;
  font-family: 'Courier New', monospace;
  overflow: hidden;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  user-select: none;
}

.hidden { display: none !important; }

/* ─── LOCKED SCREEN ─── */
#locked-screen {
  text-align: center;
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
#locked-screen .game-title { color: rgba(255,80,80,0.7); }

/* ─── START SCREEN ─── */
#start-screen {
  text-align: center;
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}
.game-title {
  font-size: clamp(0.9rem, 2.5vw, 1.4rem);
  letter-spacing: 0.2em;
  color: #00d4ff;
}
#start-stage-name {
  font-size: clamp(1.2rem, 4vw, 2rem);
  letter-spacing: 0.3em;
  color: #e8e8e8;
}
.start-btn {
  background: rgba(0,212,255,0.1);
  border: 1px solid rgba(0,212,255,0.5);
  color: #00d4ff;
  font-family: monospace;
  font-size: 1rem;
  letter-spacing: 0.3em;
  padding: 12px 40px;
  cursor: pointer;
  transition: all 0.2s;
}
.start-btn:hover {
  background: rgba(0,212,255,0.25);
  border-color: #00d4ff;
}

/* ─── GAME SCREEN ─── */
#game-screen {
  width: 100%;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* HUD TOP */
#hud-top {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  background: rgba(0,0,0,0.85);
  border-bottom: 1px solid rgba(0,212,255,0.12);
  flex-shrink: 0;
}
.king-hp {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
}
.enemy-side { flex-direction: row-reverse; }
.king-name {
  font-size: 10px;
  letter-spacing: 0.08em;
  white-space: nowrap;
  color: #888;
}
.hp-squares {
  flex: 1;
  font-family: monospace;
  font-size: 11px;
  letter-spacing: 0.05em;
  overflow: hidden;
  white-space: nowrap;
}
.player-squares { color: #00d4ff; text-align: right; }
.enemy-squares  { color: #ff4444; }
.hp-text {
  font-size: 11px;
  min-width: 2.5em;
  text-align: center;
  color: #ccc;
}
#stage-label {
  font-size: 10px;
  letter-spacing: 0.15em;
  color: rgba(0,212,255,0.5);
  white-space: nowrap;
  padding: 0 8px;
}

/* CANVAS */
#canvas-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #0a0a0a;
}
#game-canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  image-rendering: pixelated;
}

/* HUD BOTTOM */
#hud-bottom {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: rgba(0,0,0,0.9);
  border-top: 1px solid rgba(0,212,255,0.12);
  flex-shrink: 0;
}
#money-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 52px;
  gap: 1px;
}
.money-label {
  font-size: 7px;
  letter-spacing: 0.1em;
  color: #555;
}
#money-val {
  font-size: 18px;
  color: #ffdd88;
  letter-spacing: 0.05em;
}
#unit-buttons {
  display: flex;
  gap: 6px;
  flex: 1;
  justify-content: center;
}
.unit-btn {
  position: relative;
  overflow: hidden;
  background: rgba(0,212,255,0.06);
  border: 1px solid rgba(0,212,255,0.3);
  color: #e8e8e8;
  font-family: monospace;
  font-size: 10px;
  padding: 6px 8px;
  cursor: pointer;
  transition: all 0.15s;
  min-width: 64px;
  text-align: center;
  line-height: 1.4;
}
.unit-btn:hover:not(:disabled) {
  background: rgba(0,212,255,0.18);
  border-color: rgba(0,212,255,0.65);
}
.unit-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.unit-btn-stats { display: flex; justify-content: center; gap: 6px; margin-bottom: 4px; }
.unit-btn-stat  { display: flex; align-items: center; gap: 2px; font-size: 9px; color: #e8e8e8; }
.unit-btn-stat.atk { color: #ffdd88; }
.unit-btn-stat.spd { color: #aaffcc; }
.stat-icon      { width: 10px; height: 10px; object-fit: contain; }
.unit-btn-img   { width: 40px; height: 40px; object-fit: contain; display: block; margin: 0 auto 2px; }
.unit-btn-name  { font-size: 10px; }
.unit-btn-cost  { font-size: 9px; color: #ffdd88; }
/* クールダウンオーバーレイ（下から上に消える） */
.cd-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 0%;
  background: rgba(0,0,0,0.55);
  pointer-events: none;
}

.sys-btn {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.15);
  color: #666;
  font-family: monospace;
  font-size: 10px;
  letter-spacing: 0.08em;
  padding: 6px 10px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.sys-btn:hover {
  border-color: rgba(255,255,255,0.4);
  color: #ccc;
}

/* ─── RESULT ─── */
#result-screen {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
#result-box {
  text-align: center;
  padding: 40px 32px;
  border: 1px solid rgba(0,212,255,0.25);
  background: rgba(0,0,0,0.95);
  max-width: 320px;
  width: 90%;
}
#result-title {
  font-size: 2rem;
  letter-spacing: 0.3em;
  margin-bottom: 12px;
}
#result-msg {
  font-size: 11px;
  color: #666;
  letter-spacing: 0.08em;
  margin-bottom: 28px;
  line-height: 1.6;
}
.result-btns {
  display: flex;
  gap: 12px;
  justify-content: center;
}
