:root {
  --ink: #f6efe6;
  --ink-soft: rgba(246, 239, 230, 0.82);
  --paper: #efe3cd;
  --paper-edge: #d9c6a6;
  --paper-ink: #3a2f27;
  --paper-soft: #6c5b4b;
  --wood: #5b4334;
  --wood-dark: #3a2a20;
  --wood-light: #7a5c47;
  --accent: #f3c98b;
  --navy: #26345a;
  --glass: rgba(34, 32, 52, 0.5);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --serif: "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", "Noto Serif JP", serif;
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
  font-synthesis: none;
  -webkit-text-size-adjust: 100%;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #2b2d48;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

[hidden] {
  display: none !important;
}

#sea {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

button {
  min-width: 44px;
  min-height: 44px;
  font: inherit;
  color: inherit;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* 前景：桟橋の先端に座って竿を持つねこ。糸は画像の竿先から3Dの浮きへつなぐ */
.cat-pier {
  position: fixed;
  --pier-x: -50%;
  --pier-y: 9%;
  left: 50%;
  bottom: 0;
  width: min(118vw, 80vh);
  height: auto;
  pointer-events: none;
  transform: translate(var(--pier-x), var(--pier-y));
  transform-origin: 50% 100%;
  filter: drop-shadow(0 -2px 14px rgba(20, 16, 30, 0.28));
  transition:
    transform 0.6s ease,
    opacity 0.6s ease;
}

/* 縦画面では大きめに置き、桟橋の先端とねこを操作ボタンより上に出す */
@media (orientation: portrait) {
  .cat-pier {
    width: min(142vw, 86vh);
  }
}

/* 投げた瞬間、ねこが竿をあおって少し伸び上がる */
.cat-pier.casting {
  animation: cat-cast 0.55s ease-out;
}

@keyframes cat-cast {
  0% {
    transform: translate(var(--pier-x), var(--pier-y));
  }
  35% {
    transform: translate(var(--pier-x), calc(var(--pier-y) - 1.4%)) scale(1.012);
  }
  100% {
    transform: translate(var(--pier-x), var(--pier-y));
  }
}

/* 一度竿をあおって、一本釣りのように引き上げる */
.cat-pier.hoisting {
  animation: cat-hoist 0.9s ease-out;
}
@keyframes cat-hoist {
  0% {
    transform: translate(var(--pier-x), var(--pier-y)) rotate(0);
  }
  28% {
    transform: translate(var(--pier-x), calc(var(--pier-y) - 5%)) rotate(-4deg);
  }
  65% {
    transform: translate(var(--pier-x), calc(var(--pier-y) - 2%)) rotate(-2deg);
  }
  100% {
    transform: translate(var(--pier-x), var(--pier-y));
  }
}
/* 望遠で浮きへ寄っているあいだは、手前の桟橋とねこをそっと下げる */
.closeup .cat-pier:not(.hoisting) {
  animation: none;
  transform: translate(var(--pier-x), 60%);
  opacity: 0;
}

/* 上部の表示 */
.hud {
  position: fixed;
  top: calc(var(--safe-top) + 8px);
  left: calc(var(--safe-left) + 8px);
  right: calc(var(--safe-right) + 8px);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 6px;
  pointer-events: none;
}

.hud > * {
  pointer-events: auto;
}

.sign {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px 6px 10px;
  border-radius: 8px;
  background:
    repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.06) 0 2px, transparent 2px 7px), linear-gradient(180deg, var(--wood-light), var(--wood));
  box-shadow:
    inset 0 0 0 1px rgba(255, 230, 200, 0.15),
    0 4px 10px rgba(10, 8, 20, 0.35);
  color: #f6eadb;
}

.sign-anchor {
  font-size: 20px;
  opacity: 0.85;
}

.sign-text {
  display: grid;
  line-height: 1.2;
}

.sign-place {
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.sign-place rt {
  font-size: 8px;
  letter-spacing: 0;
}

.sign-tide {
  font-size: 11px;
  opacity: 0.85;
  letter-spacing: 0.1em;
}

.stats {
  display: flex;
  align-items: center;
  gap: 6px;
}

.stat {
  display: grid;
  justify-items: center;
  min-width: 56px;
  margin: 0;
  padding: 4px 10px;
  border-radius: 8px;
  background: var(--paper);
  color: var(--paper-ink);
  box-shadow:
    inset 0 0 0 1px var(--paper-edge),
    0 4px 10px rgba(10, 8, 20, 0.3);
  line-height: 1.15;
}

.stat-label {
  font-size: 10px;
  color: var(--paper-soft);
  letter-spacing: 0.1em;
}

.stat-value {
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 700;
}

.stat-value small {
  font-size: 12px;
}

.round-button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, var(--wood-light), var(--wood-dark));
  color: #f6eadb;
  font-size: 18px;
  box-shadow: 0 4px 10px rgba(10, 8, 20, 0.4);
}

.hint {
  position: fixed;
  top: calc(var(--safe-top) + 64px);
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100vw - 24px);
  margin: 0;
  padding: 6px 14px;
  font-family: var(--serif);
  font-size: 14px;
  line-height: 1.5;
  text-align: center;
  color: #fffaf2;
  text-shadow:
    0 1px 2px rgba(20, 14, 30, 0.9),
    0 0 10px rgba(20, 14, 30, 0.6);
  pointer-events: none;
  word-break: auto-phrase;
}

.hint.alert {
  padding: 6px 18px;
  border-radius: 999px;
  background: rgba(150, 50, 40, 0.85);
  font-size: 18px;
  letter-spacing: 0.1em;
}

.toast {
  position: fixed;
  top: calc(var(--safe-top) + 104px);
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  padding: 8px 16px;
  border-radius: 8px;
  background: var(--paper);
  color: var(--paper-ink);
  font-family: var(--serif);
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 6px 16px rgba(10, 8, 20, 0.35);
  pointer-events: none;
  animation: toast-in 0.25s ease-out;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, -8px);
  }
}

