/* ── Reset ────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  background: #1a2a35;
  -webkit-font-smoothing: antialiased;
}

/* ── Ocean world ─────────────────────────────────────────────────────────── */

#ocean {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

#sky-layer {
  position: absolute;
  top: -60px; left: 0;
  display: flex;
  width: max-content;
  z-index: 5;
}

#sky-layer img { display: block; }

/* Waves — left:50% + translateX(-50%) in keyframes = centered */
.wave {
  position: absolute;
  left: 50%;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1.5s ease;
}
.wave.visible { opacity: 1; }
.wave3 { width: 1553px; bottom: 105px;  z-index: 10; }
.wave2 { width: 1553px; bottom: -8px;   z-index: 20; }
.wave1 { width: 1454px; bottom: -132px; z-index: 40; }

.bottle {
  position: absolute;
  width: 600px;
  bottom: -33px;
  left: 50%;
  z-index: 35;
  pointer-events: none;
  opacity: 0;
  transition: opacity 2s ease;
  filter: drop-shadow(6px 6px 16px rgba(0,0,0,0.4));
}
.bottle.visible { opacity: 1; }

.wave-undulate-1 { animation: wave-undulate-1 15.6s linear infinite; }
.wave-undulate-2 { animation: wave-undulate-2 19.5s linear infinite 0.5s both; }
.wave-undulate-3 { animation: wave-undulate-3 23.4s linear infinite 1s both; }
.bottle-float    { animation: bottle-float 17.55s linear infinite 0.3s; }
.sky-scroll      { animation: sky-scroll 800s linear infinite; }

@keyframes wave-undulate-1 {
  0%,100% { transform: translateX(-50%) translateY(0)   scale(1.3); }
  25%     { transform: translateX(calc(-50% + 25px)) translateY(-8px)  scale(1.3); }
  50%     { transform: translateX(-50%) translateY(-12px) scale(1.3); }
  75%     { transform: translateX(calc(-50% - 25px)) translateY(-8px)  scale(1.3); }
}
@keyframes wave-undulate-2 {
  0%,100% { transform: translateX(-50%) translateY(0)    scaleX(1.25); }
  25%     { transform: translateX(calc(-50% - 30px)) translateY(-10px) scaleX(1.25); }
  50%     { transform: translateX(-50%) translateY(-15px) scaleX(1.25); }
  75%     { transform: translateX(calc(-50% + 30px)) translateY(-10px) scaleX(1.25); }
}
@keyframes wave-undulate-3 {
  0%,100% { transform: translateX(-50%) translateY(0)    scaleX(1.25); }
  25%     { transform: translateX(calc(-50% + 20px)) translateY(-12px) scaleX(1.25); }
  50%     { transform: translateX(-50%) translateY(-18px) scaleX(1.25); }
  75%     { transform: translateX(calc(-50% - 20px)) translateY(-12px) scaleX(1.25); }
}
@keyframes bottle-float {
  0%,100% { transform: translateX(-50%)            translateY(0)     rotate(-3deg); }
  25%     { transform: translateX(calc(-50% - 35px)) translateY(-15px) rotate(0deg); }
  50%     { transform: translateX(-50%)            translateY(-25px) rotate(3deg); }
  75%     { transform: translateX(calc(-50% + 35px)) translateY(-15px) rotate(0deg); }
}
@keyframes sky-scroll {
  0%   { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

/* ── Begin journey button ────────────────────────────────────────────────── */

#begin-btn {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 50;
  background: none;
  border: none;
  font-family: Georgia, serif;
  font-size: 1.5rem;
  color: #b8956a;
  text-decoration: underline;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.3s;
  padding: 8px;
  letter-spacing: 0.02em;
}

/* ── Title ───────────────────────────────────────────────────────────────── */

#title-block {
  position: fixed;
  top: 20vh;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  z-index: 8;
  opacity: 0;
  pointer-events: none;
  transition: opacity 1s;
}
#title-block.visible { opacity: 1; pointer-events: auto; }

#title-word {
  font-family: Georgia, serif;
  font-size: 3.75rem;
  color: #b8956a;
  letter-spacing: 0.04em;
  display: block;
  margin-bottom: 1.5rem;
}

#enter-btn {
  font-family: Georgia, serif;
  font-size: 1.1rem;
  color: #b8956a;
  text-decoration: underline;
  background: none;
  border: none;
  cursor: pointer;
  letter-spacing: 0.01em;
}

/* ── Paper layer ─────────────────────────────────────────────────────────── */

