:root {
  --bg-color: #07090e;
  --panel-bg: #0e131d;
  --panel-border: #1f2737;
  --header-bg: #141b29;
  --text-main: #dce2ee;
  --text-dim: #7987a1;
  --accent-gold: #e5b567;
  --accent-cyan: #70c0de;
  --accent-green: #90c978;
  --accent-red: #e06c75;
  --accent-blue: #61afef;
  --accent-purple: #c678dd;
  --font-mono: "Consolas", "Courier New", "Liberation Mono", "DejaVu Sans Mono", monospace;
}

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

body {
  background-color: var(--bg-color);
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.4;
  height: 100vh;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Subtle CRT scanline effect */
#crt-overlay {
  pointer-events: none;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.22) 50%);
  background-size: 100% 4px;
  z-index: 999;
  opacity: 0.6;
}

/* Main 3-Column Layout */
#app-layout {
  display: grid;
  grid-template-columns: 280px 1fr 280px;
  gap: 12px;
  width: 98vw;
  max-width: 1600px;
  height: 96vh;
}

/* Responsive collapse for small screens */
@media (max-width: 1100px) {
  #app-layout {
    grid-template-columns: 240px 1fr;
  }
  #sidebar-right {
    display: none;
  }
}

@media (max-width: 768px) {
  #app-layout {
    grid-template-columns: 1fr;
  }
  #sidebar-left {
    display: none;
  }
}

/* Panel Containers */
.panel {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--header-bg);
  padding: 8px 14px;
  border-bottom: 1px solid var(--panel-border);
  font-weight: bold;
  font-size: 12px;
  letter-spacing: 1.5px;
  color: var(--accent-gold);
}

.badge {
  font-size: 10px;
  background: #1e283d;
  color: var(--accent-cyan);
  padding: 2px 6px;
  border-radius: 3px;
  border: 1px solid #2d3c5b;
}

.panel-content {
  flex: 1;
  padding: 12px;
  overflow-y: auto;
}

.panel-content::-webkit-scrollbar {
  width: 5px;
}
.panel-content::-webkit-scrollbar-thumb {
  background: #242e42;
  border-radius: 3px;
}

/* Left Sidebar Styles */
#char-identity {
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid #1a2233;
}
#char-name {
  font-size: 17px;
  font-weight: bold;
  color: #fff;
}
#char-sub {
  font-size: 12px;
  color: var(--accent-cyan);
}

