:root {
  color-scheme: dark;
  --background: #05080c;
  --surface: #0b1118;
  --surface-raised: #101923;
  --border: #253441;
  --border-bright: #3d5364;
  --text: #e4e9e9;
  --muted: #8c9ba3;
  --accent: #e0b86a;
  --accent-soft: #3a2e1b;
  --signal: #79d8c1;
  --error: #ff9292;
  --shadow: 0 30px 80px rgb(0 0 0 / 38%);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
  background: var(--background);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    linear-gradient(rgb(255 255 255 / 1%) 1px, transparent 1px),
    linear-gradient(90deg, rgb(255 255 255 / 1%) 1px, transparent 1px),
    radial-gradient(circle at 50% -10%, #162736 0%, transparent 42rem),
    var(--background);
  background-size: 48px 48px, 48px 48px, auto, auto;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
.primary-action {
  min-height: 46px;
  border: 1px solid var(--accent);
  border-radius: 3px;
  padding: 0.8rem 1.2rem;
  color: #171005;
  background: var(--accent);
  font-weight: 750;
  text-decoration: none;
  cursor: pointer;
  transition:
    background-color 150ms ease,
    border-color 150ms ease,
    transform 150ms ease;
}

button:hover,
.primary-action:hover {
  background: #f0cb82;
  border-color: #f0cb82;
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
}

.shell {
  width: min(1180px, calc(100% - 2rem));
  min-height: 100vh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}

.masthead {
  min-height: 92px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  color: var(--text);
  text-decoration: none;
}

.brand-symbol {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border: 1px solid var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
  font-family: Georgia, serif;
  font-size: 1.45rem;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  letter-spacing: 0.12em;
}

.brand small {
  margin-top: 0.22rem;
  color: var(--muted);
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.61rem;
  letter-spacing: 0.12em;
}

nav {
  display: flex;
  align-items: center;
  gap: 1rem;
}

nav a,
nav button {
  color: var(--muted);
  background: transparent;
  border: 0;
  padding: 0.4rem;
  min-height: auto;
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.74rem;
  text-transform: uppercase;
  text-decoration: none;
  letter-spacing: 0.06em;
}

nav a:hover,
nav button:hover {
  color: var(--text);
  background: transparent;
  border: 0;
  transform: none;
}

.system-code {
  margin: 0 0 0.85rem;
  color: var(--accent);
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
}

.system-message {
  margin: 1.5rem 0 0;
  border: 1px solid var(--border-bright);
  border-left: 3px solid var(--signal);
  padding: 1rem 1.1rem;
  background: var(--surface);
}

.system-message.error {
  border-left-color: var(--error);
  color: #ffd4d4;
}

.centered-view {
  width: min(620px, 100%);
  min-height: 60vh;
  margin: auto;
  display: grid;
  place-items: center;
  align-content: center;
  text-align: center;
}

.centered-view h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 3.8rem);
  letter-spacing: -0.045em;
}

.centered-view > p:not(.system-code) {
  max-width: 570px;
  margin: 1.2rem auto 1.8rem;
  color: var(--muted);
  line-height: 1.75;
}

.primary-action {
  display: inline-grid;
  place-items: center;
}

.terminal-loader {
  display: flex;
  gap: 0.45rem;
  margin-bottom: 1.4rem;
}

.terminal-loader span {
  width: 8px;
  height: 8px;
  background: var(--accent);
  animation: pulse 1.1s ease-in-out infinite;
}

.terminal-loader span:nth-child(2) {
  animation-delay: 140ms;
}

.terminal-loader span:nth-child(3) {
  animation-delay: 280ms;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.2;
    transform: translateY(0);
  }

  50% {
    opacity: 1;
    transform: translateY(-5px);
  }
}

.section-intro {
  max-width: 760px;
  padding: clamp(3.5rem, 8vw, 6rem) 0 2.5rem;
}

.section-intro h1 {
  margin: 0;
  font-size: clamp(2.5rem, 6vw, 5rem);
  line-height: 1;
  letter-spacing: -0.055em;
}

.section-intro > p:last-child {
  max-width: 650px;
  margin: 1.35rem 0 0;
  color: var(--muted);
  line-height: 1.75;
}

.character-form {
  display: grid;
  gap: 1.25rem;
  padding-bottom: 3rem;
}

fieldset {
  min-width: 0;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: clamp(1.3rem, 3vw, 2rem);
  background:
    linear-gradient(135deg, rgb(255 255 255 / 2%), transparent 40%),
    var(--surface);
  box-shadow: var(--shadow);
}

legend {
  padding: 0 0.65rem;
  color: var(--text);
  font-size: 1.05rem;
  font-weight: 700;
}

.field-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(120px, 1fr);
  gap: 1rem;
}

label {
  display: grid;
  gap: 0.5rem;
  margin-top: 1.1rem;
  color: #c7d1d5;
  font-size: 0.85rem;
  font-weight: 650;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.8rem 0.9rem;
  color: var(--text);
  background: #070c11;
  outline: none;
}

input,
select {
  min-height: 48px;
}

textarea {
  resize: vertical;
  line-height: 1.55;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgb(224 184 106 / 11%);
}

.form-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.5rem;
  border-top: 1px solid var(--border);
  padding: 1.5rem 0;
}

.form-actions p {
  max-width: 570px;
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.55;
}

.console-view {
  padding: clamp(2.5rem, 6vw, 5rem) 0;
}

.console-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 2rem;
  border: 1px solid var(--border);
  border-bottom: 0;
  padding: 1.4rem 1.6rem;
  background: var(--surface-raised);
}

.console-header h1 {
  margin: 0;
  font-size: 1.6rem;
}

.connection-state {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--signal);
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.72rem;
  text-transform: uppercase;
}

.connection-state span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--signal);
  box-shadow: 0 0 10px var(--signal);
}

.console-output {
  min-height: 420px;
  max-height: 60vh;
  overflow-y: auto;
  border: 1px solid var(--border);
  padding: clamp(1.2rem, 3vw, 2rem);
  background: #030609;
  box-shadow: var(--shadow);
  font-family: Consolas, "Courier New", monospace;
  line-height: 1.7;
}

.console-line {
  margin: 0 0 1rem;
  white-space: pre-wrap;
}

.console-line.system {
  color: var(--muted);
}

.console-input {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.8rem;
  border: 1px solid var(--border);
  border-top: 0;
  padding: 0.85rem 1rem;
  background: var(--surface-raised);
  color: var(--accent);
  font-family: Consolas, "Courier New", monospace;
}

.console-input input {
  border: 0;
  padding-inline: 0;
  background: transparent;
  box-shadow: none;
}

footer {
  min-height: 82px;
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-top: 1px solid var(--border);
  color: #64747d;
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 700px) {
  .field-grid {
    grid-template-columns: 1fr;
  }

  .form-actions,
  .console-header {
    align-items: stretch;
    flex-direction: column;
  }

  .form-actions button {
    width: 100%;
  }
}

@media (max-width: 520px) {
  .shell {
    width: calc(100% - 1.2rem);
  }

  .masthead {
    min-height: 76px;
  }

  .brand small {
    display: none;
  }

  nav {
    gap: 0.25rem;
  }

  nav a,
  nav button {
    font-size: 0.64rem;
  }

  .console-input {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .console-input button {
    grid-column: 1 / -1;
  }

  footer {
    align-items: flex-start;
    flex-direction: column;
    justify-content: center;
  }
}
