* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  width: 100%; height: 100%; overflow: hidden;
  background: #000; color: #e8efe4;
  font-family: "Segoe UI", "Hiragino Sans", "Meiryo", sans-serif;
}
#app { position: relative; width: 100%; height: 100%; }
#game-canvas { display: block; width: 100%; height: 100%; cursor: crosshair; }
#game-canvas.pointer-locked { cursor: none; }
#loading {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: #0a0f0a; color: #9ab; z-index: 20;
}
#hud { position: absolute; inset: 0; pointer-events: none; z-index: 10; }

.panel {
  position: absolute; top: 52px; left: 8px; max-width: min(320px, calc(100vw - 120px));
  padding: 0; background: rgba(0,0,0,0.6); border: 1px solid rgba(120,180,100,0.35);
  border-radius: 6px; font-size: 0.82rem; line-height: 1.45; pointer-events: auto;
  overflow: hidden;
}
.panel .tutorial-body { padding: 8px 12px; }
.panel .tutorial-body.collapsed { display: none; }
.tutorial-toggle {
  display: block; width: 100%; text-align: left;
  padding: 8px 12px; background: rgba(20,35,18,0.85); color: #dfe;
  border: none; border-bottom: 1px solid rgba(120,180,100,0.25);
  font-size: 0.82rem; font-weight: 700; cursor: pointer;
}
.tutorial-toggle:hover { background: rgba(35,55,30,0.9); }
.panel .hint { margin-top: 6px; color: #9ab; font-size: 0.78rem; }
.panel.hidden { display: none; }

#hud-menu-wrap { position: absolute; top: 8px; right: 8px; pointer-events: auto; z-index: 15; }
.hud-menu-btn {
  width: 40px; height: 40px; border-radius: 8px; border: 1px solid rgba(140,190,120,0.5);
  background: rgba(0,0,0,0.65); color: #dfe; font-size: 1.2rem; cursor: pointer;
}
.hud-menu-btn:hover { background: rgba(30,50,25,0.85); }
.hud-menu-panel {
  position: absolute; top: 44px; right: 0; min-width: 160px;
  background: rgba(10,18,10,0.95); border: 1px solid rgba(120,180,100,0.4);
  border-radius: 8px; padding: 6px; display: flex; flex-direction: column; gap: 4px;
}
.hud-menu-panel[hidden] { display: none !important; }
.hud-btn {
  padding: 8px 10px; text-align: left; background: rgba(40,60,35,0.8); color: #e8efe4;
  border: 1px solid rgba(100,150,90,0.35); border-radius: 6px; cursor: pointer; font-size: 0.9rem;
}
.hud-btn:hover { background: rgba(55,85,48,0.95); }

#status-row {
  position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 16px; flex-wrap: wrap; background: rgba(0,0,0,0.65);
  padding: 8px 14px; border-radius: 8px; font-size: 0.9rem; text-shadow: 0 1px 3px #000;
}
.stamina-bar-wrap {
  position: absolute;
  bottom: 52px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  z-index: 12;
}
.stamina-bar-track {
  width: min(220px, 42vw);
  height: 10px;
  background: rgba(0, 0, 0, 0.65);
  border: 1px solid rgba(120, 180, 100, 0.45);
  border-radius: 5px;
  overflow: hidden;
}
.stamina-bar-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #3a8f4a, #6ecf7a);
  border-radius: 4px;
  transition: width 0.08s linear;
}
.stamina-bar-fill.consuming {
  background: linear-gradient(90deg, #b8860b, #ffd54f);
}
.stamina-bar-fill.recovering {
  background: linear-gradient(90deg, #2a6a8a, #5eb8e8);
}
.stamina-bar-label {
  font-size: 0.72rem;
  font-weight: bold;
  color: #b8d4ae;
  text-shadow: 0 1px 2px #000;
  min-width: 1.4em;
}
.enemy-status {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -120px);
  background: rgba(0,0,0,0.55); padding: 6px 14px; border-radius: 8px;
  font-size: 0.95rem; font-weight: bold; color: #dfe; pointer-events: none;
  border: 1px solid rgba(180,120,120,0.45); text-shadow: 0 1px 4px #000;
}
.cpu-info {
  position: absolute; top: 56px; left: 8px; background: rgba(0,0,0,0.65);
  padding: 8px 12px; border-radius: 8px; font-size: 0.85rem; max-width: min(280px, calc(100vw - 180px));
  border: 1px solid rgba(120,180,100,0.3);
}
.camera-view-btn {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 30;
  pointer-events: auto;
  background: rgba(8, 24, 8, 0.92);
  color: #e8ffe0;
  border: 2px solid rgba(168, 232, 144, 0.75);
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.45);
}
.camera-view-btn:hover { background: rgba(30,50,28,0.92); }
.camera-view-btn.active { border-color: #a8e890; color: #a8e890; }
.sens-hud-label {
  position: absolute; bottom: 12px; left: 8px; background: rgba(0,0,0,0.55);
  padding: 6px 10px; border-radius: 6px; font-size: 0.78rem; color: #b8d4ae;
  pointer-events: none;
}
#message {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  font-size: 1.25rem; text-shadow: 0 0 8px #000; pointer-events: none;
}

