/* ============================================================
   COLD CREEK GAS PLANT SIMULATOR
   Honeywell Experion DCS Aesthetic — ISA-101 HP HMI Standard
   ============================================================
   Color = alarm state ONLY. Normal operation = gray.
   "If everything is colored, nothing stands out."
   ============================================================ */

:root {
  /* Background colors */
  --bg-deep:     #2E2E2E;
  --bg-panel:    #3C3C3C;
  --bg-card:     #424242;
  --bg-input:    #505050;
  --bg-faceplate:#404040;

  /* Borders */
  --border:      #606060;
  --border-lite: #555555;

  /* Text colors */
  --text-normal: #E8E8E8;
  --text-label:  #A0A0A0;
  --text-unit:   #808080;
  --text-tag:    #C8C8C8;
  --text-desc:   #909090;

  /* Alarm state colors — ONLY source of color in UI */
  --alarm-crit:       #FF2020;
  --alarm-crit-ack:   #CC0000;
  --alarm-hi:         #FF6600;
  --alarm-hi-ack:     #CC4400;
  --alarm-lo:         #FFD700;
  --alarm-lo-ack:     #B8960C;
  --alarm-advisory:   #FFFF80;
  --alarm-rtn:        #00CC44;
  --alarm-oos:        #00AAAA;

  /* Equipment fills */
  --equip-fill:       #505050;
  --equip-stopped:    #383838;
  --equip-fault:      #AA1111;
  --equip-starting:   #AA8800;

  /* Flow lines */
  --flow-normal:      #808080;
  --flow-active:      #A0A0A0;
  --flow-none:        #505050;
  --flow-alarm:       #FF2020;

  /* Valve */
  --valve-normal:     #787878;
  --valve-closed:     #484848;

  /* Selection accent — used sparingly */
  --accent:           #4ab3f4;

  /* Font stack */
  --font-mono: "Courier New", Consolas, "Liberation Mono", monospace;
  --font-sans: Arial, "Helvetica Neue", sans-serif;
  --font-condensed: "Arial Narrow", Arial, sans-serif;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-deep);
  color: var(--text-normal);
  font-family: var(--font-sans);
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  /* iOS safe area — prevents content from hiding behind notch/home indicator */
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  user-select: none;
  -webkit-user-select: none;
}

/* ---- SCREENS ---- */
.screen {
  display: none;
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  overflow-y: auto;
}
.screen.active {
  display: flex;
}

/* ============================================================
   TITLE SCREEN
   ============================================================ */
#title-screen {
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  background: var(--bg-deep);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: env(safe-area-inset-top, 20px) 16px 20px;
}
.title-content {
  text-align: center;
  width: 100%;
  max-width: 500px;
  padding-top: 24px;
  margin: auto 0;
}
.title-logo {
  font-family: var(--font-mono);
  font-size: 48px;
  font-weight: 700;
  letter-spacing: 0.2em;
  color: var(--text-normal);
  margin-bottom: 4px;
}
.title-sub {
  font-family: var(--font-condensed);
  font-size: 14px;
  letter-spacing: 0.3em;
  color: var(--text-unit);
  margin-bottom: 40px;
  text-transform: uppercase;
}
.title-menu {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}
.menu-btn {
  font-family: var(--font-mono);
  font-size: 14px;
  padding: 12px 40px;
  background: var(--bg-card);
  color: var(--text-normal);
  border: 1px solid var(--border);
  cursor: pointer;
  letter-spacing: 0.1em;
  min-width: 220px;
  transition: background 0.15s;
}
.menu-btn:hover {
  background: var(--bg-input);
}
.menu-btn:active {
  background: var(--border);
}
/* Username Section */
.username-section {
  margin-bottom: 20px;
}
.username-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.username-label {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-unit);
  letter-spacing: 0.1em;
}
.username-name {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--text-normal);
  letter-spacing: 0.05em;
}
.username-edit-btn {
  background: none;
  border: none;
  color: var(--text-unit);
  cursor: pointer;
  font-size: 14px;
  padding: 2px 6px;
}
.username-edit-btn:hover {
  color: var(--text-normal);
}
.username-prompt {
  display: flex;
  gap: 8px;
  justify-content: center;
  align-items: center;
}
.username-input {
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 8px 12px;
  background: var(--bg-input);
  color: var(--text-normal);
  border: 1px solid var(--border);
  text-align: center;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  width: 180px;
}
.username-input::placeholder {
  color: var(--text-unit);
  text-transform: uppercase;
}
.username-save-btn {
  min-width: unset;
  padding: 8px 16px;
  font-size: 12px;
}

/* Leaderboard */
.leaderboard-box {
  margin-top: 24px;
  padding: 14px 16px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  max-width: 360px;
  margin-left: auto;
  margin-right: auto;
}
.leaderboard-title {
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.15em;
  color: var(--text-label);
  margin-bottom: 10px;
  text-align: center;
}
.leaderboard-list {
  max-height: 240px;
  overflow-y: auto;
}
.leaderboard-loading {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-unit);
  text-align: center;
  padding: 12px;
}
.leaderboard-empty {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-unit);
  text-align: center;
  padding: 12px;
}
.lb-row {
  display: flex;
  align-items: center;
  padding: 5px 8px;
  border-bottom: 1px solid var(--border-lite);
  gap: 8px;
}
.lb-row:last-child {
  border-bottom: none;
}
.lb-row.lb-self {
  background: rgba(90, 155, 212, 0.1);
}
.lb-rank {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-unit);
  width: 24px;
  text-align: right;
  flex-shrink: 0;
}
.lb-rank-1 { color: #FFD700; }
.lb-rank-2 { color: #C0C0C0; }
.lb-rank-3 { color: #CD7F32; }
.lb-name {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-normal);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lb-facility {
  font-family: var(--font-condensed);
  font-size: 10px;
  color: var(--text-unit);
  letter-spacing: 0.05em;
  flex-shrink: 0;
}
.lb-score {
  font-family: var(--font-mono);
  font-size: 12px;
  color: #4CAF50;
  text-align: right;
  flex-shrink: 0;
  min-width: 70px;
}
.lb-score.negative {
  color: #E04040;
}

.title-footer-links {
  margin-top: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.title-footer-sep {
  color: var(--border);
  font-size: 12px;
}
.donate-link {
  font-family: var(--font-condensed);
  font-size: 12px;
  letter-spacing: 0.15em;
  color: var(--text-unit);
  text-decoration: none;
  text-transform: uppercase;
  transition: color 0.2s ease;
}
.donate-link:hover {
  color: var(--text-normal);
}

.title-credit {
  margin-top: 40px;
  font-size: 11px;
  color: var(--text-unit);
  font-style: italic;
}

/* Objectives Overlay */
.objectives-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(30, 30, 30, 0.95);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
}
.obj-briefing, .obj-results {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  padding: 24px 32px;
  max-width: 400px;
  width: 90%;
  text-align: center;
}
.obj-briefing-title, .obj-results-title {
  font-family: var(--font-mono);
  font-size: 15px;
  letter-spacing: 0.15em;
  color: var(--text-normal);
  margin-bottom: 8px;
}
.obj-briefing-sub {
  font-family: var(--font-condensed);
  font-size: 12px;
  color: var(--text-unit);
  margin-bottom: 16px;
}
.obj-group {
  margin-bottom: 12px;
  text-align: left;
}
.obj-group-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.15em;
  display: block;
  margin-bottom: 4px;
}
.obj-group-label.obj-primary { color: var(--text-normal); }
.obj-group-label.obj-secondary { color: var(--text-label); }
.obj-group-label.obj-bonus { color: #D4A843; }
.obj-item {
  font-family: var(--font-condensed);
  font-size: 12px;
  color: var(--text-normal);
  padding: 3px 0 3px 4px;
}
.obj-bullet {
  font-size: 8px;
  margin-right: 6px;
}
.obj-bullet.obj-primary { color: var(--text-normal); }
.obj-bullet.obj-secondary { color: var(--text-label); }
.obj-bullet.obj-bonus { color: #D4A843; }
.obj-start-btn, .obj-done-btn {
  margin-top: 20px;
  min-width: 200px;
}

/* Shift Results */
.obj-grade {
  font-family: var(--font-mono);
  font-size: 48px;
  font-weight: 700;
  margin: 8px 0 2px;
}
.obj-grade-label {
  font-family: var(--font-condensed);
  font-size: 13px;
  letter-spacing: 0.2em;
  margin-bottom: 12px;
}
.obj-earnings {
  font-family: var(--font-mono);
  font-size: 16px;
  margin-bottom: 16px;
}
.obj-earnings.positive { color: #4CAF50; }
.obj-earnings.negative { color: #E04040; }
.obj-checklist {
  text-align: left;
  margin-bottom: 8px;
}
.obj-result-row {
  font-family: var(--font-condensed);
  font-size: 12px;
  padding: 4px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.obj-result-row.obj-pass .obj-check-icon { color: #4CAF50; }
.obj-result-row.obj-fail .obj-check-icon { color: #E04040; }
.obj-check-label {
  color: var(--text-normal);
}

/* Feedback Boys */
.feedback-box {
  margin-top: 32px;
  padding: 16px 20px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  max-width: 300px;
  margin-left: auto;
  margin-right: auto;
  text-align: left;
}
.feedback-title {
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.15em;
  color: var(--text-label);
  margin-bottom: 10px;
  text-align: center;
}
.feedback-textarea {
  width: 100%;
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--bg-input);
  color: var(--text-normal);
  border: 1px solid var(--border-lite);
  padding: 8px;
  resize: vertical;
  margin-bottom: 8px;
  box-sizing: border-box;
}
.feedback-textarea::placeholder,
.feedback-input::placeholder {
  color: var(--text-unit);
}
.feedback-input {
  width: 100%;
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--bg-input);
  color: var(--text-normal);
  border: 1px solid var(--border-lite);
  padding: 8px;
  margin-bottom: 10px;
  box-sizing: border-box;
}
.feedback-btn {
  width: 100%;
  min-width: unset;
  padding: 10px;
  font-size: 13px;
}
.feedback-sent {
  color: var(--alarm-rtn);
  font-family: var(--font-mono);
  font-size: 12px;
  text-align: center;
  margin-top: 8px;
}

/* ============================================================
   MODE / FACILITY SELECT
   ============================================================ */
.mode-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  background: var(--bg-deep);
  border-bottom: 1px solid var(--border);
  width: 100%;
}
.mode-header h2 {
  font-family: var(--font-mono);
  font-size: 16px;
  letter-spacing: 0.1em;
  color: var(--text-label);
}
.back-btn {
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 6px 12px;
  background: var(--bg-card);
  color: var(--text-label);
  border: 1px solid var(--border);
  cursor: pointer;
}
.back-btn:hover {
  background: var(--bg-input);
}
#mode-screen, #facility-screen, #settings-screen, #crisis-screen, #profile-screen {
  flex-direction: column;
  background: var(--bg-panel);
}
.mode-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  padding: 24px 20px;
  max-width: 900px;
}
.mode-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 20px;
  cursor: pointer;
  transition: border-color 0.15s;
  position: relative;
}
.mode-card:hover {
  border-color: var(--text-label);
}
.mode-card.locked {
  opacity: 0.5;
  cursor: not-allowed;
}
.mode-card.locked:hover {
  border-color: var(--border);
}
.mode-card h3 {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--text-normal);
  margin-bottom: 8px;
  letter-spacing: 0.05em;
}
.mode-card p {
  font-size: 12px;
  color: var(--text-label);
  line-height: 1.5;
}
.mode-icon {
  font-size: 10px;
  color: var(--text-label);
  margin-bottom: 4px;
  display: block;
}
.mode-yellow { color: var(--alarm-lo); }
.mode-red { color: var(--alarm-crit); }
.mode-gold { color: var(--alarm-lo-ack); }
.tier-label {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-unit);
  margin-top: 10px;
  letter-spacing: 0.1em;
}
.lock-label {
  display: block;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--alarm-lo-ack);
  margin-top: 8px;
  letter-spacing: 0.05em;
}