#paper-layer {
  position: fixed;
  inset: 0;
  z-index: 9;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2.5vh 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.8s;
}
#paper-layer.visible { opacity: 1; }

#paper-layer img {
  width: auto;
  height: 123.5vh;
  max-width: 120vw;
  object-fit: contain;
  transform: scaleX(1.265) translateY(30px);
}

/* ── Check-in card ───────────────────────────────────────────────────────── */

#card {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.6s;
}
#card.visible { opacity: 1; pointer-events: auto; }

.stage {
  width: 100%;
  max-width: 340px;
  padding: 0 24px;
  text-align: center;
  display: none;
}
.stage.active { display: block; }

.stage-prompt {
  font-family: Georgia, serif;
  font-size: 1.2rem;
  font-style: italic;
  color: #b8956a;
  letter-spacing: 0.01em;
  margin-bottom: 2.5rem;
  line-height: 1.5;
}

/* State buttons */
.state-btn {
  display: block;
  width: 100%;
  background: none;
  border: none;
  font-family: Georgia, serif;
  font-size: 2.6rem;
  letter-spacing: 0.06em;
  cursor: pointer;
  padding: 0.3rem 0;
  transition: letter-spacing 0.2s, opacity 0.15s;
  line-height: 1.3;
}
.state-btn:hover { letter-spacing: 0.12em; }

.state-flowing  { color: #8badb1; }
.state-holding  { color: #a5c9b8; }
.state-slipping { color: #b8956a; }
.state-sinking  { color: #9e7b5a; }

/* Driver pills */
.drivers-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-bottom: 2rem;
}

.driver-pill {
  background: rgba(184,149,106,0.1);
  border: 1px solid rgba(184,149,106,0.3);
  border-radius: 20px;
  padding: 7px 16px;
  font-family: Georgia, serif;
  font-size: 0.88rem;
  color: #b8956a;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  letter-spacing: 0.01em;
}
.driver-pill:hover     { background: rgba(184,149,106,0.18); }
.driver-pill.selected  { background: rgba(184,149,106,0.25); border-color: #b8956a; }

/* Text input */
.honest-input {
  width: 100%;
  background: none;
  border: none;
  border-bottom: 1px solid rgba(184,149,106,0.35);
  outline: none;
  font-family: Georgia, serif;
  font-style: italic;
  font-size: 0.95rem;
  color: #b8956a;
  text-align: center;
  padding: 6px 0;
  letter-spacing: 0.02em;
  margin-bottom: 2rem;
}
.honest-input::placeholder { color: rgba(184,149,106,0.45); }

/* Action links */
.action-row {
  display: flex;
  justify-content: center;
  gap: 28px;
  margin-top: 0.5rem;
}

.action-link {
  font-family: Georgia, serif;
  font-size: 0.82rem;
  color: rgba(184,149,106,0.7);
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: underline;
  letter-spacing: 0.02em;
  transition: color 0.15s;
}
.action-link:hover { color: #b8956a; }
.action-link.primary {
  color: #b8956a;
  font-size: 0.9rem;
}

/* Continue button */
.continue-btn {
  display: inline-block;
  font-family: Georgia, serif;
  font-size: 0.9rem;
  color: #b8956a;
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: underline;
  letter-spacing: 0.02em;
  margin-top: 1rem;
  transition: opacity 0.2s;
}
.continue-btn:disabled { opacity: 0.3; cursor: default; }

/* Done / reflection */
.reflection-text {
  font-family: Georgia, serif;
  font-size: 1.2rem;
  font-style: italic;
  color: #b8956a;
  line-height: 1.7;
  letter-spacing: 0.01em;
  margin-bottom: 3rem;
}

/* Exit glyph */
.exit-glyph {
  font-size: 1.8rem;
  color: #8badb1;
  background: none;
  border: none;
  cursor: pointer;
  opacity: 0;
  transition: opacity 1s;
  display: block;
  margin: 0 auto;
}
.exit-glyph.visible { opacity: 0.35; }

/* Say more */
.say-more-toggle {
  font-family: Georgia, serif;
  font-size: 0.78rem;
  font-style: italic;
  color: rgba(184,149,106,0.55);
  background: none;
  border: none;
  cursor: pointer;
  transition: color 0.2s;
  margin-bottom: 2rem;
  display: inline-block;
}
.say-more-toggle:hover { color: rgba(184,149,106,0.9); }

/* ── Recovery map ────────────────────────────────────────────────────────── */

#map-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(6px);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 20px;
}
#map-overlay.visible {
  display: flex;
}

#map-card {
  background: rgba(26,42,53,0.95);
  border: 1px solid rgba(184,149,106,0.2);
  border-radius: 16px;
  padding: 28px 24px;
  max-width: 420px;
  width: calc(100% - 32px);
}

#map-title {
  font-family: Georgia, serif;
  font-size: 1rem;
  font-style: italic;
  color: #b8956a;
  text-align: center;
  margin-bottom: 20px;
  letter-spacing: 0.02em;
}

#map-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: flex-start;
  margin-bottom: 16px;
}

