:root {
  --space: #211b4d;
  --deep: #11102f;
  --moon: #fff0b7;
  --paper: #fff8df;
  --cyan: #55d8d1;
  --red: #ef6858;
  --gold: #f5c85c;
  --ink: #272044;
  --muted: #685f79;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  background:
    radial-gradient(circle at 14% 8%, rgba(85, 216, 209, 0.22), transparent 28%),
    radial-gradient(circle at 88% 22%, rgba(239, 104, 88, 0.2), transparent 25%),
    var(--paper);
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.13;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='100' height='100'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.55' numOctaves='3'/></filter><rect width='100' height='100' filter='url(%23n)' opacity='.45'/></svg>");
}

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

.site-header {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 18px 5px;
}

.site-header a { color: var(--space); font-weight: 900; text-decoration: none; }
.site-header p { margin: 0; color: var(--muted); font-size: 0.75rem; letter-spacing: 0.13em; }

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

main { position: relative; z-index: 1; width: min(1080px, 100%); margin: 0 auto; padding: 5px 16px 54px; }
.intro { padding: 4px 4px 14px; }
.eyebrow { margin: 0; color: var(--red); font: 900 0.72rem/1.2 "Trebuchet MS", sans-serif; letter-spacing: 0.2em; }
.intro h1 { margin: 4px 0 6px; color: var(--space); font-size: clamp(2rem, 6vw, 4rem); line-height: 1; letter-spacing: -0.05em; }
.intro h1 span { color: var(--red); }
.intro > p:last-child { margin: 0; line-height: 1.65; }
.layout { display: grid; gap: 18px; }

.game-panel, .help {
  position: relative;
  overflow: hidden;
  border: 3px solid var(--space);
  border-radius: 22px;
  background: rgba(255, 248, 223, 0.9);
  box-shadow: 7px 8px 0 rgba(33, 27, 77, 0.16);
}

.game-panel { padding: 12px; display: grid; gap: 8px; }
.hud { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; }
.hud p { margin: 0; padding: 6px 9px; color: var(--moon); background: var(--space); border-radius: 10px; }
.hud span { display: block; color: var(--cyan); font-size: 0.62rem; font-weight: 900; letter-spacing: 0.08em; }
.hud strong { display: block; font: 900 1rem/1.2 "Trebuchet MS", sans-serif; }

.stage { position: relative; overflow: hidden; border: 3px solid var(--space); border-radius: 16px; background: var(--deep); }
#game { display: block; width: 100%; height: min(62vh, 650px); min-height: 330px; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
#game.is-playing { touch-action: none; }

.overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 9px;
  padding: 24px;
  text-align: center;
  color: var(--moon);
  background: linear-gradient(180deg, rgba(17, 16, 47, 0.15), rgba(17, 16, 47, 0.88) 38%, rgba(17, 16, 47, 0.96));
}
.overlay[hidden] { display: none !important; }
.overlay-kicker { margin: 0; padding: 4px 12px; color: var(--deep); background: var(--cyan); border-radius: 999px; font-weight: 900; letter-spacing: 0.1em; }
.overlay-lead { margin: 0; max-width: 20em; font-size: clamp(1.35rem, 4vw, 2rem); font-weight: 900; }
.overlay-note { margin: 0 0 7px; max-width: 29em; color: rgba(255, 240, 183, 0.82); line-height: 1.65; }

button { font: inherit; }
.start, .share-x, .sound-btn, .reset, .control-btn { border: 0; cursor: pointer; font-weight: 900; }
.start { padding: 13px 24px; color: var(--deep); background: var(--gold); border-radius: 999px; box-shadow: 0 5px 0 var(--red); }
.start:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--red); }
.share-x { padding: 10px 18px; color: var(--deep); background: var(--cyan); border-radius: 999px; }
.share-x[hidden] { display: none; }

.controls { display: flex; align-items: stretch; justify-content: space-between; gap: 14px; }
.move-controls { display: grid; grid-template-columns: repeat(2, minmax(74px, 1fr)); gap: 8px; flex: 1; max-width: 370px; }
.control-btn {
  min-height: 64px;
  color: var(--moon);
  background: var(--space);
  border: 2px solid var(--cyan);
  border-radius: 18px;
  font-size: 1.55rem;
  touch-action: none;
  user-select: none;
}
.control-btn span { display: block; font-size: 0.68rem; letter-spacing: 0.06em; }
.control-btn.is-pressed { transform: translateY(3px); color: var(--deep); background: var(--cyan); }
.jump-btn { min-width: 112px; color: var(--deep); background: var(--gold); border-color: var(--red); }
.jump-btn.is-pressed { background: var(--red); color: var(--paper); }