/* 下部の操作 */
.controls {
  position: fixed;
  left: calc(var(--safe-left) + 10px);
  right: calc(var(--safe-right) + 10px);
  bottom: calc(var(--safe-bottom) + 10px);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  width: min(100% - 20px - var(--safe-left) - var(--safe-right), 420px);
  margin-inline: auto;
}
/* アタリの間は「ひく」を目立たせる */
#pull-button.biting {
  background: linear-gradient(180deg, #c7714f, #a24d33 55%, #7d3522);
  animation: pull-pulse 0.5s ease-in-out infinite alternate;
}
@keyframes pull-pulse {
  to {
    transform: scale(1.04);
    box-shadow:
      inset 0 1px 0 rgba(255, 230, 200, 0.3),
      0 0 18px rgba(255, 170, 120, 0.6),
      0 5px 12px rgba(10, 8, 20, 0.45);
  }
}
@media (prefers-reduced-motion: reduce) {
  #pull-button.biting {
    animation: none;
  }
}

.plank {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  padding: 0 14px;
  border: 0;
  border-radius: 10px;
  background:
    repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.07) 0 2px, transparent 2px 8px),
    linear-gradient(180deg, var(--wood-light), var(--wood) 55%, var(--wood-dark));
  color: #fbf1e3;
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.12em;
  box-shadow:
    inset 0 1px 0 rgba(255, 230, 200, 0.25),
    inset 0 0 0 1px rgba(0, 0, 0, 0.25),
    0 5px 12px rgba(10, 8, 20, 0.45);
}

.plank.small {
  font-size: 14px;
  letter-spacing: 0.04em;
  padding: 0 8px;
  gap: 4px;
}

.plank[aria-pressed="true"] {
  background: linear-gradient(180deg, #9fb3d6, #5f7299);
  color: #fff;
}

.plank:disabled {
  filter: grayscale(0.6) brightness(0.7);
  cursor: default;
}

.plank.pressing {
  transform: translateY(2px);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.45);
}

.plank-icon {
  font-size: 1.1em;
  opacity: 0.85;
}

.paper-button {
  min-height: 48px;
  padding: 0 20px;
  border: 0;
  border-radius: 10px;
  background: var(--paper);
  color: var(--paper-ink);
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.1em;
  box-shadow:
    inset 0 0 0 1px var(--paper-edge),
    0 4px 10px rgba(10, 8, 20, 0.3);
}

.paper-button:disabled {
  opacity: 0.55;
  cursor: default;
}

.wide {
  width: 100%;
}

/* 印 */
.bite-mark {
  position: fixed;
  left: 0;
  top: 0;
  transform: translate(-50%, -130%);
  color: #fff;
  font-size: 46px;
  font-weight: 900;
  text-shadow:
    0 0 12px rgba(255, 90, 60, 0.9),
    0 2px 0 #9b2a20;
  pointer-events: none;
}

/* タイトル */
.title-screen {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-rows: auto auto 1fr;
  justify-items: center;
  padding: calc(var(--safe-top) + 16px) calc(var(--safe-right) + 16px) calc(var(--safe-bottom) + 16px) calc(var(--safe-left) + 16px);
  background:
    url("../assets/web/home-bg.webp") center / cover no-repeat,
    #6b6385;
}

.title-count {
  justify-self: end;
  margin: 0;
  padding: 6px 12px;
  border-radius: 8px;
  background: var(--paper);
  color: var(--paper-ink);
  font-family: var(--serif);
  font-size: 13px;
  box-shadow: 0 4px 10px rgba(10, 8, 20, 0.3);
}

.title-count strong {
  font-size: 18px;
}

.title-head {
  display: grid;
  justify-items: center;
  margin-top: 4vh;
  text-align: center;
}

.logo {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(46px, 15vw, 88px);
  font-weight: 600;
  letter-spacing: 0.08em;
  line-height: 1.1;
  color: var(--navy);
  text-shadow:
    0 0 18px rgba(255, 240, 235, 0.85),
    0 0 2px rgba(255, 255, 255, 0.9);
}

.logo-roman {
  margin: 2px 0 0;
  font-family: var(--serif);
  font-size: 11px;
  letter-spacing: 0.6em;
  color: var(--navy);
  opacity: 0.8;
}

.title-lead {
  margin: 10px 0 0;
  font-family: var(--serif);
  font-size: 14px;
  letter-spacing: 0.08em;
  color: var(--navy);
  text-shadow: 0 0 10px rgba(255, 240, 235, 0.9);
  word-break: auto-phrase;
}

.title-menu {
  display: grid;
  gap: 10px;
  width: min(72vw, 300px);
  align-self: center;
  margin-top: 4vh;
}

.title-menu .plank {
  min-height: 56px;
  font-size: 20px;
}

.title-murmur {
  position: absolute;
  left: calc(var(--safe-left) + 18px);
  top: calc(var(--safe-top) + 18px);
  margin: 0;
  font-family: var(--serif);
  font-size: 12px;
  line-height: 1.8;
  color: rgba(255, 250, 245, 0.9);
  text-shadow: 0 1px 4px rgba(30, 20, 40, 0.6);
}

/* タイトル右上の歯車（言語と音の設定を開く） */
.title-settings {
  position: absolute;
  top: calc(var(--safe-top) + 12px);
  right: calc(var(--safe-right) + 12px);
  z-index: 3;
}
.title-settings svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linejoin: round;
}
.settings-language {
  display: grid;
  gap: 6px;
  font-weight: 700;
}
.settings-language select {
  min-height: 44px;
  border: 1px solid var(--paper-edge);
  border-radius: 999px;
  padding: 0 14px;
  background: var(--paper);
  color: var(--paper-ink);
  font: inherit;
  font-size: 15px;
}