/* ============================================================
   SETTINGS
   ============================================================ */
.settings-panel {
  padding: 24px 20px;
  max-width: 500px;
}
.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-label);
}
.setting-row select, .setting-row input[type="checkbox"] {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-normal);
  padding: 4px 8px;
  font-family: var(--font-mono);
  font-size: 12px;
}

/* ============================================================
   GAME SCREEN — MAIN LAYOUT
   ============================================================ */
#game-screen {
  flex-direction: column;
  background: var(--bg-panel);
}

/* ---- TOP BAR ---- */
#topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 36px;
  padding: 0 12px;
  background: var(--bg-deep);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.topbar-left, .topbar-center, .topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.topbar-menu-btn {
  background: none;
  border: 1px solid var(--border-lite);
  color: var(--text-label);
  font-size: 16px;
  cursor: pointer;
  padding: 2px 6px;
  line-height: 1;
}
.topbar-menu-btn:hover {
  color: var(--text-normal);
  border-color: var(--text-label);
}
#plant-name {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-tag);
  letter-spacing: 0.1em;
}
#game-mode-label {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-unit);
  padding: 2px 6px;
  border: 1px solid var(--border);
}
#game-time {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--text-normal);
}
#shift-label {
  font-family: var(--font-condensed);
  font-size: 10px;
  color: var(--text-unit);
  letter-spacing: 0.1em;
}
.pnl-value {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-normal);
}
.pnl-total {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-label);
}

/* ---- ALARM SUMMARY BAR ---- */
#alarm-bar {
  display: flex;
  align-items: center;
  height: 28px;
  padding: 0 12px;
  background: var(--bg-deep);
  border-bottom: 1px solid var(--border);
  gap: 12px;
  flex-shrink: 0;
  cursor: pointer;
}
#alarm-bar.has-alarms {
  background: #440000;
}
#alarm-bar.has-unacked {
  animation: alarm-flash 1s infinite;
}
@keyframes alarm-flash {
  0%, 100% { background: #660000; }
  50% { background: #440000; }
}
#alarm-count {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-label);
  min-width: 90px;
}
#alarm-bar.has-alarms #alarm-count {
  color: var(--alarm-crit);
}
#alarm-message {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-unit);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#alarm-bar.has-alarms #alarm-message {
  color: var(--alarm-lo);
}
#alarm-ack-btn {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 2px 8px;
  background: var(--bg-card);
  color: var(--text-normal);
  border: 1px solid var(--border);
  cursor: pointer;
}

/* ---- MAIN CONTENT AREA ---- */
#main-content {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ---- LEFT PANEL (Process Values) ---- */
#left-panel {
  width: 220px;
  overflow-y: auto;
  border-right: 1px solid var(--border);
  background: var(--bg-panel);
  padding: 4px 0;
  flex-shrink: 0;
}
.panel-section {
  padding: 4px 8px;
  border-bottom: 1px solid var(--border-lite);
}
.section-header {
  font-family: var(--font-sans);
  font-size: 10px;
  color: var(--text-desc);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 4px 0 2px;
}

/* ---- GAUGE ROW (DCS Tag Format) ---- */
.gauge-row {
  display: flex;
  align-items: center;
  padding: 3px 4px;
  border-left: 3px solid transparent;
  cursor: pointer;
  gap: 4px;
  min-height: 28px;
  background: var(--bg-card);
  margin: 2px 0;
  transition: border-color 0.2s, background 0.15s;
}
.gauge-row:hover {
  background: var(--bg-input);
}
.gauge-row.alarm-hi {
  border-left-color: var(--alarm-lo);
}
.gauge-row.alarm-hihi {
  border-left-color: var(--alarm-crit);
  animation: gauge-flash 1s infinite;
}
@keyframes gauge-flash {
  0%, 100% { background: var(--bg-card); }
  50% { background: #3a1010; }
}
.gauge-row.alarm-lo {
  border-left-color: var(--alarm-lo);
}
.gauge-row.alarm-lolo {
  border-left-color: var(--alarm-crit);
  animation: gauge-flash 1s infinite;
}
.gauge-tag-block {
  display: flex;
  flex-direction: column;
  min-width: 62px;
}
.gauge-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-tag);
  letter-spacing: 0.02em;
}
.gauge-desc {
  font-family: var(--font-condensed);
  font-size: 8px;
  color: var(--text-unit);
  letter-spacing: 0.02em;
}
.gauge-val-block {
  display: flex;
  align-items: baseline;
  gap: 3px;
  flex: 1;
  justify-content: flex-end;
}
.gauge-val {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-normal);
  text-align: right;
  min-width: 48px;
}
.gauge-row.alarm-hi .gauge-val,
.gauge-row.alarm-lo .gauge-val {
  color: var(--alarm-lo);
}
.gauge-row.alarm-hihi .gauge-val,
.gauge-row.alarm-lolo .gauge-val {
  color: var(--alarm-crit);
}
.gauge-unit {
  font-family: var(--font-condensed);
  font-size: 9px;
  color: var(--text-unit);
  min-width: 30px;
}
.gauge-mode {
  font-family: var(--font-mono);
  font-size: 8px;
  color: var(--text-unit);
  padding: 1px 3px;
  border: 1px solid var(--border);
}
.gauge-trend {
  font-size: 11px;
  color: var(--text-label);
  width: 14px;
  text-align: center;
}
.gauge-trend.rising { color: var(--alarm-lo); }
.gauge-trend.falling { color: var(--alarm-lo); }
.gauge-trend.rising-fast { color: var(--alarm-crit); }
.gauge-trend.falling-fast { color: var(--alarm-crit); }

/* ---- CENTER PANEL (P&ID) ---- */
#center-panel {
  flex: 1;
  overflow: hidden;
  position: relative;
  background: var(--bg-panel);
  display: flex;
  align-items: center;
  justify-content: center;
}
#pid-diagram {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
}

/* SVG flow lines — colors set via inline stroke attributes per stream type */
.flow-line {
  stroke-width: 1.5px;
  fill: none;
}
/* Animated flow when sim is running */
.flow-line.flowing {
  stroke-dasharray: 6 4;
  animation: flow-move 0.8s linear infinite;
}
.flow-line.flowing-2x {
  stroke-dasharray: 6 4;
  animation: flow-move 0.4s linear infinite;
}
.flow-line.flowing-4x {
  stroke-dasharray: 6 4;
  animation: flow-move 0.2s linear infinite;
}
@keyframes flow-move {
  to { stroke-dashoffset: -10; }
}
.flow-line.no-flow {
  stroke: var(--flow-none) !important;
  stroke-width: 1px;
  animation: none;
}
.flow-line.alarm {
  stroke: var(--flow-alarm) !important;
  stroke-width: 2px;
}

/* Tag bubbles on P&ID — clickable */
.tag-bubble {
  cursor: pointer;
  transition: stroke 0.2s, filter 0.2s;
  stroke: #5A9FD4 !important;
  stroke-width: 1.2;
  fill: rgba(90, 159, 212, 0.08);
  animation: tag-pulse 3s ease-in-out infinite;
}
.tag-bubble:hover {
  stroke: #7BC0FF !important;
  stroke-width: 2;
  fill: rgba(90, 159, 212, 0.15);
  filter: drop-shadow(0 0 4px rgba(90, 159, 212, 0.5));
}
@keyframes tag-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* Valve groups — clickable */
g[id^="equip-"] {
  cursor: pointer;
}
g[id^="equip-"] polygon {
  transition: fill 0.2s;
}
g[id^="equip-"]:hover polygon {
  fill: #5A9FD4;
}
g[id^="equip-"]:hover circle {
  stroke: #5A9FD4;
}
g[id^="equip-"]:hover line {
  stroke: #5A9FD4;
}

