:root {
  --paper: #f3e6c8;
  --indigo: #1e2a44;
  --ink: #2a241c;
  --copper: #b87333;
  --vermilion: #c23b22;
  --teal: #2f6f63;
  --soot: #3a3344;
  --muted: #5c5346;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at 18% 12%, rgba(194, 59, 34, 0.08), transparent 28%),
    radial-gradient(circle at 82% 88%, rgba(47, 111, 99, 0.1), transparent 32%),
    var(--paper);
  color: var(--ink);
  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='120' height='120'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='120' height='120' filter='url(%23n)' opacity='0.07'/></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(--indigo);
  font-weight: 800;
  text-decoration: none;
}

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

main {
  max-width: 980px;
  margin: 0 auto;
  padding: 8px 16px 48px;
}

.intro { padding: 8px 4px 12px; }
.eyebrow {
  margin: 0;
  font-family: "Trebuchet MS", sans-serif;
  letter-spacing: 0.16em;
  font-size: 0.72rem;
  color: var(--vermilion);
}
.intro h1 {
  margin: 4px 0 8px;
  font-size: 2rem;
  font-weight: 900;
}
.intro h1 span { color: var(--copper); }
.intro p { margin: 0; line-height: 1.6; }

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

.game-panel, .help {
  background: rgba(243, 230, 200, 0.72);
  border: 2px solid rgba(30, 42, 68, 0.18);
  border-radius: 18px;
  box-shadow: 4px 6px 0 rgba(30, 42, 68, 0.08);
}

.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: rgba(30, 42, 68, 0.08);
  border-radius: 10px;
}

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

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

.stage {
  position: relative;
  overflow: hidden;
  border-radius: 14px;
  background: #d9c7a3;
}

#game {
  display: block;
  width: 100%;
  height: min(72vh, 720px);
  touch-action: none;
  outline: 3px solid transparent;
}

#game:focus-visible { outline-color: var(--vermilion); }

.banner, .hint-line {
  position: absolute;
  left: 10%;
  right: 18%;
  margin: 0;
  text-align: center;
  pointer-events: none;
  font-weight: 900;
}

.banner {
  top: 9%;
  color: #f7efe0;
  text-shadow: 0 1px 0 #1e2a44;
}

.hint-line {
  bottom: 7%;
  left: 18%;
  right: 18%;
  color: #f7efe0;
  background: rgba(30, 42, 68, 0.55);
  padding: 6px 10px;
  border-radius: 999px;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 8px;
  padding: 24px;
  background: linear-gradient(180deg, transparent 28%, rgba(30, 42, 68, 0.78) 100%);
  color: var(--paper);
  text-align: center;
  z-index: 3;
}

.overlay[hidden] { display: none !important; }
.overlay-kicker {
  margin: 0;
  letter-spacing: 0.16em;
  color: #e6b184;
  font-family: "Trebuchet MS", sans-serif;
}
.overlay-lead { margin: 0; font-size: 1.28rem; font-weight: 900; }
.overlay-note { margin: 0 0 8px; color: #d9c7a3; }

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

.start {
  background: var(--vermilion);
  color: var(--paper);
  padding: 10px 22px;
}

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

.sound-btn, .reset {
  background: rgba(30, 42, 68, 0.1);
  padding: 6px 12px;
}

.level-chip, .live, .records, .save-note, .key-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.live { min-height: 1.4em; }

.share-x {
  background: var(--teal);
  color: var(--paper);
  padding: 8px 16px;
}

.help { display: grid; gap: 10px; padding: 14px; }
.help h2 { margin: 4px 0 0; font-size: 1.12rem; }
.help ol { margin: 0; padding: 0; display: grid; gap: 8px; }
.help li {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 8px;
  list-style: none;
}
.help li span {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--copper);
  color: var(--paper);
  font-weight: 900;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.gallery button {
  padding: 8px 6px;
  border: 1px solid rgba(30, 42, 68, 0.2);
  border-radius: 10px;
  background: rgba(243, 230, 200, 0.9);
  color: var(--ink);
}

.gallery button[disabled] { opacity: 0.55; }

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] .end-actions,
html[data-capture] .hud,
html[data-capture] .tool-row,
html[data-capture] .overlay {
  display: none !important;
}

html[data-capture],
html[data-capture] body {
  height: 100%;
  overflow: hidden;
  background: #1e2a44;
}

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] .stage { height: 100dvh; border-radius: 0; }
html[data-capture] #game { width: 100%; height: 100dvh; }
html[data-capture] .banner { top: 10%; left: 10%; right: 18%; }
html[data-capture] .hint-line { bottom: 12%; right: 18%; }

@media (min-width: 880px) {
  .layout {
    grid-template-columns: minmax(0, 1fr) 280px;
    align-items: start;
  }
  #game { height: min(76vh, 740px); }
}

@media (max-width: 430px) {
  .intro h1 { font-size: 1.34rem; }
  .hud { gap: 4px; }
  .hud strong { font-size: 0.92rem; }
  #game { height: min(64vh, 560px); }
  .overlay-note { display: none; }
}

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