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

:root {
  --bg: #1a1428;
  --panel: #2d2540;
  --text: #e8dcc8;
  --accent: #c9a55c;
  --muted: #8a7f9a;
}

html, body {
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "MS Gothic", "Yu Gothic UI", monospace;
  overflow: hidden;
}

#app {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 16px;
}

#load-error {
  max-width: 480px;
  margin: 24px auto;
  padding: 16px;
  border: 2px solid #8a4a4a;
  background: #2d2540;
  font-size: 0.8rem;
  text-align: center;
}

#load-error a {
  color: var(--accent);
}

canvas {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  border: 4px solid #3a3050;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.6);
}

#title-screen {
  position: relative;
  text-align: center;
}

.title-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding: 24px;
  background: linear-gradient(transparent 40%, rgba(26, 20, 40, 0.85));
  pointer-events: none;
}

.title-overlay * {
  pointer-events: auto;
}

.title-overlay h1 {
  font-size: 1.1rem;
  letter-spacing: 0.15em;
  color: var(--accent);
  margin-bottom: 6px;
  text-shadow: 2px 2px 0 #000;
}

.subtitle {
  font-size: 0.7rem;
  color: var(--muted);
  margin-bottom: 16px;
}

.hint {
  font-size: 0.6rem;
  color: var(--muted);
  margin-top: 12px;
}

button {
  background: var(--panel);
  color: var(--text);
  border: 2px solid var(--accent);
  padding: 8px 24px;
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

button:hover {
  background: #3d3558;
}

.guide-link {
  display: inline-block;
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.7rem;
  text-decoration: none;
  border-bottom: 1px solid var(--panel);
}

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

#game-screen {
  position: relative;
}

#hud {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
}

#dialogue-box {
  margin: 8px;
  padding: 10px 12px;
  background: rgba(20, 16, 32, 0.92);
  border: 2px solid var(--accent);
  min-height: 52px;
}

#speaker {
  display: block;
  font-size: 0.65rem;
  color: var(--accent);
  margin-bottom: 4px;
}

#dialogue-text {
  font-size: 0.75rem;
  line-height: 1.5;
}

.dialogue-hint {
  font-size: 0.6rem;
  color: var(--muted);
  margin-top: 6px;
}

#tool-bar {
  display: flex;
  justify-content: space-between;
  padding: 4px 10px;
  font-size: 0.6rem;
  background: rgba(20, 16, 32, 0.75);
  color: var(--muted);
}

#journal-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(420px, 90vw);
  max-height: 70vh;
  overflow-y: auto;
  background: var(--panel);
  border: 3px solid var(--accent);
  padding: 16px;
  z-index: 100;
}

#journal-panel h2 {
  font-size: 0.9rem;
  color: var(--accent);
  margin-bottom: 12px;
}

#journal-list {
  list-style: none;
  font-size: 0.75rem;
  line-height: 1.6;
}

#journal-list li {
  padding: 8px 0;
  border-bottom: 1px solid #4a4060;
}

#journal-list li.law {
  color: var(--accent);
}

#journal-close {
  margin-top: 12px;
  width: 100%;
}

@media (min-width: 600px) {
  canvas {
    width: 960px;
    height: 540px;
  }
}
