:root {
  --sky: #f5efe3;
  --ink: #1e2a3a;
  --accent: #c45c3e;
  --leaf: #d4782a;
  --mint: #7ee8d8;
  --paper: #faf6ee;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Hiragino Maru Gothic ProN", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", sans-serif;
  background:
    radial-gradient(ellipse 120% 80% at 50% -10%, #8ab4d8 0%, transparent 55%),
    linear-gradient(180deg, #4a6a8a 0%, var(--paper) 48%, #efe6d6 100%);
  color: var(--ink);
  min-height: 100dvh;
}

.masthead {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.65rem 0.85rem;
  font-size: 0.88rem;
}

.masthead a {
  color: var(--ink);
  text-decoration: none;
}

#sound {
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: #fff8;
  padding: 0.25rem 0.65rem;
  cursor: pointer;
}

main {
  max-width: 560px;
  margin: 0 auto;
  padding: 0 0.5rem 1.25rem;
}

.intro {
  text-align: center;
  margin-bottom: 0.35rem;
}

.intro .eyebrow {
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  margin: 0;
  opacity: 0.75;
}

.intro h1 {
  margin: 0.15rem 0;
  font-size: 1.45rem;
}

.intro h1 span {
  color: var(--accent);
}

.intro p {
  margin: 0.2rem 0 0;
  font-size: 0.9rem;
}

.play-shell {
  position: relative;
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 18px;
  padding: 0.5rem 0.55rem 0.75rem;
  box-shadow: 0 8px 0 #1e2a3a22, inset 0 0 0 1px #fff9;
}

.hud {
  display: flex;
  justify-content: center;
  gap: 1.1rem;
  font-size: 0.95rem;
  margin-bottom: 0.25rem;
}

.hud small {
  display: block;
  font-size: 0.68rem;
  opacity: 0.7;
}

.live {
  text-align: center;
  font-size: 0.88rem;
  margin: 0 0 0.35rem;
  min-height: 1.3em;
}

.stage-wrap {
  border-radius: 12px;
  overflow: hidden;
  touch-action: none;
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  background: var(--sky);
  cursor: crosshair;
}

.kbd-hint {
  text-align: center;
  font-size: 0.75rem;
  opacity: 0.75;
  margin: 0.35rem 0 0;
}

.panel {
  position: absolute;
  inset: 0.5rem 0.55rem 0.75rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  background: #fff9f0ee;
  border-radius: 14px;
  padding: 1rem;
  z-index: 3;
}

.panel[hidden] {
  display: none !important;
}

.panel h2 {
  margin: 0 0 0.5rem;
  font-size: 1.15rem;
}

.panel p {
  margin: 0 0 0.85rem;
  font-size: 0.9rem;
  line-height: 1.45;
}

.btn-primary,
.btn-ghost {
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 0.55rem 1.2rem;
  font-size: 1rem;
  cursor: pointer;
}

.btn-primary {
  background: var(--mint);
}

.btn-ghost {
  background: #fff;
  margin-top: 0.5rem;
}

.summary .rank {
  font-size: 2rem;
  font-weight: 700;
  margin: 0.2rem 0 0.6rem;
}

.stats {
  list-style: none;
  padding: 0;
  margin: 0 0 0.6rem;
  font-size: 0.9rem;
}

.stats li {
  margin: 0.2rem 0;
}

.hint {
  font-size: 0.85rem;
  opacity: 0.85;
}

.records {
  margin-top: 0.65rem;
  text-align: center;
  font-size: 0.82rem;
}

.linkish {
  background: none;
  border: none;
  text-decoration: underline;
  cursor: pointer;
  font-size: 0.82rem;
}

html[data-capture="1"] {
  --capture-shell-w: min(93vw, 1000px);
}

html[data-capture="1"] .capture-hide {
  display: none !important;
}

html[data-capture="1"] body {
  background: #2a3d5c;
  min-height: 100dvh;
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  margin: 0;
}

html[data-capture="1"] main {
  max-width: none !important;
  width: 100%;
  padding: 0;
  margin: 0;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
}

html[data-capture="1"] .play-shell {
  width: var(--capture-shell-w) !important;
  max-width: 1000px !important;
  border: none;
  border-radius: 0;
  box-shadow: none;
  padding: 0.5rem 0.55rem 0.65rem;
  margin: 0 auto;
}

html[data-capture="1"] .capture-stage {
  width: 100%;
}

html[data-capture="1"] canvas {
  width: 100% !important;
  height: auto;
  display: block;
}

html[data-capture="1"] .hud {
  font-size: 0.95rem;
  gap: 1.4rem;
}

html[data-capture="1"] .hud strong {
  font-size: 1.35rem;
}

html[data-capture="1"] .live {
  font-size: 0.95rem;
}

html[data-capture="1"] .summary {
  background: #fff9f0f2;
}

@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
  }
}
