:root {
  --bg: #000;
  --fg: #f2f2f2;
  --fg-dim: #888;
  --accent: #1f51ff;
  --danger: #ff4444;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: 'Courier New', Consolas, monospace;
  height: 100%;
}

#game {
  max-width: 800px;
  margin: 0 auto;
  padding: 1rem;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

#status-bar {
  flex-shrink: 0;
  border: 1px solid var(--fg-dim);
  padding: 0.5rem 0.75rem;
  margin-bottom: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.9rem;
  color: var(--fg-dim);
}

#status-bar span.label { color: var(--fg); }

#status-bar span.player-name { font-weight: bold; }

#status-bar button {
  background: none;
  border: 1px solid var(--fg-dim);
  color: var(--fg-dim);
  font-family: inherit;
  cursor: pointer;
  padding: 0.15rem 0.5rem;
}

#status-bar button:first-of-type {
  margin-left: auto;
}

#status-bar button:hover { color: var(--danger); border-color: var(--danger); }

#text-output {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-bottom: 1rem;
  padding-right: 1rem;
  line-height: 1.5;
  text-shadow: 0 0 4px rgba(255, 255, 255, 0.25);
  scrollbar-color: var(--fg-dim) var(--bg);
  scrollbar-width: thin;
}

#text-output::-webkit-scrollbar {
  width: 10px;
}

#text-output::-webkit-scrollbar-track {
  background: var(--bg);
}

#text-output::-webkit-scrollbar-thumb {
  background: var(--fg-dim);
  border: 2px solid var(--bg);
  border-radius: 6px;
}

#text-output::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

#text-output p {
  margin: 0 0 1rem 0;
  white-space: pre-wrap;
}

#text-output p.combat-log {
  color: var(--accent);
  margin: 0 0 0.25rem 0;
  text-shadow: 0 0 4px var(--accent);
}

#text-output p.choice-echo {
  text-align: right;
  font-weight: bold;
  color: var(--accent);
  margin: 0 0 1rem 0;
  text-shadow: 0 0 4px var(--accent);
}

#text-output p.scene-sep {
  color: var(--fg-dim);
  border-top: 1px dashed var(--fg-dim);
  margin: 1rem 0;
}

#choice-list {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding-top: 0.5rem;
}

#choice-list button {
  text-align: left;
  background: none;
  border: 1px solid var(--fg-dim);
  color: var(--fg);
  font-family: inherit;
  font-size: 1rem;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
}

#choice-list button:hover,
#choice-list button:focus {
  background: var(--fg);
  color: #000;
  outline: none;
}

#choice-list button .num {
  color: var(--accent);
  margin-right: 0.5rem;
}

#choice-list button:hover .num,
#choice-list button:focus .num {
  color: #000;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.92);
  display: flex;
  align-items: center;
  justify-content: center;
}

.overlay.hidden { display: none; }

.overlay-box {
  border: 1px solid var(--fg-dim);
  padding: 2rem;
  max-width: 560px;
  text-align: center;
}

.overlay-box h1 {
  color: var(--fg);
  text-shadow: 0 0 6px rgba(255,255,255,0.4);
}

.ascii-title {
  color: var(--fg);
  text-align: center;
  white-space: pre;
  line-height: 1.15;
  letter-spacing: 0;
  font-size: 0.82rem;
  margin: 0 0 1rem 0;
  text-shadow: 0 0 6px rgba(255,255,255,0.4);
}

#boot-message {
  color: var(--fg-dim);
  margin-bottom: 1rem;
}

.overlay-box button {
  display: block;
  width: 100%;
  margin-top: 0.75rem;
  background: none;
  border: 1px solid var(--fg-dim);
  color: var(--fg);
  font-family: inherit;
  font-size: 1rem;
  padding: 0.6rem;
  cursor: pointer;
}

