:root {
  --bg:           #0a0b09;
  --surface:      #111310;
  --surface-2:    #171913;
  --border:       #2a2d23;
  --green:        #6b9c52;
  --green-bright: #8ec46e;
  --green-dim:    #1e2d17;
  --amber:        #b8922a;
  --amber-bright: #d4a93a;
  --red:          #a83030;
  --red-bright:   #c94040;
  --text:         #bdc1b0;
  --text-dim:     #525749;
  --text-muted:   #727866;
  --mono:         monospace;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

#title-screen,
#game-container {
  width: min(680px, 100vw);
}

#title-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  gap: 20px;
  text-align: center;
  padding: 40px 32px;
}

#big-title {
  font-size: clamp(36px, 8vw, 54px);
  color: var(--text);
  line-height: 1.1;
  font-weight: bold;
}

#subtitle {
  font-size: 12px;
  color: var(--text-dim);
  text-transform: uppercase;
}

#title-rule {
  width: 48px;
  height: 1px;
  background: var(--border);
}

#title-blurb {
  font-size: 13px;
  color: var(--text-muted);
  max-width: 380px;
  line-height: 1.8;
  font-style: italic;
}

#start-btn {
  background: transparent;
  border: 1px solid var(--green);
  color: var(--green-bright);
  font-family: var(--mono);
  font-size: 13px;
  padding: 10px 32px;
  cursor: pointer;
}

#start-btn:hover { background: var(--green-dim); }
#start-btn:disabled { opacity: 0.3; cursor: not-allowed; }

.title-note {
  font-size: 11px;
  color: var(--text-dim);
  max-width: 340px;
  line-height: 1.7;
}

#game-container {
  display: none;
  flex-direction: column;
  height: 100vh;
  padding: 16px 18px;
  gap: 10px;
}

#header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

#header-title {
  font-size: 13px;
  font-style: italic;
  color: var(--text-dim);
}

#header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

#day-counter {
  font-size: 11px;
  color: var(--text-dim);
}

#stats-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 9px 12px 10px;
}

.stat-label {
  font-size: 10px;
  color: var(--text-dim);
  text-transform: uppercase;
}

.stat-value {
  font-size: 20px;
  margin-top: 4px;
  line-height: 1;
}

.stat-track {
  height: 1px;
  background: var(--border);
  margin-top: 8px;
}

.stat-fill {
  height: 100%;
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

#main-panel {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 24px 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: relative;
  overflow: hidden;
  min-height: 0;
}

#scene-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#scene-label {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
}

#progress-track {
  display: flex;
  gap: 3px;
  align-items: center;
}

.prog-dot {
  width: 4px;
  height: 4px;
  background: var(--border);
  transition: background 0.3s, transform 0.3s;
}

.prog-dot.done {
  background: var(--green-dim);
  border: 1px solid var(--green);
  opacity: 0.6;
}
.prog-dot.current {
  background: var(--green);
  transform: scale(1.4);
}
.prog-dot.minigame {
  background: var(--amber);
  opacity: 0.7;
}
.prog-dot.minigame.current {
  background: var(--amber);
  transform: scale(1.4);
  opacity: 1;
}

#event-title {
  font-size: 20px;
  color: var(--text);
  line-height: 1.2;
  font-weight: bold;
}

#event-text {
  font-size: 13px;
  line-height: 1.9;
  color: var(--text-muted);
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border-2) transparent;
}

#choices {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.choice-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 12px;
  padding: 10px 14px;
  text-align: left;
  cursor: pointer;
  line-height: 1.55;
}

.choice-btn::before {
  content: '> ';
  color: var(--green);
}

.choice-btn:hover {
  border-color: var(--green);
  color: var(--text);
}

.choice-btn:disabled { opacity: 0.25; cursor: not-allowed; }

#outcome-panel {
  display: none;
  padding: 12px 16px;
  border-left: 2px solid var(--green);
  font-size: 13px;
  line-height: 1.8;
  color: var(--text-muted);
}

#outcome-panel.bad {
  border-color: var(--red);
}

#continue-btn {
  display: none;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 12px;
  padding: 8px 22px;
  cursor: pointer;
  align-self: flex-end;
}

#continue-btn:hover { border-color: var(--text-muted); color: var(--text); }

#minigame-overlay {
  display: none;
  position: absolute;
  inset: 0;
  background: var(--surface);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  z-index: 10;
  padding: 20px;
}

#mg-header { text-align: center; }

#mg-title {
  font-size: 18px;
  color: var(--amber-bright);
  margin-bottom: 6px;
  font-weight: bold;
}

#mg-instruction {
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.8;
  max-width: 340px;
  text-align: center;
}

#cam-wrap {
  position: relative;
  width: 320px;
  height: 240px;
  border: 1px solid var(--border);
  overflow: hidden;
  flex-shrink: 0;
  transition: border-color 0.25s;
}

#cam-wrap.state-danger { border-color: var(--red); }
#cam-wrap.state-safe   { border-color: var(--green); }

#video-el {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
  filter: brightness(0.48) saturate(0.15) sepia(0.3) hue-rotate(55deg);
}

#hand-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#drive-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  display: none;
}

#mg-status {
  font-size: 12px;
  color: var(--amber-bright);
  text-align: center;
  min-height: 18px;
  font-family: var(--mono);
}

#mg-timer-track {
  width: 320px;
  height: 1px;
  background: var(--border);
}

#mg-timer-fill {
  height: 100%;
}

#mg-skip-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 11px;
  padding: 7px 16px;
  cursor: pointer;
  display: none;
}

#mg-skip-btn:hover { color: var(--text); border-color: var(--text-muted); }

#mg-no-cam-msg {
  font-size: 11px;
  color: var(--text-dim);
  text-align: center;
  max-width: 280px;
  line-height: 1.75;
}

#end-screen {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 14px;
  text-align: center;
  padding: 6px 0;
  overflow-y: auto;
  max-height: 100%;
}

#end-title {
  font-size: 26px;
  font-weight: bold;
}

#end-text {
  font-size: 12px;
  color: var(--text-muted);
  max-width: 380px;
  line-height: 1.9;
}

#end-score-big {
  font-size: 64px;
  font-weight: bold;
  color: var(--green-bright);
  line-height: 1;
}

#end-score-label {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 5px;
}

#end-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  width: 100%;
}

.end-stat {
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 10px 12px;
  text-align: center;
}

.end-stat-label {
  font-size: 10px;
  color: var(--text-dim);
  text-transform: uppercase;
  margin-bottom: 6px;
}

.end-stat-val {
  font-size: 22px;
  color: var(--text);
}

#restart-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 12px;
  padding: 8px 22px;
  cursor: pointer;
}

#restart-btn:hover { border-color: var(--text-muted); color: var(--text); }

@keyframes flash-red {
  0%   { background: rgba(168, 48, 48, 0.18); }
  100% { background: var(--surface); }
}

.flash-bad { animation: flash-red 0.4s ease-out; }

#event-text::-webkit-scrollbar { width: 3px; }
#event-text::-webkit-scrollbar-track { background: transparent; }
#event-text::-webkit-scrollbar-thumb { background: var(--border); }