/* 紙のシート */
.sheet {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: calc(var(--safe-top) + 16px) calc(var(--safe-right) + 14px) calc(var(--safe-bottom) + 16px) calc(var(--safe-left) + 14px);
  background: rgba(24, 20, 40, 0.45);
  animation: fade-in 0.3s ease-out;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

.paper {
  position: relative;
  width: min(100%, 420px);
  max-height: 100%;
  overflow: auto;
  padding: 20px 20px 16px;
  border-radius: 6px 10px 8px 12px;
  background:
    radial-gradient(ellipse at 20% 10%, rgba(255, 255, 255, 0.35), transparent 60%),
    radial-gradient(ellipse at 90% 100%, rgba(150, 110, 70, 0.18), transparent 55%), var(--paper);
  color: var(--paper-ink);
  font-family: var(--serif);
  box-shadow:
    inset 0 0 0 1px var(--paper-edge),
    inset 0 0 40px rgba(140, 100, 60, 0.15),
    0 18px 40px rgba(10, 8, 20, 0.5);
  -webkit-user-select: text;
  user-select: text;
}

.paper h2 {
  margin: 4px 0 12px;
  font-size: 21px;
  letter-spacing: 0.05em;
}

.kicker {
  margin: 0;
  font-size: 13px;
  letter-spacing: 0.2em;
  color: #8a5a3c;
}

.sheet-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

.letter-lines {
  margin: 0;
  padding: 10px 0;
  border-top: 1px solid rgba(90, 70, 50, 0.2);
  border-bottom: 1px solid rgba(90, 70, 50, 0.2);
  background: repeating-linear-gradient(180deg, transparent 0 31px, rgba(120, 90, 60, 0.15) 31px 32px);
}

.letter-lines p {
  margin: 0;
  font-size: 16px;
  line-height: 32px;
  word-break: auto-phrase;
}

.letter-lines p.missing {
  color: rgba(90, 70, 50, 0.4);
  letter-spacing: 0.3em;
}

.letter-from {
  margin: 8px 0 0;
  text-align: right;
  font-size: 15px;
}

.pieces {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  font-size: 13px;
  color: var(--paper-soft);
}

.dots {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 4px;
}

.dots span {
  flex: 1;
  height: 2px;
  background: rgba(90, 70, 50, 0.3);
  position: relative;
}

.dots span::before {
  content: "";
  position: absolute;
  left: -4px;
  top: -4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #b9a68a;
}

.dots span.on::before {
  background: #3f6fa8;
  box-shadow: 0 0 0 3px rgba(63, 111, 168, 0.25);
}

.fish-figure {
  display: block;
  width: 100%;
  height: 180px;
  object-fit: contain;
  margin: 4px 0 6px;
}

.big {
  margin: 0;
  font-size: 26px;
  font-weight: 700;
}

.note {
  margin: 8px 0 0;
  color: var(--paper-soft);
  font-size: 14px;
  line-height: 1.7;
}

.summary {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 6px;
  font-size: 16px;
}

.summary li {
  display: flex;
  justify-content: space-between;
  padding: 6px 2px;
  border-bottom: 1px dashed rgba(90, 70, 50, 0.3);
}

.ending-text {
  margin: 0;
  font-size: 16px;
  line-height: 2;
}

.credit {
  margin: 12px 0 0;
  color: var(--paper-soft);
  font-size: 12px;
  line-height: 1.6;
}

.howto-list {
  margin: 0;
  padding-left: 1.4em;
  display: grid;
  gap: 8px;
  font-size: 15px;
  line-height: 1.7;
}

.book {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 12px;
  max-height: min(100%, 640px);
  overflow: hidden;
}

.book-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.book-head h2 {
  margin: 0;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.tab {
  border: 0;
  border-radius: 8px;
  background: rgba(90, 70, 50, 0.1);
  color: var(--paper-ink);
  font-family: var(--serif);
  font-weight: 700;
}

.tab[aria-selected="true"] {
  background: var(--wood);
  color: #fbf1e3;
}

.panel {
  display: grid;
  align-content: start;
  gap: 8px;
  overflow: auto;
}

.entry {
  display: grid;
  grid-template-columns: 2em 1fr auto;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 52px;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.4);
  box-shadow: inset 0 0 0 1px rgba(90, 70, 50, 0.18);
  color: var(--paper-ink);
  font-family: var(--serif);
  text-align: left;
}

.entry .num {
  color: #8a5a3c;
  font-weight: 700;
}

.entry .meta {
  color: var(--paper-soft);
  font-size: 13px;
}

.entry.locked {
  color: rgba(58, 47, 39, 0.45);
}

.menu-card {
  display: grid;
  gap: 10px;
  width: min(100%, 320px);
}

.menu-card h2 {
  margin: 0 0 4px;
  text-align: center;
}

.error {
  position: fixed;
  inset: auto 16px calc(var(--safe-bottom) + 16px);
  margin: 0;
  padding: 14px;
  border-radius: 10px;
  background: #5a1d1d;
  line-height: 1.6;
}

@media (orientation: landscape) and (max-height: 520px) {
  /* 横画面では操作ボタンが右下に並ぶので、桟橋とねこを左下に寄せる */
  .cat-pier {
    --pier-x: -14%;
    --pier-y: 12%;
    left: var(--safe-left);
    width: min(48vw, 96vh);
  }
  .controls {
    left: auto;
    width: min(36vw, 300px);
    margin-inline: 0;
  }
  .title-screen {
    grid-template-rows: auto 1fr;
    grid-template-columns: 1fr 1fr;
    align-items: center;
  }
  .title-count {
    grid-column: 2;
  }
  .title-head {
    grid-row: 2;
    margin-top: 0;
  }
  .logo {
    font-size: clamp(36px, 13vh, 72px);
  }
  .title-menu {
    grid-row: 2;
    margin-top: 0;
  }
  .fish-figure {
    height: 100px;
  }

  .paper {
    padding: 14px 18px 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .toast,
  .sheet {
    animation: none;
  }
}

/* 瓶から紙を取り出し、破れた5枚を一通へ戻す */
.bottle-discovery {
  position: relative;
  width: 220px;
  height: 286px;
  margin: 12px auto 4px;
}
.bottle-body {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 8px 7px rgba(49, 62, 53, 0.15));
}
.bottle-cork {
  position: absolute;
  width: 82px;
  height: auto;
  left: 50%;
  top: -14px;
  transform: translateX(-50%);
}
.bottled-paper {
  position: absolute;
  width: 110px;
  height: 44px;
  left: 50%;
  top: 60%;
  transform: translate(-50%, -50%) rotate(-68deg);
  opacity: 0.85;
  mix-blend-mode: multiply;
}
.extracting .bottle-cork {
  animation: uncork 0.6s ease-out forwards;
}
.extracting .bottled-paper {
  animation: extract-paper 0.75s ease-in forwards;
}
@keyframes uncork {
  to {
    transform: translate(-20%, -35px) rotate(15deg);
    opacity: 0;
  }
}
@keyframes extract-paper {
  to {
    transform: translate(-50%, -185px) rotate(-5deg) scale(1.3);
    opacity: 0;
  }
}
.fragment-tray {
  display: grid;
  gap: 10px;
  padding: 8px 4px;
}
/* 破れた切れ端：形は main.js の clip-path（上下に深い破れ目、左右に小さなささくれ） */
.paper-fragment {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: #4f3b28;
  font: inherit;
  text-align: left;
  transform: rotate(var(--tilt, 0deg));
  filter: drop-shadow(0 2px 1.5px rgba(60, 40, 20, 0.35)) drop-shadow(0 6px 8px rgba(60, 40, 20, 0.18));
}
.piece-paper {
  display: block;
  padding: 26px 24px 28px;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(255, 250, 232, 0.5), transparent 60%),
    radial-gradient(ellipse at 85% 95%, rgba(120, 80, 40, 0.22), transparent 55%),
    url("../assets/web/letter-sheet.webp") center / 160% auto,
    #e6d2a6;
}
.piece-text {
  display: block;
  font-size: 15px;
  line-height: 1.65;
  white-space: pre-line;
  overflow-wrap: anywhere;
}
button.paper-fragment {
  cursor: pointer;
  touch-action: manipulation;
}
button.paper-fragment:focus-visible {
  outline: 3px solid var(--wood);
  outline-offset: 2px;
}
button.paper-fragment:active:not(:disabled) {
  transform: rotate(var(--tilt, 0deg)) scale(0.98);
}
.paper-fragment.wrong {
  animation: piece-wrong 0.4s ease-out;
}
@keyframes piece-wrong {
  25% {
    translate: -8px 0;
  }
  50% {
    translate: 7px 0;
  }
  75% {
    translate: -4px 0;
  }
}

