:root {
  --sky: #8ecfff;
  --sky-deep: #6bb8f2;
  --coral: #ff8b73;
  --coral-deep: #e56a58;
  --cream: #fff6e8;
  --paper: #fffaf2;
  --rape: #ffd45a;
  --lavender: #c5b0e0;
  --lavender-deep: #8d6fb3;
  --ink: #3a2a28;
  --muted: #6d5752;
  --line: rgba(58, 42, 40, 0.16);
  --shadow: rgba(58, 42, 40, 0.18);
  --font: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;
  --font-serif: "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: var(--font);
  background:
    radial-gradient(ellipse at 12% -10%, rgba(142, 207, 255, 0.55), transparent 28rem),
    radial-gradient(ellipse at 92% 8%, rgba(255, 139, 115, 0.28), transparent 24rem),
    linear-gradient(180deg, #f7ecdc 0%, #f3e2cc 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.18;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='.45'/%3E%3C/svg%3E");
}

a { color: var(--coral-deep); }

.site-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: baseline;
  padding: 1rem 1.2rem 0;
  font-size: .82rem;
}

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

.site-header a:focus-visible,
button:focus-visible,
.journey-item:focus-visible {
  outline: 3px solid var(--coral);
  outline-offset: 3px;
}

.site-header p {
  margin: 0;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

main {
  width: min(1080px, calc(100% - 1.6rem));
  margin: 0 auto;
  padding: 1rem 0 3rem;
}

.intro { margin-bottom: 1.1rem; }

.eyebrow {
  margin: 0 0 .35rem;
  color: var(--coral-deep);
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .16em;
}

.intro h1 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: clamp(2.4rem, 8vw, 4.4rem);
  font-weight: 700;
  line-height: .92;
  letter-spacing: -.04em;
}

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

.intro p {
  max-width: 38rem;
  margin: .8rem 0 0;
  color: var(--muted);
  line-height: 1.75;
}

.game-panel,
.album-panel,
.help {
  position: relative;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--paper);
  box-shadow: 0 18px 0 rgba(58, 42, 40, 0.06), 0 28px 40px var(--shadow);
}

.scoreboard {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: .55rem;
  margin-bottom: .85rem;
}

.scoreboard p {
  margin: 0;
  padding: .55rem .65rem;
  border-radius: 14px;
  background: #fff3e0;
  box-shadow: 0 6px 0 rgba(255, 139, 115, 0.16);
}

.scoreboard span {
  display: block;
  color: var(--muted);
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .08em;
}

.scoreboard strong {
  display: block;
  margin-top: .15rem;
  font-size: 1.05rem;
}

.stage-wrap {
  position: relative;
  overflow: hidden;
  border-radius: 18px;
  background: var(--sky);
  box-shadow: inset 0 0 0 1px rgba(58, 42, 40, 0.08);
  touch-action: none;
  cursor: grab;
}

.stage-wrap.is-dragging { cursor: grabbing; }

#game-canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  background: var(--sky);
}

.goal-card {
  position: absolute;
  top: .7rem;
  left: .7rem;
  z-index: 3;
  width: min(240px, calc(100% - 1.4rem));
  padding: .65rem .75rem .55rem;
  border-radius: 16px 18px 14px 20px;
  background: rgba(255, 250, 242, 0.92);
  box-shadow: 8px 10px 0 rgba(58, 42, 40, 0.1);
  color: var(--ink);
  pointer-events: none;
}

.goal-kicker {
  margin: 0 0 .35rem;
  color: var(--coral-deep);
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .1em;
}

.goal-card ul {
  margin: 0;
  padding: 0 0 0 1rem;
}

.goal-card li {
  margin: .15rem 0;
  font-size: .82rem;
  line-height: 1.45;
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-content: center;
  padding: 1.4rem;
  text-align: center;
  background:
    linear-gradient(180deg, rgba(255, 246, 232, 0.2), transparent 30%),
    rgba(255, 246, 232, 0.78);
}

.overlay.is-hidden { display: none; }