.tool-row { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 9px; align-items: center; }
.sound-btn, .reset { padding: 8px 12px; color: var(--space); background: rgba(85, 216, 209, 0.2); border: 1px solid var(--space); border-radius: 999px; }
.tool-row p, .live { margin: 0; color: var(--muted); font-size: 0.87rem; line-height: 1.5; }
.tool-row p { font-weight: 800; color: var(--space); }
.live { min-height: 1.4em; }

.help { padding: 18px; display: grid; gap: 13px; }
.help h2 { margin: 5px 0 0; font-size: 1.35rem; }
.help ol { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.help li { display: grid; grid-template-columns: 32px 1fr; gap: 9px; align-items: center; line-height: 1.55; }
.help li span { display: grid; place-items: center; aspect-ratio: 1; color: var(--moon); background: var(--space); border-radius: 50%; font-weight: 900; }
.key-hint, .save-note { margin: 0; color: var(--muted); font-size: 0.86rem; line-height: 1.7; }
kbd { display: inline-block; min-width: 1.8em; margin: 0 2px; padding: 1px 5px; text-align: center; color: var(--space); background: #fff; border: 1px solid rgba(33, 27, 77, 0.4); border-radius: 5px; box-shadow: 0 2px 0 rgba(33, 27, 77, 0.2); }
.records { margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.records div { padding: 8px 10px; border-radius: 10px; background: rgba(245, 200, 92, 0.18); }
.records dt { color: var(--muted); font-size: 0.7rem; }
.records dd { margin: 2px 0 0; font-weight: 900; color: var(--space); }
.reset { justify-self: start; }

html[data-capture="1"] body { overflow: hidden; background: var(--deep); }
html[data-capture="1"] .site-header,
html[data-capture="1"] .intro,
html[data-capture="1"] .help,
html[data-capture="1"] [data-account],
html[data-capture="1"] .tool-row,
html[data-capture="1"] .live { display: none !important; }
html[data-capture="1"] main { width: 100vw; height: 100dvh; max-width: none; padding: 0; }
html[data-capture="1"] .layout,
html[data-capture="1"] .game-panel { width: 100%; height: 100%; }
html[data-capture="1"] .layout { display: block !important; grid-template-columns: 1fr !important; }
html[data-capture="1"] .game-panel { grid-template-rows: auto minmax(0, 1fr) auto; gap: 0; padding: 0; border: 0; border-radius: 0; box-shadow: none; background: var(--deep); }
html[data-capture="1"] .hud { position: absolute; z-index: 6; top: max(4.5%, env(safe-area-inset-top)); left: 8%; right: 18%; pointer-events: none; }
html[data-capture="1"] .hud p { background: rgba(17, 16, 47, 0.78); border: 1px solid rgba(85, 216, 209, 0.5); }
html[data-capture="1"] .stage { grid-row: 1 / 4; width: 100%; height: 100%; border: 0; border-radius: 0; }
html[data-capture="1"] #game { width: 100%; height: 100%; min-height: 0; }
html[data-capture="1"] .controls { position: absolute; z-index: 6; left: 8%; right: 18%; bottom: 7%; opacity: 0.55; pointer-events: none; }
html[data-capture="1"] .control-btn { min-height: 86px; }

@media (min-width: 880px) {
  .layout { grid-template-columns: minmax(0, 1.7fr) minmax(280px, 0.8fr); align-items: start; }
  #game { min-height: 510px; }
  .help { position: sticky; top: 12px; }
}

@media (max-width: 520px) {
  .site-header { padding-inline: 12px; }
  .site-header p { display: none; }
  main { padding: 4px 8px 42px; }
  .intro h1 { font-size: 2rem; }
  .game-panel { padding: 7px; border-radius: 16px; }
  .hud { gap: 4px; }
  .hud p { padding: 5px 6px; }
  .hud strong { font-size: 0.86rem; }
  #game { height: min(46vh, 400px); min-height: 330px; }
  .control-btn { min-height: 62px; }
  .move-controls { grid-template-columns: repeat(2, minmax(64px, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}
