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

body {
  background: #1a0a0a;
  color: #e0d0c0;
  font-family: 'Courier New', monospace;
  font-size: 14px;
  min-height: 100vh;
  overflow-x: hidden;
}

#game-screen main, #game-screen header, .login-box, .modal-content, #victory-content {
  font-size: 14px;
}
#stages-timeline {
  font-size: 12px;
}

.screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

#game-screen.screen {
  display: block;
}

.hidden {
  display: none !important;
}

/* ============================================================
   LOGIN
   ============================================================ */
.login-box {
  background: #2a1515;
  border: 3px solid #ff6633;
  padding: 40px;
  text-align: center;
  box-shadow: 0 0 30px rgba(255, 102, 51, 0.3);
}

.pixel-title {
  font-size: 28px;
  color: #ff6633;
  text-shadow: 2px 2px 0 #330000;
  margin-bottom: 10px;
  letter-spacing: 2px;
}

.subtitle {
  color: #aa8866;
  margin-bottom: 30px;
  font-size: 14px;
}

.pixel-text {
  font-size: 14px;
  letter-spacing: 1px;
}

.pixel-text.small {
  font-size: 14px;
  color: #aa8866;
}

input[type="text"] {
  background: #1a0a0a;
  border: 2px solid #ff6633;
  color: #ff9966;
  padding: 12px 20px;
  font-family: 'Courier New', monospace;
  font-size: 16px;
  width: 100%;
  margin-bottom: 15px;
  outline: none;
}

input[type="text"]:focus {
  border-color: #ffaa66;
  box-shadow: 0 0 10px rgba(255, 102, 51, 0.5);
}

.pixel-btn {
  background: #ff6633;
  color: #1a0a0a;
  border: none;
  padding: 12px 24px;
  font-family: 'Courier New', monospace;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  letter-spacing: 1px;
  transition: all 0.1s;
  margin: 5px;
}

.pixel-btn:hover {
  background: #ff9966;
  transform: scale(1.05);
}

.pixel-btn:active {
  transform: scale(0.95);
}

.pixel-btn.secondary {
  background: #553322;
  color: #ff9966;
}

.pixel-btn.secondary:hover {
  background: #774433;
}

.pixel-btn.small {
  padding: 8px 16px;
  font-size: 13px;
}

/* ============================================================
   HEADER
   ============================================================ */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: #2a1515;
  border-bottom: 2px solid #ff6633;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  gap: 20px;
}

.header-left {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.header-resources {
  display: flex;
  gap: 8px;
}

.resource-badge {
  padding: 3px 10px;
  font-size: 15px;
  font-weight: bold;
  border: 1px solid;
}

.resource-badge.ore {
  background: #2a2010;
  border-color: #886633;
  color: #ffcc66;
}

.resource-badge.fuel {
  background: #1a1a2a;
  border-color: #555588;
  color: #aabbdd;
}

.elapsed-badge {
  font-family: 'Courier New', monospace;
  font-size: 15px; color: #66ffaa;
  background: #0a1a15; border: 1px solid #2a5544;
  padding: 5px 12px; margin-right: 10px;
  letter-spacing: 1px;
  text-shadow: 0 0 6px rgba(102, 255, 170, 0.3);
}

.resource-badge.energy {
  background: #102030;
  border-color: #3388cc;
  color: #66ccff;
}

.resource-badge.energy.negative-energy {
  background: #301010;
  border-color: #cc3333;
  color: #ff6666;
}

.resource-badge.contrib {
  background: #1a1a2a;
  border-color: #555588;
  color: #aaaacc;
}

.header-center {
  flex: 1;
  max-width: 550px;
}

.header-right {
  display: flex;
  gap: 5px;
}

/* Ti progress bar */
.progress-bar-container {
  background: #1a0a0a;
  border: 2px solid #553322;
  height: 22px;
  position: relative;
  width: 100%;
  margin-bottom: 6px;
}

.progress-bar-fill {
  height: 100%;
  transition: width 0.5s ease;
  width: 0%;
}

#total-progress-fill {
  background: linear-gradient(90deg, #ff3300, #ff6633, #ffaa00, #66ff66);
}

.progress-bar-container span {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 13px;
  font-weight: bold;
  color: #fff;
  text-shadow: 1px 1px 0 #000;
}

/* Header metrics */
#header-metrics {
  display: flex;
  gap: 12px;
}

