:root {
  color-scheme: light;
  --cream: #f3e6d0;
  --plaster: #ead7b8;
  --terracotta: #c45c3e;
  --teal: #3d8b7a;
  --mustard: #d4a04a;
  --deep: #1e3a5f;
  --ink: #2a241c;
  --muted: #6b5e4e;
  --paper: #fbf3e4;
  --shadow: rgba(30, 58, 95, 0.18);
  --font: "Hiragino Maru Gothic ProN", "Hiragino Sans", "Yu Gothic", "Trebuchet MS", sans-serif;
}

* { box-sizing: border-box; }

html {
  overflow-x: clip;
  overflow-y: scroll;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: var(--font);
  background:
    radial-gradient(circle at 18% -8%, rgba(212, 160, 74, 0.28), transparent 22rem),
    radial-gradient(circle at 92% 12%, rgba(61, 139, 122, 0.18), transparent 20rem),
    linear-gradient(180deg, #dce7e2 0%, var(--cream) 38%, #e7d3b4 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.08;
  background-image: radial-gradient(#1e3a5f 0.8px, transparent 0.9px);
  background-size: 6px 6px;
}

a { color: inherit; }
button { font: inherit; color: inherit; }

a:focus-visible,
button:focus-visible,
canvas:focus-visible {
  outline: 3px solid var(--mustard);
  outline-offset: 3px;
  box-shadow: 0 0 0 6px rgba(196, 92, 62, 0.45);
}

.site-header,
main {
  width: min(94vw, 1080px);
  margin-inline: auto;
}

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 44px;
}

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

.site-header p {
  margin: 0;
  color: var(--muted);
  font: 700 0.72rem/1 "Trebuchet MS", sans-serif;
  letter-spacing: 0.08em;
}

main {
  display: grid;
  gap: 12px;
  padding: 0 0 72px;
}

.intro {
  background: rgba(251, 243, 228, 0.82);
  border-radius: 22px;
  padding: 10px 16px 12px;
  box-shadow: 0 10px 24px var(--shadow);
}

.eyebrow {
  margin: 0;
  color: var(--terracotta);
  font: 800 0.68rem/1 "Trebuchet MS", sans-serif;
  letter-spacing: 0.14em;
}

.intro h1 {
  margin: 4px 0 0;
  font-size: clamp(1.6rem, 4.4vw, 2.6rem);
  line-height: 0.95;
  color: var(--deep);
}

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

.intro p {
  margin: 6px 0 0;
  font-weight: 700;
  color: var(--muted);
}

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

.game-panel {
  display: grid;
  gap: 8px;
  background: rgba(251, 243, 228, 0.9);
  border-radius: 24px;
  padding: 10px;
  box-shadow: 0 14px 30px var(--shadow);
}

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

.hud p {
  margin: 0;
  padding: 6px 8px;
  border-radius: 14px;
  background: var(--paper);
  box-shadow: inset 0 -2px 0 rgba(30, 58, 95, 0.08);
}

.hud span {
  display: block;
  color: var(--muted);
  font: 700 0.62rem/1 "Trebuchet MS", sans-serif;
  letter-spacing: 0.08em;
}

.hud strong {
  font-size: 1.05rem;
  color: var(--deep);
}

.stage {
  position: relative;
  overflow: hidden;
  border-radius: 20px;
  background: #cbb89a;
  box-shadow: inset 0 0 0 3px rgba(42, 36, 28, 0.12);
}

#game {
  display: block;
  width: 100%;
  height: min(68vh, 640px);
  touch-action: none;
  cursor: grab;
}

#game:active { cursor: grabbing; }

.banner {
  position: absolute;
  left: 10%;
  right: 16%;
  top: 18%;
  margin: 0;
  padding: 10px 14px;
  text-align: center;
  font-weight: 900;
  color: var(--deep);
  background: rgba(251, 243, 228, 0.88);
  border-radius: 999px;
  box-shadow: 0 8px 18px var(--shadow);
  pointer-events: none;
  z-index: 2;
}

