:root {
  --font-serif: 'Noto Serif TC', 'Songti TC', 'PMingLiU', serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, monospace;

  /* Paper & Ink Palette */
  --paper: #f3ede2;
  --paper-deep: #e6ddcc;
  --ink: #1f1d1a;
  --ink-soft: #5c554c;
  --ink-faint: #8e8579;
  --rule: #d5cbb9;
  --vermilion: #a8382b;

  /* Atmospheric UI Text (Sky vs Sea separated for crisp readability) */
  --sky-text: #f3efe6;
  --sky-muted: rgba(243, 239, 230, 0.8);
  --sky-line: rgba(243, 239, 230, 0.36);
  --sky-shadow: 0 1px 12px rgba(5, 10, 18, 0.42);

  --sea-text: #f3efe6;
  --sea-muted: rgba(243, 239, 230, 0.8);
  --sea-line: rgba(243, 239, 230, 0.42);
  --sea-btn-bg: rgba(8, 16, 28, 0.28);
  --sea-shadow: 0 1px 10px rgba(5, 10, 18, 0.48);
}

body.theme-day {
  --sky-text: #152330;
  --sky-muted: rgba(21, 35, 48, 0.78);
  --sky-line: rgba(21, 35, 48, 0.34);
  --sky-shadow: 0 1px 8px rgba(240, 246, 250, 0.55);

  --sea-text: #f7f4ec;
  --sea-muted: rgba(247, 244, 236, 0.86);
  --sea-line: rgba(247, 244, 236, 0.56);
  --sea-btn-bg: rgba(20, 42, 58, 0.36);
  --sea-shadow: 0 1px 10px rgba(10, 24, 36, 0.5);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  font-family: var(--font-serif);
  background: #0d1520;
  color: var(--sky-text);
  -webkit-font-smoothing: antialiased;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.hidden {
  display: none !important;
}

/* ===== CANVAS OCEAN & FILM GRAIN ===== */
.ocean-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  display: block;
}