/* つなぐ台：上から順に重ね、隣の破れ目を噛み合わせる（重なりは破れ目の深さ 18px） */
.puzzle-board {
  display: grid;
  min-height: 92px;
  padding: 10px 6px;
  border: 1.5px dashed rgba(110, 85, 60, 0.35);
  border-radius: 8px;
  background: rgba(255, 250, 238, 0.35);
}
.puzzle-board .paper-fragment {
  transform: none;
  animation: piece-snap 0.35s ease-out;
}
.puzzle-board .paper-fragment + .paper-fragment {
  margin-top: -18px;
}
.puzzle-board.joined {
  border-color: transparent;
  background: none;
}
.puzzle-board.joined .paper-fragment {
  filter: drop-shadow(0 0 6px rgba(255, 236, 190, 0.9));
  transition: filter 0.4s;
}
@keyframes piece-snap {
  from {
    opacity: 0.3;
    transform: translateY(14px) scale(0.97);
  }
}
.puzzle-empty {
  align-self: center;
  margin: 0;
  text-align: center;
  color: var(--paper-soft);
  font-size: 13px;
}
.puzzle-status {
  min-height: 1.7em;
  text-align: center;
}
.puzzle-tray .piece-text {
  font-size: 14px;
  line-height: 1.55;
}
.extracted .paper-fragment.newest {
  animation: paper-arrive 0.5s ease-out;
}
@keyframes paper-arrive {
  from {
    opacity: 0;
    translate: 0 -18px;
    rotate: -5deg;
  }
}
.assembling p {
  animation: join-paper 0.9s ease-out both;
}
.assembling p:nth-child(2) {
  --offset: 20px;
  animation-delay: 0.06s;
}
.assembling p:nth-child(3) {
  --offset: -14px;
  animation-delay: 0.12s;
}
.assembling p:nth-child(4) {
  --offset: 18px;
  animation-delay: 0.18s;
}
.assembling p:nth-child(5) {
  --offset: -22px;
  animation-delay: 0.24s;
}
@keyframes join-paper {
  from {
    transform: translate(var(--offset, -18px), 16px) rotate(-2deg);
    background: #ead7ad;
    clip-path: polygon(0 10%, 15% 0, 35% 8%, 55% 0, 75% 10%, 100% 0, 100% 95%, 80% 100%, 60% 91%, 40% 100%, 20% 92%, 0 100%);
  }
  to {
    transform: none;
    background: transparent;
    clip-path: polygon(0 0, 15% 0, 35% 0, 55% 0, 75% 0, 100% 0, 100% 100%, 80% 100%, 60% 100%, 40% 100%, 20% 100%, 0 100%);
  }
}
@media (prefers-reduced-motion: reduce) {
  .cat-pier.casting,
  .cat-pier.hoisting,
  .extracting .bottle-cork,
  .extracting .bottled-paper,
  .extracted .paper-fragment.newest,
  .assembling p,
  .paper-fragment.wrong,
  .puzzle-board .paper-fragment {
    animation-duration: 0.01s;
    animation-delay: 0s;
  }
}