.hm {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
}

.hm-icon {
  font-size: 14px;
}

.hm-label {
  font-size: 13px;
  color: #aa8866;
  min-width: 55px;
}

.hm-bar {
  flex: 1;
  height: 10px;
  background: #111;
  border: 1px solid #333;
  min-width: 50px;
}

.hm-fill {
  height: 100%;
  transition: width 0.5s ease;
  width: 0%;
}

.hm-fill.pressure { background: linear-gradient(90deg, #554466, #aa88ff); }
.hm-fill.oxygen { background: linear-gradient(90deg, #336699, #66aaff); }
.hm-fill.heat { background: linear-gradient(90deg, #993300, #ff6600); }
.hm-fill.biomass { background: linear-gradient(90deg, #336600, #66cc00); }

.hm-val {
  font-size: 13px;
  color: #aa8866;
  min-width: 32px;
  text-align: right;
}

/* ============================================================
   VERTICAL TIMELINE (left sidebar)
   ============================================================ */
#stages-timeline {
  position: fixed;
  top: 62px;
  left: 0;
  bottom: 0;
  width: 280px;
  background: #1e0e0e;
  border-right: 1px solid #3a2020;
  display: flex;
  flex-direction: column;
  z-index: 90;
  overflow: hidden;
}

#timeline-track {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 12px;
  width: 4px;
  background: #2a1818;
  border-radius: 2px;
}

#timeline-progress {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  background: linear-gradient(180deg, #ff3300, #ff6633, #ffaa00, #66ff66);
  border-radius: 2px;
  transition: height 0.5s ease;
}

#timeline-stages {
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow-y: auto;
  padding: 10px 0;
  flex: 1;
}

#timeline-stages::-webkit-scrollbar {
  width: 4px;
}

#timeline-stages::-webkit-scrollbar-thumb {
  background: #553322;
  border-radius: 2px;
}

.tl-stage {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px 10px 32px;
  position: relative;
  min-height: 50px;
}

.tl-stage::before {
  content: '';
  position: absolute;
  left: 9px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #2a1818;
  border: 2px solid #443322;
}

.tl-stage .tl-icon {
  font-size: 24px;
  opacity: 0.3;
  transition: all 0.3s;
  flex-shrink: 0;
}

.tl-stage .tl-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
  flex: 1;
  min-width: 0;
}

.tl-stage .tl-name {
  font-size: clamp(13px, 1.4vw, 16px);
  color: #554433;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tl-stage .tl-pct {
  font-size: clamp(12px, 1.2vw, 15px);
  color: #443322;
  font-weight: bold;
}

/* Reached stages */
.tl-stage.reached::before {
  background: #ff6633;
  border-color: #ff6633;
}

.tl-stage.reached .tl-icon {
  opacity: 1;
}

.tl-stage.reached .tl-name {
  color: #aa8866;
}

.tl-stage.reached .tl-pct {
  color: #66cc66;
}

/* Current stage */
.tl-stage.current::before {
  background: #ffaa00;
  border-color: #ffcc33;
  box-shadow: 0 0 8px #ffaa00;
}

.tl-stage.current .tl-icon {
  opacity: 1;
  font-size: 30px;
  filter: drop-shadow(0 0 4px #ffaa00);
}

.tl-stage.current .tl-name {
  color: #ff9966;
  font-weight: bold;
  font-size: clamp(14px, 1.5vw, 18px);
}

.tl-stage.current .tl-pct {
  color: #ffcc66;
  font-size: clamp(13px, 1.3vw, 16px);
}

/* ============================================================
   MAIN LAYOUT (with left sidebar offset)
   ============================================================ */
main {
  display: flex;
  gap: 20px;
  padding: 75px 20px 20px 300px;
  margin: 0;
  align-items: stretch;
  height: calc(100vh - 62px);
  min-height: 0;
}

#left-panel {
  flex: 4;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  overflow: hidden;
}

#mars-canvas-container {
  border: 3px solid #ff6633;
  box-shadow: 0 0 20px rgba(255, 102, 51, 0.2);
  cursor: crosshair;
  position: relative;
  width: 100%;
  max-width: 100%;
  aspect-ratio: 1;
  flex-shrink: 1;
  min-height: 0;
}

#mars-canvas {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  width: 100%;
  height: auto;
}

