:root {
  --bg: #04060b;
  --ink: #e8eefc;
  --dim: #8b98b4;
  --line: rgba(120, 150, 200, 0.16);
  --warm: #ffb45c;
  --cyanish: #7fd6ff;
  --glass: rgba(10, 15, 26, 0.72);
  --radius: 18px;
}

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

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.7 "Noto Serif SC", "Songti SC", "Source Han Serif SC", Georgia, serif;
  overscroll-behavior: none;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }

/* ---------- 全屏场景 ---------- */

.scene { position: fixed; inset: 0; overflow: hidden; background: #04060b; }
.scene-layer { position: absolute; inset: 0; opacity: 1; transition: opacity 0.45s ease; }
.scene-layer.fading { opacity: 0.12; }
.scene-layer iframe, .scene-layer > iframe {
  display: block; width: 100%; height: 100%; border: 0;
}
.vignette {
  position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(120% 80% at 50% 42%, transparent 40%, rgba(2, 4, 8, 0.72) 100%),
    linear-gradient(180deg, rgba(2, 4, 8, 0.55) 0%, transparent 22%, transparent 72%, rgba(2, 4, 8, 0.82) 100%);
}

/* ---------- 划船的人 ---------- */

.boat {
  position: absolute; left: 50%; bottom: max(58px, env(safe-area-inset-bottom));
  width: clamp(210px, 24vw, 340px);
  transform: translateX(-50%);
  pointer-events: none;
  filter: drop-shadow(0 10px 26px rgba(0, 0, 0, 0.55));
  animation: bob 5.5s ease-in-out infinite alternate;
  z-index: 2;
}
.boat svg { width: 100%; height: auto; overflow: visible; }
.boat::after {
  content: ""; position: absolute; left: 50%; top: 88%; width: 78%; height: 34px;
  transform: translateX(-50%); pointer-events: none;
  background: radial-gradient(ellipse at 50% 0%, rgba(150, 190, 235, .16), rgba(6, 12, 20, .35) 55%, transparent 75%);
  filter: blur(5px);
}
.hull { fill: url(#hullGrad); stroke: rgba(140, 170, 210, 0.3); stroke-width: 1.1; }
.hull-rim { opacity: 0.9; }
.wake { fill: rgba(127, 214, 255, 0.05); }
.wake-2 { fill: rgba(127, 214, 255, 0.04); }
.hull-line { fill: none; stroke: rgba(140, 170, 210, 0.18); stroke-width: 1; }
.wake { fill: rgba(127, 214, 255, 0.07); }
.rower .head { fill: #0b1320; stroke: rgba(160, 190, 230, 0.35); stroke-width: 1.1; }
.rower .body { fill: #0b1320; stroke: rgba(160, 190, 230, 0.3); stroke-width: 1.1; }
.rower .arm { fill: none; stroke: rgba(160, 190, 230, 0.3); stroke-width: 2.2; stroke-linecap: round; }
.oar { stroke: rgba(150, 180, 220, 0.5); stroke-width: 2; stroke-linecap: round; transform-origin: 150px 70px; }
.oar-blade { fill: rgba(150, 180, 220, 0.35); }
.lantern { fill: #ffb45c; filter: drop-shadow(0 0 6px rgba(255, 180, 92, .9)); }
.lantern-glow { opacity: .9; }
.boat .caught { fill: #ffb45c; filter: drop-shadow(0 0 10px rgba(255, 180, 92, 0.85)); animation: caught 3.2s ease-in-out infinite alternate; }
@keyframes caught { from { opacity: 0.72; } to { opacity: 1; } }
.boat.rowing .oar { animation: row 0.9s ease-in-out; }
.boat.rowing { animation: bob 5.5s ease-in-out infinite alternate, lean 0.9s ease-in-out; }
@keyframes bob { from { transform: translateX(-50%) translateY(0) rotate(-0.6deg); } to { transform: translateX(-50%) translateY(5px) rotate(0.6deg); } }
@keyframes row { 0%, 100% { transform: rotate(0deg); } 45% { transform: rotate(-16deg); } 70% { transform: rotate(10deg); } }
@keyframes lean { 45% { filter: drop-shadow(-6px 12px 28px rgba(0, 0, 0, 0.6)); } }

/* 简版兜底 */
.fallback-field { position: absolute; inset: 0; }
.fb-lamp {
  position: absolute; max-width: 180px; padding: 10px 12px; border-radius: 12px;
  background: rgba(10, 16, 26, 0.86); border: 1px solid var(--line);
  font-size: 12px; line-height: 1.5; cursor: pointer;
  box-shadow: 0 0 24px rgba(255, 180, 92, 0.12);
}
.fb-lamp:hover { border-color: rgba(255, 180, 92, 0.5); }

/* ---------- 顶栏 ---------- */

.top {
  position: fixed; inset: 0 0 auto 0; z-index: 5;
  display: flex; align-items: center; gap: 16px;
  padding: max(18px, env(safe-area-inset-top)) 22px 14px;
  background: linear-gradient(180deg, rgba(3, 5, 10, 0.72), transparent);
  pointer-events: none;
}
.top > * { pointer-events: auto; }
.brand { font-size: 21px; letter-spacing: 0.42em; color: #eef4ff; text-shadow: 0 0 22px rgba(127, 214, 255, 0.25); }
.nav { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.nav a, .nav button {
  padding: 7px 13px; border-radius: 999px; font-size: 13px; color: var(--dim);
  border: 1px solid transparent; background: transparent; cursor: pointer;
  transition: color 0.25s, border-color 0.25s, background 0.25s;
}
.nav a:hover, .nav button:hover { color: var(--ink); border-color: var(--line); background: rgba(12, 18, 30, 0.55); }
.nav a.on { color: var(--warm); }
.nav a.admin-link { opacity: .5; }
.nav a.admin-link:hover { opacity: 1; }

.banner {
  position: fixed; z-index: 6; left: 50%; top: 64px; transform: translateX(-50%);
  padding: 9px 16px; border-radius: 999px; font-size: 13px;
  border: 1px solid rgba(255, 154, 90, 0.35); background: rgba(42, 20, 12, 0.85); color: #ffd7bd;
  backdrop-filter: blur(8px);
}

/* ---------- 提示与划船条 ---------- */

.hint-line {
  position: fixed; z-index: 6; left: 50%; top: 66px;
  transform: translateX(-50%);
  padding: 8px 18px; border-radius: 999px; max-width: min(88vw, 520px);
  font-size: 13px; letter-spacing: 0.04em; text-align: center; color: #ffe2c0;
  background: rgba(10, 14, 24, 0.6); border: 1px solid rgba(255, 180, 92, 0.2);
  backdrop-filter: blur(10px);
  transition: opacity 0.4s ease;
}
.hint-line.gone { opacity: 0; }

.rowbar {
  position: fixed; z-index: 5; left: 50%; bottom: max(14px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px;
  padding: 7px 9px; border-radius: 999px;
  background: rgba(8, 12, 22, 0.62);
  border: 1px solid var(--line);
  backdrop-filter: blur(14px);
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.45);
}
.row {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 17px; border-radius: 999px; cursor: pointer;
  border: 1px solid transparent; background: transparent; color: #cbd8ee; font-size: 14px;
  transition: color 0.25s, background 0.25s;
}
.row:hover { color: var(--warm); background: rgba(255, 180, 92, 0.08); }
.row .arrow { font-size: 13px; opacity: 0.7; }
.depth { display: flex; gap: 4px; padding: 0 6px; }
.depth i { width: 4px; height: 4px; border-radius: 50%; background: rgba(160, 190, 230, 0.28); }
.depth i.on { background: var(--warm); box-shadow: 0 0 8px rgba(255, 180, 92, 0.7); }

/* ---------- 浮层 ---------- */

.sheet[hidden] { display: none; }
.sheet {
  position: fixed; inset: 0; z-index: 10;
  display: grid; place-items: center;
  padding: 24px 18px;
  background: rgba(3, 5, 10, 0.55);
  backdrop-filter: blur(6px);
  animation: fade 0.25s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.sheet-card {
  width: min(560px, 100%); max-height: min(78vh, 720px); overflow: auto;
  padding: 26px 26px 22px;
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(14, 20, 33, 0.96), rgba(8, 12, 21, 0.97));
  border: 1px solid var(--line);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}
.sheet-card h2 { margin: 0 0 6px; font-size: 19px; font-weight: 500; letter-spacing: 0.1em; }
.sheet-card .sub { color: var(--dim); font-size: 13px; margin: 0 0 16px; }

.field { display: block; margin: 16px 0 6px; color: var(--dim); font-size: 12px; letter-spacing: 0.1em; }
textarea, input[type="text"] {
  width: 100%; font: inherit; color: var(--ink);
  background: rgba(6, 10, 18, 0.9); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; outline: none; resize: vertical;
}
textarea { min-height: 150px; line-height: 1.8; }
textarea:focus, input:focus { border-color: rgba(255, 180, 92, 0.45); }
.counter { display: flex; justify-content: space-between; color: var(--dim); font-size: 12px; margin-top: 6px; }
.counter .heavy { color: var(--warm); }

.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 18px; }
button.primary, button.ghost {
  padding: 10px 20px; border-radius: 999px; cursor: pointer; font-size: 14px;
  border: 1px solid var(--line); background: rgba(20, 28, 44, 0.9); color: var(--ink);
}
button.primary { background: linear-gradient(180deg, #ffd09a, #e8893c); color: #221304; border: 0; font-weight: 600; }
button.primary:hover { filter: brightness(1.06); }
button.ghost:hover { border-color: rgba(255, 180, 92, 0.45); color: var(--warm); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
.note { color: var(--dim); font-size: 13px; margin: 10px 0 0; }
.warn { color: #ffb39b; }

.choice-row { display: flex; gap: 10px; margin-top: 8px; }
.choice {
  flex: 1; padding: 12px; text-align: center; cursor: pointer; font-size: 14px;
  border: 1px solid var(--line); border-radius: 12px; background: rgba(6, 10, 18, 0.8);
}
.choice input { display: none; }
.choice:has(input:checked) { border-color: rgba(255, 180, 92, 0.6); color: var(--warm); }

.keybox {
  margin-top: 14px; padding: 16px; border-radius: 14px;
  background: rgba(30, 22, 10, 0.55); border: 1px solid rgba(255, 180, 92, 0.22);
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; line-height: 1.9;
  word-break: break-all;
}
.keybox .key { color: var(--warm); font-size: 14px; }
.keybox .small { color: var(--dim); font-size: 12px; font-family: inherit; }

.lamp-card {
  margin-top: 12px; padding: 18px; border-radius: 14px;
  background: rgba(8, 13, 22, 0.9); border: 1px solid var(--line);
}
.lamp-card .text { white-space: pre-wrap; word-break: break-word; font-size: 15px; }
.lamp-card .meta { margin-top: 10px; display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--dim); }
.chain { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.chain article { padding: 12px; border-radius: 12px; background: rgba(12, 18, 30, 0.9); border: 1px solid var(--line); cursor: pointer; }
.chain article .t { font-size: 13px; }
.chain article .m { margin-top: 6px; font-size: 11px; color: var(--dim); }
hr.rule { border: none; border-top: 1px solid var(--line); margin: 20px 0; }

/* ---------- 移动端 ---------- */

@media (max-width: 640px) {
  .brand { font-size: 18px; letter-spacing: 0.34em; }
  .top { padding: max(14px, env(safe-area-inset-top)) 14px 10px; gap: 8px; }
  .nav a, .nav button { padding: 6px 10px; font-size: 12px; }
  .boat { width: clamp(150px, 44vw, 210px); bottom: max(84px, env(safe-area-inset-bottom)); }
  .rowbar { bottom: max(10px, env(safe-area-inset-bottom)); gap: 2px; padding: 5px 6px; }
  .row { padding: 9px 12px; font-size: 13px; white-space: nowrap; }
  .depth { display: none; }
  .hint-line { top: 58px; font-size: 12px; max-width: 82vw; }
  .sheet { align-items: end; padding: 0; }
  .sheet-card {
    width: 100%; max-height: 86vh; border-radius: 20px 20px 0 0;
    padding: 20px 18px calc(18px + env(safe-area-inset-bottom));
  }
  .chain { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .boat, .boat.rowing, .oar { animation: none !important; }
}

/* ---------- 后台 ---------- */

.admin-body {
  overflow-y: auto;
  background:
    radial-gradient(120% 70% at 50% -10%, #101a2e 0%, #070a12 45%, #04060b 100%) fixed;
}
.admin-view { padding: 84px 22px 90px; max-width: 980px; margin: 0 auto; }
.admin-body .foot {
  position: fixed; left: 0; right: 0; bottom: 0; padding: 10px 22px;
  border-top: 1px solid var(--line); background: rgba(4, 6, 11, .88);
  backdrop-filter: blur(10px);
}
.admin-top { background: linear-gradient(180deg, rgba(3,5,10,.9), transparent); }
.login-card { max-width: 420px; margin: 4vh auto 0; }
.login-card h2 { margin: 0 0 6px; font-size: 18px; font-weight: 500; }

.admin-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.admin-tabs button {
  border: 0; background: transparent; color: var(--dim); cursor: pointer;
  padding: 10px 14px; border-radius: 10px 10px 0 0; font-size: 14px;
}
.admin-tabs button.on { color: var(--warm); background: rgba(255, 180, 92, 0.08); }
.admin-tabs button:hover { color: var(--ink); }

.admin-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.admin-head h2 { margin: 0; font-size: 18px; font-weight: 500; }

.admin-card {
  display: flex; gap: 18px; justify-content: space-between; align-items: flex-start;
  padding: 16px 18px; margin-bottom: 12px; border-radius: 14px;
  border: 1px solid var(--line); background: rgba(10, 16, 26, 0.72);
}
.admin-card-body { min-width: 0; flex: 1; }
.admin-text { margin: 0 0 8px; white-space: pre-wrap; word-break: break-word; font-size: 15px; }
.admin-meta { display: flex; gap: 12px; flex-wrap: wrap; color: var(--dim); font-size: 12px; }
.admin-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.admin-actions button { padding: 8px 14px; font-size: 13px; }

.admin-table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table td.ip-cell { font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; font-size: 12px; white-space: nowrap; }
.admin-table td.ip-region { white-space: nowrap; }
.notice button { margin-left: 8px; }
.notice .grow { flex: 1; }
.admin-table th { color: var(--dim); font-weight: 400; text-align: left; }
.admin-table th, .admin-table td { padding: 9px 10px; border-bottom: 1px solid var(--line); }
.admin-table td.dim { color: var(--dim); }

.admin-filter { display: flex; gap: 10px; margin: 14px 0; flex-wrap: wrap; }
.admin-filter input { flex: 1; min-width: 180px; }
.admin-add {
  margin-top: 22px; padding: 16px; border: 1px solid var(--line); border-radius: 14px;
  display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
  background: rgba(10, 16, 26, 0.6);
}
.admin-add h3 { width: 100%; margin: 0 0 6px; font-size: 14px; font-weight: 500; color: var(--dim); }
.admin-add input, .admin-add select { flex: 1; min-width: 140px; }
.role-badge {
  font-size: 12px; color: var(--warm); padding: 4px 10px; border-radius: 999px;
  border: 1px solid rgba(255, 180, 92, 0.3);
}

@media (max-width: 640px) {
  .admin-view { padding: 72px 14px 48px; }
  .admin-card { flex-direction: column; }
  .admin-tabs { overflow-x: auto; }
}

.admin-text-cell { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-actions { text-align: right; white-space: nowrap; }
.pager { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 16px; }
.pager button[disabled] { opacity: .35; }

body[data-template="river3d"] .vignette { opacity: .15; }
body[data-template="river3d"] .scene-layer { background: #000; }

.music-btn {
  background: none; border: 1px solid rgba(255,255,255,.18); color: inherit;
  border-radius: 999px; width: 30px; height: 30px; line-height: 1;
  font-size: 14px; cursor: pointer; opacity: .55; transition: opacity .2s, border-color .2s;
}
.music-btn:hover { opacity: .9; }
.music-btn[aria-pressed="true"] { opacity: 1; border-color: rgba(255,200,140,.7); color: #ffcf8a; }

.music-dock {
  position: fixed; left: 16px; bottom: 16px; width: 320px; z-index: 40;
  background: rgba(10,14,20,.82); border: 1px solid rgba(255,255,255,.14);
  border-radius: 12px; overflow: hidden; backdrop-filter: blur(8px);
}
.music-dock[hidden] { display: none; }
.music-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 10px; font-size: 12px; opacity: .75;
}
.music-head button { background: none; border: none; color: inherit; cursor: pointer; font-size: 14px; }
.music-dock { width: 300px; }
.music-dock.min iframe { display: none; }

.music-toggle {
  position: fixed; left: 16px; bottom: 16px; z-index: 41;
  width: 36px; height: 36px; border-radius: 999px; cursor: pointer;
  background: rgba(10,14,20,.7); border: 1px solid rgba(255,255,255,.16);
  color: #ffcf8a; font-size: 15px;
}

.music-actions { display: flex; gap: 8px; align-items: center; }
.music-actions button {
  background: none; border: 1px solid rgba(255,255,255,.18); color: inherit;
  border-radius: 6px; padding: 2px 6px; font-size: 11px; cursor: pointer; opacity: .8;
}
.music-actions button:hover { opacity: 1; border-color: rgba(255,200,140,.6); }

.music-list { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.music-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 10px; border: 1px solid rgba(255,255,255,.12); border-radius: 8px;
}
.music-meta { min-width: 0; }
.music-meta > div:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.music-ops { display: flex; gap: 6px; flex-shrink: 0; }
.music-ops button {
  background: none; border: 1px solid rgba(255,255,255,.18); color: inherit;
  border-radius: 6px; padding: 2px 8px; font-size: 12px; cursor: pointer;
}
.music-ops button:disabled { opacity: .3; cursor: default; }
.music-ops button.warn { border-color: rgba(255,120,120,.5); color: #ff9a9a; }

/* 音频模式：把 B站播放器的画面裁掉，只保留底部控制条 */
.music-body { position: relative; height: 46px; overflow: hidden; background: #0b0f16; }
.music-body iframe {
  position: absolute; left: 0; top: -134px; width: 300px; height: 180px; border: 0;
}

.notice {
  display: flex; gap: 8px; align-items: flex-start;
  margin: 10px 0 14px; padding: 10px 12px;
  border: 1px solid rgba(255,200,140,.22); border-radius: 10px;
  background: rgba(255,180,90,.06);
  font-size: 13px; line-height: 1.6; color: #e8d6bd;
}
.notice-dot { color: #ffb45c; font-weight: 700; }
