:root {
  --bg: #000000;
  --surface: #691414;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --accent-2: #efeb00;
  --glow: rgba(236, 55, 0, 0.4);
}

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

body {
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  height: 100vh;
}

body.with-site-header {
  display: flex;
  flex-direction: column;
}

.site-header-bar {
  flex-shrink: 0;
  background: rgba(0, 0, 0, 0.92);
  border-bottom: 1px solid rgba(148, 163, 184, 0.15);
  z-index: 20;
}

.site-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.55rem 1rem;
}

.site-logo {
  font-weight: 800;
  font-size: 0.95rem;
  letter-spacing: -0.02em;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-decoration: none;
}

.site-header-link {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.85rem;
  white-space: nowrap;
}

.site-header-link:hover {
  color: var(--text);
}

#game-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

body.with-site-header #game-container {
  flex: 1;
  min-height: 0;
  height: auto;
}

#game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1.2rem;
  background: rgba(0, 0, 0, 0.9);
  border-bottom: 1px solid rgba(148, 163, 184, 0.15);
  flex-shrink: 0;
  gap: 1rem;
}

#game-header .header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.back-link {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.85rem;
  white-space: nowrap;
}

.back-link:hover {
  color: var(--accent);
}

#game-header h1 {
  font-size: 1.1rem;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  font-weight: 700;
}

#game-header .stats {
  display: flex;
  gap: 1.5rem;
  font-size: 0.85rem;
  color: var(--muted);
}

#game-header .stats span {
  color: var(--accent-2);
  font-weight: 600;
}

#canvas-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #050505;
  position: relative;
}

canvas {
  image-rendering: pixelated;
  border: 2px solid rgba(56, 189, 248, 0.25);
  box-shadow: 0 0 40px var(--glow);
}

#hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1.2rem;
  background: rgba(0, 0, 0, 0.9);
  border-top: 1px solid rgba(148, 163, 184, 0.15);
  flex-shrink: 0;
  font-size: 0.8rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

#inventory {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

#inventory .label {
  color: var(--muted);
  margin-right: 0.25rem;
}

.inv-slot {
  width: 32px;
  height: 32px;
  background: rgba(105, 20, 20, 0.6);
  border: 2px solid rgba(148, 163, 184, 0.2);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

.inv-slot.filled {
  border-color: var(--accent);
  background: rgba(56, 189, 248, 0.1);
}

#controls-hint {
  color: var(--muted);
}

#controls-hint kbd {
  background: var(--surface);
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 4px;
  padding: 0.1rem 0.4rem;
  font-family: inherit;
  font-size: 0.75rem;
  color: var(--text);
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.overlay.active {
  display: flex;
}

.panel {
  background: var(--surface);
  border: 1px solid rgba(148, 163, 184, 0.15);
  border-radius: 14px;
  padding: 1.5rem 2rem;
  max-width: 480px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.panel h2 {
  color: var(--accent);
  margin-bottom: 0.75rem;
  font-size: 1.2rem;
}

.panel p {
  color: var(--text);
  line-height: 1.6;
  margin-bottom: 1rem;
  font-size: 0.95rem;
}

.panel .npc-name {
  color: var(--accent-2);
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.panel input[type="text"] {
  width: 100%;
  padding: 0.6rem 0.8rem;
  background: rgba(0, 0, 0, 0.4);
  border: 2px solid rgba(148, 163, 184, 0.2);
  border-radius: 8px;
  color: var(--text);
  font-size: 1rem;
  margin-bottom: 0.75rem;
}

.panel input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
}

.panel .choices {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.panel .btn-row {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.btn {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: none;
  border-radius: 10px;
  color: #0b1020;
  padding: 0.55rem 1.2rem;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  transition: transform 0.15s;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-secondary {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(148, 163, 184, 0.35);
  color: var(--text);
}

#scoreboard-list,
#scoreboard-standalone-list {
  list-style: none;
  margin-bottom: 1rem;
  max-height: 240px;
  overflow-y: auto;
}

#scoreboard-list li,
#scoreboard-standalone-list li {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  margin-bottom: 0.25rem;
  font-size: 0.9rem;
}

#scoreboard-list li:nth-child(odd),
#scoreboard-standalone-list li:nth-child(odd) {
  background: rgba(0, 0, 0, 0.3);
}

#scoreboard-list li .rank,
#scoreboard-standalone-list li .rank {
  color: var(--accent-2);
  font-weight: 700;
  min-width: 2rem;
}

#scoreboard-list li .name,
#scoreboard-standalone-list li .name {
  flex: 1;
  color: var(--text);
}

#scoreboard-list li .time,
#scoreboard-standalone-list li .time {
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

#scoreboard-list .empty,
#scoreboard-standalone-list .empty {
  color: var(--muted);
  text-align: center;
  padding: 1rem;
}

#start-screen .panel {
  text-align: center;
  max-width: 520px;
}

#start-screen .panel p {
  text-align: left;
}

#start-screen .logo {
  font-size: 2rem;
  margin-bottom: 0.25rem;
}

#start-screen .subtitle {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 1.25rem;
}

#start-screen input[type="text"] {
  text-align: center;
}

@media (max-width: 700px) {
  #game-header .stats {
    display: none;
  }
}