/* ---- FACEPLATE POPUP ---- */
.faceplate {
  position: absolute;
  width: 260px;
  background: var(--bg-faceplate);
  border: 1px solid var(--border);
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  z-index: 100;
  font-family: var(--font-mono);
}
.fp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  background: var(--bg-deep);
  border-bottom: 1px solid var(--border);
}
#fp-tag {
  font-size: 12px;
  color: var(--text-tag);
}
#fp-desc {
  font-size: 10px;
  color: var(--text-unit);
  flex: 1;
  margin-left: 8px;
}
.fp-close-btn {
  font-family: var(--font-mono);
  font-size: 11px;
  background: none;
  border: none;
  color: var(--text-unit);
  cursor: pointer;
  padding: 2px 6px;
}
.fp-close-btn:hover {
  color: var(--text-normal);
}
.fp-body {
  padding: 8px 10px;
}
.fp-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}
.fp-label {
  font-size: 11px;
  color: var(--text-label);
  min-width: 30px;
}
.fp-value {
  font-size: 14px;
  color: var(--text-normal);
  min-width: 60px;
  text-align: right;
}
.fp-unit {
  font-size: 10px;
  color: var(--text-unit);
}
.fp-mode {
  font-size: 9px;
  color: var(--text-unit);
  padding: 1px 4px;
  border: 1px solid var(--border);
  margin-left: auto;
}
.fp-input {
  font-family: var(--font-mono);
  font-size: 13px;
  width: 70px;
  padding: 2px 4px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-normal);
  text-align: right;
}
.fp-input:focus {
  border-color: var(--accent);
  outline: none;
}
.fp-limits {
  display: flex;
  gap: 8px;
  font-size: 9px;
  color: var(--text-unit);
  padding: 4px 0;
  border-top: 1px solid var(--border-lite);
  border-bottom: 1px solid var(--border-lite);
  margin: 4px 0;
}
.fp-bar {
  height: 8px;
  background: var(--bg-input);
  position: relative;
  margin: 6px 0;
}
.fp-bar-fill {
  height: 100%;
  background: var(--text-unit);
  width: 50%;
  transition: width 0.3s;
}
.fp-bar-sp {
  position: absolute;
  top: 0;
  height: 100%;
  width: 2px;
  background: var(--text-normal);
  left: 50%;
}
.fp-trend {
  margin: 6px 0;
}
.fp-trend canvas {
  width: 100%;
  height: 60px;
  background: var(--bg-deep);
  border: 1px solid var(--border-lite);
}
.fp-buttons {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}
.fp-mode-btn {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 4px 10px;
  background: var(--bg-card);
  color: var(--text-label);
  border: 1px solid var(--border);
  cursor: pointer;
  flex: 1;
}
.fp-mode-btn:hover {
  background: var(--bg-input);
  color: var(--text-normal);
}
.fp-mode-btn.active {
  border-color: var(--text-label);
  color: var(--text-normal);
}
.fp-apply-btn {
  background: var(--bg-input);
  color: var(--text-normal);
}

/* ---- RIGHT PANEL ---- */
#right-panel {
  width: 200px;
  overflow-y: auto;
  border-left: 1px solid var(--border);
  background: var(--bg-panel);
  padding: 4px 0;
  flex-shrink: 0;
}

/* Spec Board */
.spec-row {
  display: grid;
  grid-template-columns: 55px 45px 1fr auto;
  align-items: center;
  gap: 4px;
  padding: 3px 4px;
  margin: 2px 8px;
  background: var(--bg-card);
  font-family: var(--font-mono);
}
.spec-label {
  font-size: 9px;
  color: var(--text-unit);
}
.spec-val {
  font-size: 12px;
  color: var(--text-normal);
  text-align: right;
}
.spec-range {
  font-size: 8px;
  color: var(--text-unit);
  text-align: center;
}
.spec-status {
  font-size: 9px;
  color: var(--text-unit);
  min-width: 20px;
  text-align: center;
}
.spec-row.in-spec .spec-status {
  color: var(--text-label);
}
.spec-row.off-spec .spec-val {
  color: var(--alarm-crit);
}
.spec-row.warning .spec-val {
  color: var(--alarm-lo);
}

/* P&L Block */
.pnl-block {
  padding: 4px 8px;
}
.pnl-row {
  display: flex;
  justify-content: space-between;
  padding: 2px 0;
}
.pnl-label {
  font-family: var(--font-condensed);
  font-size: 10px;
  color: var(--text-unit);
  letter-spacing: 0.05em;
}
.pnl-val {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-normal);
}
.pnl-penalty {
  color: var(--alarm-crit);
}
.pnl-total-row {
  border-top: 1px solid var(--border);
  margin-top: 2px;
  padding-top: 4px;
}

/* Event Block */
.event-block {
  padding: 4px 8px;
}
.event-item {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-unit);
  display: block;
  padding: 2px 0;
}
.event-item.active-event {
  color: var(--alarm-lo);
}

/* Weather */
.weather-block {
  padding: 4px 8px;
}
.weather-row {
  display: flex;
  justify-content: space-between;
  padding: 1px 0;
}
.weather-label {
  font-family: var(--font-condensed);
  font-size: 9px;
  color: var(--text-unit);
}
.weather-val {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-label);
}

/* Radio Log */
.radio-block {
  padding: 4px 8px;
  max-height: 80px;
  overflow-y: auto;
}
.radio-msg {
  display: block;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-unit);
  padding: 2px 0;
  border-bottom: 1px solid var(--border-lite);
}
.radio-msg.new {
  color: var(--text-normal);
}

/* ---- BUILDING TABS ---- */
#building-tabs {
  display: flex;
  height: 32px;
  background: var(--bg-deep);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.building-tab {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-unit);
  padding: 0 14px;
  background: var(--bg-deep);
  border: none;
  border-right: 1px solid var(--border);
  cursor: pointer;
  letter-spacing: 0.05em;
  transition: background 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}
.building-tab:hover {
  background: var(--bg-card);
}
.building-tab.active {
  background: var(--bg-panel);
  color: var(--text-normal);
}

/* ---- TIME CONTROLS ---- */
#time-controls {
  display: flex;
  align-items: center;
  height: 28px;
  padding: 0 12px;
  background: var(--bg-deep);
  border-top: 1px solid var(--border);
  gap: 4px;
  flex-shrink: 0;
}
.game-support-link {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-unit);
  text-decoration: none;
  letter-spacing: 0.1em;
  opacity: 0.6;
  transition: opacity 0.2s;
}
.game-support-link:hover {
  opacity: 1;
  color: var(--text-normal);
}
.time-btn {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 2px 10px;
  background: var(--bg-card);
  color: var(--text-unit);
  border: 1px solid var(--border);
  cursor: pointer;
}
.time-btn:hover {
  background: var(--bg-input);
}
.time-btn.active {
  background: var(--bg-input);
  color: var(--text-normal);
  border-color: var(--text-label);
}
#time-speed-label {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-unit);
  margin-left: 8px;
}

/* ---- LEARN MODE OVERLAY ---- */
#learn-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(46,46,46,0.85);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 60px;
}
#learn-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 20px 24px;
  max-width: 500px;
  width: 90%;
}
#learn-title {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--text-tag);
  margin-bottom: 8px;
  letter-spacing: 0.1em;
}
#learn-text {
  font-size: 13px;
  color: var(--text-label);
  line-height: 1.6;
  margin-bottom: 16px;
}
#learn-next {
  font-size: 12px;
  padding: 8px 24px;
}
.learn-highlight-indicator {
  display: none;
}

/* ---- POPUP (Alarm List) ---- */
.popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--bg-faceplate);
  border: 1px solid var(--border);
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
  z-index: 300;
  width: 90%;
  max-width: 500px;
  max-height: 70vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: var(--bg-deep);
  border-bottom: 1px solid var(--border);
}
.popup-header h3 {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-tag);
  letter-spacing: 0.1em;
}
.popup-close {
  font-family: var(--font-mono);
  font-size: 12px;
  background: none;
  border: none;
  color: var(--text-unit);
  cursor: pointer;
  padding: 2px 6px;
}
.popup-close:hover {
  color: var(--text-normal);
}
.alarm-list {
  overflow-y: auto;
  padding: 4px;
  flex: 1;
}
.alarm-entry {
  display: flex;
  align-items: center;
  padding: 4px 8px;
  margin: 2px 0;
  background: var(--bg-card);
  font-family: var(--font-mono);
  font-size: 11px;
  gap: 8px;
}
.alarm-entry.unacked {
  background: #3a1010;
  border-left: 3px solid var(--alarm-crit);
}
.alarm-entry:not(.unacked) {
  opacity: 0.6;
  border-left: 3px solid transparent;
}
.alarm-entry .alarm-tag {
  color: var(--text-tag);
  min-width: 60px;
}
.alarm-entry .alarm-type {
  color: var(--alarm-crit);
  min-width: 30px;
}
.alarm-entry .alarm-type.hi { color: var(--alarm-hi); }
.alarm-entry .alarm-type.lo { color: var(--alarm-lo); }
.alarm-entry .alarm-desc {
  color: var(--text-label);
  flex: 1;
}
.alarm-entry .alarm-time {
  color: var(--text-unit);
}
.alarm-entry .alarm-ack-btn {
  font-family: var(--font-mono);
  font-size: 9px;
  padding: 1px 6px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-label);
  cursor: pointer;
}
.alarm-empty {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-unit);
  text-align: center;
  padding: 20px;
}

