:root {
  --bg: #1b1726;
  --surface: #2a2438;
  --accent: #f2b35b;
  --text: #f1ece4;
  --text-muted: #a59cb8;
  --border: #3d3550;
  --danger: #ef6f6c;
  --good: #7cc78f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  touch-action: manipulation;
}

.page {
  max-width: 560px;
  margin: 0 auto;
  padding: 1rem 1rem 2rem;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar h1 {
  margin: 0;
  font-size: 1.5rem;
}

.round-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
  cursor: pointer;
}

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.8rem 0;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.25rem 0.7rem;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

.hp-bar {
  flex-basis: 100%;
  height: 8px;
  background: var(--surface);
  border-radius: 999px;
  overflow: hidden;
}

.hp-fill {
  height: 100%;
  background: var(--good);
  transition: width 0.2s, background 0.2s;
}

.hp-fill.low {
  background: var(--danger);
}

.board {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #0f0c16;
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  image-rendering: pixelated;
}

.board.hit {
  animation: shake 0.2s;
}

@keyframes shake {
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 12, 22, 0.8);
}

.overlay[hidden] {
  display: none;
}

.overlay-card {
  text-align: center;
  padding: 1.2rem;
}

.overlay-card h2 {
  margin: 0 0 0.5rem;
}

.overlay-card p {
  margin: 0 0 1rem;
  color: var(--text-muted);
  white-space: pre-line;
}

.btn-primary {
  background: var(--accent);
  color: #1b1726;
  border: none;
  border-radius: 8px;
  padding: 0.6rem 1.4rem;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
}

.log {
  list-style: none;
  margin: 0.8rem 0;
  padding: 0.6rem 0.8rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.85rem;
  min-height: 5.6rem;
}

.log li {
  padding: 0.1rem 0;
  color: var(--text-muted);
}

.log li:first-child {
  color: var(--text);
}

.dpad {
  display: grid;
  grid-template-columns: repeat(3, 64px);
  grid-template-rows: repeat(3, 56px);
  gap: 6px;
  justify-content: center;
}

.dpad button {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 10px;
  font-size: 1.2rem;
  cursor: pointer;
}

.dpad button:active {
  background: var(--border);
}

.dpad-up { grid-column: 2; grid-row: 1; }
.dpad-left { grid-column: 1; grid-row: 2; }
.dpad-wait { grid-column: 2; grid-row: 2; }
.dpad-right { grid-column: 3; grid-row: 2; }
.dpad-down { grid-column: 2; grid-row: 3; }

.modal-overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  padding: 1rem;
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.2rem 1.4rem;
  max-width: 420px;
  width: 100%;
}

.modal h2 {
  margin-top: 0;
}

.help-list {
  padding-left: 1.1rem;
  line-height: 1.7;
}

.modal-actions {
  text-align: right;
}