#mine-hint {
  text-align: center;
  padding: 4px;
  background: #1a0a0a;
  border: 1px solid #553322;
  border-top: none;
  font-size: 14px;
  width: 100%;
  box-sizing: border-box;
  flex-shrink: 0;
}

/* ============================================================
   RIGHT PANEL (tabs + sub-panels)
   ============================================================ */
#right-panel {
  background: #2a1515;
  border: 2px solid #553322;
  padding: 14px;
  flex: 6;
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Panel tabs (top-level) */
#panel-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 10px;
  flex-shrink: 0;
  border-bottom: 2px solid #553322;
}

.panel-tab {
  background: #1a0a0a;
  color: #887766;
  border: 1px solid #3a2020;
  border-bottom: none;
  padding: 8px 14px;
  font-family: 'Courier New', monospace;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s;
}

.panel-tab:hover { background: #2a1818; color: #ffaa66; }
.panel-tab.active { background: #3a1e1e; color: #ff9966; border-color: #ff6633; border-bottom: 2px solid #3a1e1e; margin-bottom: -2px; }
.panel-tab { position: relative; }
.notif-dot {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 8px;
  height: 8px;
  background: #ff3333;
  border-radius: 50%;
  box-shadow: 0 0 4px #ff3333;
  animation: notif-pulse 1.5s ease-in-out infinite;
}
@keyframes notif-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(1.3); }
}

.sub-panel { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.sub-panel.hidden { display: none; }
#help-content { overflow-y: auto; flex: 1; padding-right: 6px; }

/* Player bar */
#player-bar {
  display: flex; align-items: center; gap: 10px; margin-top: 8px; padding: 6px 10px; background: #1a0a0a; border: 1px solid #333; width: 100%; box-sizing: border-box; flex-shrink: 0;
}
#xp-bar { flex: 1; height: 16px; background: #111; border: 1px solid #444; position: relative; }
#xp-fill { height: 100%; background: linear-gradient(90deg, #9933ff, #cc66ff); width: 0%; transition: width 0.3s; }
#xp-text { position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); font-size: 12px; color: #fff; font-weight: bold; text-shadow: 1px 1px 0 #000; }
.resource-badge.rp { color: #cc99ff; font-size: 14px; }
#specialty-badge { font-size: 14px; color: #ffcc66; }

#buildings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  flex-shrink: 0;
}

#buildings-header h2 {
  color: #ff9966;
  font-size: 18px;
}

#production-summary {
  display: flex;
  gap: 10px;
  font-size: 13px;
  flex-wrap: wrap;
  align-items: center;
}

#production-summary .rate-separator {
  color: #555;
  margin: 0 2px;
}

#production-summary .tf-rate {
  color: #aad;
  font-size: 12px;
}

/* Energy meter */
#energy-bar-container {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  padding: 6px 10px;
  background: #1a0a0a;
  border: 1px solid #333;
  flex-shrink: 0;
}

.energy-label {
  font-size: 13px;
  color: #66ccff;
  min-width: 60px;
}

.energy-meter {
  flex: 1;
  height: 18px;
  background: #111;
  border: 1px solid #333;
  position: relative;
}

.energy-fill {
  height: 100%;
  transition: width 0.3s ease;
  background: linear-gradient(90deg, #2266aa, #44aaff);
}

.energy-fill.negative {
  background: linear-gradient(90deg, #aa2222, #ff4444);
}

.energy-meter span {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 11px;
  font-weight: bold;
  color: #fff;
  text-shadow: 1px 1px 0 #000;
}

/* Tabs */
#buildings-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 10px;
  flex-shrink: 0;
}

.tab-btn {
  background: #1a0a0a;
  color: #887766;
  border: 1px solid #3a2020;
  padding: 6px 10px;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.tab-btn:hover {
  background: #2a1818;
  color: #ffaa66;
  border-color: #664422;
}

.tab-btn.active {
  background: #3a1e1e;
  color: #ff9966;
  border-color: #ff6633;
}

.tab-btn.tab-hidden {
  display: none;
}

/* Buildings grid (scrollable) */
#buildings-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
  flex: 1;
  padding-right: 6px;
}

#buildings-grid::-webkit-scrollbar {
  width: 6px;
}

#buildings-grid::-webkit-scrollbar-track {
  background: #1a0a0a;
}

#buildings-grid::-webkit-scrollbar-thumb {
  background: #553322;
  border-radius: 3px;
}

