:root {
  color-scheme: dark;
  --bg: #0f1419;
  --panel: #1a2332;
  --border: #2d3a4f;
  --text: #d8dee9;
  --muted: #8b9cb3;
  --accent: #6cb6ff;
  --error: #f07178;
  --output-bg: #0a0e14;
  --font-mono: "Consolas", "Courier New", monospace;
  --font-ui: "Segoe UI", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
}

#app {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.5rem;
}

header h1 {
  margin: 0 0 0.25rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.tagline {
  margin: 0 0 1.5rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
}

.panel h2 {
  margin-top: 0;
  font-size: 1.1rem;
}

.hint {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

label {
  display: block;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
}

.auth-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.auth-tab {
  margin-top: 0;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}

.auth-tab.active {
  background: var(--output-bg);
  color: var(--text);
  border-color: var(--accent);
}

input[type="text"],
input[type="password"],
select {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--output-bg);
  color: var(--text);
  font-size: 1rem;
}

button {
  margin-top: 0.5rem;
  padding: 0.55rem 1rem;
  border: none;
  border-radius: 4px;
  background: var(--accent);
  color: #0a0e14;
  font-weight: 600;
  cursor: pointer;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.error {
  color: var(--error);
  margin-top: 0.75rem;
}

#status-bar {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
  color: var(--muted);
}

#output.mud-output {
  height: 55vh;
  min-height: 280px;
  overflow-x: auto;
  overflow-y: auto;
  margin: 0 0 0.75rem;
  padding: 0.75rem 0.75rem 0.75rem 1.25rem;
  background: var(--output-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.92rem;
  line-height: 1.45;
  white-space: pre;
  overflow-wrap: normal;
  word-break: normal;
  tab-size: 8;
  box-sizing: border-box;
  unicode-bidi: plaintext;
}

/* ANSI spans: color/weight only — no layout that can clip the first glyph */
.mud-output span {
  display: inline;
  margin: 0;
  padding: 0;
  border: 0;
  position: static;
  transform: none;
  vertical-align: baseline;
  letter-spacing: inherit;
  text-indent: 0;
}

/* ANSI foreground (basic 16-color) */
.mud-output .ansi-black { color: #000000; }
.mud-output .ansi-red { color: #cc6666; }
.mud-output .ansi-green { color: #689d6a; }
.mud-output .ansi-yellow { color: #d4a373; }
.mud-output .ansi-blue { color: #6d9eeb; }
.mud-output .ansi-magenta { color: #c678dd; }
.mud-output .ansi-cyan { color: #56b6c2; }
.mud-output .ansi-white { color: #d8dee9; }

.mud-output .ansi-bright-black { color: #808080; }
.mud-output .ansi-bright-red { color: #f07178; }
.mud-output .ansi-bright-green { color: #98c379; }
.mud-output .ansi-bright-yellow { color: #e5c07b; }
.mud-output .ansi-bright-blue { color: #61afef; }
.mud-output .ansi-bright-magenta { color: #e06c75; }
.mud-output .ansi-bright-cyan { color: #56b6c2; }
.mud-output .ansi-bright-white { color: #ffffff; }

.mud-output .ansi-bold {
  font-weight: 700;
}

#command-form input {
  width: 100%;
  padding: 0.65rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--output-bg);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 1rem;
}

#command-form input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

#connection-status.disconnected {
  color: var(--error);
}

.muted-hint {
  color: var(--muted);
  font-size: 0.85rem;
}

#game-panel .hint {
  margin-top: 0.75rem;
  margin-bottom: 0;
}
