:root {
  color-scheme: dark;
  --ink: #f5eddc;
  --muted: #c8bcaa;
  --panel: #211c24;
  --panel-2: #30252b;
  --copper: #b86c38;
  --moss: #7fa85d;
  --gold: #f2c84b;
  --danger: #df5a4d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow: hidden;
  color: var(--ink);
  font-family:
    Inter, "Segoe UI", "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  background:
    linear-gradient(90deg, rgba(63, 43, 35, 0.45), transparent 26%, transparent 74%, rgba(63, 43, 35, 0.45)),
    #17191b;
}

button,
canvas {
  -webkit-tap-highlight-color: transparent;
}

.game-app {
  width: min(100vw, 980px);
  height: 100vh;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(300px, 480px) minmax(180px, 260px);
  gap: 24px;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.stage {
  position: relative;
  width: min(100%, 480px);
  aspect-ratio: 12 / 19;
  max-height: calc(100vh - 40px);
  margin: 0 auto;
  border: 2px solid rgba(245, 237, 220, 0.2);
  border-radius: 8px;
  overflow: hidden;
  background: #2d3031;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.42);
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  image-rendering: auto;
}

.hud {
  position: absolute;
  inset: 12px 12px auto 12px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.55);
}

.hud > div {
  min-width: 96px;
}

.hud-label {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.hud strong {
  color: var(--gold);
  font-size: 30px;
  line-height: 1;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 28px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
  background: rgba(20, 17, 18, 0.58);
}

.overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.overlay-panel {
  width: min(100%, 330px);
  padding: 24px;
  border-radius: 8px;
  background: rgba(31, 26, 28, 0.9);
  border: 1px solid rgba(245, 237, 220, 0.18);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.34);
}

.overlay-panel h1 {
  margin: 0 0 10px;
  color: var(--ink);
  font-size: 34px;
  line-height: 1.05;
  letter-spacing: 0;
}

.overlay-panel p {
  margin: 0 0 18px;
  color: var(--muted);
  line-height: 1.6;
}

.primary-action {
  width: 100%;
  min-height: 46px;
  border: 0;
  border-radius: 8px;
  color: #1a1410;
  background: linear-gradient(180deg, #ffd86e, #e8983f);
  font-size: 18px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: inset 0 -3px 0 rgba(89, 46, 16, 0.32);
}

.primary-action:active {
  transform: translateY(1px);
}

.side-panel {
  align-self: center;
  padding: 18px;
  border-radius: 8px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid rgba(245, 237, 220, 0.14);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.28);
}

.side-panel h2 {
  margin: 0 0 14px;
  color: var(--gold);
  font-size: 18px;
  letter-spacing: 0;
}

.stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 11px 0;
  border-top: 1px solid rgba(245, 237, 220, 0.1);
  color: var(--muted);
}

.stat-row strong {
  color: var(--ink);
}

.control-hints {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

kbd {
  min-width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  border-radius: 6px;
  color: #1d1814;
  background: #e8dac3;
  border-bottom: 3px solid #92775d;
  font: inherit;
  font-weight: 800;
}

@media (max-width: 760px) {
  body {
    overflow: auto;
  }

  .game-app {
    min-height: 100vh;
    height: auto;
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 10px;
  }

  .stage {
    width: min(100%, calc((100vh - 132px) * 12 / 19));
    max-height: calc(100vh - 132px);
  }

  .side-panel {
    width: min(100%, 480px);
    margin: 0 auto;
    padding: 12px;
  }

  .side-panel h2 {
    display: none;
  }

  .stat-row {
    display: none;
  }
}