.overlay {
  display: none; position: absolute; inset: 0; background: rgba(0,0,0,0.78);
  align-items: center; justify-content: center; pointer-events: auto; z-index: 30;
}
.overlay-box {
  background: #1a2618; border: 1px solid #4a7a42; border-radius: 12px;
  padding: 28px 32px; max-width: 520px; width: min(92vw, 520px); text-align: center;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.overlay-box h1 { margin-bottom: 12px; color: #a8e890; font-size: 1.5rem; }
.overlay-box > p { margin-bottom: 16px; line-height: 1.55; color: #d8e8d0; }

.title-screen {
  margin: 16px 0 20px; padding: 14px 16px; text-align: left;
  background: rgba(0,0,0,0.45); border: 1px solid rgba(140,200,120,0.45); border-radius: 8px;
}
.mode-label { display: block; font-weight: 600; color: #cfe8c0; margin-bottom: 8px; font-size: 1rem; }
.mode-select {
  width: 100%; padding: 10px 12px; font-size: 1rem; color: #1a1a1a;
  background: #e8f0e4; border: 2px solid #6a9a5a; border-radius: 6px; cursor: pointer;
}
.mode-select:focus { outline: 2px solid #8fd070; outline-offset: 2px; }
.mode-hint { margin-top: 10px; font-size: 0.85rem; color: #b8d4ae; line-height: 1.4; }
.title-setting { margin-top: 12px; }
.title-check {
  display: block; margin-top: 10px; font-size: 0.92rem; cursor: pointer;
}
.title-check input { margin-right: 8px; vertical-align: middle; }

.overlay-box button#overlay-btn {
  padding: 12px 36px; font-size: 1.05rem; font-weight: 600;
  background: linear-gradient(180deg, #5aa048, #4a8a3a); color: #fff;
  border: none; border-radius: 8px; cursor: pointer; min-width: 160px;
}
.overlay-box button#overlay-btn:hover { background: linear-gradient(180deg, #6ab858, #5aa048); }

.settings-panel {
  display: none; position: absolute; inset: 0; background: rgba(0,0,0,0.72);
  align-items: center; justify-content: center; pointer-events: auto; z-index: 40;
}
.settings-panel.open { display: flex; }
.settings-box {
  background: #1a2618; border: 1px solid #4a7a42; border-radius: 12px;
  padding: 24px 28px; max-width: 420px; width: min(92vw, 420px);
}
.settings-box h2 { color: #a8e890; margin-bottom: 16px; font-size: 1.2rem; }
.settings-slider {
  display: block; margin-bottom: 16px; font-size: 0.95rem; line-height: 1.6;
}
.settings-slider input[type="range"] { width: 100%; margin: 6px 0; }
.settings-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }
.settings-actions button {
  padding: 8px 16px; border-radius: 6px; border: 1px solid #5a8a4a;
  background: #3a5a32; color: #e8efe4; cursor: pointer;
}
.settings-actions button:hover { background: #4a7040; }

/* --- スマホ / タッチレイアウト (REQ-2026-145) --- */
body.touch-mode #game-canvas { cursor: default; }
body.touch-mode .sens-hud-label { display: none; }
body.touch-mode #tutorial.panel {
  top: 46px;
  left: 6px;
  max-width: min(200px, 40vw);
  font-size: 0.74rem;
}
body.touch-mode .tutorial-toggle {
  padding: 6px 10px;
  font-size: 0.74rem;
}
body.touch-mode .panel .tutorial-body { padding: 6px 10px; }
body.touch-mode .hud-menu-btn {
  width: 36px;
  height: 36px;
  font-size: 1rem;
}
body.touch-mode .hud-menu-panel .hud-btn {
  min-height: 36px;
  padding: 6px 8px;
  font-size: 0.74rem;
}
body.touch-mode #status-row {
  bottom: 10px;
  font-size: 0.72rem;
  gap: 8px;
  padding: 6px 10px;
  max-width: calc(100vw - 16px);
  justify-content: center;
}
body.touch-mode .stamina-bar-wrap {
  bottom: 44px;
}
body.touch-mode .stamina-bar-track {
  width: min(180px, 38vw);
  height: 8px;
}
body.touch-mode .camera-view-btn {
  padding: 8px 12px;
  font-size: 0.82rem;
}
body.touch-mode #message {
  font-size: 0.9rem;
  max-width: 88vw;
}
body.touch-mode.touch-landscape #hud-menu-wrap {
  top: auto;
  bottom: 10px;
  right: 8px;
}
body.touch-mode.touch-landscape .cpu-info {
  top: auto;
  bottom: 78px;
  left: 8px;
  max-width: min(220px, 42vw);
  font-size: 0.72rem;
  padding: 4px 8px;
}
body.touch-mode.touch-landscape #tutorial.panel {
  top: 6px;
  left: auto;
  right: auto;
  max-width: min(160px, 34vw);
}
body.touch-mode.touch-landscape .camera-view-btn {
  top: 6px;
  left: 6px;
}
body.touch-mode.portrait-mode #hud-menu-wrap {
  top: 8px;
  right: 8px;
}
body.touch-mode.portrait-mode .cpu-info {
  top: 52px;
  max-width: calc(100vw - 100px);
}
