:root {
  color: #ece9e1;
  background: #111315;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  letter-spacing: 0;
  --ink: #111315;
  --coal: #181b1d;
  --iron: #252a2d;
  --line: #3a4144;
  --fog: #b9c6c9;
  --paper: #ece9e1;
  --blood: #9e3036;
  --blood-bright: #c94b52;
  --gold: #c9a65b;
  --cyan: #79aeb7;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; margin: 0; }

body {
  min-height: 100vh;
  background: var(--ink);
  color: var(--paper);
}

button, input, textarea { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
.hidden { display: none !important; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(320px, 520px);
  background: #101214;
}

.brand-field {
  min-height: 100vh;
  display: flex;
  align-items: flex-end;
  padding: 64px;
  background-color: #1a1d1e;
  background-image: url("/brand-image");
  background-position: center;
  background-size: cover;
  border-right: 1px solid #34393b;
  position: relative;
}

.brand-field::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(7, 9, 10, 0.42);
}

.brand-copy { position: relative; z-index: 1; max-width: 660px; }
.domain { color: var(--gold); margin: 0 0 8px; font-weight: 700; text-transform: uppercase; }
.brand-copy h1 {
  font-family: Copperplate, "Palatino Linotype", Georgia, "Times New Roman", serif;
  font-size: 64px;
  line-height: 1;
  margin: 0;
  font-weight: 600;
  text-shadow: 0 2px 18px #000;
}
.brand-line { color: #e4e7e4; font-size: 20px; margin: 14px 0 0; }

.auth-panel {
  min-height: 100vh;
  padding: 56px clamp(28px, 5vw, 72px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: #171a1c;
}

.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; border-bottom: 1px solid var(--line); margin-bottom: 30px; }
.tab {
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: #aeb7b9;
  padding: 13px 8px;
  font-weight: 700;
}
.tab.active { color: var(--paper); border-bottom-color: var(--blood-bright); }
.tab:focus-visible, button:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

.auth-form { display: grid; gap: 10px; }
.auth-form h2 { margin: 0; font-family: Georgia, serif; font-size: 24px; }
.form-note { margin: 0 0 8px; color: #aeb7b9; line-height: 1.5; }
.auth-form label { color: #c9d0d1; font-size: 14px; font-weight: 650; margin-top: 7px; }
.auth-form input {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid #4a5255;
  border-radius: 4px;
  color: var(--paper);
  background: #101315;
}
.primary-command {
  min-height: 48px;
  border: 1px solid #d85f66;
  border-radius: 4px;
  background: var(--blood);
  color: #fff;
  font-weight: 750;
  margin-top: 16px;
}
.primary-command:hover { background: #b73940; }
.form-error { min-height: 24px; color: #ff9398; margin: 16px 0 0; }

.game-shell {
  min-height: 100vh;
  height: 100vh;
  display: grid;
  grid-template-rows: 64px 42px minmax(0, 1fr) auto;
  background: #121416;
}

.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 0 max(20px, calc((100vw - 1040px) / 2));
  border-bottom: 1px solid #303638;
  background: #181b1d;
}
.game-brand, .player-identity { display: flex; align-items: center; gap: 12px; min-width: 0; }
.crest {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid var(--gold);
  border-radius: 50%;
  color: var(--gold);
  font-family: Georgia, serif;
  font-size: 21px;
}
.game-brand div { display: grid; min-width: 0; }
.game-brand strong { font-family: Copperplate, "Palatino Linotype", Georgia, serif; font-size: 18px; }
.game-brand span:not(.crest) { color: #9eabad; font-size: 12px; }
#player-name { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #cbd1d2; }
.quiet-command { border: 0; background: transparent; color: #d7b66d; padding: 8px; }

.quick-actions {
  width: min(100%, 1040px);
  margin: 0 auto;
  display: flex;
  align-items: stretch;
  gap: 0;
  padding: 0 28px;
  overflow-x: auto;
  border-bottom: 1px solid #2e3436;
}
.quick-actions button {
  flex: 0 0 auto;
  min-width: 88px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: #aeb8ba;
  font-size: 13px;
  font-weight: 700;
}
.quick-actions button:hover { color: var(--paper); border-bottom-color: var(--gold); }

.story-column {
  width: min(100%, 1040px);
  margin: 0 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 28px 28px 16px;
  scrollbar-color: #4b5558 transparent;
}
.message { max-width: 820px; margin: 0 0 26px; }
.message.user { margin-left: auto; max-width: 680px; }
.message-author { color: var(--gold); font-size: 12px; font-weight: 800; text-transform: uppercase; margin-bottom: 7px; }
.message.user .message-author { color: var(--cyan); text-align: right; }
.message-body {
  color: #e7e5de;
  font-family: "Palatino Linotype", Palatino, Georgia, serif;
  font-size: 17px;
  line-height: 1.68;
  overflow-wrap: anywhere;
  white-space: normal;
}
.message.user .message-body {
  padding: 12px 14px;
  border-left: 3px solid var(--cyan);
  background: #1b2426;
  border-radius: 0 4px 4px 0;
}
.message-body strong { color: #fff; }
.message.failed .message-body { color: #ff9da2; border-color: var(--blood-bright); }
.message-media { display: grid; gap: 10px; margin-top: 14px; }
.message-media figure { margin: 0; border: 1px solid #3d4547; background: #0d0f10; }
.message-media img { display: block; width: 100%; max-height: 620px; object-fit: contain; }
.message-media figcaption { padding: 8px 10px; color: #bdc6c7; font-size: 13px; }

.typing { width: min(100%, 984px); margin: 0 auto; padding: 8px 28px 14px; color: #9facad; display: flex; align-items: center; gap: 5px; }
.typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--gold); animation: pulse 1.2s infinite ease-in-out; }
.typing span:nth-child(2) { animation-delay: 0.15s; }
.typing span:nth-child(3) { animation-delay: 0.3s; }
.typing em { margin-left: 7px; font-size: 13px; }
@keyframes pulse { 0%, 70%, 100% { opacity: .25; } 35% { opacity: 1; } }

.composer {
  width: min(calc(100% - 32px), 984px);
  margin: 0 auto 18px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 48px;
  gap: 10px;
  padding: 10px;
  border: 1px solid #3e4649;
  border-radius: 6px;
  background: #1a1e20;
}
.composer textarea {
  width: 100%;
  max-height: 180px;
  resize: none;
  border: 0;
  outline: 0;
  padding: 8px;
  color: #f0eee8;
  background: transparent;
  line-height: 1.45;
}
.send-command {
  width: 48px;
  height: 48px;
  align-self: end;
  border: 1px solid #c0474e;
  border-radius: 4px;
  background: var(--blood);
  color: #fff;
  font-size: 22px;
}
.send-command:disabled { cursor: wait; opacity: .5; }

@media (max-width: 760px) {
  .auth-shell { grid-template-columns: 1fr; }
  .brand-field { min-height: 34vh; padding: 32px 24px; border-right: 0; border-bottom: 1px solid #34393b; }
  .brand-copy h1 { font-size: 46px; }
  .brand-line { font-size: 16px; }
  .auth-panel { min-height: 66vh; padding: 32px 24px 48px; justify-content: flex-start; }
  .game-header { padding: 0 14px; }
  .quick-actions { padding: 0 10px; }
  #player-name { max-width: 110px; }
  .messages { padding: 22px 16px 8px; }
  .message { margin-bottom: 22px; }
  .composer { width: calc(100% - 20px); margin-bottom: 10px; grid-template-columns: minmax(0, 1fr) 44px; }
  .send-command { width: 44px; height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}