/* ---- ALARM TIP TOAST ---- */
.alarm-tip {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: min(500px, 90vw);
  padding: 8px 12px;
  background: #1A2A1A;
  border: 1px solid #3A6A3A;
  border-left: 3px solid #4CAF50;
  font-family: var(--font-mono);
  font-size: 11px;
  color: #C0D8C0;
  z-index: 300;
  animation: tip-slide-in 0.3s ease;
}
@keyframes tip-slide-in {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}
.alarm-tip-icon {
  font-size: 14px;
  flex-shrink: 0;
}
.alarm-tip-text {
  flex: 1;
  line-height: 1.3;
}
.alarm-tip-dismiss {
  background: none;
  border: none;
  color: #6A8A6A;
  font-size: 12px;
  cursor: pointer;
  padding: 2px 4px;
  flex-shrink: 0;
}
.alarm-tip-off {
  background: none;
  border: 1px solid #3A5A3A;
  color: #6A8A6A;
  font-family: var(--font-mono);
  font-size: 8px;
  cursor: pointer;
  padding: 2px 6px;
  flex-shrink: 0;
  white-space: nowrap;
}

/* ============================================================
   MOBILE RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
  #title-screen {
    padding-top: env(safe-area-inset-top, 16px);
  }
  .title-content {
    padding-top: 16px;
  }
  .title-logo {
    margin-bottom: 2px;
  }
  .title-sub {
    margin-bottom: 20px;
  }
  #left-panel {
    width: 170px;
  }
  #right-panel {
    display: none;
  }
  /* Mobile info drawer — slides up from bottom */
  .mobile-info-drawer {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    max-height: 55vh;
    background: var(--bg-panel);
    border-top: 2px solid var(--border);
    z-index: 200;
    transform: translateY(100%);
    transition: transform 0.25s ease;
    overflow-y: auto;
    padding: 0 8px 8px;
  }
  .mobile-info-drawer.open {
    transform: translateY(0);
  }
  .mobile-info-handle {
    text-align: center;
    padding: 6px 0 2px;
    cursor: pointer;
  }
  .mobile-info-handle span {
    display: inline-block;
    width: 36px;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
  }
  .mobile-info-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 6px;
  }
  .mobile-info-tab {
    flex: 1;
    font-family: var(--font-mono);
    font-size: 9px;
    padding: 6px 4px;
    background: none;
    border: none;
    color: var(--text-unit);
    cursor: pointer;
    letter-spacing: 0.05em;
    border-bottom: 2px solid transparent;
  }
  .mobile-info-tab.active {
    color: var(--text-normal);
    border-bottom-color: var(--text-normal);
  }
  .mobile-info-content {
    min-height: 100px;
  }
  .mobile-info-content .panel-section {
    padding: 4px 0;
  }
  /* Mobile P&L strip above time controls */
  .mobile-pnl-strip {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 3px 10px;
    background: var(--bg-deep);
    border-top: 1px solid var(--border);
    font-family: var(--font-mono);
    font-size: 10px;
  }
  .mobile-pnl-strip .mpnl-rate { color: #4CAF50; }
  .mobile-pnl-strip .mpnl-shift { color: var(--text-label); }
  .mobile-pnl-strip .mpnl-penalties { color: #E04040; font-size: 9px; }
  .mobile-pnl-strip .mpnl-btn {
    background: none;
    border: 1px solid var(--border-lite);
    color: var(--text-label);
    font-family: var(--font-mono);
    font-size: 9px;
    padding: 2px 8px;
    cursor: pointer;
  }
  .gauge-tag-block {
    min-width: 52px;
  }
  .gauge-val {
    font-size: 12px;
    min-width: 40px;
  }
  .title-logo {
    font-size: 32px;
  }
  .mode-grid {
    grid-template-columns: 1fr;
  }
  /* Faceplate as fixed overlay on mobile */
  .faceplate {
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%);
    width: min(300px, 90vw);
    z-index: 200;
  }
  /* Dim background when faceplate open */
  .faceplate-backdrop {
    display: block;
  }
}

@media (max-width: 480px) {
  #left-panel {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 180px;
    z-index: 50;
    transform: translateX(0);
    transition: transform 0.2s ease;
  }
  #left-panel.collapsed {
    transform: translateX(-100%);
  }
  #main-content {
    position: relative;
  }
  #center-panel {
    margin-left: 0;
  }
  /* Panel toggle button */
  #panel-toggle {
    display: flex;
  }
  .gauge-row {
    padding: 2px 2px;
  }
  .gauge-tag {
    font-size: 9px;
  }
  .gauge-val {
    font-size: 11px;
  }
  .gauge-desc, .gauge-unit, .gauge-mode {
    display: none;
  }
  #topbar {
    font-size: 11px;
  }
  .building-tab {
    font-size: 9px;
    padding: 0 8px;
  }
}

/* Touch targets */
@media (pointer: coarse) {
  .gauge-row {
    min-height: 44px;
    padding: 6px 4px;
  }
  .building-tab {
    min-height: 44px;
  }
  .time-btn {
    min-height: 44px;
    padding: 4px 14px;
  }
  .tag-bubble {
    cursor: pointer;
  }
}

/* ---- MOBILE PANEL TOGGLE ---- */
#panel-toggle {
  display: none;
  position: absolute;
  top: 4px;
  left: 4px;
  z-index: 60;
  width: 32px;
  height: 32px;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-label);
  font-family: var(--font-mono);
  font-size: 14px;
  cursor: pointer;
}

/* Faceplate backdrop for mobile */
.faceplate-backdrop {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.6);
  z-index: 199;
}

/* ---- GAUGE BOTTOM SHEET (Mobile) ---- */
.gauge-sheet {
  display: none;
  background: var(--bg-panel);
  border-top: 1px solid var(--border);
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s ease;
}
.gauge-sheet.open {
  display: block;
  max-height: 45vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.gauge-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  background: var(--bg-deep);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1;
}
.gauge-sheet-title {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-normal);
  letter-spacing: 0.1em;
}
.gauge-sheet-close {
  background: none;
  border: none;
  color: var(--text-unit);
  font-size: 14px;
  cursor: pointer;
  padding: 4px 8px;
}
.gauge-sheet-body {
  padding: 4px 0;
}
.gauge-sheet-section {
  font-family: var(--font-sans);
  font-size: 9px;
  color: var(--text-desc);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 6px 10px 2px;
}
.gauge-sheet-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  margin: 2px 6px;
  background: var(--bg-card);
  cursor: pointer;
  min-height: 40px;
}
.gauge-sheet-row:active {
  background: var(--bg-input);
}
.gauge-sheet-tag {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-tag);
  min-width: 55px;
}
.gauge-sheet-val {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--text-normal);
  flex: 1;
  text-align: right;
}
.gauge-sheet-unit {
  font-family: var(--font-condensed);
  font-size: 10px;
  color: var(--text-unit);
  min-width: 35px;
}
.gauge-sheet-mode {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-unit);
  padding: 1px 4px;
  border: 1px solid var(--border);
}

/* ---- GAS CHROMATOGRAPH DISPLAY ---- */
.gc-display {
  font-family: var(--font-mono);
  padding: 0;
}
.gc-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  background: var(--bg-deep);
  border-bottom: 1px solid var(--border);
}
.gc-title {
  font-size: 10px;
  color: var(--text-tag);
  letter-spacing: 0.1em;
}
.gc-stream {
  font-size: 9px;
  color: var(--text-unit);
}
.gc-cycle {
  font-size: 9px;
  color: var(--text-unit);
  margin-left: auto;
}
.gc-chart {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 6px;
  padding: 10px 12px 4px;
  height: 120px;
}
.gc-bar-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  max-width: 60px;
  height: 100%;
}
.gc-bar-val {
  font-size: 10px;
  color: var(--text-normal);
  margin-bottom: 2px;
  min-height: 14px;
}
.gc-bar-wrap {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: flex-end;
  background: var(--bg-input);
  border: 1px solid var(--border-lite);
}
.gc-bar {
  width: 100%;
  transition: height 0.5s ease;
  min-height: 2px;
}
.gc-bar-label {
  font-size: 10px;
  color: var(--text-label);
  margin-top: 3px;
  letter-spacing: 0.05em;
}
.gc-table {
  padding: 4px 8px 8px;
}
.gc-table-row {
  display: grid;
  grid-template-columns: 32px 70px 1fr 36px 40px;
  align-items: center;
  gap: 4px;
  padding: 3px 4px;
  margin: 1px 0;
  background: var(--bg-card);
  font-size: 10px;
}
.gc-total-row {
  border-top: 1px solid var(--border);
  margin-top: 2px;
  padding-top: 4px;
}
.gc-comp-name {
  color: var(--text-tag);
  font-weight: bold;
}
.gc-comp-full {
  color: var(--text-unit);
  font-size: 8px;
}
.gc-comp-val {
  color: var(--text-normal);
  text-align: right;
  font-size: 12px;
}
.gc-comp-unit {
  color: var(--text-unit);
  font-size: 9px;
}
.gc-comp-status {
  text-align: center;
  font-size: 9px;
  padding: 1px 3px;
}
.gc-ok { color: var(--text-label); }
.gc-warn { color: var(--alarm-lo); }
.gc-alarm { color: var(--alarm-crit); }

/* Desktop GC panel overlay on center panel */
.gc-panel {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 280px;
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  z-index: 30;
  display: none;
}

/* ---- SCROLLBAR STYLING ---- */
::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-deep);
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-unit);
}