.vital-group {
  margin-bottom: 12px;
}
.vital-label {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  font-weight: bold;
  margin-bottom: 4px;
  color: var(--text-dim);
}
.bar-container {
  height: 14px;
  background: #182030;
  border-radius: 3px;
  overflow: hidden;
  border: 1px solid #26334d;
}
.bar-fill {
  height: 100%;
  transition: width 0.3s ease;
}
.hp-healthy { background: linear-gradient(90deg, #5b9243, #90c978); }
.hp-caution { background: linear-gradient(90deg, #b08235, #e5b567); }
.hp-danger { background: linear-gradient(90deg, #993339, #e06c75); }
.xp-bar { background: linear-gradient(90deg, #376594, #61afef); }

.wealth-group {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 10px;
  background: #141a27;
  border-radius: 4px;
  margin-bottom: 14px;
  border: 1px solid #1e2638;
}
.wealth-label { font-size: 11px; font-weight: bold; color: var(--text-dim); }
.wealth-val { color: var(--accent-gold); font-weight: bold; }

.section-title {
  font-size: 11px;
  letter-spacing: 1px;
  font-weight: bold;
  color: var(--text-dim);
  margin: 12px 0 6px 0;
}

#stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 12px;
}
.stat-box {
  background: #131926;
  border: 1px solid #1f2a3f;
  padding: 6px 4px;
  text-align: center;
  border-radius: 4px;
}
.stat-name { display: block; font-size: 10px; color: var(--text-dim); }
.stat-val { display: block; font-size: 15px; font-weight: bold; color: #fff; }
.stat-mod { display: inline-block; font-size: 10px; color: var(--accent-cyan); }

#conditions-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 12px;
}
.condition-tag {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 3px;
  text-transform: uppercase;
}
.tag-normal { background: rgba(144, 201, 120, 0.15); color: var(--accent-green); border: 1px solid #3c5a31; }
.tag-alert { background: rgba(224, 108, 117, 0.15); color: var(--accent-red); border: 1px solid #662a2f; }

#equipment-list { font-size: 11px; }
.eq-slot { margin-bottom: 4px; }
.eq-type { color: var(--text-dim); font-weight: bold; }
.eq-item { color: #fff; }

/* Center Terminal Panel */
#mud-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  background-color: var(--header-bg);
  border-bottom: 1px solid var(--panel-border);
}
.logo { font-weight: bold; letter-spacing: 2px; color: var(--accent-gold); }
.logo .sub { font-size: 11px; color: var(--accent-cyan); border: 1px solid var(--accent-cyan); padding: 1px 5px; border-radius: 3px; margin-left: 6px; }

#combat-indicator {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 3px;
  font-weight: bold;
}
.combat-peace { color: var(--accent-green); background: rgba(144, 201, 120, 0.1); }
.combat-engaged { color: var(--accent-red); background: rgba(224, 108, 117, 0.2); animation: pulse 1s infinite alternate; }

@keyframes pulse { from { opacity: 0.6; } to { opacity: 1; } }

#connection-status {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 3px;
}
.status-online { color: var(--accent-green); background: rgba(144, 201, 120, 0.15); border: 1px solid #3c5a31; }
.status-offline { color: var(--accent-red); background: rgba(224, 108, 117, 0.15); border: 1px solid #662a2f; }

#terminal-wrapper {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  background: #090c13;
}
#terminal-wrapper::-webkit-scrollbar { width: 6px; }
#terminal-wrapper::-webkit-scrollbar-thumb { background: #283348; border-radius: 3px; }

/* Action Bar (1-8 keys) */
#action-bar {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
  padding: 6px 12px;
  background: #0d121c;
  border-top: 1px solid var(--panel-border);
}
.action-btn {
  background: #171f2e;
  border: 1px solid #2a374f;
  color: var(--text-main);
  padding: 4px 2px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  font-family: var(--font-mono);
  transition: all 0.15s;
}
.action-btn:hover { background: #243147; border-color: var(--accent-cyan); }
.action-btn .key { font-size: 9px; color: var(--accent-gold); font-weight: bold; }
.action-btn .label { font-size: 10px; }

/* Input Bar & Dynamic Password State */
#input-form {
  display: flex;
  align-items: center;
  padding: 10px 14px;
  background: #111724;
  border-top: 1px solid var(--panel-border);
}
#prompt-label {
  color: var(--accent-gold);
  font-weight: bold;
  margin-right: 10px;
  user-select: none;
}
#prompt-label.password-prompt { color: var(--accent-red); }

#command-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: #fff;
  font-family: var(--font-mono);
  font-size: 15px;
}
#command-input[type="password"] { letter-spacing: 3px; color: var(--accent-gold); }

#send-btn {
  background: #1e283d;
  color: var(--text-main);
  border: 1px solid #2d3c5b;
  border-radius: 4px;
  padding: 6px 14px;
  cursor: pointer;
  font-family: var(--font-mono);
}
#send-btn:hover { background: #2d3c5b; color: #fff; }

/* Right Sidebar: Compass & Navigation */
#room-name {
  font-weight: bold;
  font-size: 14px;
  color: var(--accent-cyan);
  margin-bottom: 12px;
  border-bottom: 1px solid #1a2233;
  padding-bottom: 6px;
}

#compass-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 14px;
}
.compass-grid {
  display: grid;
  grid-template-columns: repeat(3, 44px);
  gap: 4px;
}
.dir-btn {
  height: 38px;
  background: #171f2e;
  border: 1px solid #2a374f;
  color: var(--accent-gold);
  font-weight: bold;
  border-radius: 4px;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 11px;
  transition: all 0.15s;
}
.dir-btn:not(.disabled):hover {
  background: #2a374f;
  color: #fff;
  border-color: var(--accent-gold);
}
.dir-btn.disabled {
  opacity: 0.25;
  cursor: default;
  color: var(--text-dim);
}
.center-btn {
  background: #1f2a3f;
  color: var(--accent-cyan);
  font-size: 9px;
}

.vertical-dirs {
  display: flex;
  gap: 8px;
  margin-top: 6px;
  width: 140px;
}
.vertical-dirs .dir-btn { flex: 1; height: 28px; }

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 12px;
}
.exit-pill {
  font-size: 10px;
  padding: 2px 8px;
  background: #182030;
  border: 1px solid #2a374f;
  border-radius: 3px;
  color: var(--accent-gold);
  cursor: pointer;
}
.exit-pill:hover { background: #2a374f; }
.tag-empty { font-size: 11px; color: var(--text-dim); font-style: italic; }

.occupants-list {
  font-size: 11px;
  margin-bottom: 12px;
  max-height: 80px;
  overflow-y: auto;
}
.occupant-item { color: #fff; margin-bottom: 2px; }
.occupant-none { color: var(--text-dim); font-style: italic; }

.quick-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.action-pill {
  background: #141b27;
  border: 1px solid #232d3f;
  color: var(--text-main);
  padding: 6px;
  border-radius: 4px;
  font-size: 11px;
  font-family: var(--font-mono);
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
}
.action-pill:hover { background: #222d42; color: #fff; border-color: var(--accent-cyan); }

/* ANSI Color Classes */
.ansi-bold { font-weight: bold; }
.ansi-dim { opacity: 0.7; }
.ansi-black { color: #4c566a; }
.ansi-red { color: #e06c75; }
.ansi-green { color: #98c379; }
.ansi-yellow { color: #e5c07b; }
.ansi-blue { color: #61afef; }
.ansi-magenta { color: #c678dd; }
.ansi-cyan { color: #56b6c2; }
.ansi-white { color: #abb2bf; }
.ansi-bright-black { color: #5c6370; }
.ansi-bright-red { color: #be5046; }
.ansi-bright-green { color: #90c978; }
.ansi-bright-yellow { color: #e5b567; }
.ansi-bright-blue { color: #70c0de; }
.ansi-bright-magenta { color: #d19a66; }
.ansi-bright-cyan { color: #70c0de; }
.ansi-bright-white { color: #ffffff; }
