:root {
  --ink: #26351f;
  --ink-soft: rgba(38, 53, 31, 0.62);
  --cream: #fffaf0;
  --glass: rgba(255, 250, 239, 0.58);
  --glass-strong: rgba(255, 252, 244, 0.78);
  --line: rgba(255, 255, 255, 0.58);
  --shadow: 0 18px 48px rgba(37, 58, 38, 0.14), 0 2px 8px rgba(37, 58, 38, 0.07);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

body[data-weather="rain"] {
  --ink: #eef1e4;
  --ink-soft: rgba(238, 241, 228, 0.66);
  --glass: rgba(30, 45, 48, 0.54);
  --glass-strong: rgba(31, 47, 49, 0.72);
  --line: rgba(255, 255, 255, 0.2);
  --shadow: 0 18px 48px rgba(10, 22, 25, 0.25), 0 2px 8px rgba(10, 22, 25, 0.14);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #9ccfc8;
  color: var(--ink);
  font-family: "Avenir Next", "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  position: relative;
}

#scene {
  position: fixed;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
  cursor: grab;
  touch-action: none;
  filter: saturate(1.03) contrast(1.02) brightness(1.0);
  transition: filter 1.5s var(--ease);
}

body[data-weather="rain"] #scene {
  filter: saturate(0.78) contrast(1.065) brightness(0.9);
}

body.is-dragging #scene {
  cursor: grabbing;
}

.atmosphere {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 46%, transparent 32%, rgba(13, 22, 18, 0.28) 100%),
    radial-gradient(circle at 86% 2%, rgba(255, 208, 138, 0.18), transparent 36%),
    linear-gradient(180deg, rgba(255, 194, 112, 0.035) 0%, transparent 36%, rgba(16, 31, 26, 0.16) 100%);
  opacity: 1;
  transition: opacity 1.4s var(--ease), background 1.4s var(--ease);
}

.atmosphere::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 94% -4%, rgba(255, 232, 181, 0.24), transparent 34%),
    linear-gradient(123deg, transparent 40%, rgba(255, 215, 152, 0.055) 49%, transparent 60%),
    linear-gradient(112deg, transparent 57%, rgba(255, 215, 152, 0.04) 64%, transparent 71%);
  mix-blend-mode: screen;
  opacity: 0.9;
}

.atmosphere::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(137deg, rgba(255, 194, 118, 0.09) 0%, transparent 43%, rgba(31, 79, 91, 0.14) 100%);
  mix-blend-mode: soft-light;
}

body[data-weather="rain"] .atmosphere {
  background:
    radial-gradient(ellipse at 50% 42%, transparent 27%, rgba(10, 21, 26, 0.37) 100%),
    radial-gradient(circle at 65% 0%, rgba(151, 175, 190, 0.12), transparent 42%),
    linear-gradient(180deg, rgba(27, 43, 51, 0.06) 0%, rgba(13, 27, 33, 0.32) 100%);
  opacity: 1;
}

body[data-weather="rain"] .atmosphere::before {
  opacity: 0.18;
}

body[data-weather="rain"] .atmosphere::after {
  background: linear-gradient(140deg, rgba(130, 145, 143, 0.05), transparent 45%, rgba(8, 28, 35, 0.18));
}

.grain {
  position: fixed;
  inset: -30%;
  z-index: 4;
  pointer-events: none;
  opacity: 0.16;
  mix-blend-mode: soft-light;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.82' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.52'/%3E%3C/svg%3E");
  background-size: 180px 180px;
  animation: grain-shift 9s steps(2) infinite;
}