.overlay-box button:hover { background: var(--fg); color: #000; }

.name-input {
  display: block;
  width: 100%;
  margin-top: 0.75rem;
  background: none;
  border: 1px solid var(--fg-dim);
  color: var(--fg);
  font-family: inherit;
  font-size: 1rem;
  padding: 0.6rem;
  text-align: center;
}

.name-input:focus {
  outline: none;
  border-color: var(--fg);
}

.name-input.invalid {
  border-color: var(--danger);
}

.cursor {
  display: inline-block;
  width: 0.6em;
  background: var(--fg);
  animation: blink 1s step-start infinite;
}

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

#achievement-toast-container {
  position: fixed;
  top: 1rem;
  left: calc(50% + 400px + 1rem);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 10;
  pointer-events: none;
}

@media (max-width: 1500px) {
  #achievement-toast-container {
    left: auto;
    right: 1rem;
  }
}

.achievement-toast {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  border: 1px solid var(--accent);
  background: rgba(0, 0, 0, 0.92);
  color: var(--fg);
  padding: 0.6rem 0.9rem;
  max-width: 360px;
  box-shadow: 0 0 8px var(--accent);
  animation: achievement-in 0.25s ease-out;
}

.achievement-toast.fade-out {
  animation: achievement-out 0.4s ease-in forwards;
}

.achievement-icon {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  margin-top: 0.1rem;
}

.achievement-icon svg {
  width: 100%;
  height: 100%;
  fill: var(--accent);
}

.achievement-body {
  min-width: 0;
}

.achievement-title {
  margin: 0 0 0.2rem 0;
  color: var(--accent);
  font-size: 0.9rem;
  text-shadow: 0 0 4px var(--accent);
}

.achievement-desc {
  margin: 0;
  color: var(--fg-dim);
  font-size: 0.85rem;
}

@keyframes achievement-in {
  from { transform: translateX(20px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes achievement-out {
  from { opacity: 1; }
  to { opacity: 0; }
}

#achievements-overlay,
#inventory-overlay {
  z-index: 20;
}

.overlay-panel {
  border: 1px solid var(--fg-dim);
  background: var(--bg);
  padding: 1.5rem;
  width: 100%;
  max-width: 700px;
  max-height: 85vh;
  overflow-y: auto;
  text-align: left;
}

.overlay-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.overlay-panel-header h1 {
  margin: 0;
  font-size: 1.2rem;
  color: var(--fg);
  text-shadow: 0 0 6px rgba(255,255,255,0.4);
}

.overlay-panel-header button {
  background: none;
  border: 1px solid var(--fg-dim);
  color: var(--fg-dim);
  font-family: inherit;
  cursor: pointer;
  padding: 0.3rem 0.75rem;
}

.overlay-panel-header button:hover { color: var(--danger); border-color: var(--danger); }

.achievements-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.overlay-empty {
  color: var(--fg-dim);
  margin: 0;
}

.achievements-divider {
  border-top: 1px dashed var(--fg-dim);
  margin: 1.25rem 0;
}

.achievement-entry {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  border: 1px solid var(--fg-dim);
  padding: 0.6rem 0.9rem;
}

.achievement-entry .achievement-icon svg { fill: var(--fg-dim); }

.achievement-entry.unlocked {
  border-color: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}

.achievement-entry.unlocked .achievement-icon svg { fill: var(--accent); }

.achievement-entry.unlocked .achievement-title {
  color: var(--accent);
  text-shadow: 0 0 4px var(--accent);
}

.achievement-entry.locked {
  opacity: 0.6;
}

.achievement-entry.locked .achievement-icon svg { fill: var(--fg-dim); }

.achievement-entry.locked .achievement-title { color: var(--fg-dim); }

.achievement-entry .achievement-title {
  margin: 0 0 0.2rem 0;
  font-size: 0.95rem;
}

.achievement-entry .achievement-desc {
  margin: 0;
  color: var(--fg-dim);
  font-size: 0.85rem;
}

.inventory-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.inventory-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  border: 1px solid var(--fg-dim);
  padding: 0.5rem 0.9rem;
}

.inventory-row button {
  background: none;
  border: 1px solid var(--accent);
  color: var(--accent);
  font-family: inherit;
  cursor: pointer;
  padding: 0.25rem 0.6rem;
  flex-shrink: 0;
}

.inventory-row button:hover { background: var(--accent); color: #000; }
