* {
  box-sizing: border-box;
}

html {
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  height: 100dvh;
  height: 100vh; /* fallback */
  overflow: hidden;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: #1a1b26;
  color: #c0caf5;
  display: flex;
  flex-direction: column;
}

.header {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #3b4261;
  flex-shrink: 0;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.header-left {
  min-width: 0;
}

.player-status-strip {
  font-size: 0.8125rem;
  font-weight: 500;
  color: #9aa5ce;
  flex-shrink: 0;
  white-space: nowrap;
}

.header-brand {
  margin: 0 0 0.5rem 0;
  line-height: 0;
}

.header-logo {
  display: block;
  max-width: min(100%, 320px);
  height: auto;
  max-height: 4.5rem;
  width: auto;
}

.status-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.status {
  font-size: 0.8125rem;
  font-weight: 500;
}

.status-disconnected {
  color: #f7768e;
}

.status-connecting {
  color: #e0af68;
}

.status-connected {
  color: #9ece6a;
}

.btn {
  padding: 0.25rem 0.5rem;
  font-size: 0.8125rem;
  background: #3b4261;
  color: #c0caf5;
  border: 1px solid #565f89;
  border-radius: 4px;
  cursor: pointer;
}

.btn:hover:not(:disabled) {
  background: #414868;
}

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

.main {
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
  padding: 0.5rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.panels {
  display: grid;
  grid-template-columns: 1fr 2fr 1fr; /* Inventory ~25%, Context ~50%, Help ~25% */
  gap: 0.5rem;
  flex: 0 0 195px;
  height: 195px;
  min-height: 195px;
  max-height: 195px;
  min-width: 0;
}

.panel {
  background: #16161e;
  border: 1px solid #3b4261;
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.panel-title {
  margin: 0 0 0.35rem 0;
  font-size: 0.75rem;
  font-weight: 600;
  color: #9aa5ce;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  flex-shrink: 0;
}

.panel-content {
  font-size: 0.8125rem;
  color: #c0caf5;
  min-height: 0;
  flex: 1 1 0;
  overflow-y: auto;
}

.panel-item {
  padding: 0.15rem 0;
}

.panel-location {
  font-weight: 500;
}

.panel-ship-line {
  padding: 0.15rem 0;
  font-size: 0.8125rem;
  line-height: 1.35;
}

.panel-ship-line--bars {
  padding: 0.25rem 0 0.35rem;
}

/* ship_context v4: horizontal hull / shields / fuel bars */
.ship-ctx-hbars {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  margin: 0;
  min-width: 0;
}

.ship-ctx-hbar-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
  font-size: 0.75rem;
}

.ship-ctx-hbar-label {
  flex: 0 0 4.25rem;
  min-width: 0;
  color: #9aa5ce;
}

/* Bar + value read as one unit: value immediately after the bar */
.ship-ctx-hbar-bar-unit {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
  flex: 1 1 auto;
}

/* Bar track: 60% of the bar-unit row (left-aligned within the unit) */
.ship-ctx-bar {
  flex: 0 0 60%;
  width: 60%;
  max-width: 60%;
  box-sizing: border-box;
}

.ship-ctx-hbar-track {
  display: block;
  width: 100%;
  height: 6px;
  background: #24283b;
  border-radius: 3px;
  overflow: hidden;
  min-width: 0;
}

.ship-ctx-bar-fill {
  display: block;
  height: 100%;
  background: #565f89;
  border-radius: 3px;
  min-width: 0;
}

.ship-ctx-bar--shields-up .ship-ctx-bar-fill {
  background-color: #4a7c59;
}

.ship-ctx-bar--shields-down .ship-ctx-bar-fill {
  background-color: #565f89;
}

.ship-ctx-hbar-display {
  color: #a9b1d6;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ship_info: vertical power / cargo bars (lower-left panel replaces inventory when visible) */
.panel--ship-info .panel-content {
  overflow-x: auto;
}

.ship-info-header {
  margin-bottom: 0.35rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: #9aa5ce;
}

.ship-info-name {
  word-break: break-word;
}

.ship-info-bars {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  justify-content: space-between;
  gap: 0.25rem;
  min-height: 5.5rem;
}

.ship-info-vbar {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
}

.ship-info-vbar-label {
  font-size: 0.6rem;
  line-height: 1.1;
  text-align: center;
  color: #9aa5ce;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ship-info-vbar-track {
  flex: 1 1 auto;
  width: 55%;
  max-width: 2.25rem;
  min-height: 3.25rem;
  background: #24283b;
  border-radius: 3px;
  position: relative;
  overflow: hidden;
  align-self: center;
}

.ship-info-vbar-fill {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  background: #565f89;
  border-radius: 3px;
  min-height: 0;
}

.ship-info-vbar--at-max .ship-info-vbar-fill {
  box-shadow: inset 0 0 0 1px #6c7086;
}

.ship-info-vbar-display {
  font-size: 0.6rem;
  line-height: 1.1;
  text-align: center;
  color: #a9b1d6;
  font-variant-numeric: tabular-nums;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.panel-hint-msg {
  margin-bottom: 0.25rem;
}

.panel-hint-syntax code {
  font-size: 0.75rem;
  background: #24283b;
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
}

/* Tactical panel: neutral text only (no accent colors). */
.tactical-panel {
  font-size: 0.8125rem;
  line-height: 1.35;
  color: inherit;
}

.panel-tactical-idle {
  font-size: 0.8125rem;
  line-height: 1.35;
  color: inherit;
  font-style: italic;
}

.tactical-line {
  white-space: pre-wrap;
  word-break: break-word;
}

.tactical-line-indented {
  padding-left: 0.5rem;
}

.tactical-block {
  margin-bottom: 0.45rem;
}

.tactical-block:last-child {
  margin-bottom: 0;
}

.terminal-wrap {
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
}

.hidden {
  display: none !important;
}

.jump-to-login {
  position: absolute;
  bottom: 0.5rem;
  right: 0.5rem;
  z-index: 10;
  padding: 0.35rem 0.6rem;
  font-size: 0.75rem;
  background: #1a1b26;
  color: #7aa2f7;
  border: 1px solid #3b4261;
  border-radius: 4px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.jump-to-login:hover {
  background: #24283b;
  color: #7dcfff;
}

.command-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.command-bar-label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: #9aa5ce;
  flex-shrink: 0;
}

.command-input {
  flex: 1;
  min-width: 0;
  padding: 0.35rem 0.5rem;
  font-size: 0.8125rem;
  font-family: inherit;
  background: #16161e;
  color: #c0caf5;
  border: 1px solid #3b4261;
  border-radius: 4px;
}

.command-input::placeholder {
  color: #6c7086;
}

.command-input:focus {
  outline: none;
  border-color: #565f89;
}

#terminal-container {
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 0.5rem;
  background: #16161e;
  border: 1px solid #3b4261;
  border-radius: 6px;
}

#terminal-container .xterm {
  padding: 0.25rem;
}

.footer {
  padding: 0.5rem 1rem;
  border-top: 1px solid #3b4261;
  flex-shrink: 0;
}

.help {
  margin: 0;
  font-size: 0.75rem;
  color: #6c7086;
}
