:root {
  color-scheme: light;
  --ink: #17242d;
  --muted: #677986;
  --panel: rgba(255, 255, 255, 0.78);
  --panel-solid: #fbfdff;
  --line: rgba(43, 73, 91, 0.12);
  --accent: #207ea6;
  --accent-dark: #145c7b;
  --warm: #f4b95e;
  --shadow: 0 24px 80px rgba(52, 93, 115, 0.16);
  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-sm: 12px;
  font-family: Inter, ui-rounded, "SF Pro Rounded", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html { min-width: 320px; background: #eaf7fb; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 14%, rgba(255,255,255,.95), transparent 25rem),
    linear-gradient(145deg, #eefbff 0%, #dff2f6 48%, #f7f2e5 100%);
  overflow-x: hidden;
}

button, input { font: inherit; }
button { color: inherit; }
button:focus-visible, input:focus-visible, summary:focus-visible {
  outline: 3px solid rgba(31, 137, 180, .3);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.ambient-orb {
  position: fixed;
  z-index: -1;
  border-radius: 50%;
  filter: blur(4px);
  pointer-events: none;
}
.ambient-orb--one { width: 28rem; height: 28rem; right: -12rem; top: 8rem; background: rgba(150, 208, 255, .23); }
.ambient-orb--two { width: 22rem; height: 22rem; left: -10rem; bottom: -7rem; background: rgba(255, 214, 142, .2); }

.topbar {
  min-height: 72px;
  padding: 12px clamp(16px, 3vw, 44px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: inherit;
  text-decoration: none;
}
.brand__mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 50% 46% 52% 44%;
  background: #1f2d36;
  color: white;
  font-size: 29px;
  box-shadow: inset 0 0 0 7px #f4c24e;
  transform: rotate(-8deg);
}
.brand strong, .brand small { display: block; }
.brand strong { font-size: 16px; letter-spacing: .08em; }
.brand small { margin-top: 1px; color: var(--muted); font-size: 11px; letter-spacing: .16em; }

.topbar__status { display: flex; align-items: center; gap: 8px; }
.status-pill, .glass-chip {
  border: 1px solid rgba(255,255,255,.72);
  background: rgba(255,255,255,.58);
  box-shadow: 0 8px 28px rgba(44, 82, 100, .08);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
.status-pill { padding: 8px 12px; border-radius: 999px; font-size: 12px; color: #426170; }
.status-pill::before { content: ""; width: 7px; height: 7px; display: inline-block; margin-right: 7px; border-radius: 50%; background: #68b887; }
.status-pill--loading::before { background: #e3ad4e; animation: pulse 1s infinite alternate; }
.status-pill--offline::before { background: #8aa4b3; }

.icon-button, .text-button {
  border: 1px solid var(--line);
  background: rgba(255,255,255,.66);
  cursor: pointer;
  transition: transform .18s ease, background .18s ease;
}
.icon-button:hover, .text-button:hover { transform: translateY(-1px); background: rgba(255,255,255,.95); }
.icon-button { width: 38px; height: 38px; border-radius: 50%; }
.text-button { min-height: 38px; padding: 0 13px; border-radius: 999px; font-size: 12px; }
.text-button[aria-pressed="false"] { color: var(--muted); }

.app-shell {
  width: min(1580px, calc(100vw - clamp(20px, 3vw, 52px)));
  min-height: calc(100vh - 94px);
  margin: 0 auto 24px;
  display: grid;
  grid-template-columns: minmax(0, 1.72fr) minmax(360px, .78fr);
  gap: 16px;
}

.world-column, .story-panel {
  border: 1px solid rgba(255,255,255,.74);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
}
.world-column { padding: 14px; border-radius: var(--radius-lg); display: flex; flex-direction: column; min-width: 0; }
.story-panel { padding: clamp(18px, 2.3vw, 30px); border-radius: var(--radius-lg); overflow: auto; max-height: calc(100vh - 96px); }

.zone-nav { display: flex; gap: 8px; overflow-x: auto; padding: 0 0 12px; scrollbar-width: none; }
.zone-nav::-webkit-scrollbar { display: none; }
.zone-nav button {
  flex: 0 0 auto;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,.64);
  color: #5d717c;
  font-size: 12px;
  cursor: pointer;
  transition: all .2s ease;
}
.zone-nav button:hover { background: white; }
.zone-nav button[aria-current="true"] { background: #1e303a; color: white; border-color: #1e303a; box-shadow: 0 8px 20px rgba(30,48,58,.2); }

.world-stage {
  position: relative;
  min-height: 0;
  flex: 1;
  overflow: hidden;
  border-radius: 22px;
  background: #cbeeff;
  border: 1px solid rgba(58, 99, 119, .08);
  isolation: isolate;
}
.world-stage::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.45), inset 0 -60px 90px rgba(38,94,118,.08);
  border-radius: inherit;
}
#world-canvas { display: block; width: 100%; height: 100%; min-height: 510px; cursor: crosshair; }
.world-stage__topline { position: absolute; z-index: 3; top: 14px; left: 14px; right: 14px; display: flex; justify-content: space-between; gap: 8px; pointer-events: none; }
.glass-chip { display: inline-flex; align-items: center; min-height: 34px; padding: 0 12px; border-radius: 999px; color: #36515e; font-size: 12px; }
.glass-chip--soft { color: #617683; }
.world-stage__hint { position: absolute; z-index: 3; bottom: 12px; left: 50%; transform: translateX(-50%); padding: 7px 11px; border-radius: 999px; background: rgba(19,42,54,.56); color: rgba(255,255,255,.9); font-size: 11px; pointer-events: none; white-space: nowrap; opacity: .82; }

.event-card {
  position: absolute;
  z-index: 5;
  top: 62px;
  left: 50%;
  width: min(420px, calc(100% - 32px));
  transform: translateX(-50%);
  padding: 14px 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-radius: 17px;
  border: 1px solid rgba(255,255,255,.75);
  background: rgba(255, 251, 240, .88);
  box-shadow: 0 16px 44px rgba(70,87,96,.18);
  backdrop-filter: blur(18px);
  animation: event-in .34s cubic-bezier(.2,.8,.2,1);
}
.event-card[hidden] { display: none; }
.event-card small, .event-card strong { display: block; }
.event-card small { color: #9e6c33; font-size: 10px; letter-spacing: .12em; text-transform: uppercase; }
.event-card strong { margin-top: 2px; font-size: 15px; }
.event-card p { margin: 3px 0 0; color: #6e6e64; font-size: 11px; }
.event-card button { flex: 0 0 auto; border: 0; border-radius: 999px; padding: 9px 12px; background: #293d47; color: white; font-size: 11px; cursor: pointer; }

.agent-strip { display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px; padding-top: 12px; }
.agent-card { min-width: 0; display: grid; grid-template-columns: auto minmax(0,1fr) auto; align-items: center; gap: 10px; padding: 10px 11px; border: 1px solid var(--line); border-radius: 16px; background: rgba(255,255,255,.62); }
.agent-card__dot { width: 34px; height: 34px; border-radius: 50%; border: 4px solid rgba(255,255,255,.9); box-shadow: 0 3px 12px rgba(34,68,83,.16); }
.agent-card__dot--bobo { background: radial-gradient(circle at 42% 35%, #f8c1b0 0 15%, #26333b 17% 70%, #f6c84f 72%); }
.agent-card__dot--xuetuan { background: radial-gradient(circle at 40% 34%, #89d8ff 0 16%, #edf4f7 18% 68%, #69a9d2 70%); }
.agent-card strong, .agent-card span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agent-card strong { font-size: 13px; }
.agent-card span { margin-top: 2px; font-size: 11px; color: var(--muted); }
.agent-card button { border: 0; background: transparent; color: var(--accent-dark); font-size: 11px; cursor: pointer; }
.surprise-button { min-width: 148px; border: 1px solid rgba(44,71,84,.1); border-radius: 16px; background: #263943; color: white; padding: 0 16px; cursor: pointer; box-shadow: 0 8px 22px rgba(38,57,67,.18); transition: transform .18s ease; }
.surprise-button:hover { transform: translateY(-2px) rotate(-.5deg); }
.surprise-button span { color: #ffd978; margin-right: 5px; }

.scene-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.scene-heading small { display: block; color: #76909e; font-size: 10px; letter-spacing: .13em; text-transform: uppercase; }
.scene-heading h1 { margin: 5px 0 0; font-family: ui-serif, "Songti SC", "STSong", serif; font-size: clamp(25px, 3vw, 38px); line-height: 1.12; font-weight: 650; letter-spacing: -.02em; }
.weather-mark { width: 48px; height: 48px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 50%; background: #fff5c8; color: #d89128; font-size: 24px; box-shadow: inset 0 0 0 1px rgba(230,170,71,.15); }

.background-card { position: relative; margin-top: 18px; padding: 17px 17px 15px; border: 1px solid rgba(37,85,105,.08); border-radius: 17px; background: linear-gradient(145deg, rgba(231,247,253,.85), rgba(255,255,255,.72)); }
.background-card > span { color: #6a8999; font-size: 10px; letter-spacing: .1em; }
.background-card p { min-height: 48px; margin: 8px 0 12px; font-family: ui-serif, "Songti SC", serif; font-size: 14px; line-height: 1.72; }
.background-card button { padding: 0; border: 0; background: transparent; color: var(--accent-dark); font-size: 12px; font-weight: 650; cursor: pointer; }

.dialogue-log { min-height: 118px; max-height: 190px; margin: 16px -4px 0 0; padding-right: 4px; overflow-y: auto; display: flex; flex-direction: column; gap: 9px; scroll-behavior: smooth; }
.message { max-width: 94%; padding: 10px 12px; border-radius: 14px; animation: message-in .28s ease-out; }
.message--world { align-self: center; max-width: 100%; padding: 6px 10px; background: rgba(77,104,117,.08); color: #687b85; font-size: 11px; text-align: center; }
.message--player { align-self: flex-end; border-bottom-right-radius: 4px; background: #233741; color: white; }
.message--bobo, .message--xuetuan { align-self: flex-start; border-bottom-left-radius: 4px; background: rgba(255,255,255,.88); border: 1px solid var(--line); }
.message header { display: flex; align-items: baseline; gap: 7px; margin-bottom: 4px; }
.message header strong { font-size: 11px; }
.message header span { color: #8a9ba4; font-size: 9px; }
.message p { margin: 0; font-size: 13px; line-height: 1.55; }
.message em { display: block; margin-bottom: 3px; color: #71848e; font-size: 10px; font-style: normal; }

.section-label { margin: 18px 0 9px; display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.section-label span { font-size: 12px; font-weight: 700; }
.section-label small { color: #91a0a8; font-size: 9px; }
.scene-choices { display: grid; gap: 7px; }
.scene-choices button { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 13px; background: rgba(255,255,255,.7); text-align: left; font-size: 12px; line-height: 1.45; cursor: pointer; transition: transform .16s ease, border-color .16s ease, background .16s ease; }
.scene-choices button:hover { transform: translateX(2px); border-color: rgba(31,126,166,.28); background: white; }
.scene-choices button::before { content: "›"; margin-right: 7px; color: var(--accent); font-weight: 800; }

.quick-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.quick-actions button { min-height: 39px; border: 1px solid var(--line); border-radius: 999px; background: rgba(239,248,251,.8); font-size: 11px; cursor: pointer; }
.quick-actions button:hover { border-color: rgba(31,126,166,.3); color: var(--accent-dark); background: white; }

.custom-form { margin-top: 18px; }
.custom-form label { display: block; margin-bottom: 8px; font-size: 11px; font-weight: 700; }
.custom-form__row { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 7px; }
.custom-form input { min-width: 0; height: 43px; padding: 0 12px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.78); color: var(--ink); font-size: 12px; }
.custom-form button { padding: 0 14px; border: 0; border-radius: 12px; background: var(--accent); color: white; font-size: 11px; font-weight: 700; cursor: pointer; }
.custom-form button:disabled { opacity: .55; cursor: wait; }
.custom-form > p { margin: 7px 1px 0; color: #8999a1; font-size: 9px; line-height: 1.45; }
.director-note { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 10px; }
.director-note summary { color: #6e828d; font-size: 10px; cursor: pointer; }
.director-note p { margin: 8px 0 0; color: #607681; font-size: 10px; line-height: 1.55; }

.splash { position: fixed; z-index: 50; inset: 0; display: grid; place-items: center; padding: 22px; background: rgba(214, 237, 245, .72); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); transition: opacity .45s ease, visibility .45s ease; }
.splash.is-hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.splash__card { width: min(540px, 100%); padding: clamp(28px, 5vw, 48px); border: 1px solid rgba(255,255,255,.82); border-radius: 34px; background: rgba(255,255,255,.82); box-shadow: 0 40px 120px rgba(55,94,113,.22); text-align: center; }
.splash__eyebrow { color: #6790a3; font-size: 10px; letter-spacing: .22em; text-transform: uppercase; }
.splash h2 { margin: 10px 0 12px; font-family: ui-serif, "Songti SC", serif; font-size: clamp(32px, 6vw, 54px); line-height: 1.08; font-weight: 600; }
.splash p { margin: 0 auto; max-width: 430px; color: #5e727e; font-size: 13px; line-height: 1.8; }
.splash ul { margin: 22px 0; padding: 0; display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; list-style: none; }
.splash li { padding: 11px 6px; border-radius: 14px; background: rgba(227,242,247,.68); font-size: 10px; }
.splash li span { display: block; margin-bottom: 2px; color: #8aa0ab; font-size: 8px; letter-spacing: .12em; }
.splash button { width: 100%; height: 50px; border: 0; border-radius: 15px; background: #223741; color: white; font-weight: 700; cursor: pointer; box-shadow: 0 12px 28px rgba(34,55,65,.2); }
.splash small { display: block; margin-top: 12px; color: #92a0a7; font-size: 9px; }

@keyframes pulse { to { opacity: .35; } }
@keyframes event-in { from { opacity: 0; transform: translate(-50%, -10px) scale(.97); } }
@keyframes message-in { from { opacity: 0; transform: translateY(6px); } }

@media (max-width: 1050px) {
  .app-shell { grid-template-columns: minmax(0, 1.45fr) minmax(340px, .8fr); }
  .agent-strip { grid-template-columns: 1fr 1fr; }
  .surprise-button { grid-column: 1 / -1; min-height: 42px; }
}

@media (max-width: 860px) {
  .topbar { padding: 10px 14px; }
  .status-pill { display: none; }
  .text-button { padding: 0 10px; }
  .app-shell { width: calc(100vw - 16px); margin-bottom: 10px; grid-template-columns: 1fr; }
  .world-column { min-height: 70vh; }
  .story-panel { max-height: none; }
  #world-canvas { min-height: 470px; }
}

@media (max-width: 560px) {
  .brand small { display: none; }
  .topbar__status { gap: 5px; }
  .text-button { max-width: 108px; white-space: nowrap; overflow: hidden; }
  .world-column { padding: 8px; border-radius: 20px; }
  .world-stage { border-radius: 17px; }
  #world-canvas { min-height: 410px; }
  .world-stage__topline { top: 8px; left: 8px; right: 8px; }
  .glass-chip { min-height: 30px; padding: 0 9px; font-size: 10px; }
  .glass-chip--soft { display: none; }
  .agent-strip { grid-template-columns: 1fr; }
  .surprise-button { min-height: 43px; }
  .story-panel { padding: 20px 16px; border-radius: 20px; }
  .quick-actions { grid-template-columns: repeat(2, 1fr); }
  .splash { padding: 10px; }
  .splash__card { padding: 30px 20px; border-radius: 26px; }
  .splash ul { grid-template-columns: 1fr; }
}

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

/* Autonomous ambient world: the finished experience is only the illustrated world. */
body.ambient-mode {
  width: 100vw;
  height: 100vh;
  min-height: 100vh;
  overflow: hidden;
  background: #bfe5f4;
}

.ambient-mode .ambient-orb,
.ambient-mode .topbar,
.ambient-mode .zone-nav,
.ambient-mode .world-stage__topline,
.ambient-mode .world-stage__hint,
.ambient-mode .event-card,
.ambient-mode .agent-strip,
.ambient-mode .story-panel,
.ambient-mode .splash,
.ambient-mode noscript {
  display: none !important;
}

.ambient-mode .app-shell {
  width: 100vw;
  height: 100vh;
  min-height: 100vh;
  margin: 0;
  display: block;
}

.ambient-mode .world-column {
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
}

.ambient-mode .world-stage {
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 0;
  background: #bfe5f4;
}

.ambient-mode .world-stage::after {
  border-radius: 0;
  box-shadow: inset 0 0 80px rgba(255,255,255,.08);
}

.ambient-mode #world-canvas {
  width: 100%;
  height: 100%;
  min-height: 0;
  cursor: default;
}

/* Keep portfolio navigation outside the product canvas and controls. */
.portfolio-return-bar { min-height: 52px; padding: 3px 16px; border-bottom: 1px solid var(--line); }
.portfolio-return-bar a { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 8px; color: inherit; font: 500 14px/1.4 system-ui, -apple-system, "PingFang SC", sans-serif; text-decoration: none; border-radius: 8px; }
.portfolio-return-bar a:hover { text-decoration: underline; text-underline-offset: 4px; }
.portfolio-return-bar a:focus-visible { outline: 2px solid currentColor; outline-offset: -2px; }
button { min-height: 44px; min-width: 44px; }
input, textarea, select { font-size: 16px; }
label { font-size: 14px; }
.portfolio-return-bar { background: #eef8f7; }
body.ambient-mode { height: 100dvh; min-height: 100dvh; }
.ambient-mode .app-shell { height: calc(100vh - 52px); height: calc(100dvh - 52px); min-height: 0; }
.custom-form input { font-size: 16px; min-height: 44px; }
.custom-form label { font-size: 12px; }

/* A quiet, reachable exit without shrinking the ambient canvas. */
.portfolio-return-bar{position:fixed;top:max(12px,env(safe-area-inset-top));left:16px;z-index:30}
.portfolio-return-bar a{display:inline-flex;align-items:center;gap:8px;min-height:44px;padding:10px 16px;border:1px solid rgba(255,255,255,.7);border-radius:24px;background:rgba(255,255,255,.9);color:#26313c;font:14px/1.5 -apple-system,BlinkMacSystemFont,"PingFang SC",sans-serif;text-decoration:none;box-shadow:0 2px 12px #26313c0d}
.portfolio-return-bar a:focus-visible{outline:2px solid #8a4b38;outline-offset:3px}