.building-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: #221111;
  border: 1px solid #3a2020;
  transition: all 0.15s;
  cursor: pointer;
  flex-shrink: 0;
}

.building-card:hover {
  border-color: #ff6633;
  background: #2a1818;
}

.building-card.cant-afford {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.building-card .b-icon {
  font-size: 26px;
  min-width: 34px;
  text-align: center;
}

.building-card .b-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.building-card .b-name {
  font-size: 15px;
  font-weight: bold;
  color: #ff9966;
}

.building-card .b-desc {
  font-size: 13px;
  color: #887766;
}

.building-card .b-stats {
  font-size: 13px;
  color: #aa8866;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 2px;
}

.building-card .b-stats .tf-stat { color: #66cc66; }
.building-card .b-stats .energy-stat { color: #66ccff; }
.building-card .b-stats .energy-stat.negative { color: #ff6666; }
.building-card .b-stats .ore-stat { color: #ffcc66; }
.building-card .b-stats .fuel-stat { color: #aabbdd; }

.building-card .b-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
  min-width: 70px;
}

.building-card .b-count {
  font-size: 18px;
  font-weight: bold;
  color: #ffcc66;
}

.building-card .b-cost {
  font-size: 14px;
  color: #cc9955;
}

/* Mine click animation */
@keyframes mine-pop {
  0% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -100%) scale(1.5); opacity: 0; }
}

.mine-popup {
  position: absolute;
  color: #ffcc66;
  font-family: 'Courier New', monospace;
  font-size: 16px;
  font-weight: bold;
  pointer-events: none;
  animation: mine-pop 0.6s ease-out forwards;
  text-shadow: 1px 1px 0 #000;
}

/* ============================================================
   MODAL
   ============================================================ */
.modal {
  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: 200;
}

.modal-content {
  background: #2a1515;
  border: 3px solid #ff6633;
  padding: 30px;
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
}

.modal-content h2 {
  margin-bottom: 20px;
  text-align: center;
}

#leaderboard-list {
  margin-bottom: 20px;
}

.lb-entry {
  display: flex;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid #3a2020;
  font-size: 14px;
}

.lb-entry:nth-child(1) { color: #ffd700; }
.lb-entry:nth-child(2) { color: #c0c0c0; }
.lb-entry:nth-child(3) { color: #cd7f32; }

.lb-rank { min-width: 30px; }
.lb-name { flex: 1; }
.lb-score { color: #ff9966; }

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes stage-unlock {
  0% { transform: scale(1); }
  50% { transform: scale(1.4); filter: drop-shadow(0 0 20px #ffaa00); }
  100% { transform: scale(1); }
}

.stage-unlocked {
  animation: stage-unlock 1s ease;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1200px) {
  main {
    flex-direction: column;
    align-items: stretch;
    padding-left: 290px;
    height: auto;
  }

  #left-panel {
    flex: none;
    max-width: 400px;
    align-self: center;
  }

  #right-panel {
    flex: none;
    width: 100%;
    max-width: 520px;
    height: 500px;
    align-self: center;
  }
}

@media (max-width: 900px) {
  #stages-timeline {
    display: none;
  }

  main {
    padding: 70px 10px 10px 10px;
    flex-direction: column;
    height: auto;
    gap: 10px;
  }

  #left-panel {
    flex: none;
    max-width: 100%;
    width: 100%;
  }

  #mars-canvas-container {
    max-width: 350px;
    margin: 0 auto;
  }

  #right-panel {
    flex: none;
    width: 100%;
    max-width: 100%;
    height: 50vh;
    min-height: 350px;
  }

  header {
    flex-wrap: wrap;
    padding: 8px 10px;
    gap: 6px;
  }

  .header-center {
    order: 3;
    width: 100%;
    max-width: 100%;
  }

  #header-metrics {
    flex-wrap: wrap;
    gap: 6px;
  }

  .hm-label {
    display: none;
  }

  .header-right {
    order: 2;
  }
}

/* Mini timeline (mobile only) */
#mini-timeline {
  display: none;
}

