:root {
  --bg-primary: #0a0d13;
  --bg-card: #111621;
  --bg-card-hover: #161d2b;
  --border: rgba(255,255,255,0.07);
  --border-highlight: rgba(255,255,255,0.15);
  --amber: #f6a623;
  --amber-dim: #a67416;
  --green: #3ecf8e;
  --green-dim: #1a7a4e;
  --red: #ef4444;
  --red-dim: #991b1b;
  --blue: #60a5fa;
  --blue-dim: #1e4a8a;
  --brown: #a0845c;
  --yellow: #facc15;
}

* {
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  font-family: 'IBM Plex Sans', sans-serif;
  background: var(--bg-primary);
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  touch-action: manipulation;
  overscroll-behavior: none;
  position: fixed;
  width: 100%;
}

.font-mono { font-family: 'JetBrains Mono', monospace; }

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  transition: border-color 0.2s;
}

.progress-bar {
  height: 12px;
  border-radius: 3px;
  background: rgba(255,255,255,0.05);
  overflow: hidden;
  position: relative;
}
.progress-bar .fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s ease, background-color 0.3s;
}
.progress-bar .label {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
  color: white;
  text-shadow: 0 1px 3px rgba(0,0,0,0.6);
}

@keyframes pulse-warning {
  0%, 100% { opacity: 1; box-shadow: 0 0 8px currentColor; }
  50% { opacity: 0.6; box-shadow: 0 0 2px currentColor; }
}
.pulse-warn { animation: pulse-warning 1s infinite; }

@keyframes glow-pulse {
  0%, 100% { box-shadow: 0 0 10px rgba(246,166,35,0.4); }
  50% { box-shadow: 0 0 20px rgba(246,166,35,0.8); }
}
.glow-pulse { animation: glow-pulse 1.5s infinite; }

.action-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  cursor: pointer;
  transition: all 0.15s;
  color: #e2e8f0;
  font-family: 'IBM Plex Sans', sans-serif;
  font-size: 14px;
  text-align: left;
  min-height: 44px;
  display: flex;
  align-items: center;
}
.action-btn:active:not(:disabled) {
  border-color: var(--amber);
  background: var(--bg-card-hover);
  transform: scale(0.97);
}
.action-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.log-entry {
  padding: 3px 8px;
  font-size: 12px;
  font-family: 'JetBrains Mono', monospace;
  border-left: 2px solid transparent;
  line-height: 1.6;
}
.log-entry.positive { border-left-color: var(--green); color: #86efac; }
.log-entry.warning { border-left-color: var(--yellow); color: #fde68a; }
.log-entry.danger { border-left-color: var(--red); color: #fca5a5; }
.log-entry.neutral { border-left-color: rgba(255,255,255,0.2); color: #94a3b8; }

.game-over-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.9);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(6px);
}

.dpad-btn {
  width: 52px; height: 52px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: #b0b8c8;
  font-size: 20px;
  transition: all 0.08s;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
.dpad-btn:active {
  background: rgba(246,166,35,0.25);
  border-color: var(--amber);
  color: var(--amber);
  transform: scale(0.9);
}

.drawer-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 80;
  backdrop-filter: blur(2px);
}

.drawer-left {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: 82%;
  max-width: 360px;
  background: rgba(15,17,23,0.97);
  z-index: 90;
  overflow-y: auto;
  border-right: 1px solid var(--border-highlight);
  transition: transform 0.25s ease;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.drawer-right {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 82%;
  max-width: 360px;
  background: rgba(15,17,23,0.97);
  z-index: 90;
  overflow-y: auto;
  border-left: 1px solid var(--border-highlight);
  transition: transform 0.25s ease;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) 0;
}

.bottom-sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: rgba(15,17,23,0.97);
  z-index: 100;
  border-top: 1px solid var(--amber);
  border-radius: 16px 16px 0 0;
  max-height: 70vh;
  overflow-y: auto;
  padding: 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
}

.bottom-sheet-handle {
  width: 40px;
  height: 4px;
  background: rgba(255,255,255,0.2);
  border-radius: 2px;
  margin: 0 auto 12px;
}

canvas#game-canvas {
  image-rendering: pixelated;
  display: block;
  width: 100%;
  height: 100%;
}

.settings-modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.8);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(4px);
}

::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

@media (max-height: 600px) {
  .dpad-btn { width: 44px; height: 44px; font-size: 16px; }
}