:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
  color: #405247;
  background: #f8f7f1;
  -webkit-text-size-adjust: 100%;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }
body { overscroll-behavior: none; }
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; cursor: pointer; }
button:disabled { cursor: default; }
button:focus-visible, a:focus-visible, .stage:focus-visible { outline: 3px solid #75957d; outline-offset: 4px; }
[hidden] { display: none !important; }

.app {
  position: relative;
  width: 100%;
  height: var(--app-height, 100vh);
  height: var(--app-height, 100dvh);
  overflow: hidden;
  background: #f8f7f1;
}

.screen {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  padding-top: env(safe-area-inset-top, 0px);
}

.brand {
  position: absolute;
  z-index: 1;
  top: calc(env(safe-area-inset-top, 0px) + 16px);
  left: 0;
  width: 100%;
  margin: 0;
  color: #607267;
  text-align: center;
  font-size: 0.9375rem;
  letter-spacing: 0.04em;
}

.picture-pane, .stage { position: relative; min-width: 0; min-height: 0; overflow: hidden; }
.cover .picture-pane { margin-top: 44px; }
.picture {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
}

.picture-pane .picture, .frame .picture { max-width: 1100px; margin-inline: auto; }
.cover-controls, .ending-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 10px max(20px, env(safe-area-inset-left, 0px)) calc(20px + env(safe-area-inset-bottom, 0px));
  text-align: center;
}
h1 { margin: 0; font-size: 1.375rem; font-weight: 600; letter-spacing: 0.08em; }
.cover-help { margin: 0; font-size: 0.875rem; line-height: 1.75; color: #647367; }
.primary-button {
  width: min(100%, 300px);
  min-height: 56px;
  padding: 14px 20px;
  border: 0;
  border-radius: 999px;
  color: #fff;
  background: #49634f;
  font-size: 1.125rem;
  font-weight: 600;
  touch-action: manipulation;
}
.primary-button:active { background: #36523e; }
.primary-button:disabled { background: #88988b; }
.return-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 8px 16px;
  color: #546b5b;
  font-size: 0.9375rem;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}

.stage { touch-action: none; user-select: none; -webkit-user-select: none; cursor: default; }
.stage[aria-disabled="false"] { cursor: pointer; }
.frames { position: absolute; inset: 0; }
.frame {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  visibility: hidden;
  pointer-events: none;
  background: #f8f7f1;
  transform: translateY(100%);
}
.frame.is-current { visibility: visible; transform: translateY(0); }
.frame.is-moving { visibility: visible; will-change: transform; }

.player-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: calc(86px + env(safe-area-inset-bottom, 0px));
  padding: 8px 16px calc(14px + env(safe-area-inset-bottom, 0px));
}
.dots { display: flex; gap: 10px; height: 10px; align-items: center; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: #c7cec4; }
.dot.is-current { width: 8px; height: 8px; background: #617c63; }
.sound-row { min-height: 38px; display: flex; align-items: center; justify-content: center; }
.hint { display: flex; align-items: center; justify-content: center; gap: 10px; font-size: 0.9375rem; color: #65756a; }
.sound-bars { display: flex; gap: 3px; align-items: center; height: 18px; }
.sound-bars i { width: 3px; height: 8px; border-radius: 3px; background: #7a927b; }
.sound-bars i:nth-child(2) { height: 16px; }
[data-sound="playing"] .sound-bars i { animation: voice-wave 1s ease-in-out infinite; }
[data-sound="playing"] .sound-bars i:nth-child(2) { animation-delay: 0.2s; }
[data-sound="playing"] .sound-bars i:nth-child(3) { animation-delay: 0.4s; }
.swipe-cue { display: none; width: 10px; height: 10px; border-top: 2px solid #617c63; border-right: 2px solid #617c63; transform: rotate(-45deg); }
[data-sound="ready"] .sound-bars { display: none; }
[data-sound="ready"] .swipe-cue { display: inline-block; animation: swipe-hint 1.8s ease-in-out infinite; }
.voice-button { min-height: 44px; padding: 8px 22px; border: 1px solid #8ca18d; border-radius: 999px; color: #405f48; background: #fffef9; font-size: 1rem; touch-action: manipulation; }
.ending-controls { gap: 16px; padding-top: 12px; }
.no-script { position: absolute; z-index: 2; inset: 0; background: #f8f7f1; padding: 32px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@keyframes voice-wave { 0%, 100% { transform: scaleY(0.55); } 50% { transform: scaleY(1); } }
@keyframes swipe-hint { 0%, 100% { transform: translateY(3px) rotate(-45deg); } 50% { transform: translateY(-3px) rotate(-45deg); } }

@media (max-height: 480px) {
  .cover .picture-pane { margin-top: 26px; }
  .brand { top: calc(env(safe-area-inset-top, 0px) + 6px); }
  .cover-controls, .ending-controls { gap: 4px; padding-top: 4px; padding-bottom: calc(4px + env(safe-area-inset-bottom, 0px)); }
  h1 { font-size: 1.125rem; }
  .cover-help { font-size: 0.875rem; line-height: 1.4; }
  .primary-button { min-height: 44px; padding: 9px 20px; }
  .player-controls { min-height: calc(64px + env(safe-area-inset-bottom, 0px)); gap: 4px; padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px)); }
}

@media (prefers-reduced-motion: reduce) {
  .sound-bars i, .swipe-cue { animation: none !important; }
}