/* 各言語の長い語・文、3つの入り江の操作を狭い縦横画面へ収める。 */
.title-murmur {
  top: calc(var(--safe-top) + 230px);
  white-space: pre-line;
  max-width: 40vw;
}
/* ぱせりいぬゲームズメニュー。全作品共通の形（docs/brain/decisions/asobiba-back-link.md）。ホームの空が明るいので白系 */
.home-portal-menu {
  position: absolute;
  top: max(10px, var(--safe-top));
  left: max(10px, var(--safe-left));
  z-index: 5;
  width: 44px;
  height: 44px;
  color: #07132f;
}
.home-portal-menu:has([data-asobiba-link][hidden]) {
  display: none;
}
.home-portal-menu > summary,
.home-portal {
  box-sizing: border-box;
  min-height: 44px;
  border: 1px solid #07132f33;
  border-radius: 999px;
  background: #ffffffeb;
  color: #07132f;
  box-shadow: 0 6px 16px #0006;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  font:
    800 13px / 1 system-ui,
    sans-serif;
  text-decoration: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.home-portal-menu > summary {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  cursor: pointer;
  list-style: none;
}
.home-portal-menu > summary::-webkit-details-marker {
  display: none;
}
.home-portal-menu > summary::marker {
  content: "";
}
.home-portal-menu[open] > summary svg {
  transform: rotate(180deg);
}
.home-portal {
  position: absolute;
  top: 0;
  left: 50px;
  display: flex;
  align-items: center;
  gap: 4px;
  width: max-content;
  max-width: calc(100vw - 80px);
  padding: 0 14px 0 10px;
  white-space: nowrap;
}
.home-portal-menu:not([open]) > .home-portal,
.home-portal[hidden] {
  display: none;
}
.home-portal-menu svg {
  flex: none;
}
.home-portal-menu > summary:focus-visible,
.home-portal:focus-visible {
  outline: 3px solid #07132f;
  outline-offset: 2px;
}
select:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
.sign {
  min-width: 0;
  max-width: 54%;
  padding: 6px 8px;
  gap: 4px;
}
.sign-text {
  min-width: 0;
  gap: 3px;
}
.sign-place,
.sign-tide {
  letter-spacing: 0;
  overflow-wrap: anywhere;
}
.sign-place {
  font-size: 14px;
}
.stats {
  flex-shrink: 0;
  gap: 4px;
}
.stat {
  min-width: 44px;
  max-width: 68px;
  padding: 4px 6px;
}
.stat-label {
  letter-spacing: 0;
  overflow-wrap: anywhere;
  text-align: center;
}
.hint {
  top: calc(var(--safe-top) + 91px);
}
.toast {
  max-width: calc(100vw - 28px);
  white-space: normal;
  text-align: center;
  top: calc(var(--safe-top) + 140px);
}
.plank,
.paper-button,
.tab {
  letter-spacing: 0.02em;
  overflow-wrap: anywhere;
  padding-block: 8px;
}
.title-menu {
  gap: 7px;
}
.title-menu .plank {
  min-height: 50px;
}
.title-menu .paper-button {
  min-height: 44px;
}
.paper h2,
.title-lead {
  text-wrap: balance;
  overflow-wrap: anywhere;
}
.entry {
  grid-template-columns: 1.6em minmax(0, 1fr) auto;
}
.entry > span {
  overflow-wrap: anywhere;
}
.entry .meta {
  max-width: 100px;
}
.letter-lines p {
  overflow-wrap: anywhere;
}
.ending-text,
.credit {
  white-space: pre-line;
}
#cove-list {
  display: grid;
  gap: 10px;
}
#cove-list [aria-current="true"] {
  box-shadow: inset 0 0 0 2px var(--wood);
}
#cove-list button:disabled {
  opacity: 0.65;
}
html:not([lang="ja"]) .logo {
  font-size: clamp(30px, 9vw, 65px);
  letter-spacing: 0.03em;
}
@media (max-width: 340px) {
  .paper {
    padding-inline: 12px;
  }
  .letter-lines {
    padding-inline: 25px;
  }
  .piece-paper {
    padding-inline: 18px;
  }
}
@media (max-height: 740px) {
  .title-murmur {
    display: none;
  }
}
@media (orientation: landscape) and (max-height: 520px) {
  .title-murmur {
    display: none;
  }
  .title-menu {
    gap: 5px;
    width: min(90%, 300px);
  }
  .title-menu .plank,
  .title-menu .paper-button {
    min-height: 44px;
    padding-block: 4px;
  }
  .title-head {
    max-width: 95%;
  }
  .title-lead {
    margin-top: 6px;
  }
}

/* 短い横画面でも結果の操作を紙の下端に残す。本文と切れ端はスクロールできる。 */
#reveal .sheet-actions {
  position: sticky;
  bottom: 0;
  padding-top: 8px;
  background: var(--paper);
}

.letter-lines {
  border: 0;
  padding: 40px 34px 36px;
  background: url("../assets/web/letter-sheet.webp") center / 100% 100% no-repeat;
  filter: drop-shadow(0 3px 3px rgba(73, 51, 28, 0.12));
}
@media (orientation: landscape) and (max-height: 520px) {
  .bottle-discovery {
    width: 160px;
    height: 208px;
  }
  .bottle-cork {
    width: 60px;
    top: -10px;
  }
  .bottled-paper {
    width: 80px;
    height: 32px;
  }
}

.cove-lock-note {
  display: block;
  margin-top: 5px;
  font-size: 12px;
  font-weight: normal;
}
#share-status:empty {
  display: none;
}
@media (orientation: landscape) and (max-height: 520px) {
  #complete .paper {
    width: min(100%, 560px);
    padding: 12px 16px;
  }
  #complete h2 {
    font-size: 19px;
    margin: 3px 0 8px;
  }
  #complete .ending-text {
    font-size: 16px;
    line-height: 1.45;
    margin: 8px 0;
  }
  #complete .sheet-actions {
    margin-top: 8px;
    gap: 8px;
  }
  #complete button {
    font-size: 16px;
    min-height: 44px;
    padding: 6px 12px;
  }
  html:not([lang="ja"]) .logo {
    font-size: clamp(24px, 4.5vw, 42px);
  }
  .title-screen {
    grid-template-rows: 1fr;
    padding-top: calc(var(--safe-top) + 8px);
    padding-bottom: calc(var(--safe-bottom) + 8px);
  }
  .title-head,
  .title-menu {
    grid-row: 1;
  }
  .title-head {
    min-width: 0;
    width: 90%;
  }
  .title-count {
    position: absolute;
    grid-column: auto;
    grid-row: auto;
    right: auto;
    left: calc(var(--safe-left) + 62px);
    top: calc(var(--safe-top) + 8px);
    z-index: 2;
  }
  .title-menu {
    margin-top: 0;
    max-height: 100%;
    overflow-y: auto;
  }
}