/* ============================================================
   FIELD NOTES
   ============================================================ */

.field-notes-list {
  padding: 8px;
  max-height: 400px;
  overflow-y: auto;
}
.field-note-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--text-unit);
  padding: 8px 10px;
  margin-bottom: 6px;
}
.field-note-category {
  font-family: var(--font-mono);
  font-size: 8px;
  color: var(--text-unit);
  letter-spacing: 0.1em;
  margin-bottom: 2px;
}
.field-note-title {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-tag);
  margin-bottom: 4px;
}
.field-note-text {
  font-size: 10px;
  color: var(--text-label);
  line-height: 1.4;
}
.field-note-locked {
  opacity: 0.4;
  border-left-color: var(--border);
}
.field-note-locked .field-note-text {
  font-style: italic;
  color: var(--text-unit);
}

/* ============================================================
   CRISIS SCENARIO SELECT
   ============================================================ */

.crisis-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 12px;
  cursor: pointer;
}
.crisis-card:hover {
  border-color: var(--text-unit);
}
.crisis-card-name {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-tag);
  margin-bottom: 4px;
}
.crisis-card-desc {
  font-size: 10px;
  color: var(--text-label);
  margin-bottom: 6px;
  line-height: 1.3;
}
.crisis-card-meta {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-unit);
  display: flex;
  gap: 12px;
}
.crisis-difficulty {
  color: var(--alarm-lo);
}
.crisis-difficulty.legendary {
  color: var(--alarm-crit);
}

/* ============================================================
   DYNAMIC SPEC BOARD
   ============================================================ */

#spec-board .spec-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 0;
  font-family: var(--font-mono);
  font-size: 10px;
}

/* ============================================================
   HENRY — GAS PLANT MASCOT CHARACTER
   ============================================================ */

.henry-container {
  position: fixed;
  z-index: 600;
  pointer-events: none;
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
  opacity: 0;
  display: flex;
  align-items: flex-end;
  gap: 12px;
}

.henry-container.henry-visible {
  opacity: 1;
  pointer-events: auto;
}

/* Position variants */
.henry-container.henry-right {
  bottom: 80px;
  right: 20px;
  transform: translateX(120%);
  flex-direction: row-reverse;
}
.henry-container.henry-right.henry-visible {
  transform: translateX(0);
}

.henry-container.henry-left {
  bottom: 80px;
  left: 20px;
  transform: translateX(-120%);
  flex-direction: row;
}
.henry-container.henry-left.henry-visible {
  transform: translateX(0);
}

.henry-container.henry-top {
  top: 70px;
  left: 50%;
  transform: translate(-50%, -120%);
  flex-direction: column;
  align-items: center;
}
.henry-container.henry-top.henry-visible {
  transform: translate(-50%, 0);
}

/* Event type styling */
.henry-container.henry-event .henry-speech {
  border-color: var(--alarm-lo);
  background: linear-gradient(135deg, #2a2000, #1a1a00);
}
.henry-container.henry-event .henry-speech-arrow {
  border-right-color: #2a2000;
}
.henry-container.henry-tutorial .henry-speech {
  border-color: var(--accent);
}

/* ---- Henry Character (CSS art) ---- */
.henry-character {
  width: 64px;
  height: 100px;
  position: relative;
  flex-shrink: 0;
  animation: henry-idle 3s ease-in-out infinite;
}

@keyframes henry-idle {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2px); }
}

/* Hard hat */
.henry-hardhat {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 48px;
  height: 22px;
}
.henry-hardhat-dome {
  width: 40px;
  height: 18px;
  background: #F5C518;
  border-radius: 20px 20px 2px 2px;
  margin: 0 auto;
  border: 1px solid #D4A810;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}
.henry-hardhat-brim {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 48px;
  height: 6px;
  background: #D4A810;
  border-radius: 2px;
}
.henry-lamp {
  position: absolute;
  top: 2px;
  left: 50%;
  transform: translateX(-50%);
  width: 8px;
  height: 6px;
  background: #E8E8E8;
  border-radius: 2px;
  box-shadow: 0 0 6px rgba(255, 255, 200, 0.6);
}

/* Face */
.henry-face {
  position: absolute;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  width: 36px;
  height: 32px;
  background: #D4A574;
  border-radius: 6px 6px 8px 8px;
  border: 1px solid #B8895C;
}

.henry-eye {
  position: absolute;
  width: 5px;
  height: 5px;
  background: #2C2C2C;
  border-radius: 50%;
  top: 10px;
  animation: henry-blink 4s ease-in-out infinite;
}
.henry-eye-left { left: 8px; }
.henry-eye-right { right: 8px; }

@keyframes henry-blink {
  0%, 95%, 100% { transform: scaleY(1); }
  97% { transform: scaleY(0.1); }
}

.henry-eye-wide {
  width: 7px;
  height: 7px;
  top: 9px;
  animation: none;
}
.henry-eye-squint {
  height: 3px;
  top: 11px;
  border-radius: 50%;
}

.henry-mustache {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: 20px;
  height: 5px;
  background: #6B4C30;
  border-radius: 0 0 6px 6px;
}

.henry-mouth {
  position: absolute;
  bottom: 5px;
  left: 50%;
  transform: translateX(-50%);
  width: 10px;
  height: 3px;
  background: #8B5E3C;
  border-radius: 0 0 4px 4px;
}
.henry-mouth-open {
  width: 12px;
  height: 8px;
  background: #5A3A20;
  border-radius: 50%;
}
.henry-mouth-smile {
  width: 14px;
  height: 4px;
  border-top: none;
  border-bottom: 2px solid #8B5E3C;
  background: transparent;
  border-radius: 0 0 8px 8px;
}
.henry-mouth-frown {
  width: 12px;
  height: 4px;
  border-bottom: none;
  border-top: 2px solid #8B5E3C;
  background: transparent;
  border-radius: 8px 8px 0 0;
}
.henry-mouth-talk {
  animation: henry-talking 0.3s ease infinite;
}
@keyframes henry-talking {
  0%, 100% { height: 3px; }
  50% { height: 6px; border-radius: 50%; }
}
.henry-mouth-neutral {
  width: 10px;
  height: 2px;
}

/* Body */
.henry-body {
  position: absolute;
  top: 48px;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 52px;
}

.henry-coveralls {
  width: 40px;
  height: 44px;
  background: #2B5EA7;
  border-radius: 4px 4px 6px 6px;
  border: 1px solid #1E4D8C;
  position: relative;
}
.henry-coveralls::before {
  content: '';
  position: absolute;
  top: 4px;
  left: 50%;
  transform: translateX(-50%);
  width: 20px;
  height: 12px;
  border: 1px solid #3572C4;
  border-radius: 2px;
  background: rgba(53, 114, 196, 0.3);
}

.henry-badge {
  position: absolute;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 5px;
  color: #E8E8E8;
  background: #1E4D8C;
  padding: 1px 4px;
  border-radius: 1px;
  letter-spacing: 0.1em;
  white-space: nowrap;
}

.henry-arm {
  position: absolute;
  width: 10px;
  height: 30px;
  background: #2B5EA7;
  border: 1px solid #1E4D8C;
  border-radius: 4px;
  top: 2px;
}
.henry-arm-left {
  left: -8px;
  transform-origin: top center;
}
.henry-arm-right {
  right: -8px;
  transform-origin: top center;
}

/* Wave animation */
.henry-wave .henry-arm-right {
  animation: henry-arm-wave 0.6s ease 2;
}
@keyframes henry-arm-wave {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(-30deg); }
}

/* Shake animation (urgent events) */
.henry-shake {
  animation: henry-shake-anim 0.1s ease 3 !important;
}
@keyframes henry-shake-anim {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* Nod animation */
.henry-nod .henry-face {
  animation: henry-nod-anim 0.25s ease 2;
}
@keyframes henry-nod-anim {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(-50%) translateY(3px); }
}