@media (max-width: 900px) {
  #mini-timeline {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    margin: 6px auto;
    max-width: 350px;
    background: #1a0a0a;
    border: 1px solid #3a2020;
    border-radius: 6px;
    font-family: 'Courier New', monospace;
    font-size: 11px;
  }
  #mini-timeline .mt-stage {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 50px;
  }
  #mini-timeline .mt-stage .mt-icon { font-size: 16px; }
  #mini-timeline .mt-stage .mt-name { color: #aa8866; font-size: 10px; white-space: nowrap; }
  #mini-timeline .mt-current .mt-name { color: #ff9966; font-weight: bold; }
  #mini-timeline .mt-next .mt-name { color: #887766; }
  #mini-timeline .mt-bar {
    flex: 1;
    height: 6px;
    background: #2a1515;
    border-radius: 3px;
    position: relative;
    min-width: 40px;
  }
  #mini-timeline .mt-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #ff6633, #ffaa33);
    border-radius: 3px;
    transition: width 0.3s;
  }
  #mini-timeline .mt-pct {
    color: #ffcc66;
    font-size: 10px;
    font-weight: bold;
    white-space: nowrap;
  }
}

@media (max-width: 600px) {
  #stages-timeline {
    display: none;
  }

  header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    padding: 6px 8px;
    gap: 4px;
    flex-wrap: wrap;
    z-index: 100;
  }

  .header-left {
    width: 100%;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .header-resources {
    flex-wrap: wrap;
    gap: 4px;
  }

  .resource-badge {
    font-size: 12px;
    padding: 2px 6px;
  }

  .header-center {
    order: 3;
    width: 100%;
    max-width: 100%;
  }

  .header-right {
    display: none;
  }

  #header-metrics {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
  }

  .hm {
    gap: 3px;
  }

  .hm-label {
    display: none;
  }

  .hm-bar {
    min-width: 30px;
  }

  .hm-val {
    font-size: 11px;
    min-width: 28px;
  }

  .progress-bar-container {
    height: 18px;
    margin-bottom: 4px;
  }

  main {
    padding: 115px 6px 6px 6px;
    flex-direction: column;
    height: auto;
    gap: 8px;
  }

  #left-panel {
    flex: none;
    width: 100%;
  }

  #mars-canvas-container {
    max-width: 280px;
    margin: 0 auto;
  }

  #mars-canvas {
    width: 100%;
    height: auto;
  }

  #mine-hint {
    font-size: 12px;
    padding: 3px;
  }

  #player-bar {
    flex-wrap: wrap;
    gap: 6px;
    padding: 4px 6px;
  }

  #xp-bar {
    min-width: 120px;
  }

  #xp-text {
    font-size: 10px;
    white-space: nowrap;
  }

  #right-panel {
    flex: none;
    width: 100%;
    max-width: 100%;
    height: calc(100vh - 160px);
    min-height: 300px;
    padding: 8px;
  }

  #panel-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 0;
    margin-bottom: 6px;
    -webkit-overflow-scrolling: touch;
  }

  .panel-tab {
    padding: 6px 10px;
    font-size: 11px;
    flex: 0 0 auto;
    text-align: center;
    white-space: nowrap;
    min-width: 0;
  }

  .building-card {
    padding: 8px;
    gap: 6px;
  }

  .building-card .b-icon {
    font-size: 20px;
    min-width: 26px;
  }

  .building-card .b-name {
    font-size: 13px;
  }

  .building-card .b-desc {
    font-size: 11px;
  }

  .building-card .b-stats {
    font-size: 11px;
  }

  .building-card .b-right {
    min-width: 55px;
  }

  .building-card .b-count {
    font-size: 15px;
  }

  .building-card .b-cost {
    font-size: 12px;
  }

  .skill-card {
    padding: 8px;
    gap: 6px;
  }

  .modal-content {
    padding: 15px;
    max-width: 95%;
  }

  #specialty-choices {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .login-box {
    padding: 20px;
    width: 95%;
  }

  .pixel-title {
    font-size: 20px;
  }

  .pixel-btn {
    padding: 10px 16px;
    font-size: 13px;
    width: 100%;
  }

  /* Chat */
  #chat-input-bar {
    padding: 6px;
    gap: 4px;
  }

  #chat-input {
    font-size: 13px;
    padding: 6px 8px;
  }

  /* Victory */
  #victory-content {
    padding: 15px;
    max-width: 95%;
  }

  #victory-stats {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .victory-title {
    font-size: 22px !important;
  }
}

/* ============================================================
   SKILLS PANEL
   ============================================================ */