/* ホーム画面: ねこの待つ桟橋の絵を主役にし、題字・主操作・小さな3項目へ整理する。 */
.title-screen {
  grid-template-rows: auto auto 1fr auto;
  /* 画面より広い背景の絵で、フォーカス移動時に横へスクロールさせない。 */
  overflow: hidden;
  /* biome-ignore lint/suspicious/noDuplicateProperties: clip に対応しないブラウザでは前の hidden を使う */
  overflow: clip;
  isolation: isolate;
  background: #6b6385;
}
/* 背景の絵とゆらぐ光を同じ座標系に置く。縦画面は下端合わせで、ねこをボタンの上に見せる。 */
.title-art {
  position: absolute;
  z-index: -2;
  left: 50%;
  bottom: 0;
  height: max(108%, 162vw);
  aspect-ratio: 2 / 3;
  /* 細い縦画面でも右奥の灯台とねこを両方残す。 */
  transform: translateX(-54%);
  pointer-events: none;
}
.title-art::before {
  content: "";
  position: absolute;
  inset: 0;
  background: url("../assets/web/home-bg.webp") center / 100% 100% no-repeat;
  transform-origin: 50% 62%;
  animation: title-drift 40s ease-in-out infinite alternate;
}
/* 題字とボタンの下だけ、絵を少し落ち着かせる。 */
.title-screen::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(120% 30% at 50% 13%, rgba(255, 244, 236, 0.5), transparent 70%),
    linear-gradient(to top, rgba(30, 24, 38, 0.66), rgba(30, 24, 38, 0.18) 24%, transparent 36%);
}
@keyframes title-drift {
  from {
    transform: scale(1);
  }
  to {
    transform: scale(1.025);
  }
}
.title-art i {
  position: absolute;
  display: block;
  border-radius: 50%;
}
/* 夕日の道のきらめき */
.title-shimmer {
  left: 18%;
  width: 26%;
  top: 40%;
  height: 18%;
  border-radius: 0 !important;
  background: repeating-linear-gradient(
    180deg,
    rgba(255, 226, 205, 0) 0 9px,
    rgba(255, 232, 214, 0.55) 9px 10px,
    rgba(255, 226, 205, 0) 10px 19px
  );
  -webkit-mask-image: radial-gradient(50% 50% at 50% 35%, #000 0, transparent 100%);
  mask-image: radial-gradient(50% 50% at 50% 35%, #000 0, transparent 100%);
  mix-blend-mode: screen;
  opacity: 0.5;
  animation: title-shimmer 6s linear infinite;
}
@keyframes title-shimmer {
  from {
    background-position: 0 0;
  }
  to {
    background-position: 0 38px;
  }
}
.title-lantern,
.title-beacon {
  width: 1px;
  height: 1px;
}
.title-lantern {
  left: 29.6%;
  top: 70.5%;
  box-shadow: 0 0 30px 20px rgba(255, 188, 105, 0.3);
  animation: title-flicker 3.2s ease-in-out infinite;
}
.title-beacon {
  left: 83.6%;
  top: 34.6%;
  box-shadow: 0 0 12px 7px rgba(255, 238, 186, 0.6);
  animation: title-beacon 4.5s ease-in-out infinite;
}
@keyframes title-flicker {
  0%,
  100% {
    opacity: 0.9;
  }
  18% {
    opacity: 0.6;
  }
  22% {
    opacity: 1;
  }
  55% {
    opacity: 0.76;
  }
  70% {
    opacity: 0.95;
  }
}
@keyframes title-beacon {
  0%,
  100% {
    opacity: 0.3;
  }
  50% {
    opacity: 1;
  }
}

.title-count {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  /* 右上の歯車（設定）と重ねない */
  margin-right: 50px;
  padding: 6px 12px 6px 9px;
  border: 1px solid rgba(255, 246, 232, 0.55);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(250, 242, 228, 0.92), rgba(236, 222, 198, 0.9));
  box-shadow:
    0 6px 16px rgba(30, 22, 40, 0.28),
    inset 0 1px 0 #fffaf2;
}
.title-count-icon {
  width: 18px;
  height: 18px;
  fill: rgba(126, 170, 172, 0.35);
  stroke: #4f6c74;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.title-head {
  position: relative;
  margin-top: clamp(8px, 3.2vh, 34px);
}
.logo {
  background: linear-gradient(180deg, #2e3e67 0%, #26345a 55%, #4a3f63 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: none;
  filter: drop-shadow(0 0 10px rgba(255, 243, 236, 0.9)) drop-shadow(0 2px 1px rgba(255, 255, 255, 0.7));
}
.logo-roman {
  margin-top: 4px;
  letter-spacing: 0.62em;
  padding-left: 0.62em;
}
.logo-wave {
  width: min(62vw, 230px);
  height: 18px;
  margin: 8px 0 2px;
  overflow: visible;
  fill: none;
  stroke: #9c7a55;
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 4px rgba(255, 244, 236, 0.9));
}
.logo-wave g {
  fill: rgba(170, 214, 214, 0.55);
  stroke: #6f8c90;
}
.logo-wave g path {
  stroke: #9c7a55;
}
.title-lead {
  margin-top: 6px;
  font-size: 14.5px;
}

.title-menu {
  grid-row: 4;
  align-self: end;
  grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
  width: min(88vw, 360px);
  margin: 0 0 calc(58px + 4px);
  gap: 8px;
}
.title-menu .plank {
  position: relative;
  min-height: 60px;
  border-radius: 14px;
  font-size: 21px;
  letter-spacing: 0.18em;
  box-shadow:
    inset 0 1px 0 rgba(255, 230, 200, 0.3),
    inset 0 0 0 1px rgba(0, 0, 0, 0.25),
    0 0 0 2px rgba(243, 201, 139, 0.55),
    0 8px 18px rgba(10, 8, 20, 0.45);
}
.title-menu .plank::before,
.title-menu .plank::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 7px;
  height: 7px;
  margin-top: -3.5px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #f2d7a6, #8c6440);
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.4);
}
.title-menu .plank::before {
  left: 14px;
}
.title-menu .plank::after {
  right: 14px;
}
.title-menu .paper-button {
  min-height: 60px;
  padding-inline: 8px;
  letter-spacing: 0.04em;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(250, 243, 230, 0.96), rgba(234, 219, 192, 0.94));
  box-shadow:
    inset 0 0 0 1px var(--paper-edge),
    inset 0 1px 0 #fffaf2,
    0 6px 14px rgba(10, 8, 20, 0.3);
}
.title-menu .paper-button:disabled {
  opacity: 0.5;
}
.title-sub {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.title-tile {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 3px;
  min-height: 66px;
  padding: 7px 4px 6px;
  border: 1px solid rgba(255, 246, 232, 0.35);
  border-radius: 14px;
  background: rgba(36, 30, 50, 0.52);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  color: #f8efe2;
  font-family: var(--serif);
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0.02em;
  overflow-wrap: break-word;
  word-break: normal;
  -webkit-hyphens: auto;
  hyphens: auto;
  text-align: center;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    0 6px 14px rgba(10, 8, 20, 0.28);
}
/* ラテン文字の言語では題字が英字なので、同じ綴りの小見出しを重ねない。 */
html:is(:lang(en), :lang(es), :lang(fr), :lang(de), :lang(pt)) .logo-roman {
  display: none;
}
.title-tile svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: #f3c98b;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.title-tile:active,
.title-menu .paper-button:active {
  transform: translateY(1px);
}
.title-murmur {
  top: auto;
  bottom: calc(var(--safe-bottom) + 330px);
}

@media (max-height: 700px) {
  .title-menu {
    gap: 7px;
  }
  .title-menu .plank,
  .title-menu .paper-button {
    min-height: 52px;
  }
  .title-tile {
    min-height: 56px;
  }
  .title-lead {
    font-size: 13px;
  }
}
@media (orientation: landscape) and (max-height: 520px) {
  .title-screen {
    grid-template-rows: auto 1fr;
    grid-template-columns: 1fr 1fr;
  }
  .title-screen::after {
    background: linear-gradient(to left, rgba(30, 24, 38, 0.5), transparent 50%);
  }
  /* 横長では海・瓶・ねこが並ぶ帯を見せ、題字は和紙の札に載せて読みやすくする。 */
  .title-art {
    top: 50%;
    bottom: auto;
    height: max(100%, 150vw);
    transform: translate(-50%, -53%);
  }
  .title-head {
    grid-row: 2;
    grid-column: 1;
    align-self: center;
    justify-self: center;
    padding: 12px 18px 14px;
    border-radius: 18px;
    background: rgba(250, 243, 232, 0.78);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    box-shadow: 0 8px 20px rgba(20, 14, 30, 0.3);
  }
  .title-menu {
    grid-row: 2;
    grid-column: 2;
    align-self: center;
    margin: 0;
    width: min(90%, 330px);
  }
  .title-menu .plank,
  .title-menu .paper-button {
    min-height: 48px;
  }
  .title-tile {
    min-height: 52px;
    gap: 2px;
    padding-block: 4px;
    font-size: 11.5px;
  }
  .title-tile svg {
    width: 19px;
    height: 19px;
  }
  .logo-wave {
    margin-top: 4px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .title-art::before,
  .title-art i {
    animation: none;
  }
}
/* 主ボタンの語を途中で折らない。字間は日本語だけ広めにする。 */
.title-menu .plank {
  padding-inline: 24px;
  font-size: clamp(16px, 5.4vw, 21px);
  letter-spacing: 0.05em;
  white-space: nowrap;
  overflow-wrap: normal;
}
html:lang(ja) .title-menu .plank {
  letter-spacing: 0.18em;
}
.title-menu .paper-button {
  white-space: normal;
  overflow-wrap: normal;
  word-break: normal;
  -webkit-hyphens: auto;
  hyphens: auto;
}

/* 日本語は文節の間（phrase.mjs が入れる <wbr>）でだけ改行する。韓国語は語の途中で折らない。 */
html:lang(ja) body {
  word-break: keep-all;
  overflow-wrap: anywhere;
  line-break: strict;
}
html:lang(ko) body {
  word-break: keep-all;
  overflow-wrap: anywhere;
}
html:lang(ja) :is(.howto-list, .note, .ending-text, .letter-lines p, .paper h2) {
  text-wrap: pretty;
}

/* 本文が長いときも、下に固定した操作の帯を紙の地となじませる */
#reveal .sheet-actions {
  padding-top: 14px;
  background: linear-gradient(180deg, rgba(239, 227, 205, 0), rgba(239, 227, 205, 0.96) 14px);
}

/* 完成画面：主の操作を1つ、補助を2つ、移動は控えめな文字の操作にする */
.complete-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 18px;
}
.complete-actions > .plank,
.complete-actions > .paper-button {
  width: 100%;
  padding-inline: 8px;
}
.complete-actions > #complete-next {
  grid-column: 1 / -1;
}
.complete-links {
  grid-column: 1 / -1;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px 18px;
  margin-top: 2px;
  padding-top: 6px;
  border-top: 1px dashed rgba(90, 70, 50, 0.3);
}
.text-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  padding: 0 8px;
  border: 0;
  background: none;
  color: var(--paper-soft);
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-decoration: none;
  text-align: center;
}
.text-button[hidden] {
  display: none;
}
a.text-button::after {
  content: "→";
  margin-left: 6px;
}
.text-button:active {
  color: var(--paper-ink);
}
.text-button:focus-visible {
  outline: 2px solid var(--wood);
  outline-offset: 2px;
  border-radius: 6px;
}
@media (orientation: landscape) and (max-height: 520px) {
  #complete .complete-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin-top: 8px;
  }
  #complete .complete-actions > #complete-next {
    grid-column: auto;
  }
  #complete .complete-actions > #complete-next[hidden] + #complete-share {
    grid-column: 1 / 3;
  }
  #complete .complete-links {
    padding-top: 2px;
  }
}
#complete-heading:focus {
  outline: none;
}
.credit {
  overflow-wrap: normal;
}

