:root {
  color-scheme: dark;
  --ink: #f7fbff;
  --muted: rgba(247, 251, 255, 0.72);
  --line: rgba(255, 255, 255, 0.18);
  --panel: rgba(8, 27, 43, 0.62);
  --panel-strong: rgba(12, 36, 52, 0.84);
  --warm: #ffd08a;
  --coral: #ff8d7c;
  --mint: #8ce6d1;
  --sky: #8ec7ff;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.36);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: #061926;
}

body {
  overflow-x: hidden;
}

button,
textarea {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
}

.gate-screen {
  position: relative;
  display: grid;
  min-height: 100vh;
  overflow: hidden;
  place-items: center;
  padding: 28px;
  isolation: isolate;
}

.ocean-layer {
  position: absolute;
  inset: 0;
  z-index: -3;
  background:
    linear-gradient(180deg, rgba(4, 15, 25, 0.18), rgba(2, 10, 18, 0.54)),
    url("assets/ocean-map.jpg") center / cover;
  transform: scale(1.02);
}

.gate-screen::before {
  position: absolute;
  inset: 0;
  z-index: -2;
  content: "";
  background:
    radial-gradient(circle at 22% 16%, rgba(255, 208, 138, 0.22), transparent 28%),
    radial-gradient(circle at 78% 72%, rgba(140, 230, 209, 0.18), transparent 30%),
    linear-gradient(90deg, rgba(4, 13, 22, 0.72), rgba(4, 13, 22, 0.16) 44%, rgba(4, 13, 22, 0.58));
}

.route-layer {
  position: absolute;
  inset: 0;
  z-index: -1;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.route-layer polyline {
  fill: none;
  stroke: transparent;
  stroke-dasharray: 0.8 1.25;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 0.35;
  filter: drop-shadow(0 0 12px rgba(255, 208, 138, 0.55));
}

.gate-header {
  position: absolute;
  top: 30px;
  left: clamp(20px, 5vw, 72px);
  width: min(500px, calc(100vw - 40px));
}

.gate-header p,
.story-panel p,
.time-card p,
.board-heading p {
  margin: 0 0 10px;
  color: var(--warm);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.gate-header h1 {
  margin: 0 0 16px;
  color: var(--ink);
  font-family: "Songti SC", "STSong", "Noto Serif SC", serif;
  font-size: clamp(34px, 5vw, 62px);
  line-height: 1.08;
  text-wrap: balance;
}

.gate-header span,
.story-panel span {
  display: inline-flex;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 14px;
  color: var(--ink);
  background: rgba(3, 14, 24, 0.4);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.16);
  backdrop-filter: blur(18px);
}

.map-stage {
  position: relative;
  width: min(1080px, calc(100vw - 32px));
  height: min(610px, calc(100vh - 170px));
  min-height: 430px;
}

.port {
  position: absolute;
  display: flex;
  align-items: center;
  width: max-content;
  min-width: 86px;
  max-width: 126px;
  min-height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  padding: 7px 11px 7px 8px;
  color: var(--ink);
  background: rgba(4, 18, 30, 0.46);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.22);
  transform: translate(-50%, -50%);
  transition: border-color 180ms ease, background 180ms ease, opacity 180ms ease;
  backdrop-filter: blur(18px);
  gap: 8px;
  text-align: left;
}

.port::before {
  flex: 0 0 auto;
  width: 10px;
  height: 10px;
  border: 2px solid var(--warm);
  border-radius: 50%;
  content: "";
  box-shadow: 0 0 0 5px rgba(255, 208, 138, 0.12), 0 0 18px rgba(255, 208, 138, 0.48);
}

.port strong {
  font-size: 14px;
  line-height: 1.1;
  white-space: nowrap;
}

.port span {
  display: none;
}

.port.is-done {
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(4, 18, 30, 0.46);
}

.port.is-touched {
  border-color: rgba(255, 208, 138, 0.78);
  background: rgba(44, 35, 27, 0.62);
  box-shadow: 0 0 0 4px rgba(255, 208, 138, 0.14), 0 18px 42px rgba(0, 0, 0, 0.24);
}

.boat {
  position: absolute;
  left: 10%;
  top: 72%;
  z-index: 3;
  display: block;
  width: 94px;
  height: 76px;
  border: 0;
  border-radius: 0;
  color: #503414;
  background: transparent;
  filter: drop-shadow(0 16px 22px rgba(0, 0, 0, 0.34));
  cursor: grab;
  touch-action: none;
  transform: translate(-50%, -50%);
}