.cover-overlay {
  background:
    linear-gradient(90deg, #e56a58 0 18px, transparent 18px),
    linear-gradient(180deg, #fff6e8, #ffe1c4);
}

.overlay-kicker {
  margin: 0;
  color: var(--coral-deep);
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .16em;
}

.overlay-lead {
  margin: .4rem 0 .55rem;
  font-family: var(--font-serif);
  font-size: clamp(1.8rem, 5vw, 2.8rem);
  line-height: 1.2;
}

.overlay-note {
  max-width: 26rem;
  margin: 0 auto;
  color: var(--muted);
  line-height: 1.7;
}

.flash {
  position: absolute;
  inset: 0;
  z-index: 6;
  background: #fff;
  opacity: 0;
  pointer-events: none;
}

.flash.is-on { animation: flash-pop 420ms ease-out; }

.page-turn {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  transform-origin: left center;
  background:
    linear-gradient(90deg, rgba(58, 42, 40, 0.12), transparent 18px),
    linear-gradient(180deg, #fffaf2, #ffe7cc);
  opacity: 0;
}

.page-turn.is-on { animation: page-flip 720ms ease-in; }

.polaroid {
  position: absolute;
  left: 50%;
  bottom: 4%;
  z-index: 7;
  width: min(220px, 46%);
  margin: 0;
  padding: .45rem .45rem 1.1rem;
  border-radius: 4px;
  background: #fff;
  box-shadow: 0 16px 28px rgba(58, 42, 40, 0.22);
  transform: translate(-50%, 120%);
  animation: polaroid-up 900ms cubic-bezier(.2, .8, .2, 1) forwards;
}

.polaroid img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: #d9ecff;
}

.polaroid figcaption {
  margin-top: .4rem;
  font-size: .72rem;
  text-align: center;
  color: var(--muted);
}

.status,
.burapi-line,
.key-hint,
.save-note,
.album-meta,
.album-empty {
  color: var(--muted);
  line-height: 1.65;
}

.status {
  min-height: 2.6rem;
  margin: .85rem 0 .15rem;
}

.burapi-line {
  margin: 0 0 .85rem;
  font-family: var(--font-serif);
  color: var(--ink);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: .7rem;
}

button {
  font-family: inherit;
  cursor: pointer;
}

.action,
.shutter,
.share-x,
.reset {
  min-height: 52px;
  padding: .7rem 1.15rem;
  border: 0;
  border-radius: 999px;
  font-weight: 800;
}

.action {
  background: var(--sky);
  color: var(--ink);
  box-shadow: 0 6px 0 #5ea8d8;
}

.shutter {
  min-width: 9.5rem;
  background: var(--coral);
  color: #fffaf2;
  box-shadow: 0 6px 0 var(--coral-deep);
}

.shutter:disabled,
.action:disabled {
  opacity: .45;
  box-shadow: none;
  cursor: not-allowed;
}

.share-x {
  background: var(--ink);
  color: var(--cream);
}

.reset {
  margin-top: 1rem;
  background: transparent;
  color: var(--ink);
  box-shadow: inset 0 0 0 2px var(--line);
}

.action:hover:not(:disabled),
.shutter:hover:not(:disabled) { filter: brightness(1.04); }

.key-hint {
  margin: .8rem 0 0;
  font-size: .88rem;
}

kbd {
  display: inline-block;
  padding: .05rem .35rem;
  border-radius: 6px;
  background: #fff3e0;
  box-shadow: 0 2px 0 rgba(58, 42, 40, 0.12);
  font-family: inherit;
  font-size: .8em;
}

.album-panel { margin-top: 1.2rem; }

.album-panel h2,
.help h2 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: clamp(1.5rem, 4vw, 2.1rem);
}

.album-spread {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .8rem;
  margin-top: 1rem;
}

.album-card {
  padding: .5rem .5rem .8rem;
  background: #fff;
  box-shadow: 0 10px 0 rgba(58, 42, 40, 0.08);
}

.album-card img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

.album-card p {
  margin: .45rem .15rem 0;
  font-size: .78rem;
  color: var(--muted);
}

.help { margin-top: 1.2rem; }

.help ol {
  display: grid;
  gap: .75rem;
  margin: 1.1rem 0 0;
  padding: 0;
  list-style: none;
}

.help li {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: .7rem;
  align-items: start;
  color: var(--muted);
  line-height: 1.65;
}

.help li span {
  display: grid;
  place-items: center;
  width: 1.8rem;
  height: 1.8rem;
  border-radius: 999px;
  background: var(--rape);
  color: var(--ink);
  font-weight: 800;
}

[data-account="compact"] {
  width: min(1080px, calc(100% - 1.6rem));
  margin: 0 auto 2rem;
}

@keyframes flash-pop {
  0% { opacity: .92; }
  100% { opacity: 0; }
}

@keyframes page-flip {
  0% { opacity: 1; transform: rotateY(0deg); }
  100% { opacity: 0; transform: rotateY(-70deg); }
}

@keyframes polaroid-up {
  0% { transform: translate(-50%, 120%) rotate(-4deg); }
  100% { transform: translate(-50%, 0) rotate(-2deg); }
}

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

@media (max-width: 720px) {
  .scoreboard { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .album-spread { grid-template-columns: 1fr; }
  .goal-card { width: min(100% - 1.2rem, 280px); }
}

@media (max-width: 420px) {
  main { width: min(100% - 1rem, 1080px); padding-top: .6rem; }
  .intro h1 { font-size: 2.35rem; }
  .intro p { font-size: .92rem; }
  .game-panel { padding: .75rem; border-radius: 16px; }
  .scoreboard p { padding: .4rem .5rem; }
  .shutter { min-width: 100%; }
  .actions { display: grid; }
  .goal-card {
    top: .4rem;
    left: .4rem;
    width: min(168px, calc(100% - .8rem));
    padding: .4rem .5rem .35rem;
  }
  .goal-card li { font-size: .7rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
  .flash.is-on { opacity: .35; }
  .page-turn.is-on { opacity: .4; }
  .polaroid { transform: translate(-50%, 0); }
}
