* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #1a1f14;
  --panel: #2a3220;
  --border: #4a5a32;
  --text: #e8e4d4;
  --muted: #9a9a7a;
  --accent: #7a9a3a;
  --warn: #c9a227;
}

html,
body {
  height: 100%;
}

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: radial-gradient(ellipse at top, #2a3a20, var(--bg) 65%);
  color: var(--text);
  overflow-x: hidden;
}

body.in-game {
  overflow: hidden;
}

body.in-game #app {
  height: 100vh;
  max-width: none;
  padding: 0;
}

body.in-game #game-section {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

#app {
  max-width: 900px;
  margin: 0 auto;
  padding: 20px 16px 40px;
}

.header {
  text-align: center;
  margin-bottom: 20px;
}

.header h1 {
  color: var(--accent);
  font-size: 1.8rem;
}

.header p {
  color: var(--muted);
  margin-top: 6px;
  font-size: 0.9rem;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
}

.panel h2 {
  text-align: center;
  margin-bottom: 8px;
}

.intro {
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 20px;
  line-height: 1.5;
}

.btn-start {
  display: block;
  width: 100%;
  max-width: 280px;
  margin: 0 auto 24px;
  padding: 14px 20px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #0a1a12;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
}

.btn-start:hover {
  filter: brightness(1.08);
}

.levels h3,
.help h3 {
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 10px;
}

#level-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 8px;
  margin-bottom: 20px;
}

.level-chip {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.4;
}

.level-chip strong {
  display: block;
  color: var(--text);
  font-size: 0.85rem;
}

.level-chip .num {
  display: inline-block;
  background: var(--accent);
  color: #0a1a12;
  font-weight: 700;
  font-size: 0.7rem;
  padding: 1px 6px;
  border-radius: 4px;
  margin-right: 4px;
}

.level-chip .phase-line {
  display: block;
  margin-top: 4px;
  font-size: 0.72rem;
  color: #8a9a78;
}

.level-chip.selected {
  border-color: var(--accent);
  background: rgba(201, 162, 39, 0.12);
  box-shadow: 0 0 0 1px rgba(201, 162, 39, 0.35);
}

.level-chip.selected .num {
  background: #e8c040;
}

.menu-hint {
  font-size: 0.82rem;
  color: var(--muted);
  margin: 0 0 10px;
}

#menu:focus {
  outline: none;
}

.help p {
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 4px;
}

kbd {
  padding: 1px 5px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.3);
  font-family: Consolas, monospace;
  font-size: 0.78rem;
}

.hidden {
  display: none !important;
}

.hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
  padding: 6px 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.78rem;
  font-family: Consolas, monospace;
  gap: 8px;
}

#hud-center {
  color: var(--warn);
  font-weight: 600;
  text-align: center;
  flex: 1;
}

#hud-right {
  text-align: right;
}

.hint {
  flex-shrink: 0;
  font-size: 0.8rem;
  color: var(--warn);
  text-align: center;
}

.canvas-wrap {
  flex-shrink: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

#game-canvas {
  display: block;
  border: 3px solid #5a6a3a;
  border-radius: 4px;
  background: #3d5c34;
  outline: none;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}

#game-canvas:focus {
  border-color: var(--accent);
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.overlay-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px 36px;
  text-align: center;
  min-width: 260px;
}

.overlay-box h2 {
  color: var(--accent);
  margin-bottom: 8px;
}

.overlay-box p {
  color: var(--muted);
  margin-bottom: 16px;
  line-height: 1.5;
}

.btn-ghost {
  padding: 10px 20px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.btn-ghost:hover {
  border-color: var(--accent);
  color: var(--text);
}