/* Mood colors */
.henry-mood-alert .henry-mustache { background: #8B6030; }
.henry-mood-worried { background: #C49060 !important; }

/* ---- Speech Bubble ---- */
.henry-speech {
  background: linear-gradient(135deg, #1a2a1a, #1a2a2a);
  border: 1px solid #3A6A3A;
  padding: 12px 14px;
  max-width: 340px;
  min-width: 200px;
  max-height: 60vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}

.henry-speech-arrow {
  position: absolute;
  width: 0;
  height: 0;
}
/* Arrow for right position (points right toward Henry) */
.henry-right .henry-speech-arrow {
  right: -8px;
  bottom: 20px;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-left: 8px solid #1a2a1a;
}
.henry-left .henry-speech-arrow {
  left: -8px;
  bottom: 20px;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-right: 8px solid #1a2a1a;
}
.henry-top .henry-speech-arrow {
  display: none;
}

.henry-speech-text {
  font-family: var(--font-mono);
  font-size: 12px;
  color: #C8D8C8;
  line-height: 1.5;
  white-space: pre-wrap;
  min-height: 20px;
}

.henry-speech-actions {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.henry-speech-actions:empty {
  display: none;
}

.henry-btn {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 6px 16px;
  background: #2A4A2A;
  color: #C8D8C8;
  border: 1px solid #4A7A4A;
  cursor: pointer;
  letter-spacing: 0.05em;
  transition: background 0.15s, border-color 0.15s;
}
.henry-btn:hover {
  background: #3A5A3A;
  border-color: #6A9A6A;
  color: #E8F8E8;
}

/* Event announcement styling */
.henry-event .henry-speech {
  border-color: var(--alarm-lo);
  background: linear-gradient(135deg, #2a2000, #2a1a00);
  animation: henry-event-pulse 2s ease infinite;
}
@keyframes henry-event-pulse {
  0%, 100% { box-shadow: 0 4px 16px rgba(0,0,0,0.4); }
  50% { box-shadow: 0 4px 24px rgba(255, 165, 0, 0.15); }
}

.henry-event .henry-speech-text {
  color: #D8C898;
}

.henry-event.henry-top .henry-speech {
  min-width: 300px;
  text-align: center;
}

/* Tutorial styling */
.henry-tutorial .henry-speech {
  border-color: #4A7ABB;
  background: linear-gradient(135deg, #1a1a2a, #1a2a3a);
}
.henry-tutorial .henry-speech-text {
  color: #C8D0E8;
}
.henry-tutorial .henry-btn {
  background: #2A3A5A;
  border-color: #4A6A9A;
  color: #C8D0E8;
}
.henry-tutorial .henry-btn:hover {
  background: #3A4A6A;
}

/* Mobile adjustments */
@media (max-width: 768px) {
  .henry-container.henry-right,
  .henry-container.henry-left {
    bottom: 100px;
    right: 10px;
    left: auto;
    flex-direction: column-reverse;
    align-items: flex-end;
  }
  .henry-character {
    width: 48px;
    height: 75px;
    transform: scale(0.75);
    transform-origin: bottom right;
  }
  .henry-speech {
    max-width: min(300px, 80vw);
    min-width: 160px;
    font-size: 11px;
  }
  .henry-speech-arrow {
    display: none;
  }
  .henry-container.henry-top {
    top: 50px;
  }
}

/* ============================================================
   ENHANCED TITLE SCREEN — ENGAGEMENT IMPROVEMENTS
   ============================================================ */

/* Animated title text with subtle glow */
.title-logo {
  text-shadow: 0 0 30px rgba(74, 179, 244, 0.08);
  animation: title-breathe 4s ease-in-out infinite;
}
@keyframes title-breathe {
  0%, 100% { text-shadow: 0 0 30px rgba(74, 179, 244, 0.05); }
  50% { text-shadow: 0 0 40px rgba(74, 179, 244, 0.12); }
}

/* Subtle pipeline animation behind title */
.title-content {
  position: relative;
}
.title-content::before {
  content: '';
  position: absolute;
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
  width: 300px;
  height: 2px;
  background: linear-gradient(90deg, transparent, #4A4A4A, transparent);
  animation: pipeline-flow 3s linear infinite;
}
@keyframes pipeline-flow {
  0% { background-position: -300px 0; }
  100% { background-position: 300px 0; }
}

/* Mode cards — hover effects */
.mode-card {
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}
.mode-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.mode-card:active {
  transform: translateY(0);
}

/* Facility cards — tier badge glow */
.tier-label {
  transition: color 0.2s;
}
.mode-card:hover .tier-label {
  color: var(--accent);
}

/* ============================================================
   ENHANCED P&ID INTERACTIVITY
   ============================================================ */

/* Clickable valve hover effects */
g[id^="equip-"]:hover {
  filter: drop-shadow(0 0 4px rgba(90, 159, 212, 0.3));
}

/* Equipment status pulsing for faults */
.equip-fault-pulse {
  animation: equip-fault-anim 1s ease infinite;
}
@keyframes equip-fault-anim {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Enhanced flow line glow during active flow */
.flow-line.flowing {
  filter: drop-shadow(0 0 1px rgba(160, 160, 160, 0.3));
}

/* Tag bubble alarm flash */
@keyframes tag-alarm-flash {
  0%, 100% { fill: rgba(255, 32, 32, 0.1); }
  50% { fill: rgba(255, 32, 32, 0.25); }
}

/* ============================================================
   WELCOME BANNER (first visit)
   ============================================================ */
.welcome-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(20, 20, 20, 0.95);
  z-index: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fade-in 0.5s ease;
}
@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
.welcome-content {
  text-align: center;
  max-width: 500px;
  padding: 40px 30px;
}
.welcome-tagline {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-label);
  line-height: 1.6;
  margin: 20px 0 30px;
}
.welcome-version {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-unit);
  letter-spacing: 0.15em;
  margin-bottom: 8px;
}
.welcome-start-btn {
  font-family: var(--font-mono);
  font-size: 16px;
  padding: 14px 48px;
  background: var(--bg-card);
  color: var(--text-normal);
  border: 2px solid var(--accent);
  cursor: pointer;
  letter-spacing: 0.1em;
  transition: background 0.2s, transform 0.15s;
}
.welcome-start-btn:hover {
  background: var(--bg-input);
  transform: scale(1.02);
}

/* ============================================================
   SCROLL HINT for building tabs
   ============================================================ */
#building-tabs {
  position: relative;
}
#building-tabs::after {
  content: '';
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 20px;
  background: linear-gradient(to right, transparent, var(--bg-deep));
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
}
#building-tabs.has-overflow::after {
  opacity: 1;
}

/* ============================================================
   TABLET-SPECIFIC LAYOUT (769px - 1024px)
   ============================================================ */
@media (min-width: 769px) and (max-width: 1024px) {
  #left-panel {
    width: 190px;
  }
  #right-panel {
    width: 180px;
  }
  .building-tab {
    padding: 0 10px;
    font-size: 9px;
  }
}

/* ============================================================
   DCS BOOT SEQUENCE OVERLAY
   ============================================================ */
.boot-overlay {
  position: fixed;
  inset: 0;
  background: #1A1A1A;
  z-index: 900;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  color: #4CAF50;
  animation: boot-fadein 0.3s ease;
}
@keyframes boot-fadein {
  from { opacity: 0; }
  to { opacity: 1; }
}
.boot-logo {
  font-size: 28px;
  font-weight: bold;
  color: var(--text-normal);
  letter-spacing: 0.3em;
  margin-bottom: 8px;
}
.boot-sub {
  font-size: 11px;
  color: var(--text-label);
  letter-spacing: 0.15em;
  margin-bottom: 32px;
}
.boot-log {
  width: 400px;
  max-width: 90vw;
  font-size: 11px;
  line-height: 1.8;
  text-align: left;
}
.boot-line {
  opacity: 0;
  animation: boot-line-in 0.15s ease forwards;
}
.boot-line .ok { color: #4CAF50; }
.boot-line .warn { color: #FFD700; }
.boot-line .info { color: var(--text-label); }
@keyframes boot-line-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
.boot-progress {
  width: 400px;
  max-width: 90vw;
  height: 3px;
  background: var(--bg-card);
  margin-top: 20px;
  border-radius: 2px;
  overflow: hidden;
}
.boot-progress-bar {
  height: 100%;
  width: 0%;
  background: #4CAF50;
  transition: width 0.2s ease;
}

/* ============================================================
   ACHIEVEMENT TOAST
   ============================================================ */
.achievement-toast {
  position: fixed;
  top: 60px;
  right: 20px;
  background: linear-gradient(135deg, #2A2A2A, #363636);
  border: 1px solid #FFD700;
  border-left: 4px solid #FFD700;
  padding: 12px 18px;
  font-family: var(--font-mono);
  z-index: 800;
  min-width: 260px;
  max-width: 350px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  transform: translateX(120%);
  animation: toast-slide-in 0.4s ease forwards;
}
.achievement-toast.toast-out {
  animation: toast-slide-out 0.3s ease forwards;
}
@keyframes toast-slide-in {
  from { transform: translateX(120%); }
  to { transform: translateX(0); }
}
@keyframes toast-slide-out {
  from { transform: translateX(0); opacity: 1; }
  to { transform: translateX(120%); opacity: 0; }
}
.toast-header {
  font-size: 9px;
  color: #FFD700;
  letter-spacing: 0.2em;
  margin-bottom: 4px;
}
.toast-title {
  font-size: 13px;
  color: var(--text-normal);
  font-weight: bold;
}
.toast-desc {
  font-size: 10px;
  color: var(--text-label);
  margin-top: 2px;
}

/* ============================================================
   ENHANCED SHIFT RESULTS SCREEN
   ============================================================ */
.obj-results {
  text-align: center;
}
.obj-grade {
  font-size: 72px;
  font-weight: bold;
  font-family: var(--font-mono);
  line-height: 1;
  margin: 12px 0 4px;
  text-shadow: 0 0 30px currentColor;
  animation: grade-pop 0.5s ease;
}
@keyframes grade-pop {
  0% { transform: scale(0.3); opacity: 0; }
  60% { transform: scale(1.15); }
  100% { transform: scale(1); opacity: 1; }
}
.obj-henry-comment {
  font-style: italic;
  color: var(--text-label);
  font-size: 12px;
  margin: 12px 0;
  padding: 8px 16px;
  border-left: 3px solid var(--accent);
  text-align: left;
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
}
.obj-henry-comment::before {
  content: 'HENRY: ';
  color: var(--accent);
  font-style: normal;
  font-weight: bold;
}
.obj-stats-row {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin: 16px 0;
}
.obj-stat {
  text-align: center;
}
.obj-stat-val {
  font-size: 20px;
  font-family: var(--font-mono);
  font-weight: bold;
  display: block;
}
.obj-stat-label {
  font-size: 9px;
  color: var(--text-label);
  letter-spacing: 0.1em;
  display: block;
}

/* ============================================================
   TITLE SCREEN — ROTATING TAGLINES
   ============================================================ */
.title-tagline {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-label);
  letter-spacing: 0.1em;
  min-height: 18px;
  margin: 12px 0 20px;
  opacity: 0;
  transition: opacity 0.6s ease;
}
.title-tagline.visible {
  opacity: 1;
}

/* ============================================================
   CTA — TRY FULL VERSION BANNER
   ============================================================ */
.cta-banner {
  margin-top: 20px;
  padding: 12px 20px;
  background: linear-gradient(135deg, rgba(74,179,244,0.1), rgba(74,179,244,0.05));
  border: 1px solid rgba(74,179,244,0.3);
  border-radius: 4px;
  text-align: center;
  max-width: 420px;
  margin-left: auto;
  margin-right: auto;
}
.cta-text {
  font-size: 11px;
  color: var(--text-label);
  margin-bottom: 8px;
}
.cta-label {
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 8px 24px;
  color: var(--accent);
  letter-spacing: 0.1em;
}

/* ============================================================
   SHIFT TIMER PULSE (when shift ending soon)
   ============================================================ */
.time-warning {
  animation: time-pulse 1s ease infinite;
}
@keyframes time-pulse {
  0%, 100% { color: var(--text-normal); }
  50% { color: #FFD700; }
}
.time-critical {
  animation: time-critical-pulse 0.5s ease infinite;
}
@keyframes time-critical-pulse {
  0%, 100% { color: var(--text-normal); }
  50% { color: #FF2020; }
}

/* ============================================================
   PROCESS VALUE CHANGE FLASH
   ============================================================ */
.pv-flash {
  animation: pv-change-flash 0.6s ease;
}
@keyframes pv-change-flash {
  0% { background: rgba(74,179,244,0.3); }
  100% { background: transparent; }
}

/* ============================================================
   TOPBAR P&L POSITIVE/NEGATIVE COLORS
   ============================================================ */
.pnl-positive { color: #4CAF50 !important; }
.pnl-negative { color: #E04040 !important; }

/* ============================================================
   SITE FOOTER
   ============================================================ */
#site-footer {
  text-align: center;
  padding: 12px 0;
  font-size: 0.75rem;
  color: var(--text-unit);
  border-top: 1px solid var(--border);
  background: var(--bg-deep);
}
#site-footer a {
  color: var(--text-label);
  text-decoration: none;
}
#site-footer a:hover {
  color: var(--text-normal);
  text-decoration: underline;
}

/* ============================================================
   OPERATOR PROFILE SCREEN
   ============================================================ */
.profile-screen {
  padding: 16px;
  max-width: 700px;
  margin: 0 auto;
}
.profile-header {
  text-align: center;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
}
.profile-name {
  font-size: 1.4rem;
  font-weight: bold;
  color: var(--text-normal);
  letter-spacing: 2px;
}
.profile-rank {
  font-size: 0.9rem;
  margin-top: 4px;
  letter-spacing: 1px;
}
.profile-stats-mini {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-top: 8px;
  font-size: 0.7rem;
  color: var(--text-label);
}
.profile-career-bar {
  margin: 12px 0 16px;
}
.career-bar-label {
  font-size: 0.7rem;
  color: var(--text-label);
  margin-bottom: 4px;
}
.career-bar-track {
  height: 8px;
  background: var(--bg-input);
  border-radius: 4px;
  overflow: hidden;
}
.career-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.5s ease;
}
.profile-section-header {
  font-size: 0.75rem;
  color: var(--text-label);
  letter-spacing: 1px;
  margin: 16px 0 8px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 4px;
}

/* Achievement Grid */
.achievement-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
}
.achievement-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 10px;
  text-align: center;
  transition: border-color 0.2s;
}
.achievement-card.unlocked {
  border-color: #4CAF50;
}
.achievement-card.locked {
  opacity: 0.5;
}
.ach-icon {
  font-size: 1.6rem;
  margin-bottom: 4px;
}
.ach-name {
  font-size: 0.75rem;
  font-weight: bold;
  color: var(--text-normal);
}
.ach-desc {
  font-size: 0.6rem;
  color: var(--text-label);
  margin-top: 2px;
}
.ach-tier {
  font-size: 0.6rem;
  letter-spacing: 1px;
  margin-top: 4px;
}
.ach-progress-bar {
  height: 4px;
  background: var(--bg-input);
  border-radius: 2px;
  margin-top: 6px;
  overflow: hidden;
}
.ach-progress-fill {
  height: 100%;
  border-radius: 2px;
}
.ach-progress-text {
  font-size: 0.55rem;
  color: var(--text-unit);
  margin-top: 2px;
}