.sunlight {
  position: fixed;
  inset: -8%;
  z-index: 3;
  pointer-events: none;
  opacity: 0.95;
  mix-blend-mode: screen;
  background:
    radial-gradient(ellipse 42% 48% at 46% -10%, rgba(255, 230, 178, 0.42), transparent 72%),
    linear-gradient(118deg, transparent 33%, rgba(255, 214, 150, 0.09) 43%, transparent 54%),
    linear-gradient(105deg, transparent 52%, rgba(255, 222, 164, 0.07) 61%, transparent 70%),
    linear-gradient(124deg, transparent 61%, rgba(255, 208, 135, 0.05) 67%, transparent 74%);
  filter: blur(10px);
  -webkit-mask-image: radial-gradient(ellipse at 48% 10%, #000 0%, rgba(0, 0, 0, 0.62) 44%, transparent 80%);
  mask-image: radial-gradient(ellipse at 48% 10%, #000 0%, rgba(0, 0, 0, 0.62) 44%, transparent 80%);
  transition: opacity 1.5s var(--ease);
}

.sunlight::before {
  content: "";
  position: absolute;
  inset: -12%;
  background:
    repeating-conic-gradient(from 202deg at 18% -12%, rgba(255, 224, 168, 0) 0deg, rgba(255, 224, 168, 0.055) 1.3deg, rgba(255, 224, 168, 0) 3.4deg, rgba(255, 224, 168, 0) 9deg);
  filter: blur(16px);
  -webkit-mask-image: radial-gradient(ellipse at 18% -8%, rgba(0, 0, 0, 0.95) 0%, transparent 63%);
  mask-image: radial-gradient(ellipse at 18% -8%, rgba(0, 0, 0, 0.95) 0%, transparent 63%);
  mix-blend-mode: screen;
  opacity: 0.65;
}

body[data-weather="rain"] .sunlight {
  opacity: 0.06;
}

@keyframes grain-shift {
  0% { transform: translate3d(0, 0, 0); }
  25% { transform: translate3d(-1.4%, 1%, 0); }
  50% { transform: translate3d(1%, -1.4%, 0); }
  75% { transform: translate3d(-0.8%, -0.6%, 0); }
  100% { transform: translate3d(0, 0, 0); }
}

.hud {
  position: fixed;
  inset: 0;
  z-index: 6;
  pointer-events: none;
}

.glass {
  background: var(--glass);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px) saturate(1.25);
  -webkit-backdrop-filter: blur(18px) saturate(1.25);
  transition: background 1.25s var(--ease), border-color 1.25s var(--ease), color 1.25s var(--ease), box-shadow 1.25s var(--ease);
}

.brand {
  position: absolute;
  top: max(26px, env(safe-area-inset-top));
  left: max(28px, env(safe-area-inset-left));
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 12px 19px 12px 12px;
  border-radius: 22px;
  opacity: 0;
  transform: translateY(-14px);
  animation: hud-in 1.1s var(--ease) 0.35s forwards;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 43px;
  height: 43px;
  flex: 0 0 43px;
  border-radius: 15px;
  color: #f9f4df;
  background:
    radial-gradient(circle at 30% 22%, rgba(255, 255, 255, 0.3), transparent 42%),
    linear-gradient(145deg, #6f9a5d, #345d42);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.24), 0 7px 16px rgba(39, 67, 45, 0.2);
}

.brand-mark svg {
  width: 27px;
  height: 27px;
}

.brand-type {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--ink-soft);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.17em;
  line-height: 1;
  transition: color 1.25s var(--ease);
}

.eyebrow i {
  display: inline-block;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.45;
}

.brand h1 {
  margin: 0;
  color: var(--ink);
  font-family: "Songti SC", "STSong", "Noto Serif SC", "SimSun", serif;
  font-size: 23px;
  font-weight: 700;
  letter-spacing: 0.15em;
  line-height: 1.1;
  white-space: nowrap;
  transition: color 1.25s var(--ease);
}

.weather-panel {
  position: absolute;
  top: max(26px, env(safe-area-inset-top));
  right: max(28px, env(safe-area-inset-right));
  width: 268px;
  padding: 15px 14px 14px;
  border-radius: 22px;
  opacity: 0;
  transform: translateY(-14px);
  animation: hud-in 1.1s var(--ease) 0.5s forwards;
}

.weather-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 0 7px 11px;
}

.weather-note {
  color: var(--ink-soft);
  font-family: "Songti SC", "STSong", "Noto Serif SC", "SimSun", serif;
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.03em;
  text-align: right;
  transition: color 1.25s var(--ease), opacity 0.35s ease;
}

.segmented {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 4px;
  border-radius: 999px;
  background: rgba(47, 68, 44, 0.12);
  box-shadow: inset 0 1px 3px rgba(33, 52, 31, 0.08);
  transition: background 1.25s var(--ease);
}

body[data-weather="rain"] .segmented {
  background: rgba(225, 238, 235, 0.1);
}

