:root {
  --ink: #1e2a3a;
  --sun: #f0a878;
  --mint: #5eead4;
  --sky: #e8b8a0;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Hiragino Maru Gothic ProN", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", sans-serif;
  background: linear-gradient(180deg, #7a9ec8 0%, var(--sky) 45%, #f5e6d8 100%);
  color: var(--ink);
  min-height: 100dvh;
}

.masthead {
  display: flex;
  justify-content: space-between;
  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.12em;
  margin: 0;
  opacity: 0.75;
}

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

.intro h1 span {
  color: #c45c3e;
}

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

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

.hud {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.65rem 1rem;
  font-size: 0.88rem;
  margin-bottom: 0.25rem;
}

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

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

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

canvas {
  display: block;
  width: 100%;
  height: auto;
  background: #c8dce8;
  cursor: default;
}

.touch-controls {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.45rem;
  margin-top: 0.45rem;
}

.pad {
  border: 2px solid var(--ink);
  border-radius: 14px;
  background: #fff;
  font-size: 1.25rem;
  padding: 0.75rem;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

.pad.jump {
  background: var(--mint);
  font-weight: 700;
}

.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: #fff9f0f0;
  border-radius: 14px;
  padding: 1rem;
  z-index: 4;
}

.panel.summary {
  inset: auto;
  left: 0.55rem;
  right: 0.55rem;
  bottom: 0.65rem;
  top: auto;
  max-height: 42%;
  justify-content: flex-start;
  background: rgba(22, 28, 48, 0.78);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #fff8ef;
  border: 2px solid rgba(255, 232, 160, 0.5);
  box-shadow: 0 10px 36px rgba(10, 15, 35, 0.45);
}

.panel.summary h2 {
  color: #ffe8a0;
  font-size: 1rem;
  margin-bottom: 0.25rem;
}

.panel.summary .hint,
.panel.summary .stats {
  color: #f0e6d8;
}

.panel.summary .rank {
  color: #fff;
  text-shadow: 0 2px 12px rgba(255, 220, 120, 0.35);
}

.capture-only {
  display: none;
}

.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;
}

.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"],
html[data-promo="shot"] {
  --capture-shell-w: min(98vw, 1080px);
}

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

html[data-capture="1"] .capture-only,
html[data-promo="shot"] .capture-only {
  display: block;
}

html[data-capture="1"] body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  background: linear-gradient(180deg, #c87868 0%, #e8a890 28%, #5a4870 100%);
}

html[data-promo="shot"] body {
  margin: 0;
  height: 100dvh;
  min-height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  background: #e8b0a0;
}

html[data-capture="1"] main,
html[data-promo="shot"] main {
  max-width: none;
  width: 100%;
  padding: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
}

html[data-capture="1"] .play-shell,
html[data-promo="shot"] .play-shell {
  width: var(--capture-shell-w) !important;
  max-width: 1080px !important;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  border: none;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
  padding: max(env(safe-area-inset-top), 4px) 0.25rem max(env(safe-area-inset-bottom), 4px);
  min-height: 0;
}

html[data-capture="1"] .capture-hook,
html[data-promo="shot"] .capture-hook {
  margin: 0 0 0.35rem;
  text-align: center;
  font-size: clamp(0.82rem, 2.8vw, 1rem);
  font-weight: 700;
  color: #fff8ef;
  text-shadow: 0 2px 10px rgba(20, 20, 40, 0.65);
  letter-spacing: 0.04em;
}

html[data-capture="1"] .capture-stage,
html[data-promo="shot"] .capture-stage {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  width: 100%;
}

html[data-capture="1"] .hud,
html[data-promo="shot"] .hud {
  position: absolute;
  z-index: 6;
  left: 0.45rem;
  right: 0.45rem;
  top: 0.35rem;
  margin: 0;
  padding: 0.35rem 0.5rem;
  gap: 0.35rem 0.75rem;
  background: rgba(255, 248, 235, 0.94);
  border: 2px solid #1e2a3a;
  border-radius: 12px;
  box-shadow: 0 4px 14px rgba(20, 30, 50, 0.28);
  color: #1e2a3a;
}

html[data-capture="1"] .hud small,
html[data-promo="shot"] .hud small {
  opacity: 0.85;
  color: #3a4a5a;
}

html[data-capture="1"] .hud strong,
html[data-promo="shot"] .hud strong {
  font-size: 1.28rem;
  color: #1e2a3a;
}

html[data-capture="1"] .live,
html[data-promo="shot"] .live {
  position: absolute;
  z-index: 6;
  left: 0.55rem;
  right: 0.55rem;
  top: 3.35rem;
  margin: 0;
  padding: 0.2rem 0.45rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: #1e2a3a;
  background: rgba(255, 248, 235, 0.88);
  border-radius: 8px;
  border: 1px solid rgba(30, 42, 58, 0.25);
}

html[data-promo="shot"] .live,
html[data-promo="shot"] .capture-hook,
html[data-promo="shot"] .hud {
  display: none !important;
}

html[data-promo="shot"] .capture-stage {
  flex: 1;
  width: 100%;
  min-height: 100dvh;
}

html[data-promo="shot"] .stage-wrap {
  height: 100% !important;
  width: 100% !important;
  max-width: none !important;
  border-radius: 0;
  box-shadow: none;
}

html[data-capture="1"] .stage-wrap,
html[data-promo="shot"] .stage-wrap {
  flex: 1;
  width: 100%;
  margin: 0 auto;
  min-height: 0;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 10px 28px rgba(15, 20, 40, 0.35);
}

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

html[data-capture="1"] #share-x,
html[data-capture="1"] .summary-actions .btn-primary {
  display: none !important;
}

html[data-capture="1"] .summary,
html[data-promo="shot"] .summary {
  bottom: max(0.55rem, env(safe-area-inset-bottom));
  max-height: 36%;
}

html[data-capture="1"] .summary .rank {
  font-size: 2.2rem;
}

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

@media (min-width: 720px) {
  .touch-controls {
    display: none;
  }
}

@media (max-width: 719px) {
  #touch-controls[hidden] {
    display: none !important;
  }
  #touch-controls:not([hidden]) {
    display: grid;
  }
}
