:root {
  color: #111827;
  background: #f3f4f6;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
}

html {
  scroll-behavior: smooth;
}

button,
canvas {
  font: inherit;
}

.game-shell {
  width: 100%;
  min-height: 100vh;
  padding: 24px 16px;
  user-select: none;
}

.game-width {
  width: min(980px, 100%);
  margin: 0 auto;
}

h1 {
  margin: 0;
  font-size: 2rem;
  line-height: 1.1;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.header-button {
  flex: 0 0 auto;
  border: 1px solid #d1d5db;
}

.intro,
.help,
.muted,
.control-note {
  color: #4b5563;
}

.intro {
  margin: 0 0 16px;
  font-size: 0.95rem;
}

.game-panel {
  padding: 16px;
  background: #ffffff;
  border-radius: 8px;
  box-shadow: 0 12px 30px rgba(17, 24, 39, 0.12);
}

.canvas {
  display: block;
  width: 100%;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
}

.game-canvas {
  background: #f8fafc;
}

.draw-canvas {
  background: #ffffff;
  touch-action: none;
}

.status-row,
.lives-row,
.controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.status-row {
  margin: 12px 0 8px;
}

.lives-row {
  margin-bottom: 8px;
}

.run-status,
.stats,
.controls,
.help {
  font-size: 0.9rem;
}

.is-running::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 8px;
  border-radius: 999px;
  background: #10b981;
}

.is-game-over {
  color: #e11d48;
  font-weight: 700;
}

.stats {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.stats span,
.loot-message,
.badge {
  padding: 4px 8px;
  border-radius: 8px;
  background: #f3f4f6;
}

.badge {
  color: #1d4ed8;
  background: #dbeafe;
}

.lives-pips {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
  flex-wrap: wrap;
  max-width: 220px;
}

.heart {
  width: 16px;
  height: 16px;
  fill: #e5e7eb;
}

.heart.is-filled {
  fill: #f43f5e;
}

.heart.is-shield {
  fill: #2563eb;
}

.loot-message {
  display: inline-block;
  margin-bottom: 8px;
  color: #4b5563;
  border: 1px solid #e5e7eb;
  font-size: 0.8rem;
}

.controls {
  margin-top: 12px;
}

.button {
  border: 0;
  border-radius: 8px;
  padding: 8px 12px;
  font-weight: 700;
  cursor: pointer;
}

.button:active {
  transform: translateY(1px);
}

.primary {
  color: #ffffff;
  background: #059669;
}

.blue {
  color: #ffffff;
  background: #2563eb;
}

.secondary {
  color: #111827;
  background: #e5e7eb;
}

.light {
  color: #1f2937;
  background: #f3f4f6;
}

.dark {
  color: #ffffff;
  background: #111827;
}

.mini {
  padding: 4px 8px;
  font-size: 0.75rem;
  background: #e5e7eb;
}

.control-note {
  margin-left: auto;
}

.debug-panel {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #f9fafb;
}

.debug-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.debug-actions {
  display: flex;
  gap: 8px;
}

.debug-log-list {
  max-height: 224px;
  overflow: auto;
  white-space: pre-wrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.75rem;
}

.shape-legend {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 16px;
}

.shape-card {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 8px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #ffffff;
}

.shape-card svg {
  width: 32px;
  height: 32px;
}

.help {
  margin-top: 16px;
  line-height: 1.45;
}

.help p {
  margin: 4px 0;
}

.hidden {
  display: none !important;
}

@media (min-width: 760px) {
  .shape-legend {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}