.hint {
  position: absolute;
  left: 10%;
  right: 16%;
  bottom: 16%;
  margin: 0;
  text-align: center;
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--deep);
  pointer-events: none;
  text-shadow: 0 1px 0 rgba(251, 243, 228, 0.8);
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  align-content: end;
  justify-items: center;
  gap: 6px;
  padding: 18px 18px 22%;
  background: linear-gradient(180deg, rgba(243, 230, 208, 0.04), rgba(243, 230, 208, 0.2) 70%);
  text-align: center;
  z-index: 3;
  pointer-events: none;
}

.overlay .start { pointer-events: auto; }

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

.overlay-kicker {
  margin: 0;
  color: var(--terracotta);
  font: 800 0.7rem/1 "Trebuchet MS", sans-serif;
  letter-spacing: 0.12em;
}

.overlay-lead {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 900;
  color: var(--deep);
}

.overlay-note {
  margin: 0 0 8px;
  color: var(--muted);
  font-weight: 700;
}

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

.start {
  background: var(--terracotta);
  color: #fff8ee;
  font-weight: 900;
  padding: 10px 22px;
  box-shadow: 0 8px 0 #8a3a28;
}

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

.mega-label {
  margin: 0;
  font: 800 0.72rem/1 "Trebuchet MS", sans-serif;
  color: var(--deep);
}

.mega-track {
  height: 10px;
  border-radius: 999px;
  background: rgba(30, 58, 95, 0.12);
  overflow: hidden;
}

.mega-fill {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--mustard));
}

.level-chip {
  margin: 0;
  font-size: 0.74rem;
  font-weight: 800;
  color: var(--deep);
  white-space: nowrap;
}

.sound-btn {
  background: var(--paper);
  padding: 6px 10px;
  font-weight: 800;
}

.live {
  margin: 0 4px;
  min-height: 1.4em;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.end-actions { min-height: 0; }

.share-x {
  background: var(--deep);
  color: #fbf3e4;
  font-weight: 800;
  padding: 8px 16px;
}

.help {
  display: grid;
  gap: 10px;
  padding: 12px 14px 16px;
  background: rgba(251, 243, 228, 0.72);
  border-radius: 22px;
}

.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;
  color: var(--muted);
  font-weight: 700;
}

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

kbd {
  display: inline-block;
  padding: 0 5px;
  border-radius: 6px;
  background: var(--mustard);
  font-size: 0.78em;
}

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

.reset {
  justify-self: start;
  background: var(--paper);
  color: var(--ink);
  padding: 6px 12px;
  box-shadow: 0 2px 0 rgba(30, 58, 95, 0.12);
}

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

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

html[data-capture] body::before { display: none; }

html[data-capture] main {
  width: 100%;
  max-width: none;
  padding: 0;
  gap: 0;
}

html[data-capture] .layout,
html[data-capture] .game-panel {
  display: block;
  background: transparent;
  box-shadow: none;
  padding: 0;
  border-radius: 0;
}

html[data-capture] .stage {
  height: 100dvh;
  border-radius: 0;
  box-shadow: none;
}

html[data-capture] #game {
  width: 100%;
  height: 100dvh;
}

html[data-capture] .banner {
  top: 16%;
  left: 10%;
  right: 18%;
}

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

  #game { height: min(72vh, 680px); }
}

@media (max-width: 430px) {
  .intro { padding: 8px 12px; }
  .intro h1 { font-size: 1.42rem; }
  .intro p { font-size: 0.84rem; }
  .hud { gap: 4px; }
  .hud p { padding: 4px 6px; }
  .hud strong { font-size: 0.95rem; }
  #game { height: min(62vh, 520px); }
  .mega-row { grid-template-columns: auto minmax(0, 1fr) auto; }
  .level-chip { grid-column: 1 / -1; }
  .site-header { min-height: 36px; }
  main { gap: 8px; }
  .overlay {
    align-content: end;
    padding: 8px 10px 10%;
    background: linear-gradient(180deg, transparent 55%, rgba(243, 230, 208, 0.62) 100%);
  }
  .overlay-lead { font-size: 1.05rem; }
  .overlay-note { display: none; }
}

@media (max-height: 760px) and (min-width: 880px) {
  .intro h1 { font-size: 1.7rem; }
  #game { height: min(62vh, 520px); }
}

@media (prefers-reduced-motion: reduce) {
  .banner,
  .mega-fill {
    transition: none;
  }
}
