* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background: #0d0d0d;
  color: #c8c8c8;
  font-family: "Courier New", Courier, monospace;
  font-size: 15px;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Onboarding screen ─────────────────────────────────────── */

#onboarding {
  width: 100%;
  max-width: 480px;
  padding: 2rem;
}

#onboarding h1 {
  font-size: 1.1rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: #fff;
  margin-bottom: 2rem;
}

.field {
  margin-bottom: 1.2rem;
}

.field label {
  display: block;
  font-size: 0.8rem;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 0.4rem;
}

.field-row {
  display: flex;
  gap: 0.5rem;
}

.field-row input {
  flex: 1;
}

.field select,
.field input {
  width: 100%;
  background: #1a1a1a;
  border: 1px solid #333;
  color: #c8c8c8;
  font-family: inherit;
  font-size: 0.95rem;
  padding: 0.5rem 0.7rem;
  outline: none;
}

#load-models-btn {
  background: #1a1a1a;
  border: 1px solid #444;
  color: #c8c8c8;
  font-family: inherit;
  font-size: 0.8rem;
  padding: 0 0.8rem;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
  flex-shrink: 0;
}

#load-models-btn:hover { background: #222; border-color: #666; }

.field-hint {
  margin-top: 0.5rem;
  font-size: 0.78rem;
  color: #555;
  line-height: 1.5;
}

.field label a {
  color: #569cd6;
  text-decoration: none;
  font-size: 0.78rem;
  text-transform: none;
  letter-spacing: 0;
}

.field label a:hover { text-decoration: underline; }

.field select:focus,
.field input:focus {
  border-color: #555;
}

#start-btn {
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.6rem;
  background: #1a1a1a;
  border: 1px solid #444;
  color: #c8c8c8;
  font-family: inherit;
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  cursor: pointer;
}

#start-btn:hover {
  background: #222;
  border-color: #666;
}

#onboarding-error {
  margin-top: 0.8rem;
  font-size: 0.85rem;
  color: #c0392b;
  min-height: 1.2em;
}

/* ── Game terminal ─────────────────────────────────────────── */

#game {
  display: none;
  flex-direction: column;
  width: 100%;
  max-width: 720px;
  height: 100vh;
  padding: 1rem;
}

@media (min-width: 900px) {
  #game { max-width: 1100px; }
}

#output {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 0.5rem;
  scrollbar-width: thin;
  scrollbar-color: #333 transparent;
}

#output::-webkit-scrollbar { width: 4px; }
#output::-webkit-scrollbar-thumb { background: #333; }

.msg {
  margin: 0.6rem 0;
  line-height: 1.6;
  white-space: pre-wrap;
}

.msg-narrator { color: #c8c8c8; }
.msg-npc      { color: #4ec9b0; }
.msg-system   { color: #888; font-size: 0.85rem; }
.msg-error    { color: #888; font-style: italic; }
.msg-player   { color: #569cd6; }
.msg-win      { color: #4ec94e; font-weight: bold; }

.divider {
  border: none;
  border-top: 1px solid #222;
  margin: 0.8rem 0;
}

#input-row {
  display: flex;
  align-items: flex-end;
  border-top: 1px solid #222;
  padding-top: 0.6rem;
  gap: 0.5rem;
}

#prompt {
  color: #569cd6;
  flex-shrink: 0;
}

#player-input {
  flex: 1;
  background: transparent;
  border: none;
  color: #c8c8c8;
  font-family: inherit;
  font-size: 1rem;
  outline: none;
  caret-color: #c8c8c8;
  resize: none;
  overflow: hidden;
  line-height: 1.5;
  min-height: 1.5em;
  padding: 0;
}

#status-btn {
  background: transparent;
  border: 1px solid #333;
  color: #666;
  font-family: inherit;
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  flex-shrink: 0;
}

#status-btn:hover { border-color: #555; color: #999; }

.thinking {
  color: #444;
  font-style: italic;
  animation: blink 1s step-start infinite;
}

@keyframes blink {
  50% { opacity: 0; }
}

/* ── Status overlay ────────────────────────────────────────── */

#status-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  align-items: center;
  justify-content: center;
  z-index: 10;
}

#status-overlay.open {
  display: flex;
}

#status-box {
  background: #111;
  border: 1px solid #333;
  padding: 2rem;
  min-width: 320px;
  max-width: 480px;
  width: 90%;
}

#status-box h2 {
  font-size: 0.8rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: #555;
  margin-bottom: 1rem;
}

#status-content { font-size: 0.9rem; line-height: 1.8; }

.milestone-done  { color: #4ec94e; }
.milestone-blank { color: #333; }
.relationship    { color: #c8c8c8; }

#status-close {
  margin-top: 1.2rem;
  background: transparent;
  border: 1px solid #333;
  color: #666;
  font-family: inherit;
  font-size: 0.8rem;
  padding: 0.3rem 0.8rem;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

#status-close:hover { border-color: #555; color: #999; }

/* ── Win overlay ───────────────────────────────────────────────────────────── */

#win-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.92);
  align-items: center;
  justify-content: center;
  z-index: 20;
}

#win-overlay.open {
  display: flex;
  animation: win-fadein 0.8s ease;
}

#win-box {
  text-align: center;
  padding: 3rem 2rem;
}

#win-ghost {
  width: 90px;
  height: 90px;
  animation: win-float 3s ease-in-out infinite, win-glow 2s ease-in-out infinite;
}

@keyframes win-float {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-14px); }
}

@keyframes win-glow {
  0%, 100% { filter: drop-shadow(0 0 8px #4ec9b0); }
  50%       { filter: drop-shadow(0 0 24px #4ec9b0) drop-shadow(0 0 48px #4ec9b055); }
}

#win-title {
  font-size: 1.5rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: #4ec9b0;
  margin: 1.8rem 0 0.6rem;
}

#win-subtitle {
  color: #555;
  font-size: 0.85rem;
  margin-bottom: 2rem;
  letter-spacing: 0.05em;
}

#win-buttons {
  display: flex;
  gap: 1rem;
  justify-content: center;
}

#win-continue, #win-reset {
  font-family: inherit;
  font-size: 0.85rem;
  padding: 0.5rem 1.8rem;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

#win-continue {
  background: #4ec9b0;
  border: 1px solid #4ec9b0;
  color: #0d0d0d;
}

#win-continue:hover { background: #3ab89f; border-color: #3ab89f; }

#win-reset {
  background: transparent;
  border: 1px solid #444;
  color: #666;
}

#win-reset:hover { border-color: #666; color: #999; }

@keyframes win-fadein {
  from { opacity: 0; }
  to   { opacity: 1; }
}