.boat::before {
  position: absolute;
  left: 45px;
  top: 13px;
  width: 3px;
  height: 42px;
  border-radius: 999px;
  background: #7c5941;
  content: "";
}

.boat::after {
  position: absolute;
  left: 12px;
  right: 10px;
  bottom: 5px;
  height: 12px;
  border-radius: 50%;
  background: rgba(142, 199, 255, 0.24);
  content: "";
  filter: blur(2px);
}

.boat:active {
  cursor: grabbing;
}

.boat-sail {
  position: absolute;
  left: 47px;
  top: 8px;
  z-index: 2;
  display: grid;
  width: 31px;
  height: 42px;
  color: #cf6357;
  background: linear-gradient(145deg, #fff9e9, #ffd697);
  clip-path: polygon(0 100%, 100% 100%, 0 0);
  font-size: 14px;
  font-weight: 800;
  place-items: end start;
  padding: 0 0 7px 5px;
}

.boat-hull {
  position: absolute;
  left: 14px;
  bottom: 17px;
  width: 68px;
  height: 20px;
  border-radius: 6px 6px 26px 26px;
  background: linear-gradient(180deg, #e08a66, #945039);
  box-shadow: inset 0 -5px 0 rgba(74, 38, 28, 0.28);
}

.boat-hull::before {
  position: absolute;
  left: 7px;
  right: 7px;
  top: 3px;
  height: 3px;
  border-radius: 999px;
  background: rgba(255, 231, 190, 0.48);
  content: "";
}

.route-dock {
  position: absolute;
  right: clamp(18px, 4vw, 60px);
  bottom: 30px;
  display: flex;
  max-width: min(760px, calc(100vw - 36px));
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 11px 13px;
  gap: 10px;
  background: rgba(2, 11, 18, 0.44);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  overflow-x: auto;
}

.route-chip {
  flex: 0 0 auto;
  width: 12px;
  height: 12px;
  border-radius: 999px;
  padding: 0;
  background: rgba(255, 255, 255, 0.32);
}

.route-chip.is-active {
  background: var(--warm);
  box-shadow: 0 0 18px rgba(255, 208, 138, 0.74);
}

.route-chip.is-done {
  background: rgba(255, 255, 255, 0.32);
}

.home-screen {
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(5, 20, 30, 0.2), #071923 620px),
    url("assets/ocean-map.jpg") center top / cover fixed;
}

.is-hidden {
  display: none;
}

.home-hero {
  min-height: auto;
  padding: 24px clamp(18px, 4vw, 56px) 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0 auto 38px;
  max-width: 1180px;
}

.topbar > div {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 12px;
}

.brand-mark {
  display: inline-grid;
  width: 74px;
  height: 36px;
  border: 1px solid rgba(255, 208, 138, 0.42);
  border-radius: 999px;
  color: var(--warm);
  background: rgba(255, 208, 138, 0.1);
  font-size: 13px;
  font-weight: 800;
  place-items: center;
}

.topbar strong {
  overflow-wrap: anywhere;
}

.soft-button,
.primary-button,
.reply-form button {
  border: 0;
  border-radius: 999px;
  color: #061926;
  background: var(--ink);
  cursor: pointer;
  font-weight: 800;
}

.soft-button {
  min-height: 40px;
  padding: 0 16px;
}

button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.hero-grid {
  display: grid;
  align-items: center;
  grid-template-columns: minmax(210px, 0.9fr) minmax(260px, 1.1fr) minmax(210px, 0.9fr);
  max-width: 1080px;
  margin: 0 auto;
  gap: 14px;
}

.time-card,
.story-panel,
.message-board {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}

.time-card {
  min-height: 210px;
  padding: 20px;
}

.time-card h2 {
  margin: 0;
  font-size: clamp(24px, 3vw, 38px);
  line-height: 1;
}

.time-card time {
  display: block;
  margin: 24px 0 16px;
  font-size: clamp(40px, 4.4vw, 58px);
  font-weight: 800;
  letter-spacing: 0;
}

.weather-line {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
}

.weather-line span {
  display: grid;
  min-width: 42px;
  height: 34px;
  border-radius: 999px;
  color: #061926;
  background: var(--warm);
  font-size: 13px;
  font-weight: 800;
  place-items: center;
}

.story-panel {
  display: flex;
  min-height: 210px;
  padding: clamp(22px, 3.4vw, 34px);
  flex-direction: column;
  justify-content: center;
  text-align: center;
}

.story-panel h1 {
  margin: 0;
  font-family: "Songti SC", "STSong", "Noto Serif SC", serif;
  font-size: clamp(30px, 4.2vw, 54px);
  line-height: 1.08;
  text-wrap: balance;
}

.message-board {
  width: min(960px, calc(100vw - 36px));
  margin: 8px auto 0;
  padding: clamp(18px, 3vw, 30px);
  background: var(--panel-strong);
}

.board-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.board-heading h2 {
  margin: 0;
  font-size: clamp(26px, 4vw, 42px);
}

#speakerBadge {
  border: 1px solid rgba(140, 230, 209, 0.35);
  border-radius: 999px;
  padding: 9px 13px;
  color: var(--mint);
  white-space: nowrap;
}

.composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  margin-bottom: 22px;
}

