:root {
  --kinari: #f6eedb;
  --shiraki: #efe0c0;
  --ai: #2c4a7c;
  --shu: #d2462f;
  --wasabi: #6f9444;
  --momo: #f4c6cf;
  --ink: #3a2f28;
  --muted: #6a5a4c;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 8%, rgba(244, 198, 207, 0.55), transparent 30%),
    radial-gradient(circle at 90% 92%, rgba(139, 178, 90, 0.18), transparent 34%),
    var(--kinari);
  font-family: "Hiragino Mincho ProN", "Yu Mincho", "MS PMincho", serif;
}

body {
  background-image:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='140'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='2' stitchTiles='stitch'/></filter><rect width='140' height='140' filter='url(%23n)' opacity='0.06'/></svg>");
}

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 18px 4px;
  font-family: "Hiragino Sans", "Yu Gothic", sans-serif;
}

.site-header a {
  color: var(--ai);
  font-weight: 800;
  text-decoration: none;
}

.site-header a:focus-visible,
button:focus-visible,
#game:focus-visible {
  outline: 3px solid var(--shu);
  outline-offset: 3px;
}

.site-header p {
  margin: 0;
  font-size: 0.74rem;
  letter-spacing: 0.14em;
  color: var(--muted);
}

main {
  max-width: 1000px;
  margin: 0 auto;
  padding: 6px 16px 48px;
}

.intro { padding: 6px 4px 12px; }

.eyebrow {
  margin: 0;
  font-family: "Trebuchet MS", sans-serif;
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  color: var(--shu);
}

.intro h1 {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 6px 0 8px;
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: 0.06em;
}

.intro h1 em {
  font-style: normal;
  color: var(--shu);
  border-bottom: 3px double var(--shu);
}

.wrap-label {
  display: inline-block;
  padding: 2px 6px;
  font-size: 0.9rem;
  color: var(--kinari);
  background: var(--shu);
  writing-mode: vertical-rl;
  border-radius: 2px;
}

.intro p { margin: 0; line-height: 1.7; }

.layout { display: grid; gap: 16px; }

.game-panel, .help {
  background: rgba(251, 245, 230, 0.86);
  border: 2px solid var(--shu);
  border-radius: 4px;
  box-shadow: 5px 6px 0 rgba(58, 47, 40, 0.12);
  position: relative;
}

.game-panel::before, .help::before {
  content: "";
  position: absolute;
  inset: 4px;
  border: 1px solid rgba(210, 70, 47, 0.45);
  pointer-events: none;
}

.game-panel { padding: 12px; display: grid; gap: 8px; }

.hud {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.hud p {
  margin: 0;
  padding: 6px 8px;
  background: var(--shiraki);
  border-left: 3px solid var(--ai);
}

.hud span {
  display: block;
  font-size: 0.68rem;
  color: var(--muted);
}

.hud strong { font-size: 1.05rem; }

.stage {
  position: relative;
  overflow: hidden;
  background: var(--kinari);
  border: 1px solid rgba(58, 47, 40, 0.25);
}

#game {
  display: block;
  width: 100%;
  height: min(76vh, 760px);
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

#game.is-playing { touch-action: none; }

.hint-line {
  position: absolute;
  left: 16%;
  right: 16%;
  bottom: 3%;
  margin: 0;
  padding: 5px 10px;
  text-align: center;
  font-weight: 900;
  font-size: 0.9rem;
  color: var(--kinari);
  background: rgba(44, 74, 124, 0.82);
  border-radius: 999px;
  pointer-events: none;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 8px;
  padding: 24px;
  text-align: center;
  color: var(--ink);
  background: linear-gradient(180deg, rgba(246, 238, 219, 0.25) 0%, rgba(246, 238, 219, 0.93) 38%, rgba(246, 238, 219, 0.96) 100%);
  z-index: 3;
}

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

.overlay-kicker {
  margin: 0;
  padding: 2px 10px;
  color: var(--kinari);
  background: var(--shu);
  letter-spacing: 0.2em;
  font-weight: 900;
}

.overlay-lead { margin: 0; font-size: 1.4rem; font-weight: 900; }
.overlay-note { margin: 0 0 6px; max-width: 26em; line-height: 1.6; color: var(--muted); }

.start, .share-x, .reset, .sound-btn {
  border: 0;
  cursor: pointer;
  font-family: inherit;
  font-weight: 900;
}

.start {
  padding: 12px 26px;
  font-size: 1.05rem;
  color: var(--kinari);
  background: var(--ai);
  border-radius: 4px;
  box-shadow: 3px 3px 0 var(--shu);
}

.start:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--shu); }

.share-x {
  padding: 9px 18px;
  color: var(--kinari);
  background: var(--wasabi);
  border-radius: 4px;
}

.share-x[hidden] { display: none; }

.tool-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px;
  align-items: center;
}

.sound-btn, .reset {
  padding: 7px 12px;
  color: var(--ai);
  background: var(--shiraki);
  border: 1px solid rgba(44, 74, 124, 0.35);
  border-radius: 4px;
}

.step-chip, .live, .save-note, .key-hint {
  margin: 0;
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.6;
}

.step-chip { font-weight: 800; color: var(--ai); }
.live { min-height: 1.5em; }

.help { display: grid; gap: 10px; padding: 16px; }
.help h2 { margin: 4px 0 0; font-size: 1.15rem; }
.help ol { margin: 0; padding: 0; display: grid; gap: 8px; }

.help li {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 8px;
  list-style: none;
  line-height: 1.6;
}

.help li span {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  color: var(--kinari);
  background: var(--shu);
  border-radius: 50%;
  font-weight: 900;
}

kbd {
  display: inline-block;
  min-width: 1.6em;
  padding: 0 4px;
  margin: 0 1px;
  text-align: center;
  font-family: "Hiragino Sans", sans-serif;
  font-size: 0.8rem;
  background: var(--shiraki);
  border: 1px solid rgba(58, 47, 40, 0.3);
  border-radius: 3px;
}

.records {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  margin: 0;
  padding: 10px 12px;
  background: var(--shiraki);
  font-size: 0.9rem;
}

.records dt { color: var(--muted); }
.records dd { margin: 0; font-weight: 800; }

html[data-capture] [data-account],
html[data-capture] .site-header,
html[data-capture] .intro,
html[data-capture] .help,
html[data-capture] .live,
html[data-capture] .hud,
html[data-capture] .tool-row,
html[data-capture] .hint-line,
html[data-capture] .overlay {
  display: none !important;
}

html[data-capture],
html[data-capture] body {
  height: 100%;
  overflow: hidden;
  background: var(--kinari);
}

html[data-capture] main,
html[data-capture] .layout,
html[data-capture] .game-panel {
  width: 100%;
  max-width: none;
  padding: 0;
  gap: 0;
  background: transparent;
  border: 0;
  box-shadow: none;
}

html[data-capture] .game-panel::before { display: none; }
html[data-capture] .stage { height: 100dvh; border: 0; }
html[data-capture] #game { height: 100dvh; }

@media (min-width: 880px) {
  .layout {
    grid-template-columns: minmax(0, 1fr) 300px;
    align-items: start;
  }
}

@media (max-width: 430px) {
  main { padding: 4px 10px 40px; }
  .intro h1 { font-size: 1.45rem; }
  .intro p { font-size: 0.92rem; }
  .hud { gap: 4px; }
  .hud p { padding: 5px 6px; }
  .hud strong { font-size: 0.95rem; }
  #game { height: min(68vh, 600px); }
  .overlay-note { font-size: 0.86rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto; }
  .start:active { transform: none; }
}