/* 横画面のパズルは、つなぐ台と切れ端を左右に並べ、それぞれをスクロールできるようにする */
@media (orientation: landscape) and (max-height: 520px) {
  #reveal .paper:has(.puzzle) {
    width: min(100%, 780px);
  }
  .puzzle {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 14px;
    align-items: start;
  }
  .puzzle-side,
  .puzzle-tray {
    max-height: calc(100dvh - var(--safe-top) - var(--safe-bottom) - 170px);
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  .puzzle-side {
    padding: 2px;
  }
}

/* 読み込み画面：夜の海に瓶が揺れる。開始を押した時点で絵がそろっていなければ出し、そろうと海へ進む */
.loading {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 14px;
  padding: calc(var(--safe-top) + 24px) calc(var(--safe-right) + 24px) calc(var(--safe-bottom) + 24px) calc(var(--safe-left) + 24px);
  background:
    radial-gradient(ellipse at 50% 18%, rgba(255, 214, 170, 0.22), transparent 55%),
    linear-gradient(180deg, #3b3a5c 0%, #2b2d48 55%, #1f2238 100%);
  color: #f6ecdc;
  text-align: center;
  transition: opacity 0.45s ease;
}
.loading.done {
  opacity: 0;
  pointer-events: none;
}
.loading-art {
  width: min(240px, 62vw);
  height: auto;
  transform-origin: 50% 70%;
  animation: bottle-bob 3.2s ease-in-out infinite;
}
@keyframes bottle-bob {
  0%,
  100% {
    transform: translateY(0) rotate(-3deg);
  }
  50% {
    transform: translateY(6px) rotate(3deg);
  }
}
.loading-logo {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(30px, 9vw, 44px);
  font-weight: 700;
  letter-spacing: 0.14em;
  color: #f6ecdc;
}
.loading-bar {
  width: min(240px, 70vw);
  height: 6px;
  border-radius: 999px;
  background: rgba(246, 236, 220, 0.18);
  overflow: hidden;
}
.loading-bar i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #d9b98a, #f6ecdc);
  transition: width 0.25s ease;
}
.loading-status {
  margin: 0;
  font-family: var(--serif);
  font-size: 14px;
  letter-spacing: 0.08em;
  color: rgba(246, 236, 220, 0.85);
  font-variant-numeric: tabular-nums;
}
.loading-status[hidden],
.loading-failed[hidden] {
  display: none;
}
.loading-failed {
  display: grid;
  justify-items: center;
  gap: 10px;
  max-width: 320px;
}
.loading-failed p {
  margin: 0;
  font-family: var(--serif);
  font-size: 14px;
  line-height: 1.7;
}
.loading-failed .text-button {
  color: #f6ecdc;
}
@media (prefers-reduced-motion: reduce) {
  .loading-art {
    animation: none;
  }
  .loading {
    transition: none;
  }
}