.composer textarea {
  min-height: 108px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  color: var(--ink);
  outline: 0;
  background: rgba(255, 255, 255, 0.08);
}

.composer textarea:focus {
  border-color: rgba(255, 208, 138, 0.7);
  box-shadow: 0 0 0 4px rgba(255, 208, 138, 0.11);
}

.primary-button {
  align-self: stretch;
  min-width: 118px;
  background: var(--warm);
}

.messages {
  display: grid;
  gap: 12px;
}

.empty-state {
  margin: 0;
  border: 1px dashed rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  padding: 20px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.05);
}

.message {
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 8px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.07);
}

.message-head {
  display: grid;
  align-items: center;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  margin-bottom: 10px;
}

.message-author {
  color: var(--warm);
  font-weight: 800;
}

.message-time {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  justify-self: end;
  gap: 6px;
  max-width: min(100%, 520px);
}

.time-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 999px;
  padding: 4px 9px 4px 5px;
  color: rgba(247, 251, 255, 0.74);
  background: rgba(255, 255, 255, 0.06);
  font-size: 12px;
  gap: 7px;
  line-height: 1;
}

.time-pill b {
  display: inline-grid;
  min-width: 50px;
  height: 20px;
  border-radius: 999px;
  color: #061926;
  font-size: 11px;
  place-items: center;
}

.time-pill-china b {
  background: var(--warm);
}

.time-pill-canada b {
  background: var(--mint);
}

.message p {
  margin: 0;
  color: rgba(247, 251, 255, 0.9);
  line-height: 1.7;
}

.reply-button {
  border: 0;
  margin-top: 12px;
  padding: 0;
  color: var(--mint);
  background: transparent;
  cursor: pointer;
  font-weight: 800;
}

.reply-form {
  display: grid;
  grid-template-columns: 1fr auto;
  margin-top: 12px;
  gap: 10px;
}

.reply-form input {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 11px 14px;
  color: var(--ink);
  outline: 0;
  background: rgba(0, 0, 0, 0.18);
}

.reply-form button {
  padding: 0 14px;
  background: var(--mint);
}

.replies {
  display: grid;
  margin-top: 12px;
  gap: 8px;
}

.reply {
  border-left: 3px solid rgba(140, 230, 209, 0.62);
  padding: 8px 0 8px 12px;
  color: var(--muted);
}

.reply-head {
  align-items: center;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 12px;
  margin-bottom: 8px;
}

.reply strong {
  color: var(--mint);
  font-size: 13px;
}

.reply .message-time {
  justify-content: flex-end;
}

.reply p {
  margin: 0;
  line-height: 1.6;
}

@media (max-width: 860px) {
  .gate-screen {
    padding: 18px;
  }

  .gate-header {
    top: 20px;
  }

  .map-stage {
    height: calc(100vh - 220px);
    min-height: 500px;
    margin-top: 70px;
  }

  .port {
    min-width: 76px;
    max-width: 108px;
    min-height: 34px;
    padding: 6px 9px 6px 7px;
  }

  .port strong {
    font-size: 12px;
  }

  .route-dock {
    left: 18px;
    right: 18px;
    bottom: 18px;
  }

  .topbar,
  .board-heading,
  .composer {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar {
    margin-bottom: 24px;
  }

  .hero-grid,
  .composer {
    grid-template-columns: 1fr;
  }

  .message-head,
  .reply-head {
    grid-template-columns: 1fr;
  }

  .message-time {
    justify-content: flex-end;
    width: 100%;
  }

  .time-card,
  .story-panel {
    min-height: auto;
  }

  .time-card time {
    margin: 18px 0 14px;
  }

  #speakerBadge {
    width: fit-content;
    white-space: normal;
  }
}

@media (max-width: 520px) {
  .gate-header h1 {
    font-size: 34px;
  }

  .boat {
    width: 76px;
    height: 76px;
  }

  .port strong {
    font-size: 13px;
  }

  .reply-form {
    grid-template-columns: 1fr;
  }

  .reply-form button {
    min-height: 40px;
  }
}
