:root {
  --bg-color: #08080a;
  --surface-color: rgba(18, 18, 22, 0.8);
  --primary-accent: #00d2ff;
  --success-color: #00ff87;
  --error-color: #ff3e6c;
  --warning-color: #ffda08;
  --text-color: #e2e8f0;
  --text-muted: #64748b;
  --glass-bg: rgba(255, 255, 255, 0.02);
  --glass-border: rgba(255, 255, 255, 0.08);
  --door-bg: linear-gradient(135deg, #1a1a1f, #222228);
}

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;700&family=Roboto+Mono:wght@500&display=swap');

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

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  background-image: radial-gradient(circle at center, #111122 0%, #08080a 100%);
}

.app-container {
  width: 98vw;
  height: 96vh;
  background: var(--surface-color);
  backdrop-filter: blur(30px);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  padding: 15px;
  gap: 10px;
}

body.modal-open .app-container { filter: blur(10px); pointer-events: none; }

header { text-align: center; margin-bottom: 5px; }
h1 { font-size: 1.8rem; letter-spacing: 2px; color: #fff; font-weight: 700; }
.subtitle { font-family: 'Inter', sans-serif; font-size: 0.8rem; color: #94a3b8; letter-spacing: 1px; }

.help-btn {
  width: 24px; height: 24px; border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: transparent; color: rgba(255, 255, 255, 0.5);
  font-weight: 700; cursor: pointer; transition: 0.2s;
  display: flex; justify-content: center; align-items: center;
}

.strategy-section {
  flex: 1;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 10px;
  display: flex;
  align-items: center;
  gap: 20px;
}

.section-label {
  writing-mode: vertical-rl;
  font-weight: 700;
  letter-spacing: 2px;
  font-size: 0.7rem;
  opacity: 0.3;
}

.stats-mini {
  width: 110px;
  display: flex; flex-direction: column; gap: 4px;
}
.stat-item { font-family: 'Roboto Mono', monospace; font-size: 0.65rem; color: var(--text-muted); }
.stat-item span { color: var(--text-color); font-weight: 700; font-size: 0.9rem; }

/* Visual Hub: Center Container */
.main-visual-area {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
}

.visual-hub {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}

.phase-hud-mini {
  width: 310px; /* Aligns with 3-door grid */
  text-align: center;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-muted);
  padding: 5px;
  border-radius: 4px;
  font-weight: 700;
  font-size: 0.75rem;
  letter-spacing: 4px;
  border: 1px solid var(--glass-border);
}

.doors-container {
  display: flex;
  align-items: center;
  gap: 20px;
}

/* Fixed width Legend & Spacer to keep doors centered under HUD */
.ui-legend, .ui-legend-spacer {
    width: 110px;
    flex-shrink: 0;
}

.ui-legend {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.legend-box {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    border-width: 2px;
    border-style: solid;
}

.legend-text {
    font-size: 0.6rem;
    color: var(--text-muted);
    font-weight: 700;
    white-space: nowrap;
}

.doors-grid {
  display: flex;
  gap: 20px;
  width: 310px;
}

.door-wrapper-small {
  width: 90px;
  height: 110px;
  position: relative;
  background: var(--door-bg);
  border: 2px solid #222;
  border-radius: 6px;
  display: flex;
  justify-content: center;
  align-items: center;
}
.door-small { font-size: 1.2rem; font-weight: 700; color: rgba(255, 255, 255, 0.04); }

.door-wrapper-small.picked { border-color: var(--primary-accent); border-width: 3px; }
.door-wrapper-small.opened { opacity: 0.2; border-style: dashed; border-color: var(--error-color); background: rgba(255, 62, 108, 0.05); }
.door-wrapper-small.final { border-color: var(--warning-color); border-width: 4px; box-shadow: 0 0 10px rgba(255, 218, 8, 0.3); }

.result-mark {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  font-size: 3rem; z-index: 10; opacity: 0; transition: 0.2s;
}
.result-mark.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }

/* Center Panel (Controls & Chart) */
.center-panel {
  height: 170px;
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 15px;
}
.chart-box { background: rgba(0, 0, 0, 0.4); border-radius: 12px; padding: 10px; border: 1px solid var(--glass-border); }
.control-box { background: var(--glass-bg); border-radius: 12px; padding: 10px; display: flex; flex-direction: column; justify-content: center; gap: 8px; border: 1px solid var(--glass-border); }
.sim-speed-control label { font-size: 0.6rem; color: var(--text-muted); font-weight: 700; }
input[type="number"] { background: rgba(0,0,0,0.3); border: 1px solid var(--glass-border); color: #fff; padding: 3px; border-radius: 4px; font-size: 0.75rem; }
input[type="range"] { width: 100%; height: 4px; border-radius: 2px; background: #333; outline: none; appearance: none; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%; background: var(--primary-accent); cursor: pointer; }

footer { font-size: 0.55rem; color: var(--text-muted); text-align: center; }

/* Modal */
.modal-overlay {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(5px);
  display: none; justify-content: center; align-items: center; z-index: 1000;
  opacity: 0; transition: opacity 0.4s ease;
}
.modal-overlay.show { display: flex; opacity: 1; }
.modal-content {
  background: #1a1a1f; border: 1px solid var(--glass-border);
  padding: 25px; border-radius: 15px; max-width: 550px;
}
.modal-content h2 { color: var(--primary-accent); margin-bottom: 10px; border-bottom: 1px solid #333; padding-bottom: 5px; font-size: 1.4rem; }
.modal-body { font-size: 0.9rem; line-height: 1.4; }