/* 遊び方の見直し（2026-10-09） */
/* 遊んだことのある人には「つづきから」を上に置く */
.title-menu.returning #continue-button {
  order: -1;
}
.title-menu .paper-button {
  min-height: 44px;
}

/* 5枚そろった手紙をつなぐ導線（操作ボタンの上と、メニューの印） */
.controls {
  gap: 8px;
}
.join-button {
  justify-self: center;
  min-height: 44px;
  padding-inline: 18px;
  font-size: 15px;
}
.round-button.has-ready::after {
  content: "";
  position: absolute;
  top: 2px;
  right: 2px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #e0634a;
  box-shadow: 0 0 0 2px #f6eadb;
}
#menu-button {
  position: relative;
}

/* はじめの数投は、浮きのそばに言葉で「まだ」「今！」を出す */
.bite-mark.word {
  font-size: 26px;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.bite-mark.word.waiting {
  color: #e8f0ff;
  font-size: 20px;
  text-shadow:
    0 0 10px rgba(30, 40, 80, 0.9),
    0 2px 0 #2a3350;
}

/* 描画が止まったときの案内 */
.error .paper-button {
  display: block;
  margin-top: 10px;
}

/* あそびかたの動く見本（4秒で1周：揺れる→まだ→沈む→今！→ひく） */
.howto-demo {
  position: relative;
  height: 120px;
  margin: 4px 0 14px;
  border-radius: 10px;
  overflow: hidden;
  background: linear-gradient(180deg, #c9b8c8 0%, #9fb0c8 46%, #5f7f9c 47%, #3f5f7e 100%);
}
.howto-demo-sea {
  position: absolute;
  inset: 0 0 auto;
  width: 100%;
  height: 92px;
}
.demo-line {
  fill: none;
  stroke: rgba(40, 30, 30, 0.55);
  stroke-width: 1;
}
.demo-water {
  fill: rgba(63, 95, 126, 0.75);
}
.demo-float {
  animation: demo-float 4s ease-in-out infinite;
}
.demo-ripple {
  fill: none;
  stroke: rgba(255, 255, 255, 0.7);
  stroke-width: 1.2;
  opacity: 0;
  animation: demo-ripple 4s ease-out infinite;
}
.demo-word {
  position: absolute;
  left: 50%;
  top: 4px;
  translate: 8px 0;
  font-weight: 900;
  font-size: 18px;
  white-space: nowrap;
  opacity: 0;
}
.demo-wait {
  color: #fff;
  text-shadow: 0 0 6px rgba(30, 40, 80, 0.9);
  animation: demo-wait 4s step-end infinite;
}
.demo-now {
  color: #fff;
  text-shadow:
    0 0 8px rgba(255, 90, 60, 0.9),
    0 2px 0 #9b2a20;
  animation: demo-now 4s step-end infinite;
}
.demo-button {
  position: absolute;
  right: 12px;
  bottom: 8px;
  min-width: 72px;
  padding: 6px 12px;
  border-radius: 8px;
  background: linear-gradient(180deg, var(--wood-light), var(--wood) 55%, var(--wood-dark));
  color: #fbf1e3;
  font-family: var(--serif);
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  animation: demo-button 4s step-end infinite;
}
.demo-tap {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 34px;
  height: 34px;
  margin: -17px 0 0 -17px;
  border: 3px solid #fff;
  border-radius: 50%;
  opacity: 0;
  animation: demo-tap 4s ease-out infinite;
}
@keyframes demo-float {
  0%,
  10%,
  30% {
    transform: translateY(0);
  }
  20%,
  40% {
    transform: translateY(-2px);
  }
  45%,
  50% {
    transform: translateY(2px);
  }
  55%,
  78% {
    transform: translateY(13px);
  }
  90%,
  100% {
    transform: translateY(0);
  }
}
@keyframes demo-ripple {
  0%,
  54% {
    opacity: 0;
  }
  58% {
    opacity: 1;
  }
  80%,
  100% {
    opacity: 0;
  }
}
@keyframes demo-wait {
  0% {
    opacity: 0;
  }
  25% {
    opacity: 1;
  }
  52%,
  100% {
    opacity: 0;
  }
}
@keyframes demo-now {
  0% {
    opacity: 0;
  }
  55% {
    opacity: 1;
  }
  80%,
  100% {
    opacity: 0;
  }
}
@keyframes demo-button {
  0% {
    background: linear-gradient(180deg, var(--wood-light), var(--wood) 55%, var(--wood-dark));
  }
  55% {
    background: linear-gradient(180deg, #c7714f, #a24d33 55%, #7d3522);
  }
  80% {
    background: linear-gradient(180deg, var(--wood-light), var(--wood) 55%, var(--wood-dark));
  }
}
@keyframes demo-tap {
  0%,
  62% {
    opacity: 0;
    transform: scale(0.6);
  }
  64% {
    opacity: 1;
    transform: scale(0.6);
  }
  76%,
  100% {
    opacity: 0;
    transform: scale(1.4);
  }
}
@media (prefers-reduced-motion: reduce) {
  .demo-float,
  .demo-ripple,
  .demo-wait,
  .demo-now,
  .demo-button,
  .demo-tap {
    animation: none;
  }
  .demo-float {
    transform: translateY(13px);
  }
  .demo-ripple,
  .demo-now,
  .demo-tap {
    opacity: 1;
  }
  .demo-tap {
    transform: scale(1);
  }
  .demo-button {
    background: linear-gradient(180deg, #c7714f, #a24d33 55%, #7d3522);
  }
}

/* 案内文は phrase.ts の <wbr> で文節の間だけ改行する（auto-phrase の推定で語の途中に切れないように） */
html:lang(ja) .hint {
  word-break: keep-all;
}