/* Profile History */
.profile-history {
  max-height: 200px;
  overflow-y: auto;
}
.profile-history-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 8px;
  font-size: 0.7rem;
  border-bottom: 1px solid var(--border-lite);
}
.ph-date { color: var(--text-unit); width: 50px; }
.ph-facility { color: var(--text-label); width: 60px; }
.ph-grade { width: 30px; text-align: center; font-weight: bold; }
.ph-earnings { width: 80px; text-align: right; }
.profile-empty {
  color: var(--text-unit);
  font-size: 0.7rem;
  text-align: center;
  padding: 12px;
}
.profile-close-btn {
  margin-top: 16px;
  width: 100%;
}

/* ============================================================
   CHALLENGES PANEL
   ============================================================ */
.challenges-container {
  position: fixed;
  top: 80px;
  right: 8px;
  width: 240px;
  z-index: 50;
  pointer-events: auto;
}
.challenges-panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px;
  font-size: 0.7rem;
}
.challenges-header {
  font-size: 0.65rem;
  color: var(--text-label);
  letter-spacing: 1px;
  margin-bottom: 4px;
}
.challenge-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 0;
}
.ch-status { width: 18px; text-align: center; }
.ch-complete .ch-status { color: #4CAF50; }
.ch-active .ch-status { color: var(--text-unit); }
.ch-name { flex: 1; color: var(--text-normal); }
.ch-complete .ch-name { text-decoration: line-through; color: var(--text-unit); }
.ch-reward { color: #FFD700; font-size: 0.6rem; }
.ch-desc {
  font-size: 0.6rem;
  color: var(--text-unit);
  padding-left: 24px;
  margin-bottom: 4px;
}

/* ============================================================
   DEBRIEF SCREEN
   ============================================================ */
.screen-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(30, 30, 30, 0.97);
  z-index: 200;
  overflow-y: auto;
  display: flex;
  justify-content: center;
  padding: 20px;
}
.debrief-screen {
  max-width: 650px;
  width: 100%;
  padding-bottom: 40px;
}
.debrief-banner {
  text-align: center;
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
  margin-bottom: 16px;
}
.debrief-title {
  font-size: 1.2rem;
  color: #4CAF50;
  letter-spacing: 2px;
}
.debrief-sub {
  font-size: 0.7rem;
  color: var(--text-label);
  margin-top: 4px;
}
.debrief-grade-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 16px;
}
.debrief-grade {
  font-size: 3rem;
  font-weight: bold;
  line-height: 1;
}
.debrief-earnings-val {
  font-size: 1.8rem;
  font-weight: bold;
}
.debrief-earnings-label {
  font-size: 0.7rem;
  color: var(--text-label);
}
.debrief-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}
.debrief-stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 10px;
  text-align: center;
}
.debrief-stat-val {
  font-size: 1.2rem;
  font-weight: bold;
}
.debrief-stat-label {
  font-size: 0.6rem;
  color: var(--text-label);
  margin-top: 2px;
}
.debrief-section-header {
  font-size: 0.7rem;
  color: var(--text-label);
  letter-spacing: 1px;
  margin: 12px 0 6px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 3px;
}
.debrief-chart {
  width: 100%;
  height: 180px;
  border: 1px solid var(--border);
  border-radius: 4px;
}
.debrief-insights {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px;
}
.insight-row {
  font-size: 0.7rem;
  padding: 4px 0;
  border-bottom: 1px solid var(--border-lite);
}
.insight-row:last-child { border-bottom: none; }
.insight-bad { color: #E04040; }
.insight-good { color: #4CAF50; }
.insight-warn { color: #D4A843; }
.insight-info { color: var(--text-label); }
.debrief-objectives, .debrief-achievements, .debrief-challenges {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px;
}
.debrief-obj-row {
  font-size: 0.7rem;
  padding: 3px 0;
}
.debrief-ach-row, .debrief-ch-row {
  font-size: 0.7rem;
  padding: 4px 0;
  color: #FFD700;
}
.debrief-henry {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 12px;
  margin: 12px 0;
  font-style: italic;
  font-size: 0.75rem;
  color: var(--text-label);
}
.debrief-henry-name {
  color: var(--text-unit);
  font-size: 0.6rem;
  font-style: normal;
}
.debrief-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}
.debrief-btn {
  flex: 1;
  min-width: 120px;
}
.debrief-main-btn {
  background: var(--bg-input);
  border-color: #4CAF50;
}

/* ============================================================
   GLOSSARY TOOLTIP & POPUP
   ============================================================ */
.glossary-term {
  color: #5A9BD4;
  border-bottom: 1px dotted #5A9BD4;
  cursor: help;
}
.glossary-tooltip {
  position: fixed;
  z-index: 300;
  background: #2A2A2A;
  border: 1px solid #5A9BD4;
  border-radius: 4px;
  padding: 10px;
  max-width: 300px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
  font-family: var(--font-mono, 'Courier New', monospace);
}
.gt-category {
  font-size: 0.55rem;
  color: #5A9BD4;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.gt-term {
  font-size: 0.8rem;
  color: var(--text-normal);
  font-weight: bold;
  margin: 2px 0;
}
.gt-desc {
  font-size: 0.7rem;
  color: var(--text-label);
  line-height: 1.4;
}
.glossary-full {
  padding: 8px;
  max-height: 60vh;
  overflow-y: auto;
}
.glossary-cat-header {
  font-size: 0.7rem;
  color: #5A9BD4;
  letter-spacing: 1px;
  margin: 12px 0 4px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 2px;
}
.glossary-entry {
  padding: 6px 0;
  border-bottom: 1px solid var(--border-lite);
}
.glossary-entry-term {
  font-size: 0.75rem;
  color: var(--text-normal);
  font-weight: bold;
}
.glossary-entry-desc {
  font-size: 0.65rem;
  color: var(--text-label);
  line-height: 1.4;
  margin-top: 2px;
}

/* ============================================================
   P&ID ZOOM CONTROLS
   ============================================================ */
.pid-zoom-controls {
  position: absolute;
  bottom: 8px;
  right: 8px;
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(50, 50, 50, 0.9);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px;
  z-index: 20;
}
.pid-zoom-btn {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-normal);
  width: 28px;
  height: 28px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pid-zoom-btn:hover {
  background: var(--border);
}
.pid-zoom-reset {
  font-size: 0.6rem;
  width: auto;
  padding: 0 8px;
}
.pid-zoom-level {
  font-size: 0.6rem;
  color: var(--text-label);
  min-width: 36px;
  text-align: center;
}

/* ============================================================
   COLOR-BLIND MODE PATTERNS
   ============================================================ */
body.cb-deuteranopia .spec-row.off-spec,
body.cb-protanopia .spec-row.off-spec {
  background: repeating-linear-gradient(
    45deg,
    transparent,
    transparent 3px,
    rgba(255, 68, 0, 0.15) 3px,
    rgba(255, 68, 0, 0.15) 6px
  );
}
body.cb-deuteranopia .spec-row.in-spec,
body.cb-protanopia .spec-row.in-spec {
  background: repeating-linear-gradient(
    -45deg,
    transparent,
    transparent 4px,
    rgba(68, 136, 255, 0.1) 4px,
    rgba(68, 136, 255, 0.1) 8px
  );
}
body.cb-tritanopia .spec-row.off-spec {
  background: repeating-linear-gradient(
    45deg,
    transparent,
    transparent 3px,
    rgba(255, 32, 32, 0.15) 3px,
    rgba(255, 32, 32, 0.15) 6px
  );
}

/* ============================================================
   PROMOTION OVERLAY
   ============================================================ */
.promotion-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 250;
  display: flex;
  align-items: center;
  justify-content: center;
}
.promotion-content {
  text-align: center;
  animation: promotion-appear 0.6s ease;
}
@keyframes promotion-appear {
  0% { transform: scale(0.5); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}
.promotion-icon {
  font-size: 3rem;
  color: #FFD700;
  margin-bottom: 8px;
}
.promotion-title {
  font-size: 0.8rem;
  color: var(--text-label);
  letter-spacing: 2px;
}
.promotion-rank {
  font-size: 1.6rem;
  color: #FFD700;
  font-weight: bold;
  letter-spacing: 2px;
  margin: 8px 0;
}
.promotion-line {
  font-size: 0.75rem;
  color: var(--text-label);
  font-style: italic;
  margin-bottom: 16px;
  max-width: 300px;
}

@media (max-width: 768px) {
  .challenges-container {
    position: static;
    width: 100%;
    margin: 8px 0;
  }
  .achievement-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .debrief-stats {
    grid-template-columns: repeat(2, 1fr);
  }
  .pid-zoom-controls {
    bottom: 4px;
    right: 4px;
    padding: 6px;
  }
  .pid-zoom-btn {
    width: 36px;
    height: 36px;
    font-size: 1.2rem;
  }
  .pid-zoom-reset {
    font-size: 0.7rem;
    padding: 0 10px;
  }
  .pid-zoom-level {
    font-size: 0.7rem;
  }
  .pid-zoom-hint {
    display: block;
  }
}

/* ============================================================
   CAREER / DEBRIEF EXTRAS
   ============================================================ */
.debrief-career {
  background: var(--bg-gauge);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 10px 14px;
  margin-bottom: 10px;
}
.debrief-rank {
  font-family: 'Courier New', monospace;
  font-size: 1rem;
  font-weight: bold;
  margin-bottom: 6px;
}
.debrief-xp-gained {
  font-family: 'Courier New', monospace;
  font-size: 0.75rem;
  font-weight: bold;
  margin-bottom: 4px;
}
.debrief-xp-bar {
  height: 8px;
  background: var(--bg-panel);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 4px;
}
.debrief-xp-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.5s ease;
}
.debrief-xp-label {
  font-size: 0.65rem;
  color: var(--text-unit);
  font-family: 'Courier New', monospace;
}

/* ============================================================
   TREND GRAPH WINDOW
   ============================================================ */
.trend-window {
  position: absolute;
  top: 60px;
  right: 20px;
  width: 460px;
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  z-index: 50;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
  display: none;
}
.trend-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 10px;
  background: var(--bg-gauge);
  border-bottom: 1px solid var(--border-subtle);
  cursor: move;
  border-radius: 6px 6px 0 0;
}
.trend-title {
  font-family: 'Courier New', monospace;
  font-size: 0.7rem;
  color: var(--text-unit);
  letter-spacing: 1px;
}
.trend-close-btn {
  background: none;
  border: none;
  color: var(--text-unit);
  font-size: 1rem;
  cursor: pointer;
  padding: 0 4px;
}
.trend-close-btn:hover { color: #E04040; }
.trend-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px 8px;
  min-height: 20px;
}
.trend-tag-chip {
  font-family: 'Courier New', monospace;
  font-size: 0.6rem;
  border: 1px solid;
  border-radius: 3px;
  padding: 1px 6px;
  cursor: pointer;
  opacity: 0.9;
}
.trend-tag-chip:hover { opacity: 1; background: rgba(255,255,255,0.05); }
.trend-canvas {
  display: block;
  width: 100%;
  height: 200px;
}
.trend-footer {
  padding: 3px 8px;
  font-size: 0.55rem;
  color: var(--text-unit);
  font-family: 'Courier New', monospace;
  text-align: center;
  opacity: 0.6;
}

