:root {
  color-scheme: dark;
  --bg: #090b0d;
  --panel: #111418;
  --panel-raised: #171b20;
  --line: #2a3038;
  --text: #eef1f3;
  --muted: #89919b;
  --accent: #d84b55;
  --accent-glow: rgba(216, 75, 85, 0.35);
  --good: #7fb58a;
  --warn: #d6a75e;
  --bad: #dc6b6b;
  --blue: #7fa4bf;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at 50% -20%, #24252b 0%, var(--bg) 45%);
  color: var(--text);
}

button, input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: .45;
}

/* Auth Surface */
.auth-surface {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(circle at 50% 30%, rgba(216, 75, 85, 0.08) 0%, transparent 60%),
    radial-gradient(circle at 50% -20%, #24252b 0%, var(--bg) 50%);
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background: rgba(17, 20, 24, 0.98);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 28px;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.auth-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.auth-card-header h2 {
  font-size: 22px;
  margin: 4px 0 0;
  letter-spacing: .03em;
}

.auth-card-header h2 span {
  color: var(--accent);
  font-weight: 500;
}

.auth-slot-tag {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .15em;
  color: var(--accent);
  border: 1px solid rgba(216, 75, 85, 0.35);
  background: rgba(216, 75, 85, 0.1);
  padding: 3px 8px;
  border-radius: 4px;
}

.auth-desc {
  margin: 14px 0 20px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.auth-label {
  font-size: 10px;
  letter-spacing: .14em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--muted);
}

.auth-field input {
  width: 100%;
  border: 1px solid var(--line);
  background: #0c0f12;
  color: var(--text);
  border-radius: 7px;
  padding: 11px 13px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.auth-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.auth-submit {
  width: 100%;
  padding: 12px;
  font-size: 13px;
  letter-spacing: .08em;
  text-transform: uppercase;
  margin-top: 4px;
}

.auth-error {
  padding: 10px 12px;
  border-radius: 6px;
  background: rgba(220, 107, 107, 0.12);
  border: 1px solid rgba(220, 107, 107, 0.4);
  color: var(--bad);
  font-size: 12px;
  line-height: 1.4;
}

.auth-foot {
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
  text-align: center;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: .05em;
}

/* App Shell & Main Layout */
.app-shell {
  min-height: 100vh;
  padding: 24px;
}

.topbar {
  max-width: 1600px;
  margin: 0 auto 18px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 20px;
}

.topbar h1 {
  margin: 2px 0 0;
  font-size: clamp(28px, 4vw, 48px);
  letter-spacing: .04em;
}

.topbar h1 span {
  color: var(--accent);
  font-weight: 500;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.operator-meta {
  min-width: 130px;
  padding: 8px 12px;
  background: #0e1115;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: relative;
}

.operator-meta span {
  display: block;
  color: var(--muted);
  text-transform: uppercase;
  font-size: 9px;
  letter-spacing: .12em;
}

.operator-meta strong {
  font-size: 13px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.logout-button {
  font-size: 10px;
  color: var(--accent);
  padding: 0;
  text-align: left;
  margin-top: 2px;
  text-decoration: underline;
  cursor: pointer;
}

.logout-button:hover {
  color: #ff7580;
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: .18em;
  font-weight: 800;
}

.night-meta {
  display: flex;
  gap: 8px;
}

.night-meta div {
  min-width: 88px;
  padding: 9px 12px;
  background: #0e1115;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.night-meta span {
  display: block;
  color: var(--muted);
  text-transform: uppercase;
  font-size: 9px;
  letter-spacing: .12em;
}

.night-meta strong {
  text-transform: capitalize;
}

.game-grid {
  max-width: 1600px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(245px, .8fr) minmax(420px, 1.45fr) minmax(320px, 1fr);
  gap: 14px;
  align-items: stretch;
}

.panel {
  min-height: calc(100vh - 125px);
  background: rgba(17, 20, 24, .96);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}

.panel-heading {
  min-height: 68px;
  padding: 15px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-heading h2 {
  font-size: 17px;
  margin: 2px 0 0;
}

.text-button {
  border: 0;
  background: transparent;
  color: var(--muted);
}

.primary-button {
  border: 1px solid #b6454e;
  background: #7f3037;
  color: #fff;
  border-radius: 7px;
  padding: 8px 12px;
  font-weight: 700;
  transition: background 0.15s ease, transform 0.1s ease;
}

.primary-button:hover:not(:disabled) {
  background: #963841;
}

.status-pill {
  border: 1px solid var(--line);
  border-radius: 99px;
  padding: 5px 9px;
  color: var(--muted);
  font-size: 11px;
}

.roster {
  padding: 10px;
  display: grid;
  gap: 9px;
  max-height: calc(100vh - 195px);
  overflow: auto;
}

.hunter-card, .threat-card {
  background: var(--panel-raised);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.hunter-card.absent {
  opacity: .58;
}

.hunter-topline, .threat-topline {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: start;
}

.hunter-card h3, .threat-card h3 {
  margin: 0;
  font-size: 14px;
}

.role {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.hunter-status, .threat-status, .difficulty {
  text-transform: uppercase;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .09em;
  color: var(--muted);
}

.hunter-status.on_mission {
  color: var(--warn);
}

.hunter-status.recovering {
  color: var(--bad);
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  margin-top: 11px;
}

.stat {
  background: #0e1115;
  border-radius: 5px;
  padding: 5px 4px;
  text-align: center;
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 8px;
  text-transform: uppercase;
}

.stat strong {
  font-size: 13px;
}

.trait-list, .tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
}

.trait, .tag {
  font-size: 9px;
  border: 1px solid #353c46;
  color: #aeb6bf;
  border-radius: 99px;
  padding: 3px 6px;
}

.personality {
  color: #afb5bd;
  line-height: 1.45;
  font-size: 10px;
  margin: 9px 0 0;
}

.chat-panel {
  display: grid;
  grid-template-rows: auto 1fr auto auto;
}

.chat-log {
  padding: 18px;
  overflow-y: auto;
  max-height: calc(100vh - 255px);
  display: flex;
  flex-direction: column;
  gap: 13px;
}

.message {
  max-width: 82%;
}

.message .speaker {
  font-size: 10px;
  letter-spacing: .06em;
  text-transform: uppercase;
  font-weight: 800;
  color: var(--blue);
  margin-bottom: 3px;
}

.message .bubble {
  background: #1a1e23;
  border: 1px solid #282e35;
  padding: 9px 11px;
  border-radius: 4px 11px 11px 11px;
  font-size: 13px;
  line-height: 1.5;
}

.message.player {
  align-self: flex-end;
}

.message.player .speaker {
  text-align: right;
  color: #cf8990;
}

.message.player .bubble {
  background: #382025;
  border-color: #5a3036;
  border-radius: 11px 4px 11px 11px;
}

.message.system {
  max-width: 100%;
  align-self: stretch;
}

.message.system .speaker {
  color: var(--muted);
}

.message.system .bubble {
  background: transparent;
  border-style: dashed;
  color: #a5abb2;
  font-size: 11px;
}

.chat-compose {
  padding: 12px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  border-top: 1px solid var(--line);
}

.chat-compose input {
  min-width: 0;
  border: 1px solid #343b44;
  background: #0c0f12;
  color: var(--text);
  border-radius: 7px;
  padding: 10px 12px;
  outline: none;
}

.chat-compose input:focus {
  border-color: var(--accent);
}

.prototype-note {
  margin: 0;
  padding: 0 13px 11px;
  color: #666f78;
  font-size: 9px;
}

.threat-list {
  padding: 10px;
  display: grid;
  gap: 10px;
  max-height: calc(100vh - 195px);
  overflow: auto;
}

.threat-card {
  border-left: 3px solid #6f3439;
}

.threat-card.dispatched {
  border-left-color: var(--warn);
}

.threat-card.resolved {
  border-left-color: var(--good);
}

.threat-card.ignored {
  border-left-color: var(--bad);
  opacity: .72;
}

.threat-card h3 {
  font-size: 15px;
  margin-top: 6px;
}

.description {
  color: #adb4bc;
  font-size: 11px;
  line-height: 1.48;
}

.skill-line {
  color: #cdd2d7;
  font-size: 10px;
  text-transform: capitalize;
}

.assignment-block {
  margin-top: 12px;
  border-top: 1px solid #2b3037;
  padding-top: 10px;
}

.assignment-label {
  margin: 0 0 7px;
  color: var(--muted);
  font-size: 9px;
  text-transform: uppercase;
}

.assignment-options {
  display: grid;
  gap: 5px;
}

.assignment-option {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  color: #c8cdd2;
}

.dispatch-button {
  margin-top: 9px;
  width: 100%;
}

.debrief {
  padding: 12px;
  border-top: 1px solid var(--line);
}

.debrief h3 {
  margin: 0 0 9px;
}

.result-card {
  background: #0e1115;
  border: 1px solid #2e343b;
  border-radius: 7px;
  padding: 10px;
  margin-bottom: 7px;
}

.result-card strong {
  text-transform: capitalize;
}

.result-card p {
  color: var(--muted);
  font-size: 10px;
  margin: 5px 0 0;
}

.hidden {
  display: none !important;
}

.error-toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  background: #4d2025;
  border: 1px solid #8b3941;
  padding: 10px 14px;
  border-radius: 8px;
  max-width: 340px;
  z-index: 10;
}

@media (max-width: 1100px) {
  .game-grid {
    grid-template-columns: 280px 1fr;
  }
  .threats-panel {
    grid-column: 1 / -1;
    min-height: auto;
  }
  .threat-list {
    max-height: none;
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding: 12px;
  }
  .topbar {
    align-items: start;
    flex-direction: column;
  }
  .topbar-right {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .operator-meta {
    width: 100%;
  }
  .night-meta {
    width: 100%;
  }
  .night-meta div {
    flex: 1;
    min-width: 0;
  }
  .game-grid {
    grid-template-columns: 1fr;
  }
  .panel, .threats-panel {
    grid-column: auto;
    min-height: auto;
  }
  .roster, .chat-log, .threat-list {
    max-height: none;
  }
  .threat-list {
    grid-template-columns: 1fr;
  }
  .chat-log {
    min-height: 420px;
  }
}