.seg-thumb {
  position: absolute;
  top: 4px;
  left: 4px;
  width: calc(50% - 4px);
  height: calc(100% - 8px);
  border-radius: 999px;
  background: var(--glass-strong);
  box-shadow: 0 5px 14px rgba(35, 55, 34, 0.16), inset 0 0 0 1px rgba(255, 255, 255, 0.52);
  transform: translateX(0);
  transition: transform 0.55s var(--ease), background 1.25s var(--ease), box-shadow 1.25s var(--ease);
}

body[data-weather="rain"] .seg-thumb {
  transform: translateX(100%);
  background: rgba(245, 246, 235, 0.92);
  box-shadow: 0 5px 14px rgba(8, 18, 20, 0.28), inset 0 0 0 1px rgba(255, 255, 255, 0.55);
}

.weather-option {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  padding: 0 10px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-soft);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  cursor: pointer;
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.35s ease, opacity 0.35s ease;
}

.weather-option svg {
  width: 17px;
  height: 17px;
  flex: none;
}

.weather-option:hover {
  color: var(--ink);
}

.weather-option.is-active {
  color: #293b24;
}

body[data-weather="rain"] .weather-option.is-active {
  color: #22332f;
}

.weather-option:focus-visible,
.reset:focus-visible {
  outline: 2px solid rgba(255, 222, 131, 0.95);
  outline-offset: 3px;
}

