:root {
  color-scheme: light;
  --ink: #173b42;
  --muted: #617b7d;
  --paper: rgba(255, 253, 245, 0.9);
  --paper-solid: #fffdf5;
  --line: rgba(28, 80, 82, 0.14);
  --green: #087f72;
  --green-dark: #066359;
  --orange: #c84f16;
  --shadow: 0 14px 38px rgba(32, 77, 73, 0.16);
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  color: var(--ink);
  background: #d9f3ef;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

button,
a { font: inherit; }

button { color: inherit; }

button:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(232, 111, 43, 0.42);
  outline-offset: 2px;
}

#cv,
#cv3dOriginal {
  position: fixed;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

#cv {
  z-index: 0;
  touch-action: none;
  cursor: grab;
}

#cv.holding { cursor: grabbing; }

#cv3dOriginal {
  z-index: 1;
  pointer-events: none;
}

.masthead {
  position: fixed;
  z-index: 5;
  top: max(14px, env(safe-area-inset-top));
  left: max(14px, env(safe-area-inset-left));
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px 8px 8px;
  border: 1px solid rgba(255, 255, 255, 0.74);
  border-radius: 18px;
  background: rgba(255, 253, 245, 0.7);
  box-shadow: 0 8px 22px rgba(37, 94, 89, 0.1);
  backdrop-filter: blur(12px);
  pointer-events: none;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 13px 9px 13px 9px;
  color: #fffaf0;
  background: var(--green);
  font: 800 21px/1 "STKaiti", "KaiTi", serif;
  transform: rotate(-3deg);
}

.masthead h1,
.masthead p { margin: 0; }

.masthead h1 {
  font: 800 20px/1.15 "STKaiti", "KaiTi", "PingFang SC", serif;
  letter-spacing: 0.12em;
}

.masthead p {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.08em;
}

.about-trigger {
  position: fixed;
  z-index: 6;
  top: max(16px, env(safe-area-inset-top));
  right: max(16px, env(safe-area-inset-right));
  min-width: 54px;
  min-height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.76);
  border-radius: 999px;
  background: rgba(255, 253, 245, 0.72);
  box-shadow: 0 8px 22px rgba(37, 94, 89, 0.1);
  backdrop-filter: blur(12px);
  cursor: pointer;
}

.hint {
  position: fixed;
  z-index: 5;
  left: 50%;
  top: max(142px, calc(env(safe-area-inset-top) + 128px));
  display: flex;
  align-items: center;
  gap: 7px;
  max-width: calc(100vw - 24px);
  padding: 8px 13px;
  border: 1px solid rgba(255, 255, 255, 0.68);
  border-radius: 999px;
  color: #365c5e;
  background: rgba(255, 253, 245, 0.67);
  box-shadow: 0 7px 18px rgba(48, 94, 92, 0.08);
  backdrop-filter: blur(10px);
  font-size: 13px;
  white-space: nowrap;
  transform: translateX(-50%);
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
}

.hint.played {
  opacity: 0;
  transform: translate(-50%, 8px);
}

.hint-orbit {
  color: var(--orange);
  font-size: 22px;
  line-height: 1;
}

.control-dock {
  position: fixed;
  z-index: 10;
  right: max(12px, env(safe-area-inset-right));
  bottom: max(12px, env(safe-area-inset-bottom));
  left: max(12px, env(safe-area-inset-left));
  display: flex;
  align-items: stretch;
  gap: 7px;
  width: max-content;
  max-width: calc(100vw - max(24px, env(safe-area-inset-left) + env(safe-area-inset-right)));
  margin: auto;
  padding: 7px;
  overflow-x: auto;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 22px;
  background: rgba(255, 253, 245, 0.76);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px) saturate(1.1);
  scrollbar-width: none;
}

.control-dock::-webkit-scrollbar { display: none; }

.control-dock button,
.food-link {
  flex: 0 0 auto;
  min-height: 48px;
  padding: 0 15px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.15s, border-color 0.15s, background 0.15s;
}

.control-dock button:hover,
.food-link:hover { transform: translateY(-2px); }

.control-dock button[aria-pressed="true"] {
  color: #fff;
  border-color: var(--green-dark);
  background: var(--green);
}

.control-dock .primary-control {
  color: #fff;
  border-color: var(--green-dark);
  background: var(--green);
  font-weight: 700;
}

.meter {
  display: grid;
  min-width: 64px;
  place-content: center;
  text-align: center;
}

.meter b {
  font-size: 20px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.meter span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
}