.film-grain {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0.055;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ===== FLOATING BOTTLES ON WATER ===== */
.bottles-layer {
  position: fixed;
  top: 53%;
  left: 0;
  right: 0;
  height: 26%;
  z-index: 3;
  pointer-events: none;
}

.sea-bottle {
  position: absolute;
  pointer-events: auto;
  cursor: pointer;
  background: none;
  border: none;
  min-width: 48px;
  min-height: 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transform: translate(-50%, -50%);
  animation: driftBob var(--bob-dur, 5.2s) ease-in-out infinite;
  animation-delay: var(--bob-delay, 0s);
  transition: transform 0.35s ease, opacity 0.35s ease;
  opacity: 0.86;
}

.sea-bottle:hover {
  opacity: 1;
  transform: translate(-50%, -58%) scale(1.16);
}

.sea-bottle svg {
  width: 22px;
  height: 32px;
  display: block;
}

.sea-bottle::after {
  content: '';
  display: block;
  width: 26px;
  height: 3px;
  margin-top: -3px;
  border-radius: 50%;
  background: rgba(255, 250, 238, 0.28);
  filter: blur(1px);
}

@keyframes driftBob {
  0%, 100% { transform: translate(-50%, -50%) rotate(-12deg); }
  50% { transform: translate(-50%, -56%) rotate(8deg); }
}

/* ===== EDITORIAL VIEWPORT FRAME ===== */
.viewport-frame {
  position: fixed;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  padding:
    max(22px, env(safe-area-inset-top))
    clamp(20px, 4vw, 44px)
    max(22px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr auto;
  transition: opacity 0.4s ease;
}

.viewport-frame.dimmed {
  opacity: 0.16;
}

/* Top Left: Vertical Book Title */
.title-block {
  grid-column: 1;
  grid-row: 1;
  display: flex;
  align-items: flex-start;
  gap: 18px;
}

.title-vertical {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.title-vertical h1 {
  writing-mode: vertical-rl;
  font-size: clamp(1.7rem, 3.2vw, 2.35rem);
  font-weight: 500;
  letter-spacing: 0.34em;
  line-height: 1;
  color: var(--sky-text);
  text-shadow: var(--sky-shadow);
}

body.lang-en .title-block {
  flex-direction: column;
  gap: 10px;
}

body.lang-en .title-vertical {
  flex-direction: row;
  align-items: center;
  gap: 12px;
}

body.lang-en .title-vertical h1 {
  writing-mode: horizontal-tb;
  letter-spacing: 0.14em;
  font-size: clamp(1.45rem, 2.8vw, 2rem);
}

.lang-select {
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  border: none;
  border-bottom: 1px solid transparent;
  color: var(--sky-text);
  text-shadow: var(--sky-shadow);
  font-family: var(--font-serif);
  font-size: 0.82rem;
  letter-spacing: 0.06em;
  padding: 6px 2px;
  cursor: pointer;
  outline: none;
}

.lang-select:hover,
.lang-select:focus {
  border-bottom-color: var(--sky-line);
}

.lang-select option {
  background: #16202e;
  color: #ece7dc;
}

.seal-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: 1px solid #b84233;
  color: #d65545;
  font-size: 0.72rem;
  font-weight: 500;
  border-radius: 2px;
  opacity: 0.92;
}

.title-epigraph {
  margin-top: 4px;
  font-size: 0.84rem;
  line-height: 1.95;
  letter-spacing: 0.08em;
  color: var(--sky-muted);
  text-shadow: var(--sky-shadow);
}

/* Top Right: Quiet Text Controls */
.top-utility {
  grid-column: 2;
  grid-row: 1;
  justify-self: end;
  align-self: start;
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
}

.text-control {
  background: none;
  border: none;
  color: var(--sky-text);
  text-shadow: var(--sky-shadow);
  font-family: var(--font-serif);
  font-size: 0.84rem;
  letter-spacing: 0.08em;
  cursor: pointer;
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  padding: 6px 2px;
  border-bottom: 1px solid transparent;
  transition: border-color 0.25s ease;
}

.text-control:hover {
  border-bottom-color: var(--sky-line);
}

.control-key {
  color: var(--sky-muted);
  font-size: 0.74rem;
}

.sep {
  color: var(--sky-line);
  font-size: 0.8rem;
}

/* Bottom Left: Sea Log */
.sea-log {
  grid-column: 1;
  grid-row: 2;
  align-self: end;
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-shadow: var(--sea-shadow);
}

.mono-meta {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  letter-spacing: 0.12em;
  color: var(--sea-text);
}

.sea-hint {
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  color: var(--sea-muted);
}

/* Bottom Right: Grounded Action Bar */
.action-bar {
  grid-column: 2;
  grid-row: 2;
  justify-self: end;
  align-self: end;
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
}

.action-btn {
  background: var(--sea-btn-bg);
  border: 1px solid var(--sea-line);
  color: var(--sea-text);
  text-shadow: var(--sea-shadow);
  font-family: var(--font-serif);
  font-size: 0.88rem;
  letter-spacing: 0.12em;
  padding: 11px 18px;
  border-radius: 2px;
  cursor: pointer;
  transition: background 0.25s ease, color 0.25s ease, border-color 0.25s ease;
}

.action-btn:hover {
  background: rgba(243, 239, 230, 0.18);
  border-color: var(--sea-text);
}

.action-write {
  background: var(--paper);
  color: var(--ink);
  border-color: var(--paper);
  text-shadow: none;
}

.action-write:hover {
  background: #ffffff;
  color: var(--ink);
  border-color: #ffffff;
}

.count-sup {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  margin-left: 5px;
  opacity: 0.8;
}

/* ===== NOTICE STRIP ===== */
.notice-strip {
  position: fixed;
  top: max(20px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  max-width: calc(100% - 32px);
  padding: 9px 18px;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--rule);
  font-size: 0.82rem;
  letter-spacing: 0.06em;
  text-align: center;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
  animation: fadeSlide 0.25s ease;
}

@keyframes fadeSlide {
  from { opacity: 0; transform: translate(-50%, -6px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ===== PAPER SHEETS (MODALS) ===== */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(9, 13, 19, 0.64);
  animation: fadeOnly 0.22s ease;
}

@keyframes fadeOnly {
  from { opacity: 0; }
  to { opacity: 1; }
}

.paper-sheet {
  width: 100%;
  max-width: 500px;
  max-height: 88dvh;
  overflow-y: auto;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--rule);
  border-radius: 2px;
  padding: 24px 26px 22px;
  box-shadow:
    0 24px 60px rgba(0, 0, 0, 0.42),
    inset 0 0 40px rgba(170, 152, 122, 0.14);
}

/* Paper unroll reveal when opening a letter from a bottle */
.paper-sheet.anim-unroll {
  transform-origin: center top;
  animation: sheetUnroll 0.55s cubic-bezier(0.22, 0.9, 0.32, 1) forwards;
}

@keyframes sheetUnroll {
  0% {
    opacity: 0;
    transform: scaleX(0.28) scaleY(0.72) translateY(16px);
    filter: brightness(0.92);
  }
  55% {
    opacity: 1;
    transform: scaleX(1.02) scaleY(0.98) translateY(0);
  }
  100% {
    opacity: 1;
    transform: scaleX(1) scaleY(1) translateY(0);
    filter: brightness(1);
  }
}

/* Paper roll-up animation when closing or putting back into bottle */
.paper-sheet.anim-rollup {
  transform-origin: center center;
  animation: sheetRollUp 0.42s cubic-bezier(0.55, 0.08, 0.68, 0.53) forwards;
}

@keyframes sheetRollUp {
  0% { opacity: 1; transform: scaleX(1) scaleY(1); }
  70% { opacity: 0.95; transform: scaleX(0.14) scaleY(0.78); }
  100% { opacity: 0; transform: scaleX(0.08) scaleY(0.55) translateY(20px); }
}

.sheet-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 12px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--rule);
}

.mono-tag {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  color: var(--ink-faint);
}

.sheet-close {
  background: none;
  border: none;
  font-family: var(--font-serif);
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  cursor: pointer;
  padding: 4px;
}

.sheet-close:hover {
  color: var(--ink);
}

.sheet-title {
  font-size: 1.2rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}

.sheet-lead {
  font-size: 0.82rem;
  color: var(--ink-soft);
  margin-bottom: 16px;
  line-height: 1.6;
}

/* Tint Selector */
.tint-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.tint-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  background: transparent;
  border: 1px solid var(--rule);
  border-radius: 2px;
  font-family: var(--font-serif);
  font-size: 0.8rem;
  color: var(--ink-soft);
  cursor: pointer;
  transition: all 0.2s ease;
}