/* ============================================================
   CRISIS STARS / COACH / SNAPSHOT
   ============================================================ */
.crisis-stars {
  font-size: 0.85rem;
  letter-spacing: 1px;
}
.crisis-multiplier {
  font-family: 'Courier New', monospace;
  font-size: 0.65rem;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 3px;
  padding: 1px 4px;
}
.coach-btn {
  font-size: 0.6rem !important;
  color: #4CAF50 !important;
  border-color: #4CAF50 !important;
}
.snapshot-btn, .trend-toggle-btn {
  font-size: 0.7rem !important;
}
.spec-target {
  font-family: 'Courier New', monospace;
  font-size: 0.55rem;
  color: #4CAF50;
  border: 1px solid rgba(76,175,80,0.3);
  border-radius: 2px;
  padding: 0 3px;
}

/* ============================================================
   LEARN MODE CERTIFICATE
   ============================================================ */
.learn-certificate-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.learn-certificate {
  background: #1a1a1a;
  border: 2px solid #D4A843;
  border-radius: 8px;
  padding: 4px;
  max-width: 500px;
  width: 90%;
}
.cert-border {
  border: 1px solid #D4A843;
  border-radius: 6px;
  padding: 30px 24px;
  text-align: center;
}
.cert-header {
  font-family: 'Courier New', monospace;
  font-size: 0.7rem;
  color: #808080;
  letter-spacing: 3px;
  margin-bottom: 8px;
}
.cert-title {
  font-family: 'Courier New', monospace;
  font-size: 1.3rem;
  color: #D4A843;
  font-weight: bold;
  letter-spacing: 2px;
  margin-bottom: 20px;
}
.cert-body {
  font-size: 0.75rem;
  color: #A0A0A0;
  line-height: 1.8;
}
.cert-name {
  font-family: 'Courier New', monospace;
  font-size: 1.1rem;
  color: #E8E8E8;
  font-weight: bold;
  margin: 8px 0;
}
.cert-course {
  font-family: 'Courier New', monospace;
  font-size: 0.85rem;
  color: #D4A843;
  margin: 8px 0;
}
.cert-date {
  font-size: 0.7rem;
  color: #606060;
  margin: 16px 0 12px;
}
.cert-signature {
  margin: 16px auto;
  width: 200px;
}
.cert-sig-line {
  border-bottom: 1px solid #606060;
  margin-bottom: 4px;
}
.cert-sig-name {
  font-size: 0.6rem;
  color: #808080;
  font-style: italic;
}
.cert-footer {
  font-style: italic;
  font-size: 0.6rem;
  color: #606060;
  margin-top: 16px;
}
.cert-close-btn {
  margin-top: 20px;
  background: var(--bg-input);
  border-color: #D4A843;
  color: #D4A843;
}

/* ============================================================
   P&ID ZOOM MOBILE HINT + LOOP HIGHLIGHT
   ============================================================ */
.pid-zoom-hint {
  display: none;
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(50, 50, 50, 0.85);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 12px;
  font-size: 0.6rem;
  color: var(--text-label);
  z-index: 20;
  pointer-events: none;
  animation: pid-hint-fade 4s ease-in forwards;
}
@keyframes pid-hint-fade {
  0%, 70% { opacity: 1; }
  100% { opacity: 0; }
}

/* Loop highlight — pulse the flow path for a tagged PV */
.flow-line.loop-highlight {
  stroke-width: 4;
  animation: loop-pulse 1.5s ease-in-out infinite;
}
@keyframes loop-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ============================================================
   SHARE IMAGE BUTTON STATES
   ============================================================ */
.debrief-btn:disabled {
  opacity: 0.5;
  cursor: wait;
}

/* ============================================================
   SITE FOOTER SUPPORT LINK
   ============================================================ */
#site-footer .footer-support-link {
  color: #D4A843;
  text-decoration: none;
  margin-left: 12px;
}
#site-footer .footer-support-link:hover {
  color: #FFD700;
  text-decoration: underline;
}
#site-footer .footer-sep {
  color: #555;
  margin: 0 8px;
}