.map-dot {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  cursor: default;
  position: relative;
  flex-shrink: 0;
}
.map-dot.flowing  { background: rgba(139,173,177,0.7); }
.map-dot.holding  { background: rgba(165,201,184,0.7); }
.map-dot.slipping { background: rgba(184,149,106,0.7); }
.map-dot.sinking  { background: rgba(158,123,90,0.7);  }
.map-dot.empty    { background: rgba(255,255,255,0.06); }

.map-legend {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-family: Georgia, serif;
  font-size: 0.72rem;
  color: rgba(184,149,106,0.6);
}
.legend-dot {
  width: 10px; height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}

#map-close {
  font-family: Georgia, serif;
  font-size: 0.82rem;
  color: rgba(184,149,106,0.5);
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: underline;
  transition: color 0.15s;
}
#map-close:hover { color: #b8956a; }

/* ── Anonymous presence ──────────────────────────────────────────────────── */

#presence-line {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  font-family: Georgia, serif;
  font-size: 0.72rem;
  font-style: italic;
  color: rgba(184,149,106,0.45);
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1s;
  white-space: nowrap;
}
#presence-line.visible { opacity: 1; }

/* ── Map + history link ──────────────────────────────────────────────────── */

#map-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 50;
  font-family: Georgia, serif;
  font-size: 0.72rem;
  font-style: italic;
  color: rgba(184,149,106,0.4);
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: underline;
  opacity: 0;
  transition: opacity 1s, color 0.15s;
}
#map-btn:hover { color: rgba(184,149,106,0.8); }
#map-btn.visible { opacity: 1; }

/* ── Key save nudge ──────────────────────────────────────────────────────── */

#key-nudge {
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: 60;
  background: rgba(26,42,53,0.92);
  border: 1px solid rgba(184,149,106,0.25);
  border-radius: 12px;
  padding: 12px 16px;
  max-width: 260px;
  display: none;
}
#key-nudge.visible { display: block; }

#key-nudge p {
  font-family: Georgia, serif;
  font-size: 0.78rem;
  color: rgba(184,149,106,0.75);
  line-height: 1.55;
  margin-bottom: 10px;
  font-style: italic;
}
#key-nudge-actions {
  display: flex;
  gap: 14px;
  align-items: center;
}
.nudge-btn {
  font-family: Georgia, serif;
  font-size: 0.75rem;
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: underline;
  letter-spacing: 0.01em;
}
.nudge-btn.primary { color: #b8956a; }
.nudge-btn.muted   { color: rgba(184,149,106,0.4); }

/* ── Wallet restore overlay ──────────────────────────────────────────────── */
/* (wallet.js injects modals dynamically — these are fallback vars) */
:root {
  --surface: rgba(26,42,53,0.96);
  --surface2: rgba(26,42,53,0.8);
  --border: rgba(184,149,106,0.2);
  --text: #e8ddd0;
  --text-muted: rgba(184,149,106,0.55);
  --accent: #b8956a;
  --danger: #e07070;
}

/* ── Anchor indicator ────────────────────────────────────────────────────── */

#wallet-btn {
  position: fixed;
  top: 14px;
  right: 18px;
  z-index: 100;
  background: none;
  border: none;
  cursor: pointer;
  color: #1e3a5f;
  padding: 8px;
  line-height: 0;
  transition: color 0.4s, opacity 0.4s;
  opacity: 0.7;
}
#wallet-btn.active { color: #1e3a5f; opacity: 1; }
#wallet-btn:hover  { color: #1e3a5f; opacity: 1; }