.tint-btn.active {
  border-color: var(--ink);
  color: var(--ink);
  background: rgba(31, 29, 26, 0.05);
}

.tint-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

.tint-amber { background: #b8822c; }
.tint-blue { background: #3b6990; }
.tint-green { background: #467860; }
.tint-clear { background: #c5c0b6; border: 1px solid #9e978b; }

/* Lined Stationery Textarea */
.letter-field {
  margin-bottom: 14px;
}

.letter-field textarea {
  width: 100%;
  border: none;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  background: transparent;
  background-image: repeating-linear-gradient(
    to bottom,
    transparent,
    transparent 31px,
    rgba(168, 156, 138, 0.26) 31px,
    rgba(168, 156, 138, 0.26) 32px
  );
  font-family: var(--font-serif);
  font-size: 16px; /* Prevents iOS Safari zoom on focus */
  line-height: 32px;
  color: var(--ink);
  padding: 2px 4px;
  resize: none;
  outline: none;
}

.letter-field textarea::placeholder,
.sub-field input::placeholder {
  color: #a69c8e;
}

.field-foot {
  display: flex;
  justify-content: flex-end;
  margin-top: 4px;
}

.mono-small {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--ink-faint);
}

.sub-field {
  margin-bottom: 14px;
}

.sub-field label {
  display: block;
  font-size: 0.78rem;
  color: var(--ink-soft);
  margin-bottom: 5px;
}

.sub-field input {
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--rule);
  padding: 6px 2px;
  font-family: var(--font-serif);
  font-size: 16px; /* Prevents iOS zoom */
  color: var(--ink);
  outline: none;
}

.sub-field input:focus {
  border-bottom-color: var(--ink);
}

/* Crisis Guardrail */
.crisis-note-box {
  margin: 14px 0;
  padding: 12px 14px;
  border-left: 2px solid var(--vermilion);
  background: rgba(168, 56, 43, 0.06);
  font-size: 0.82rem;
  line-height: 1.7;
  color: #4f201a;
}

.crisis-head {
  font-weight: 600;
  margin-bottom: 4px;
}

.mono-hotlines {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  margin-top: 6px;
}

/* Sheet Submit Buttons */
.sheet-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 18px;
}

.ink-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 12px 10px;
  border-radius: 2px;
  font-family: var(--font-serif);
  font-size: 0.9rem;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-note {
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  opacity: 0.72;
}

.ink-outline {
  background: transparent;
  border: 1px solid var(--ink-faint);
  color: var(--ink);
}

.ink-outline:hover {
  border-color: var(--ink);
  background: rgba(31, 29, 26, 0.04);
}

.ink-solid {
  background: var(--ink);
  border: 1px solid var(--ink);
  color: var(--paper);
}

.ink-solid:hover {
  background: #33302b;
}

/* ===== READ SHEET (PURE SINGLE-LETTER RITUAL) ===== */
.meta-kind {
  font-size: 0.8rem;
  color: var(--ink-soft);
  letter-spacing: 0.06em;
}

.mono-meta-dark {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--ink-faint);
}