#skills-grid {
  display: flex; flex-direction: column; gap: 6px; overflow-y: auto; flex: 1; padding-right: 6px;
}
.skill-card {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: #221111; border: 1px solid #3a2020; transition: all 0.15s; cursor: pointer;
}
.skill-card:hover { border-color: #cc66ff; background: #2a1818; }
.skill-card .sk-icon { font-size: 24px; min-width: 32px; text-align: center; }
.skill-card .sk-info { flex: 1; }
.skill-card .sk-name { font-size: 15px; font-weight: bold; color: #cc99ff; }
.skill-card .sk-desc { font-size: 13px; color: #887766; }
.skill-card .sk-level { font-size: 13px; color: #aa88cc; margin-top: 2px; }
.skill-card .sk-right { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.skill-card .sk-cost { font-size: 14px; color: #cc99ff; }
.skill-card.cant-afford { opacity: 0.45; cursor: not-allowed; pointer-events: none; }
.skill-card.maxed { opacity: 0.5; cursor: default; pointer-events: none; border-color: #224422; }
.skill-card.maxed .sk-name { color: #66cc66; }

/* ============================================================
   MISSIONS PANEL
   ============================================================ */
#missions-list {
  display: flex; flex-direction: column; gap: 6px; overflow-y: auto; flex: 1; padding-right: 6px;
}
.mission-card {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: #221111; border: 1px solid #3a2020;
}
.mission-card .m-info { flex: 1; }
.mission-card .m-desc { font-size: 14px; color: #ffcc66; }
.mission-card .m-progress { font-size: 13px; color: #aa8866; margin-top: 3px; }
.mission-card .m-bar { height: 6px; background: #111; border: 1px solid #333; margin-top: 4px; }
.mission-card .m-bar-fill { height: 100%; background: linear-gradient(90deg, #ff6633, #ffaa00); transition: width 0.3s; }
.mission-card .m-rewards { font-size: 13px; color: #66cc66; margin-top: 3px; }
.mission-card .m-btn { background: #336600; color: #66ff33; border: 1px solid #66ff33; padding: 4px 10px; font-size: 13px; cursor: pointer; font-family: 'Courier New', monospace; }
.mission-card .m-btn:hover { background: #449900; }
.mission-card .m-btn:disabled { opacity: 0.4; cursor: default; }
.mission-card .m-timer { font-size: 10px; color: #886644; }

/* Event */
#event-panel {
  margin-top: 10px; padding: 10px; background: #1a1a0a; border: 1px solid #666600; flex-shrink: 0;
}
#event-panel.hidden { display: none; }
.event-title { font-size: 15px; color: #ffff66; font-weight: bold; }
.event-desc { font-size: 13px; color: #cccc66; margin-top: 4px; }
.event-bar { height: 8px; background: #111; border: 1px solid #444; margin-top: 6px; }
.event-bar-fill { height: 100%; background: linear-gradient(90deg, #cccc00, #ffff33); transition: width 0.3s; }
.event-reward { font-size: 13px; color: #66cc66; margin-top: 4px; }
.event-btn { background: #664400; color: #ffcc00; border: 1px solid #ffcc00; padding: 4px 10px; font-size: 13px; cursor: pointer; font-family: 'Courier New', monospace; margin-top: 6px; }
.event-btn:hover { background: #886600; }
.event-btn:disabled { opacity: 0.4; cursor: default; }

/* ============================================================
   EXPEDITIONS PANEL
   ============================================================ */
#active-expeditions {
  display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px;
}
.expedition-card {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: #221111; border: 1px solid #3a2020;
}
.expedition-card .exp-icon { font-size: 22px; }
.expedition-card .exp-info { flex: 1; }
.expedition-card .exp-name { font-size: 14px; color: #66ccff; font-weight: bold; }
.expedition-card .exp-bar { height: 6px; background: #111; border: 1px solid #333; margin-top: 4px; }
.expedition-card .exp-bar-fill { height: 100%; background: linear-gradient(90deg, #2266aa, #44aaff); transition: width 0.3s; }
.expedition-card .exp-time { font-size: 10px; color: #888; margin-top: 2px; }
.expedition-card .exp-btn { background: #224466; color: #66ccff; border: 1px solid #66ccff; padding: 4px 10px; font-size: 13px; cursor: pointer; font-family: 'Courier New', monospace; }
.expedition-card .exp-btn:hover { background: #336688; }
.expedition-card .exp-btn:disabled { opacity: 0.4; cursor: default; }

#zones-grid {
  display: flex; flex-direction: column; gap: 6px; overflow-y: auto; flex: 1; padding-right: 6px;
}
.zone-card {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: #221111; border: 1px solid #3a2020; cursor: pointer; transition: all 0.15s;
}
.zone-card:hover { border-color: #66ccff; background: #2a1818; }
.zone-card.cant-afford { opacity: 0.45; cursor: not-allowed; pointer-events: none; }
.zone-card.cant-afford:hover { border-color: #3a2020; background: #221111; }
.zone-card .z-icon { font-size: 24px; }
.zone-card .z-info { flex: 1; }
.zone-card .z-name { font-size: 14px; color: #66ccff; font-weight: bold; }
.zone-card .z-desc { font-size: 13px; color: #887766; }
.zone-card .z-time { font-size: 13px; color: #888; margin-top: 2px; }
.zone-card .z-rewards { font-size: 13px; color: #66cc66; margin-top: 2px; }

/* ============================================================
   PLAYERS PANEL
   ============================================================ */
#players-list {
  display: flex; flex-direction: column; gap: 4px; overflow-y: auto; flex: 1; padding-right: 6px;
}
.player-card {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; background: #221111; border: 1px solid #3a2020;
}
.player-card.top-1 { border-color: #ffd700; background: #2a2200; }
.player-card.top-2 { border-color: #888888; background: #1a1a1a; }
.player-card.top-3 { border-color: #cd7f32; background: #2a1a0a; }
.player-card .pc-rank { min-width: 28px; font-size: 16px; text-align: center; }
.player-card .pc-name { flex: 1; font-size: 15px; color: #ffcc66; font-weight: bold; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.player-card .pc-level { font-size: 14px; color: #cc99ff; min-width: 45px; }
.player-card .pc-spec { font-size: 13px; color: #aa8866; min-width: 110px; }
.player-card .pc-score { font-size: 13px; color: #66cc66; min-width: 60px; text-align: right; }
.players-section-title {
  font-family: 'Courier New', monospace;
  font-size: 13px; color: #ffcc66; margin-bottom: 8px; padding-left: 4px;
}

/* Runs history in players panel */
#runs-history { margin-top: 15px; border-top: 1px solid #2a2020; padding-top: 12px; }
.runs-panel-title {
  font-family: 'Courier New', monospace;
  font-size: 13px; color: #ffcc66; margin-bottom: 8px; padding-left: 8px;
}

/* ============================================================
   CHAT PANEL
   ============================================================ */
#panel-chat {
  display: flex; flex-direction: column; height: 100%;
}
#chat-messages {
  flex: 1; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 4px;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: #553322 #1a0a0a;
}
#chat-messages::-webkit-scrollbar {
  width: 6px;
}
#chat-messages::-webkit-scrollbar-track {
  background: #1a0a0a;
}
#chat-messages::-webkit-scrollbar-thumb {
  background: #553322;
  border-radius: 3px;
}
.chat-msg {
  font-size: 14px; line-height: 1.4; padding: 4px 8px; border-radius: 4px; background: #1a0d0d;
}
.chat-msg .chat-name {
  font-weight: bold; color: #ffcc66; margin-right: 6px;
}
.chat-msg .chat-text {
  color: #ccbbaa;
}
.chat-msg .chat-time {
  font-size: 11px; color: #665544; margin-left: 6px;
}
#chat-input-bar {
  display: flex; gap: 6px; padding: 8px; border-top: 1px solid #3a2020; flex-shrink: 0; align-items: center;
}
#chat-char-count {
  font-size: 11px; color: #665544; min-width: 38px; text-align: right;
}
#chat-char-count.near-limit { color: #ff6633; }
#chat-input {
  flex: 1; background: #1a0d0d; border: 1px solid #3a2020; color: #eeddcc; padding: 6px 10px;
  font-size: 14px; border-radius: 4px; outline: none;
}
#chat-input:focus { border-color: #ff6633; }
#chat-send-btn {
  background: #cc4400; border: none; color: #fff; padding: 6px 12px; border-radius: 4px;
  cursor: pointer; font-size: 14px;
}
#chat-send-btn:hover { background: #ff6633; }

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
#toast-container {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
  z-index: 9999; display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none;
}
.toast {
  background: #2a1111; border: 1px solid #cc4400; color: #ffddcc; padding: 10px 18px;
  border-radius: 6px; font-size: 13px; box-shadow: 0 4px 16px rgba(0,0,0,0.6);
  animation: toastIn 0.3s ease, toastOut 0.3s ease 3s forwards;
  pointer-events: auto; max-width: 350px; text-align: center;
}
.toast.success { border-color: #44aa44; background: #112211; color: #ccffcc; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; transform: translateY(-10px); } }

/* ============================================================
   SPECIALTY MODAL
   ============================================================ */
.modal-content.wide { max-width: 650px; }
#specialty-choices {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
}
.spec-card {
  padding: 15px; background: #1a0a0a; border: 2px solid #3a2020; cursor: pointer; text-align: center; transition: all 0.2s;
}
.spec-card:hover { border-color: #ff6633; background: #2a1818; transform: scale(1.03); }
.spec-card .sp-icon { font-size: 32px; margin-bottom: 6px; }
.spec-card .sp-name { font-size: 14px; color: #ff9966; font-weight: bold; }
.spec-card .sp-desc { font-size: 11px; color: #aa8866; margin-top: 4px; }

/* ============================================================
   VICTORY SCREEN
   ============================================================ */
#victory-screen {
  position: fixed; inset: 0; z-index: 10000;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, #0a1a2a 0%, #000 70%);
  overflow: hidden;
}
#victory-screen.hidden { display: none; }
#victory-canvas {
  position: absolute; inset: 0; width: 100%; height: 100%;
  image-rendering: pixelated;
}
#victory-content {
  position: relative; z-index: 2;
  text-align: center; padding: 30px;
  background: rgba(0, 10, 20, 0.7);
  border: 3px solid #44cc88;
  box-shadow: 0 0 60px rgba(68, 204, 136, 0.3), inset 0 0 30px rgba(68, 204, 136, 0.05);
  max-width: 600px; width: 90%;
  animation: victoryPulse 3s ease-in-out infinite;
}
.victory-title {
  font-size: 28px !important; color: #66ffaa !important;
  text-shadow: 0 0 20px rgba(102, 255, 170, 0.6);
  margin-bottom: 10px;
}
.victory-subtitle {
  color: #88ccaa; font-size: 16px; margin-bottom: 20px;
  font-family: 'Courier New', monospace;
}
#victory-stats {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  margin: 15px 0; text-align: left;
}
#victory-stats .vs-item {
  background: rgba(68, 204, 136, 0.08);
  border: 1px solid #2a5544;
  padding: 8px 12px; font-family: 'Courier New', monospace;
  font-size: 12px; color: #aaddcc;
}
#victory-stats .vs-item .vs-label { color: #66aa88; }
#victory-stats .vs-item .vs-val { color: #66ffaa; font-weight: bold; float: right; }
.victory-thanks {
  color: #ffcc66; font-size: 14px; margin-top: 20px;
  font-family: 'Courier New', monospace;
  text-shadow: 0 0 10px rgba(255, 204, 102, 0.4);
}
@keyframes victoryPulse {
  0%, 100% { box-shadow: 0 0 60px rgba(68, 204, 136, 0.3), inset 0 0 30px rgba(68, 204, 136, 0.05); }
  50% { box-shadow: 0 0 80px rgba(68, 204, 136, 0.5), inset 0 0 40px rgba(68, 204, 136, 0.1); }
}
@keyframes victoryStar {
  0%, 100% { opacity: 0.3; } 50% { opacity: 1; }
}
.vs-runs-section {
  grid-column: 1 / -1; margin-top: 10px;
  border-top: 1px solid #2a5544; padding-top: 10px;
}
.runs-title {
  font-family: 'Courier New', monospace;
  font-size: 14px; color: #ffcc66; margin-bottom: 8px; text-align: center;
}
.run-entry {
  display: flex; align-items: center; gap: 10px;
  padding: 5px 8px; margin-bottom: 4px;
  background: rgba(68, 204, 136, 0.05);
  border: 1px solid #1a3322; font-family: 'Courier New', monospace; font-size: 12px;
}
.run-rank { min-width: 28px; text-align: center; }
.run-duration { color: #66ffaa; font-weight: bold; min-width: 80px; }
.run-info { color: #88aa99; font-size: 11px; }