.food-link {
  position: fixed;
  z-index: 11;
  right: max(16px, env(safe-area-inset-right));
  bottom: calc(max(14px, env(safe-area-inset-bottom)) + 72px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  color: #fff;
  border-color: #a63e0d;
  background: var(--orange);
  text-decoration: none;
  font-weight: 700;
}

.food-link small {
  margin-top: 2px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 9px;
  font-weight: 500;
}

.stats {
  position: fixed;
  z-index: 4;
  top: max(18px, env(safe-area-inset-top));
  left: 50%;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  padding: 7px 11px;
  border: 1px solid rgba(255, 255, 255, 0.64);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 253, 245, 0.58);
  backdrop-filter: blur(10px);
  font-size: 11px;
  transform: translateX(-50%);
  pointer-events: none;
}

.stats b { color: var(--ink); font-variant-numeric: tabular-nums; }
.stats-status {
  flex: 1 0 100%;
  color: var(--muted);
  text-align: center;
  white-space: normal;
}
.stats-status[hidden] { display: none; }
.stats[data-state="unavailable"],
.stats[data-state="stale"],
.stats[data-state="local"] { border-style: dashed; }

.lore {
  position: fixed;
  z-index: 3;
  bottom: calc(max(24px, env(safe-area-inset-bottom)) + 72px);
  left: max(20px, env(safe-area-inset-left));
  margin: 0;
  color: rgba(39, 86, 83, 0.6);
  font: 14px/1.8 "STKaiti", "KaiTi", serif;
  letter-spacing: 0.07em;
  pointer-events: none;
}

.skin-modal,
.modal-mask {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  place-items: center;
  padding: max(16px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  visibility: hidden;
  opacity: 0;
  background: rgba(15, 39, 43, 0.38);
  backdrop-filter: blur(7px);
  transition: opacity 0.2s, visibility 0.2s;
}

.skin-modal.open,
.modal-mask.open {
  visibility: visible;
  opacity: 1;
}

.skin-box,
.about-modal {
  --ink: #173b42;
  --muted: #617b7d;
  position: relative;
  width: min(940px, 100%);
  max-height: min(88vh, 820px);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.86);
  border-radius: 28px;
  background: var(--paper-solid);
  color: var(--ink);
  box-shadow: 0 30px 90px rgba(9, 32, 34, 0.28);
  transform: translateY(16px) scale(0.985);
  transition: transform 0.22s;
}

.open > .skin-box,
.open > .about-modal { transform: none; }

.modal-close {
  position: absolute;
  z-index: 3;
  top: 14px;
  right: 14px;
  display: grid;
  width: 42px;
  height: 42px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  font-size: 25px;
  line-height: 1;
  cursor: pointer;
}

.sheet-grip { display: none; }

.skin-scroll,
.about-scroll {
  max-height: inherit;
  padding: 28px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: rgba(18, 105, 94, 0.3) transparent;
}

.picker-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  padding-right: 52px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--green);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.picker-heading h2,
.about-modal h2 {
  margin: 0;
  font: 800 28px/1.25 "STKaiti", "KaiTi", "PingFang SC", serif;
}

.picker-heading > p {
  max-width: 360px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.skin-progress {
  margin-top: 20px;
  padding: 15px 17px;
  border: 1px solid rgba(8, 127, 114, 0.16);
  border-radius: 18px;
  background: #eef9f4;
}

.skin-progress > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}

.skin-progress b { font-variant-numeric: tabular-nums; }

.skin-progress progress {
  display: block;
  width: 100%;
  height: 8px;
  margin-top: 10px;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  background: #d8ebe5;
}

.skin-progress progress::-webkit-progress-bar { background: #d8ebe5; }
.skin-progress progress::-webkit-progress-value { border-radius: 999px; background: var(--green); }
.skin-progress progress::-moz-progress-bar { border-radius: 999px; background: var(--green); }

.scene-section { margin-top: 22px; }

.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.section-title h3,
.skin-group > h3 { margin: 0; font-size: 14px; }
.section-title span { color: var(--muted); font-size: 11px; }

.scene-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
  margin-top: 9px;
}

.scene-card {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 58px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  cursor: pointer;
}

.scene-card.active { border-color: var(--green); box-shadow: 0 0 0 2px rgba(8, 127, 114, 0.11); }

.scene-orb {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 12px;
  color: rgba(18, 53, 57, 0.7);
  font-size: 11px;
}