.letter-content {
  padding: 4px 0 18px;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 18px;
}

.letter-text {
  font-size: 1.02rem;
  line-height: 2;
  letter-spacing: 0.03em;
  white-space: pre-wrap;
  margin-bottom: 16px;
}

.letter-back {
  padding: 10px 14px;
  border-left: 2px solid var(--rule);
  background: rgba(31, 29, 26, 0.03);
  font-size: 0.85rem;
  line-height: 1.75;
  color: var(--ink-soft);
  margin-bottom: 16px;
}

.back-label {
  display: block;
  font-size: 0.72rem;
  color: var(--ink-faint);
  margin-bottom: 3px;
}

.letter-sign {
  text-align: right;
  font-size: 0.84rem;
  color: var(--ink-soft);
  letter-spacing: 0.06em;
}

/* Tactile Vermilion Ink Stamps */
.stamp-section {
  margin-bottom: 18px;
}

.stamp-caption {
  font-size: 0.76rem;
  color: var(--ink-faint);
  margin-bottom: 10px;
  letter-spacing: 0.06em;
}

.stamp-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.stamp-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: transparent;
  border: 1px dashed var(--rule);
  border-radius: 2px;
  font-family: var(--font-serif);
  font-size: 0.84rem;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  cursor: pointer;
  transition: all 0.2s ease;
}

.stamp-btn:hover {
  border-color: var(--ink-soft);
  color: var(--ink);
}

.stamp-btn.stamped {
  border: 1px solid var(--vermilion);
  color: var(--vermilion);
  background: rgba(168, 56, 43, 0.05);
}

.stamp-num {
  font-family: var(--font-mono);
  font-size: 0.74rem;
}

.read-foot-single {
  padding-top: 2px;
}

.btn-return-sea {
  width: 100%;
  padding: 12px;
}

/* ===== MY BOTTLES LOG ===== */
.mine-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.empty-mine {
  padding: 28px 0;
  text-align: center;
  font-size: 0.88rem;
  color: var(--ink-faint);
  line-height: 1.9;
}

.my-bottle-item {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--rule);
}

.my-bottle-item:last-child {
  border-bottom: none;
}

.my-bottle-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.74rem;
  color: var(--ink-faint);
  margin-bottom: 6px;
}

.my-bottle-text {
  font-size: 0.92rem;
  line-height: 1.8;
  margin-bottom: 8px;
}

.my-bottle-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 0.74rem;
  color: var(--vermilion);
}

/* ===== ABOUT SHEET ===== */
.about-section {
  padding: 12px 0;
  border-bottom: 1px solid var(--rule);
  font-size: 0.85rem;
  line-height: 1.85;
  color: var(--ink-soft);
}

.about-section:last-child {
  border-bottom: none;
  padding-bottom: 2px;
}

.about-section h3 {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}

.about-list {
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.about-support {
  border-left: 2px solid var(--vermilion);
  padding-left: 14px;
  background: rgba(168, 56, 43, 0.04);
}

.about-section a {
  color: var(--ink);
  text-underline-offset: 3px;
}

/* ===== RITUAL ANIMATION STAGE (OPEN & SEAL) ===== */
.ritual-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(9, 14, 21, 0.8);
  animation: fadeOnly 0.2s ease;
}