.hint {
  position: absolute;
  left: 50%;
  bottom: max(26px, env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px 10px 13px;
  border-radius: 999px;
  color: var(--ink-soft);
  transform: translate(-50%, 12px);
  opacity: 0;
  animation: hint-in 1.1s var(--ease) 0.8s forwards;
}

.mouse-icon {
  width: 19px;
  height: 22px;
  flex: none;
  color: var(--ink);
  opacity: 0.78;
}

.hint-copy {
  font-size: 11.5px;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.hint-copy b {
  color: var(--ink);
  font-weight: 650;
}

.hint-copy i {
  display: inline-block;
  width: 3px;
  height: 3px;
  margin: 0 8px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.4;
  vertical-align: middle;
}

.reset {
  position: absolute;
  right: max(28px, env(safe-area-inset-right));
  bottom: max(26px, env(safe-area-inset-bottom));
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  color: var(--ink);
  cursor: pointer;
  pointer-events: auto;
  opacity: 0;
  animation: hud-in 1.1s var(--ease) 0.9s forwards;
  transition: transform 0.35s var(--ease), background 1.25s var(--ease), color 1.25s var(--ease);
}

.reset svg {
  width: 20px;
  height: 20px;
  opacity: 0.78;
}

.reset:hover {
  transform: rotate(-22deg) scale(1.04);
}

.reset:active {
  transform: scale(0.95);
}

.scene-credit {
  position: absolute;
  right: max(30px, env(safe-area-inset-right));
  bottom: calc(max(26px, env(safe-area-inset-bottom)) + 58px);
  display: flex;
  align-items: center;
  gap: 7px;
  color: rgba(255, 255, 255, 0.55);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.19em;
  text-shadow: 0 1px 5px rgba(20, 40, 28, 0.32);
  opacity: 0;
  animation: hud-in 1.2s var(--ease) 1.1s forwards;
  transition: color 1.25s var(--ease);
}

body[data-weather="rain"] .scene-credit {
  color: rgba(234, 243, 239, 0.45);
}

.scene-credit i {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.7;
}

@keyframes hud-in {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes hint-in {
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

@keyframes weather-mobile-in {
  from {
    opacity: 0;
    transform: translate(50%, 14px);
  }
  to {
    opacity: 1;
    transform: translate(50%, 0);
  }
}

.loading {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  color: #3a573e;
  background:
    radial-gradient(circle at 50% 35%, rgba(255, 252, 231, 0.92), rgba(226, 241, 230, 0.96) 55%, rgba(203, 226, 221, 1));
  transition: opacity 0.8s var(--ease), visibility 0.8s;
}

body.is-ready .loading {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loading-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 13px;
  transform: translateY(-10px);
}

.loading-mark {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 19px;
  color: #f9f5e6;
  background: linear-gradient(145deg, #729d60, #365f45);
  box-shadow: 0 16px 32px rgba(38, 70, 47, 0.2), inset 0 0 0 1px rgba(255, 255, 255, 0.2);
  animation: loading-float 2.4s ease-in-out infinite;
}

.loading-mark svg {
  width: 33px;
  height: 33px;
}

.loading-copy {
  font-family: "Songti SC", "STSong", "Noto Serif SC", "SimSun", serif;
  font-size: 14px;
  letter-spacing: 0.28em;
  padding-left: 0.28em;
}

.loading-dots {
  display: flex;
  gap: 5px;
}

.loading-dots i {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #668b6b;
  animation: dot-pulse 1.25s ease-in-out infinite;
}

.loading-dots i:nth-child(2) {
  animation-delay: 0.15s;
}

.loading-dots i:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes loading-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

@keyframes dot-pulse {
  0%, 100% { opacity: 0.3; transform: translateY(0); }
  50% { opacity: 1; transform: translateY(-2px); }
}

.fallback {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #dfebe4;
  color: #2c4234;
}

.fallback[hidden] {
  display: none;
}

.fallback-card {
  max-width: 430px;
  padding: 32px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 24px;
  background: rgba(255, 253, 246, 0.75);
  box-shadow: 0 24px 60px rgba(34, 58, 43, 0.15);
  text-align: center;
}

.fallback-card h2 {
  margin: 0 0 12px;
  font-family: "Songti SC", "STSong", "Noto Serif SC", "SimSun", serif;
  font-size: 24px;
}

.fallback-card p {
  margin: 0;
  color: #607266;
  font-size: 13px;
  line-height: 1.8;
}

@media (max-width: 760px) {
  .brand {
    top: max(14px, env(safe-area-inset-top));
    left: max(14px, env(safe-area-inset-left));
    padding: 9px 14px 9px 9px;
    gap: 10px;
    border-radius: 18px;
  }

  .brand-mark {
    width: 37px;
    height: 37px;
    flex-basis: 37px;
    border-radius: 13px;
  }

  .brand-mark svg {
    width: 23px;
    height: 23px;
  }

  .brand h1 {
    font-size: 19px;
  }

  .brand .eyebrow {
    font-size: 8px;
  }

  .weather-panel {
    top: auto;
    right: 50%;
    bottom: calc(max(18px, env(safe-area-inset-bottom)) + 58px);
    width: min(268px, calc(100vw - 28px));
    padding: 9px;
    border-radius: 999px;
    transform: translate(50%, 14px);
    animation-name: weather-mobile-in;
  }

  .weather-heading {
    display: none;
  }

  .weather-option {
    min-height: 36px;
  }

  .hint {
    bottom: max(18px, env(safe-area-inset-bottom));
    padding: 9px 14px 9px 11px;
    gap: 9px;
  }

  .hint-copy {
    font-size: 10.5px;
  }

  .hint-copy .wheel-hint,
  .hint-copy .hint-sep {
    display: none;
  }

  .hint-copy b {
    font-weight: 650;
  }

  .reset {
    right: max(16px, env(safe-area-inset-right));
    bottom: calc(max(18px, env(safe-area-inset-bottom)) + 58px);
    width: 40px;
    height: 40px;
  }

  .scene-credit {
    display: none;
  }
}

@media (max-width: 430px) {
  .brand-type .eyebrow {
    display: none;
  }

  .brand h1 {
    font-size: 18px;
    letter-spacing: 0.12em;
  }

  .hint-copy {
    letter-spacing: 0.02em;
  }

  .reset {
    display: none;
  }

  .weather-panel {
    bottom: calc(max(16px, env(safe-area-inset-bottom)) + 52px);
  }
}

@media (max-height: 520px) and (orientation: landscape) {
  .brand {
    top: 12px;
    left: 12px;
  }

  .weather-panel {
    top: 12px;
    right: 12px;
  }

  .hint {
    display: none;
  }

  .reset {
    bottom: 12px;
    right: 12px;
  }

  .scene-credit {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .grain,
  .loading-mark,
  .loading-dots i {
    animation: none;
  }

  .brand,
  .weather-panel,
  .hint,
  .reset,
  .scene-credit {
    animation-duration: 0.01s;
    animation-delay: 0s;
  }
}
