:root {
  --bg-dark: #1a1005;
  --bg-panel: #2b190b;
  --gold: #d4a017;
  --gold-bright: #ffc94d;
  --green: #3d8b37;
  --red: #a82323;
  --text: #f5e7c6;
  --text-muted: #c9b28a;
  --shadow: rgba(0,0,0,0.6);
  --touch-size: 56px;
}

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

html, body {
  width:100%;
  height:100%;
  overflow:hidden;
  font-family: 'Georgia', 'Times New Roman', serif;
  background: var(--bg-dark);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
}

#app {
  position:relative;
  width:100%;
  height:100%;
}

#gameContainer {
  position:absolute;
  inset:0;
  width:100%;
  height:100%;
}
#gameContainer canvas {
  display:block;
  width:100%;
  height:100%;
}

.hidden { display:none !important; }

/* ---------- HUD ---------- */
#hud {
  position:absolute;
  top:0;
  left:0;
  width:100%;
  pointer-events:none;
  z-index:5;
}

.hud-top {
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:8px 12px;
  background:linear-gradient(180deg, rgba(20,12,5,0.9), rgba(20,12,5,0.4));
  gap:10px;
}

.player-stats { flex:1; display:flex; flex-direction:column; gap:4px; }

.stat {
  height:14px;
  background: rgba(0,0,0,0.7);
  border-radius:7px;
  overflow:hidden;
  border:1px solid #5a3b1a;
}
.stat span {
  display:block;
  height:100%;
  width:100%;
  transition: width 0.2s;
}
#healthBar { background: linear-gradient(90deg, #e33, #a82323); }
#staminaBar { background: linear-gradient(90deg, #4a9eff, #2e6bb0); }

.objective-box {
  flex:2;
  background: rgba(0,0,0,0.6);
  border:1px solid var(--gold);
  border-radius:8px;
  padding:6px 10px;
  text-align:center;
}
.objective-box span { font-weight:bold; color:var(--gold-bright); font-size:0.9rem; }
.objective-box p { font-size:0.8rem; color:var(--text); margin-top:2px; }

#minimap {
  position:absolute;
  top:70px;
  right:10px;
  width:160px;
  height:120px;
  border:2px solid var(--gold);
  border-radius:8px;
  background: rgba(0,0,0,0.6);
}

.weapon-info {
  position:absolute;
  bottom:10px;
  right:10px;
  background: rgba(0,0,0,0.6);
  padding:6px 10px;
  border-radius:8px;
  font-size:0.8rem;
  color:var(--text);
}

.icon-btn {
  pointer-events:auto;
  background: rgba(0,0,0,0.7);
  border:2px solid var(--gold);
  color: var(--gold-bright);
  font-size:1.4rem;
  width:44px;
  height:44px;
  border-radius:50%;
  cursor:pointer;
}
.icon-btn:hover { background: #3a2714; }

/* ---------- Touch controls ---------- */
#touchControls {
  position:absolute;
  bottom:20px;
  left:10px;
  right:10px;
  display:flex;
  justify-content:space-between;
  align-items:flex-end;
  z-index:6;
  pointer-events:none;
}
.dpad {
  display:grid;
  grid-template-columns:repeat(3, var(--touch-size));
  grid-template-rows:repeat(3, var(--touch-size));
  gap:4px;
  pointer-events:auto;
}
.touch-btn {
  width:var(--touch-size);
  height:var(--touch-size);
  background: rgba(0,0,0,0.6);
  border:2px solid var(--gold);
  border-radius:12px;
  color:var(--gold-bright);
  font-size:1.2rem;
  cursor:pointer;
}
.touch-btn[data-dir="up"] { grid-column:2; grid-row:1; }
.touch-btn[data-dir="left"] { grid-column:1; grid-row:2; }
.touch-btn[data-dir="down"] { grid-column:2; grid-row:2; }
.touch-btn[data-dir="right"] { grid-column:3; grid-row:2; }

.actions {
  display:flex;
  gap:12px;
  pointer-events:auto;
}
.touch-action {
  width:64px;
  height:64px;
  background: rgba(0,0,0,0.7);
  border:2px solid var(--gold);
  border-radius:50%;
  font-size:2rem;
  cursor:pointer;
}

/* ---------- Overlays / menus ---------- */
.overlay {
  position:absolute;
  inset:0;
  display:flex;
  align-items:center;
  justify-content:center;
  background: rgba(10,6,2,0.85);
  z-index:10;
  backdrop-filter: blur(4px);
}

.menu-card {
  background: var(--bg-panel);
  border:3px solid var(--gold);
  border-radius:16px;
  padding:24px;
  width:90%;
  max-width:420px;
  max-height:85vh;
  overflow-y:auto;
  box-shadow: 0 10px 30px var(--shadow);
  text-align:center;
}
.menu-card h1 {
  font-size:2.2rem;
  color:var(--gold-bright);
  letter-spacing:2px;
  text-shadow: 2px 2px 0 #000;
}
.menu-card .subtitle {
  font-style: italic;
  color: var(--text-muted);
  margin-bottom:20px;
}
.menu-card h2 { color:var(--gold-bright); margin-bottom:16px; }

.menu-card button {
  display:block;
  width:100%;
  margin:10px 0;
  padding:14px;
  font-size:1.1rem;
  font-family:inherit;
  background: #4a2d12;
  color: var(--gold-bright);
  border:2px solid var(--gold);
  border-radius:10px;
  cursor:pointer;
  transition: background 0.2s;
}
.menu-card button:hover { background: #6b4422; }
.menu-card label {
  display:block;
  margin:12px 0;
  text-align:left;
  font-size:1rem;
  color:var(--text);
}
.menu-card input[type="checkbox"] {
  transform: scale(1.3);
  margin-right:10px;
  vertical-align:middle;
}

.mission-list {
  display:flex;
  flex-direction:column;
  gap:8px;
  margin:16px 0;
}
.mission-list button {
  background: #3a2714;
  text-align:left;
  padding:12px 16px;
}
.mission-list button.locked {
  opacity:0.5;
  cursor:not-allowed;
}
.mission-list button.completed::after {
  content:" ✔";
  color: var(--green);
  font-weight:bold;
}

/* Dialogue */
.dialogue-card {
  background: var(--bg-panel);
  border:3px solid var(--gold);
  border-radius:16px;
  padding:20px;
  width:90%;
  max-width:560px;
  display:flex;
  gap:16px;
  align-items:flex-start;
}
.dialogue-card img {
  width:90px;
  height:90px;
  border-radius:50%;
  border:3px solid var(--gold);
  object-fit:cover;
  background:#4a2d12;
  flex-shrink:0;
}
.dialogue-card h3 { color:var(--gold-bright); margin-bottom:6px; }
.dialogue-card p { color:var(--text); margin-bottom:6px; line-height:1.4; }
#dialogueSubtitle { color:var(--text-muted); font-style:italic; font-size:0.9rem; }
.dialogue-card button {
  margin-top:10px;
  padding:10px 20px;
  background:#4a2d12;
  color:var(--gold-bright);
  border:2px solid var(--gold);
  border-radius:8px;
  cursor:pointer;
}

#resultOverlay .menu-card button {
  display:inline-block;
  width:auto;
  margin:10px;
}

/* Responsive adjustments */
@media (max-width: 480px) {
  .objective-box { font-size:0.7rem; }
  #minimap { width:110px; height:85px; top:65px; right:8px; }
  .touch-action { width:54px; height:54px; font-size:1.5rem; }
  :root { --touch-size: 46px; }
}