.ritual-stage {
  position: relative;
  width: 240px;
  height: 240px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ritual-caption {
  margin-top: 12px;
  font-size: 0.9rem;
  letter-spacing: 0.12em;
  text-align: center;
  color: #ece7dc;
  line-height: 1.85;
  min-height: 3.4em;
}

/* Animated Bottle Assembly */
.bottle-assembly {
  position: relative;
  width: 72px;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.bottle-assembly .part-glass {
  position: relative;
  z-index: 2;
  width: 72px;
  height: 112px;
}

.bottle-assembly .part-cork {
  position: absolute;
  top: 2px;
  left: 50%;
  width: 18px;
  height: 14px;
  margin-left: -9px;
  background: #b88d5e;
  border: 1px solid #d4b086;
  border-radius: 2px 2px 1px 1px;
  z-index: 3;
}

.bottle-assembly .part-scroll {
  position: absolute;
  top: 46px;
  left: 50%;
  width: 20px;
  height: 46px;
  margin-left: -10px;
  background: linear-gradient(90deg, #e2d8c5 0%, #f5efe3 45%, #d6cab4 100%);
  border: 1px solid #c2b59e;
  border-radius: 3px;
  z-index: 1;
}

/* --- SEQUENCE A: UNCORK & UNROLL (1.25s) --- */
.seq-open .part-cork {
  animation: corkPopOut 0.45s cubic-bezier(0.2, 0.9, 0.3, 1) 0.12s forwards;
}

.seq-open .part-scroll {
  animation: scrollPullAndUnroll 0.85s cubic-bezier(0.22, 0.85, 0.32, 1) 0.38s forwards;
}

.seq-open .part-glass {
  animation: glassFadeDown 0.55s ease 0.65s forwards;
}

@keyframes corkPopOut {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  45% { transform: translateY(-28px) rotate(-14deg); opacity: 1; }
  100% { transform: translateY(-48px) rotate(-26deg); opacity: 0; }
}

@keyframes scrollPullAndUnroll {
  0% { transform: translateY(0) scaleX(1) scaleY(1); opacity: 1; z-index: 1; }
  48% { transform: translateY(-64px) scaleX(1.1) scaleY(1.05); opacity: 1; z-index: 4; }
  100% { transform: translateY(-24px) scaleX(8.5) scaleY(2.8); opacity: 0; z-index: 4; }
}

@keyframes glassFadeDown {
  0% { transform: translateY(0); opacity: 1; }
  100% { transform: translateY(28px); opacity: 0; }
}

/* --- SEQUENCE B: ROLL PAPER -> INSERT -> CORK -> DRIFT/SINK --- */
.seq-seal .part-scroll {
  top: -42px;
  transform: scaleX(7.5) scaleY(2.4);
  animation: paperRollAndDrop 0.82s cubic-bezier(0.35, 0.1, 0.25, 1) forwards;
}

.seq-seal .part-cork {
  transform: translateY(-42px);
  opacity: 0;
  animation: corkPressIn 0.38s cubic-bezier(0.2, 0.85, 0.3, 1) 0.72s forwards;
}

.seq-seal.release-drift {
  animation: bottleDriftAway 0.95s cubic-bezier(0.28, 0.72, 0.35, 1) 1.1s forwards;
}

.seq-seal.release-sink {
  animation: bottleSinkDown 1.15s ease-in 1.1s forwards;
}

@keyframes paperRollAndDrop {
  0% { transform: translateY(0) scaleX(7.5) scaleY(2.4); opacity: 0.95; z-index: 4; }
  45% { transform: translateY(0) scaleX(1) scaleY(1); opacity: 1; z-index: 4; }
  100% { transform: translateY(88px) scaleX(0.96) scaleY(0.96); opacity: 0.95; z-index: 1; }
}

@keyframes corkPressIn {
  0% { transform: translateY(-38px); opacity: 0; }
  40% { opacity: 1; }
  100% { transform: translateY(0); opacity: 1; }
}

@keyframes bottleDriftAway {
  0% { transform: translate(0, 0) scale(1) rotate(0deg); opacity: 1; }
  38% { transform: translate(26px, -42px) scale(0.84) rotate(14deg); opacity: 1; }
  78% { transform: translate(68px, 10px) scale(0.46) rotate(-10deg); opacity: 0.7; }
  100% { transform: translate(105px, 2px) scale(0.24) rotate(6deg); opacity: 0; }
}

@keyframes bottleSinkDown {
  0% { transform: translateY(0) scale(1) rotate(0deg); opacity: 1; }
  45% { transform: translateY(36px) scale(0.9) rotate(-8deg); opacity: 0.8; }
  100% { transform: translateY(155px) scale(0.55) rotate(10deg); opacity: 0; filter: blur(3px); }
}

.bubble {
  position: absolute;
  bottom: 38%;
  border-radius: 50%;
  border: 1px solid rgba(236, 231, 220, 0.52);
  animation: riseBubble 1.5s ease-out forwards;
}

@keyframes riseBubble {
  0% { transform: translateY(0) scale(0.6); opacity: 0.85; }
  100% { transform: translateY(-130px) scale(1.15); opacity: 0; }
}

/* ===== MOBILE-FIRST POLISH (<= 640px) ===== */
@media (max-width: 640px) {
  .viewport-frame {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr auto;
    padding:
      max(14px, env(safe-area-inset-top))
      18px
      max(18px, env(safe-area-inset-bottom));
  }

  .top-utility {
    position: static;
    grid-column: 1;
    grid-row: 1;
    justify-self: stretch;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding-bottom: 10px;
    margin-bottom: 18px;
    border-bottom: 1px solid var(--sky-line);
  }

  .top-utility .text-control,
  .top-utility .lang-select {
    font-size: 0.78rem;
    padding: 4px 1px;
    letter-spacing: 0.04em;
    white-space: nowrap;
  }

  .top-utility .control-key {
    font-size: 0.72rem;
  }

  .title-block {
    grid-column: 1;
    grid-row: 2;
    gap: 14px;
    align-items: flex-start;
  }

  .title-vertical h1 {
    font-size: 1.55rem;
    letter-spacing: 0.28em;
  }

  .title-epigraph {
    font-size: 0.82rem;
    line-height: 1.85;
  }

  .sea-log {
    grid-column: 1;
    grid-row: 3;
    align-self: end;
    margin-bottom: 14px;
  }

  /* Thumb-zone bottom bar */
  .action-bar {
    grid-column: 1;
    grid-row: 4;
    justify-self: stretch;
    display: grid;
    grid-template-columns: 1.2fr 1.2fr 0.85fr;
    gap: 8px;
  }

  .action-btn {
    padding: 13px 6px;
    font-size: 0.86rem;
    letter-spacing: 0.08em;
    text-align: center;
  }

  /* Compact floating stationery card on mobile (keeps sea visible around it) */
  .sheet-backdrop {
    align-items: center;
    padding: 20px 18px;
    background: rgba(9, 13, 19, 0.5);
  }

  .paper-sheet {
    max-width: 100%;
    max-height: 76dvh;
    border-radius: 3px;
    padding: 18px 18px 16px;
  }

  .sheet-topbar {
    padding-bottom: 8px;
    margin-bottom: 12px;
  }

  .sheet-title {
    font-size: 1.08rem;
    margin-bottom: 4px;
  }

  .sheet-lead {
    font-size: 0.78rem;
    margin-bottom: 12px;
  }

  .tint-row {
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
    margin-bottom: 12px;
  }

  .tint-btn {
    padding: 7px 8px;
    font-size: 0.74rem;
    gap: 6px;
  }

  .letter-field textarea {
    height: 108px;
    line-height: 27px;
    background-image: repeating-linear-gradient(
      to bottom,
      transparent,
      transparent 26px,
      rgba(168, 156, 138, 0.26) 26px,
      rgba(168, 156, 138, 0.26) 27px
    );
  }

  .sub-field {
    margin-bottom: 10px;
  }

  .sheet-actions {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 14px;
  }

  .ink-btn {
    padding: 10px 6px;
    font-size: 0.82rem;
    letter-spacing: 0.06em;
  }

  .letter-content {
    padding: 2px 0 12px;
    margin-bottom: 12px;
  }

  .letter-text {
    font-size: 0.94rem;
    line-height: 1.82;
    margin-bottom: 12px;
  }

  .letter-back {
    padding: 8px 11px;
    font-size: 0.8rem;
    margin-bottom: 10px;
  }

  .stamp-section {
    margin-bottom: 14px;
  }

  .stamp-btn {
    padding: 8px 9px;
    font-size: 0.78rem;
    letter-spacing: 0.04em;
  }
}