.wallet-menu {
  position: fixed;
  background: rgba(22,36,46,0.97);
  border: 1px solid rgba(184,149,106,0.18);
  border-radius: 12px;
  padding: 6px;
  z-index: 500;
  min-width: 164px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.45);
}
.wallet-menu-item {
  display: block;
  width: 100%;
  background: none;
  border: none;
  padding: 9px 14px;
  text-align: left;
  cursor: pointer;
  font-family: Georgia, serif;
  font-size: 0.82rem;
  color: rgba(184,149,106,0.65);
  border-radius: 8px;
  white-space: nowrap;
}
.wallet-menu-item:hover { background: rgba(184,149,106,0.08); color: #b8956a; }
.wallet-menu-item.danger { color: rgba(200,80,80,0.6); }
.wallet-menu-item.danger:hover { background: rgba(200,80,80,0.08); color: rgba(220,80,80,0.9); }
.wallet-menu-sep { height: 1px; background: rgba(184,149,106,0.1); margin: 4px 8px; }

/* ── Notes overlay ───────────────────────────────────────────────────────── */

#notes-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
  background: rgba(10,20,28,0.5);
}
#notes-overlay.visible { opacity: 1; pointer-events: auto; }

#notes-card {
  background: rgba(22,36,46,0.97);
  border: 1px solid rgba(184,149,106,0.15);
  border-radius: 20px;
  padding: 22px 24px 18px;
  width: calc(100% - 48px);
  max-width: 420px;
  height: 52vh;
  display: flex;
  flex-direction: column;
}

#notes-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  flex-shrink: 0;
}

#notes-date {
  font-family: Georgia, serif;
  font-size: 0.78rem;
  font-style: italic;
  color: rgba(184,149,106,0.45);
}

#notes-status {
  font-family: Georgia, serif;
  font-size: 0.68rem;
  font-style: italic;
  color: rgba(184,149,106,0.3);
  transition: opacity 0.6s;
}

#notes-input {
  flex: 1;
  width: 100%;
  background: none;
  border: none;
  resize: none;
  font-family: Georgia, serif;
  font-size: 0.88rem;
  line-height: 1.75;
  color: rgba(232,221,208,0.78);
  outline: none;
  caret-color: #b8956a;
}
#notes-input::placeholder {
  color: rgba(184,149,106,0.2);
  font-style: italic;
}

#notes-close {
  font-family: Georgia, serif;
  font-size: 0.82rem;
  color: rgba(184,149,106,0.38);
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: underline;
  transition: color 0.15s;
}
#notes-close:hover { color: #b8956a; }

/* ── History overlay ─────────────────────────────────────────────────────── */

#history-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
  background: rgba(10,20,28,0.5);
}
#history-overlay.visible { opacity: 1; pointer-events: auto; }

#history-card {
  background: rgba(22,36,46,0.97);
  border: 1px solid rgba(184,149,106,0.15);
  border-radius: 20px;
  padding: 28px 24px 20px;
  width: calc(100% - 48px);
  max-width: 380px;
  max-height: 70vh;
  overflow-y: auto;
}

#history-title {
  font-family: Georgia, serif;
  font-size: 1.0rem;
  font-style: italic;
  color: rgba(184,149,106,0.55);
  text-align: center;
  margin-bottom: 20px;
  letter-spacing: 0.02em;
}

#history-list { display: flex; flex-direction: column; }

.history-entry {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(184,149,106,0.07);
}
.history-entry:last-child { border-bottom: none; }

.history-date {
  font-family: Georgia, serif;
  font-size: 0.7rem;
  color: rgba(184,149,106,0.35);
  min-width: 58px;
  padding-top: 2px;
  flex-shrink: 0;
}

.history-right { flex: 1; }

.history-state {
  font-family: Georgia, serif;
  font-size: 0.82rem;
}
.history-state.flowing  { color: #8badb1; }
.history-state.holding  { color: #a5c9b8; }
.history-state.slipping { color: #b8956a; }
.history-state.sinking  { color: #9e7b5a; }

.history-drivers {
  font-family: Georgia, serif;
  font-size: 0.68rem;
  color: rgba(184,149,106,0.32);
  font-style: italic;
  margin-top: 2px;
}

.history-anchor {
  font-family: Georgia, serif;
  font-size: 0.72rem;
  color: rgba(184,149,106,0.45);
  font-style: italic;
  margin-top: 3px;
}

.history-empty {
  text-align: center;
  font-family: Georgia, serif;
  font-style: italic;
  font-size: 0.82rem;
  color: rgba(184,149,106,0.28);
  padding: 24px 0;
}

#history-close {
  font-family: Georgia, serif;
  font-size: 0.82rem;
  color: rgba(184,149,106,0.38);
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: underline;
  transition: color 0.15s;
}
#history-close:hover { color: #b8956a; }