.day-orb { background: linear-gradient(145deg, #b9ebfa, #e9f6d8); }
.noon-orb { background: linear-gradient(145deg, #ffdca0, #bdeaff); }
.night-orb { color: #f9ebbb; background: linear-gradient(145deg, #3b3d76, #11142f); }

.skin-filter {
  display: flex;
  gap: 7px;
  margin: 22px -2px 0;
  padding: 2px 2px 6px;
  overflow-x: auto;
  scrollbar-width: none;
}

.skin-filter::-webkit-scrollbar { display: none; }

.skin-filter button {
  flex: 0 0 auto;
  min-height: 36px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  font-size: 12px;
  cursor: pointer;
}

.skin-filter button.active {
  color: #fff;
  border-color: var(--green);
  background: var(--green);
}

.skin-group { margin-top: 24px; }

.skin-group > h3 {
  margin-bottom: 9px;
  color: #426565;
  letter-spacing: 0.05em;
}

.skin-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.skin-card {
  position: relative;
  display: grid;
  min-width: 0;
  grid-template-columns: 80px minmax(0, 1fr);
  align-items: center;
  padding: 6px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  text-align: left;
  cursor: pointer;
}

.skin-card:hover { border-color: rgba(8, 127, 114, 0.5); transform: translateY(-1px); }

.skin-card.active {
  border-color: var(--green);
  box-shadow: 0 0 0 2px rgba(8, 127, 114, 0.12);
}

.skin-card.locked .skin-thumb { filter: grayscale(0.6); opacity: 0.62; }
.skin-card.locked .skin-card-copy { opacity: 0.76; }

.skin-thumb {
  display: block;
  width: 78px !important;
  height: 72px !important;
  border-radius: 13px;
  background: #eaf6ef;
}

.skin-card-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 5px;
  padding: 0 5px 0 8px;
}

.skin-card-copy b {
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.skin-card-copy small { color: var(--muted); font-size: 10px; white-space: nowrap; }

.skin-card-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  padding: 3px 6px;
  border-radius: 999px;
  color: #fff;
  background: rgba(20, 58, 60, 0.72);
  font-size: 9px;
}

.skin-card-badge:empty { display: none; }

.skin-card[data-rarity="legendary"],
.skin-card[data-rarity="masterwork"] { background: linear-gradient(145deg, #fff, #fff8e5); }

.skin-reset {
  display: block;
  min-height: 42px;
  margin: 24px auto 2px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  cursor: pointer;
}

.about-modal { width: min(560px, 100%); }

.about-scroll { padding: 34px; }
.about-modal h2 { font-size: 34px; }

.about-modal .lead {
  margin: 18px 0;
  color: #244e51;
  font-size: 17px;
  font-weight: 650;
  line-height: 1.75;
}

.about-modal p:not(.eyebrow) { line-height: 1.85; }

.privacy-note {
  padding: 12px 14px;
  border-radius: 14px;
  color: #3d6263;
  background: #eef7f3;
  font-size: 13px;
}

.about-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 20px;
}

.about-links a {
  padding: 8px 12px;
  border-radius: 999px;
  color: var(--green-dark);
  background: #e8f5f0;
  text-decoration: none;
  font-size: 12px;
  font-weight: 700;
}

.toast,
.audio-unlock {
  position: fixed;
  z-index: 150;
  left: 50%;
  top: max(142px, calc(env(safe-area-inset-top) + 128px));
  max-width: calc(100vw - 32px);
  padding: 11px 17px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 999px;
  color: #fff;
  background: rgba(20, 54, 57, 0.92);
  box-shadow: 0 12px 32px rgba(18, 46, 48, 0.24);
  opacity: 0;
  transform: translate(-50%, 8px);
  transition: opacity 0.18s, transform 0.18s;
}

.toast.visible { opacity: 1; transform: translate(-50%, 0); }
.toast[data-kind="unlock"] { color: #51350c; background: #ffe6a8; }

.audio-unlock {
  z-index: 90;
  top: clamp(160px, 28vh, 300px);
  min-width: min(290px, calc(100vw - 42px));
  min-height: 64px;
  padding: 0 28px;
  border: 1px solid rgba(141, 54, 16, 0.68);
  color: #251b17;
  background: var(--orange);
  box-shadow: 0 16px 38px rgba(113, 45, 18, 0.3);
  opacity: 1;
  cursor: pointer;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.04em;
  transform: translateX(-50%);
}

.audio-unlock:hover { transform: translate(-50%, -2px); }
.audio-unlock:active { transform: translate(-50%, 1px); }
.audio-unlock[hidden] { display: none; }

.nojs {
  position: fixed;
  z-index: 1000;
  inset: 0;
  display: grid;
  padding: 30px;
  place-content: center;
  background: #fffdf5;
  text-align: center;
}

body[data-scene="night"] { --ink: #e9ecff; --muted: #b7bbd6; background: #0a1028; }
body[data-scene="night"] .masthead,
body[data-scene="night"] .about-trigger,
body[data-scene="night"] .hint,
body[data-scene="night"] .control-dock,
body[data-scene="night"] .stats {
  border-color: rgba(255, 255, 255, 0.13);
  background: rgba(24, 25, 55, 0.72);
}

body[data-scene="night"] .control-dock button:not([aria-pressed="true"]),
body[data-scene="night"] .meter { color: #e9ecff; background: rgba(255, 255, 255, 0.06); }
body[data-scene="night"] .lore { color: rgba(223, 225, 249, 0.55); }

@media (max-width: 760px) {
  .masthead { border-radius: 16px; }
  .brand-mark { width: 34px; height: 34px; font-size: 19px; }
  .masthead h1 { font-size: 18px; }
  .stats { top: auto; bottom: calc(max(14px, env(safe-area-inset-bottom)) + 76px); left: max(10px, env(safe-area-inset-left)); max-width: calc(100vw - 164px - env(safe-area-inset-left) - env(safe-area-inset-right)); gap: 4px 7px; padding: 6px 9px; overflow: hidden; border-radius: 16px; transform: none; }
  .stats-online, .stats-visits { display: none; }
  .lore { display: none; }
  .control-dock { right: max(8px, env(safe-area-inset-right)); left: max(8px, env(safe-area-inset-left)); max-width: calc(100vw - 16px); border-radius: 20px; }
  .control-dock button, .food-link { min-height: 46px; padding: 0 13px; font-size: 12px; }
  .meter { min-width: 55px; }
  .hint { font-size: 12px; }
  .food-link { right: max(10px, env(safe-area-inset-right)); bottom: calc(max(14px, env(safe-area-inset-bottom)) + 76px); min-height: 48px; padding: 0 12px; font-size: 12px; }
  .skin-modal { align-items: end; padding: max(8px, env(safe-area-inset-top)) 0 0; }
  .skin-box { width: 100%; max-height: min(92dvh, 900px); border-radius: 26px 26px 0 0; }
  .sheet-grip { display: block; width: 42px; height: 5px; margin: 8px auto 0; border-radius: 99px; background: #d6ded9; }
  .skin-scroll { padding: 18px 14px calc(24px + env(safe-area-inset-bottom)); }
  .picker-heading { display: block; padding-right: 46px; }
  .picker-heading > p { margin-top: 7px; }
  .picker-heading h2 { font-size: 24px; }
  .scene-list { gap: 6px; }
  .scene-card { gap: 6px; min-height: 52px; padding: 6px; font-size: 12px; }
  .scene-orb { width: 34px; height: 34px; }
  .skin-list { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .skin-card { grid-template-columns: 70px minmax(0, 1fr); border-radius: 16px; }
  .skin-thumb { width: 68px !important; height: 66px !important; }
  .about-modal { max-height: min(88dvh, 720px); border-radius: 24px; }
  .about-scroll { padding: 30px 22px; }
}

@media (max-width: 355px) {
  .masthead p { display: none; }
  .about-trigger { min-width: 48px; }
  .hint { max-width: calc(100vw - 16px); padding: 7px 10px; }
  .control-dock { gap: 4px; padding: 5px; }
  .control-dock button { min-height: 44px; padding: 0 8px; font-size: 11px; }
  .meter { min-width: 46px; }
  .meter b { font-size: 18px; }
  .skin-card { grid-template-columns: 62px minmax(0, 1fr); }
  .skin-thumb { width: 60px !important; height: 61px !important; }
  .skin-card-copy { padding-left: 5px; }
  .skin-card-copy b { font-size: 12px; }
  .stats-mine { display: none; }
}

@media (max-height: 500px) and (orientation: landscape) {
  .masthead { top: 8px; left: 8px; }
  .about-trigger { top: 9px; right: 9px; }
  .hint, .lore { display: none !important; }
  .stats { top: 8px; bottom: auto; left: 50%; display: flex !important; max-width: min(48vw, 390px); transform: translateX(-50%); }
  .toast, .audio-unlock { top: max(70px, calc(env(safe-area-inset-top) + 60px)); }
  .control-dock { right: 8px; bottom: 8px; left: 8px; max-width: calc(100vw - 16px); }
  .control-dock button, .food-link { min-height: 42px; }
  .skin-box { max-height: 96dvh; }
  .skin-scroll { padding-top: 20px; }
  .skin-list { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
