:root {
  color-scheme: dark;
  --ink: #eef7f1;
  --muted: #a4bbb6;
  --mint: #a8e4ca;
  --gold: #e4cf98;
  --panel: rgba(13, 31, 36, .87);
  --line: rgba(192, 233, 216, .18);
  font-family: 'DM Sans', 'Segoe UI', sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; overflow: hidden; color: var(--ink); background: #10262c; }
button, select { font: inherit; }
button { color: inherit; }
#world-canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; background: linear-gradient(180deg,#17343c 0%,#24464b 48%,#172f33 100%); }
.world-wash { position: fixed; inset: 0; pointer-events: none; background: linear-gradient(180deg,rgba(4,18,22,.2),transparent 24%,transparent 66%,rgba(7,22,26,.38)); }
.world-header { position: fixed; z-index: 4; inset: 0 0 auto; height: 72px; display: flex; align-items: center; justify-content: space-between; padding: 0 28px; border-bottom: 1px solid rgba(219,244,231,.1); background: linear-gradient(180deg,rgba(9,25,29,.72),rgba(9,25,29,.2)); }
.world-brand { display: flex; gap: 11px; align-items: center; color: #f0f3df; text-decoration: none; font: 600 14px 'Playfair Display', Georgia, serif; letter-spacing: 2px; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border: 1px solid rgba(219,205,151,.55); border-radius: 50%; color: var(--gold); font-size: 19px; }
.world-brand small { display: block; margin-top: 3px; font: 500 7px 'DM Sans',sans-serif; letter-spacing: 1.7px; color: #adc9be; }
.header-actions { display: flex; align-items: center; gap: 10px; }
.save-state { display: inline-flex; gap: 7px; align-items: center; padding-right: 10px; color: #c2d7cd; font-size: 10px; }
.save-state i { width: 6px; height: 6px; border-radius: 50%; background: #9dd9b7; box-shadow: 0 0 9px #9dd9b7; }
.reserved-action { border: 1px solid rgba(204,228,214,.16); border-radius: 5px; padding: 8px 11px; background: rgba(10,26,30,.36); color: #9eb2ab; font-size: 10px; }
.reserved-action span { padding-right: 5px; color: #d9c994; }
.reserved-action:disabled { cursor: not-allowed; opacity: .62; }
.glass-panel { border: 1px solid var(--line); background: var(--panel); box-shadow: 0 14px 42px rgba(3,14,18,.22),inset 0 1px rgba(236,255,245,.045); backdrop-filter: blur(15px); }
.world-layout { position: fixed; z-index: 2; inset: 72px 0 124px; pointer-events: none; }
body:not(.dock-expanded) .world-layout { bottom: 56px; }
.task-panel { position: absolute; top: 20px; left: 22px; width: min(322px,calc(100vw - 44px)); max-height: calc(100% - 28px); padding: 18px 18px 14px; overflow-y: auto; border-radius: 9px; pointer-events: auto; scrollbar-color: rgba(169,213,194,.35) transparent; scrollbar-width: thin; }
.task-panel-heading { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 12px; }
.eyebrow { color: #8facaa; font-size: 8px; font-weight: 600; letter-spacing: 1.55px; }
.task-panel h1 { margin: 4px 0 0; color: #eff4e8; font: 600 22px 'Playfair Display',Georgia,serif; }
.collapse-button { width: 28px; height: 28px; border: 1px solid var(--line); border-radius: 50%; background: rgba(217,241,226,.05); color: #d9e9de; cursor: pointer; }
.task-list-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 2px 0 8px; color: #9fb9ae; font-size: 9px; }
.add-task-button { flex: 0 0 auto; border: 1px solid rgba(194,232,208,.25); border-radius: 5px; padding: 7px 9px; background: rgba(146,205,174,.12); color: #d7ebdb; font-size: 9px; cursor: pointer; }
.add-task-button:hover { background: rgba(146,205,174,.2); }
.empty-task-list { margin: 10px 2px; color: #a9c0b5; font-size: 10px; line-height: 1.6; }
.daily-progress { padding: 11px 11px 10px; border: 1px solid rgba(201,235,217,.1); border-radius: 6px; background: rgba(206,241,219,.045); }
.daily-progress>div:first-child { display: flex; justify-content: space-between; gap: 6px; color: #c7d8ce; font-size: 9px; }
.daily-progress strong { color: var(--gold); font-weight: 500; }
.progress-rail,.realm-progress { height: 4px; overflow: hidden; border-radius: 9px; background: rgba(226,246,234,.1); }
.progress-rail { margin-top: 9px; }
.progress-rail span,.realm-progress span { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg,#6fb9a1,#c5eed2); box-shadow: 0 0 10px rgba(148,229,194,.35); transition: width .32s ease; }
.difficulty-field { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 9px; margin: 13px 0 8px; color: #a9bfba; font-size: 9px; }
.difficulty-field select { min-width: 0; border: 1px solid rgba(199,229,211,.15); border-radius: 4px; padding: 6px 8px; background: #132b30; color: #dae8df; font-size: 9px; }
.world-task-list { display: grid; gap: 9px; }
.task-category { padding-top: 9px; border-top: 1px solid rgba(198,229,212,.095); }
.category-heading { display: flex; align-items: center; gap: 7px; margin-bottom: 3px; }
.category-symbol { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: rgba(168,225,199,.09); color: var(--mint); font-size: 11px; }
.category-heading h2 { flex: 1; margin: 0; color: #e0e9df; font: 500 12px 'Playfair Display',Georgia,serif; }
.category-heading>span:last-child { color: #88a39d; font-size: 8px; }
.task-items { display: grid; }
.task-item { display: flex; align-items: center; width: 100%; gap: 8px; min-height: 28px; border: 0; border-radius: 4px; padding: 4px 5px; background: transparent; color: #c7d5cc; text-align: left; cursor: pointer; }
.task-item:hover { background: rgba(189,231,209,.075); }
.task-check { display: grid; place-items: center; width: 15px; height: 15px; border: 1px solid rgba(175,220,196,.35); border-radius: 50%; color: #adc9bb; font-size: 10px; flex: 0 0 auto; }
.task-name { min-width: 0; flex: 1; font-size: 9px; }
.task-state { color: #87aaa0; font-size: 8px; }
.task-item.is-complete .task-check { border-color: rgba(155,222,180,.6); background: rgba(117,192,144,.15); color: #b1efc2; }
.task-item.is-complete .task-name { color: #93b4a4; }
.adaptation-note { margin-top: 10px; padding-top: 9px; border-top: 1px solid rgba(198,229,212,.095); color: #86a49c; font-size: 8px; line-height: 1.6; }
.pending-hint { display: flex; gap: 8px; align-items: center; margin-top: 10px; padding: 9px; border: 1px solid rgba(179,234,206,.22); border-radius: 5px; background: rgba(102,175,145,.13); color: #cee9d9; font-size: 9px; line-height: 1.5; }
.pending-hint[hidden],.placement-banner[hidden] { display: none; }
.pending-orb,.banner-orb { color: #cbf8dc; text-shadow: 0 0 12px #9ce9bd; font-size: 19px; }
.task-panel.is-collapsed { max-height: none; overflow: visible; width: min(244px,calc(100vw - 44px)); }
.task-panel.is-collapsed #task-panel-content { display: none; }
.scene-controls { position: fixed; z-index: 4; right: 18px; bottom: 58px; display: flex; justify-content: flex-end; align-items: flex-end; pointer-events: none; }
body.dock-expanded .scene-controls { bottom: 112px; }
.placement-banner { display: flex; align-items: center; gap: 9px; width: min(330px,calc(100vw - 24px)); padding: 10px 11px; border: 1px solid rgba(199,239,215,.25); border-radius: 8px; background: rgba(13,34,37,.94); box-shadow: 0 10px 35px rgba(4,18,21,.24); pointer-events: auto; }
.placement-banner>div { min-width: 0; flex: 1; }
.placement-banner strong,.placement-banner small { display: block; }
.placement-banner strong { color: #e8f5e9; font: 500 13px 'Playfair Display',Georgia,serif; }
.placement-banner small { margin-top: 3px; color: #a7c1b6; font-size: 9px; }
.place-button,.dialog-primary { border: 1px solid rgba(214,237,204,.45); border-radius: 5px; padding: 9px 12px; background: linear-gradient(130deg,#9bcdb0,#d7dbac); color: #17332e; font-size: 10px; font-weight: 700; cursor: pointer; white-space: nowrap; }
.place-button:disabled,.dialog-primary:disabled { opacity: .5; cursor: not-allowed; }
kbd { margin-left: 6px; border: 1px solid rgba(28,72,59,.3); border-radius: 3px; padding: 2px 4px; font-size: 8px; }
.world-dock { position: fixed; z-index: 3; left: 50%; bottom: 12px; width: min(860px,calc(100vw - 40px)); min-height: 36px; transform: translateX(-50%); display: block; padding: 5px 12px; border-radius: 9px; }
.dock-collapse { position: absolute; top: -13px; right: 14px; width: 32px; height: 22px; border: 1px solid var(--line); border-bottom: 0; border-radius: 7px 7px 0 0; background: rgba(13,31,36,.96); color: #d9e9de; cursor: pointer; font-size: 12px; }
.dock-content { display: none; align-items: center; gap: 24px; }
.world-dock:not(.is-collapsed) { min-height: 91px; padding: 13px 18px; }
.world-dock:not(.is-collapsed) .dock-content { display: flex; }
.realm-card { min-width: 300px; flex: 1; }
.realm-heading { display: flex; align-items: baseline; gap: 8px; margin: 4px 0 7px; }
.realm-heading strong { color: #f0edda; font: 500 17px 'Playfair Display',Georgia,serif; }
.realm-heading span { color: #aec7b9; font-size: 9px; }
.realm-progress { max-width: 360px; }
.realm-caption { display: flex; justify-content: space-between; gap: 8px; max-width: 360px; margin-top: 5px; color: #a7bdb3; font-size: 8px; }
.realm-caption span:last-child { text-align: right; }
.dock-divider { width: 1px; height: 49px; background: rgba(196,232,208,.13); }
.step-total,.task-count { display: grid; align-content: center; min-width: 124px; gap: 2px; }
.step-total strong,.task-count strong { color: #e8eddb; font: 600 21px 'Playfair Display',Georgia,serif; }
.step-total small,.task-count small { color: #93aaa2; font-size: 8px; }
.breakthrough-button { min-width: 115px; border: 1px solid rgba(218,203,151,.42); border-radius: 5px; padding: 11px 14px; background: linear-gradient(130deg,rgba(191,174,122,.22),rgba(155,188,150,.15)); color: #e9d99e; cursor: pointer; font-size: 10px; }
.breakthrough-button:hover:not(:disabled) { background: rgba(193,185,135,.26); }
.breakthrough-button:disabled { border-color: rgba(205,219,206,.12); color: #81958d; cursor: not-allowed; opacity: .68; }
.world-dialog { position: fixed; width: min(420px,calc(100vw - 30px)); border: 1px solid rgba(193,230,207,.23); border-radius: 9px; padding: 25px; background: #122c31; color: var(--ink); box-shadow: 0 20px 80px rgba(0,0,0,.55); }
.world-dialog::backdrop { background: rgba(7,18,20,.55); backdrop-filter: blur(5px); }
.dialog-close { position: absolute; top: 10px; right: 11px; }
.dialog-close button { width: 28px; height: 28px; border: 0; background: transparent; color: #b5c9be; cursor: pointer; font-size: 22px; }
.world-dialog h2 { margin: 8px 28px 9px 0; color: #f2f0dc; font: 600 23px 'Playfair Display',Georgia,serif; }
.world-dialog p { color: #b4c8bc; font-size: 12px; line-height: 1.7; }
.detail-progress { display: flex; justify-content: space-between; margin-top: 18px; padding: 10px 0; border-top: 1px solid rgba(193,230,207,.13); border-bottom: 1px solid rgba(193,230,207,.13); color: #9db6ab; font-size: 10px; }
.detail-progress strong { color: var(--mint); }
.detail-status { min-height: 34px; margin: 11px 0; color: #bdd3c5; font-size: 10px; line-height: 1.6; }
.detail-progress-rail { margin: 0 0 8px; }
.form-field { display: grid; gap: 5px; margin: 11px 0; color: #afc6ba; font-size: 10px; }
.form-field input,.form-field select,.form-field textarea { width: 100%; min-width: 0; border: 1px solid rgba(199,229,211,.19); border-radius: 5px; padding: 9px 10px; background: #0e252a; color: #e1eee4; font: inherit; font-size: 11px; }
.form-field textarea { resize: vertical; }
.quantity-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.dialog-secondary { width: 100%; margin: 1px 0 8px; border: 1px solid rgba(196,229,209,.2); border-radius: 5px; padding: 8px 10px; background: rgba(174,211,188,.09); color: #d3e7d8; cursor: pointer; font-size: 10px; }
.dialog-secondary:disabled { opacity: .5; cursor: not-allowed; }
.test-mode-banner { position: fixed; z-index: 5; top: 83px; right: 18px; display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid rgba(218,203,151,.34); border-radius: 6px; background: rgba(40,39,28,.88); color: #e6d99e; font-size: 8px; letter-spacing: .6px; }
.test-mode-banner[hidden] { display: none; }
.test-mode-banner button { border: 0; background: transparent; color: #f2e9c5; cursor: pointer; font-size: 8px; text-decoration: underline; }
.test-placement-debug { position: fixed; z-index: 4; top: 122px; right: 18px; display: grid; gap: 5px; width: min(245px,calc(100vw - 24px)); padding: 10px 12px; border: 1px solid rgba(168,221,198,.25); border-radius: 6px; background: rgba(11,30,34,.9); color: #aec6bb; font-size: 9px; box-shadow: 0 8px 26px rgba(0,0,0,.2); }
.test-placement-debug strong { color: #d5eadb; font-size: 8px; letter-spacing: 1px; }
.test-placement-debug span { display: flex; justify-content: space-between; gap: 9px; }
.test-placement-debug b { color: #e4ddae; font-weight: 500; text-align: right; }
.test-progress-presets { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; margin: 8px 0; }
.test-progress-presets span { width: 100%; margin-bottom: 2px; color: #9db8ab; font-size: 9px; }
.test-progress-presets button { border: 1px solid rgba(191,226,203,.18); border-radius: 4px; padding: 4px 6px; background: rgba(155,211,179,.08); color: #d4e8d8; cursor: pointer; font-size: 9px; }
.dialog-primary { width: 100%; margin-top: 7px; }
.world-toast { position: fixed; z-index: 10; right: 22px; bottom: 126px; max-width: min(390px,calc(100vw - 34px)); padding: 11px 15px; border: 1px solid rgba(164,226,187,.27); border-radius: 6px; background: #17383a; color: #e0f0e2; box-shadow: 0 10px 35px rgba(0,0,0,.25); font-size: 10px; opacity: 0; pointer-events: none; transform: translateY(7px); transition: .2s ease; }
.world-toast.is-visible { opacity: 1; transform: translateY(0); }
.world-toast.is-error { border-color: rgba(235,150,126,.4); background: #462e2c; color: #ffe3d8; }
[hidden] { display: none !important; }
@media (max-width: 760px) {
  .world-header { height: 62px; padding: 0 12px; }
  .world-brand { font-size: 12px; }
  .world-brand small { font-size: 6px; }
  .header-actions { gap: 5px; }
  .save-state { padding-right: 2px; font-size: 8px; }
  .reserved-action { padding: 7px; font-size: 0; }
  .reserved-action span { padding: 0; font-size: 14px; }
  .world-layout { inset: 62px 0 154px; }
  .task-panel { top: 10px; left: 10px; width: min(300px,calc(100vw - 20px)); max-height: 48%; padding: 12px; }
  .task-panel.is-collapsed { width: 220px; }
  .task-panel h1 { font-size: 19px; }
  .world-task-list { gap: 6px; }
  .task-category { padding-top: 6px; }
  .task-item { min-height: 25px; }
  .task-name { font-size: 8px; }
  .scene-controls { right: 8px; bottom: 52px; }
  body.dock-expanded .scene-controls { bottom: 143px; }
  .placement-banner { gap: 7px; padding: 8px; }
  .placement-banner small { max-width: 175px; font-size: 8px; }
  .placement-banner strong { font-size: 11px; }
  .place-button { padding: 8px; font-size: 9px; }
  kbd { display: none; }
  .world-dock { left: 50%; bottom: 7px; width: calc(100vw - 16px); min-height: 34px; padding: 4px 8px; }
  .world-dock:not(.is-collapsed) { min-height: 132px; display: block; padding: 10px; }
  .dock-content { align-items: center; gap: 8px 12px; }
  .world-dock:not(.is-collapsed) .dock-content { display: grid; grid-template-columns: minmax(0,1fr) auto auto; }
  .dock-collapse { right: 10px; }
  .realm-card { min-width: 0; grid-column: 1 / -1; }
  .realm-heading strong { font-size: 15px; }
  .realm-caption { font-size: 7px; }
  .realm-progress { max-width: none; }
  .dock-divider { display: none; }
  .step-total,.task-count { min-width: 68px; }
  .step-total strong,.task-count strong { font-size: 17px; }
  .step-total small,.task-count small { font-size: 7px; }
  .task-count small { max-width: 95px; }
  .breakthrough-button { min-width: 82px; padding: 9px; font-size: 9px; }
  .world-toast { right: 10px; bottom: 151px; }
  .test-mode-banner { top: 68px; right: 8px; gap: 5px; padding: 6px; font-size: 7px; }
  .test-placement-debug { top: 105px; right: 8px; width: min(208px,calc(100vw - 16px)); }
  .quantity-fields { grid-template-columns: 1fr; gap: 0; }
}
@media (prefers-reduced-motion: reduce) {
  *,*::before,*::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}

/* THIEN LO V2: bottom-right cultivation dock */

/* Keep the world and scene controls stationary when the panel opens. */
.world-layout,
body:not(.dock-expanded) .world-layout {
  bottom: 56px;
}

.scene-controls,
body.dock-expanded .scene-controls {
  bottom: 58px;
}

/* Default state: a compact floating arrow at the bottom-right. */
.world-dock {
  position: fixed;
  z-index: 6;
  right: 16px;
  left: auto;
  bottom: 16px;
  width: 48px;
  height: 44px;
  min-height: 44px;
  transform: none;
  display: block;
  padding: 0;
  border-radius: 10px;
  overflow: visible;
  transition:
    width .22s ease,
    background .22s ease,
    box-shadow .22s ease;
}

.world-dock.is-collapsed {
  width: 48px;
  height: 44px;
  min-height: 44px;
  padding: 0;
}

.world-dock.is-collapsed .dock-content {
  display: none;
}

/* Arrow button. */
.dock-collapse {
  position: absolute;
  top: 0;
  right: 0;
  width: 48px;
  height: 44px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #e6f3e9;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  font-size: 25px;
  line-height: 1;
  transition: background .18s ease;
}

.dock-collapse:hover {
  background: rgba(183, 231, 202, .12);
}

.world-dock.is-collapsed .dock-collapse {
  position: relative;
  width: 100%;
  height: 100%;
}

/* Expanded panel grows to the left from the same bottom-right anchor. */
.world-dock:not(.is-collapsed) {
  width: min(390px, calc(100vw - 32px));
  height: auto;
  min-height: 0;
  max-height: calc(100vh - 32px);
  padding: 50px 16px 16px;
  overflow-x: hidden;
  overflow-y: auto;
  border-radius: 12px;
}

.world-dock:not(.is-collapsed) .dock-collapse {
  top: 9px;
  right: 10px;
  width: 34px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(217, 241, 226, .05);
  font-size: 22px;
}

.world-dock:not(.is-collapsed) .dock-content {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: center;
  gap: 12px 16px;
}

/* Realm and cultivation progress occupy the full panel width. */
.world-dock .realm-card {
  min-width: 0;
  grid-column: 1 / -1;
  flex: initial;
}

.world-dock .realm-heading {
  flex-wrap: wrap;
}

.world-dock .realm-progress,
.world-dock .realm-caption {
  max-width: none;
}

.world-dock .realm-caption {
  flex-wrap: wrap;
  font-size: 9px;
  line-height: 1.5;
}

.world-dock .dock-divider {
  grid-column: 1 / -1;
  width: 100%;
  height: 1px;
}

.world-dock .step-total,
.world-dock .task-count {
  min-width: 0;
  gap: 4px;
  align-content: center;
}

.world-dock .step-total strong,
.world-dock .task-count strong {
  font-size: 20px;
}

.world-dock .breakthrough-button {
  grid-column: 1 / -1;
  width: 100%;
}

/* Small screens. */
@media (max-width: 760px) {
  .world-layout,
  body:not(.dock-expanded) .world-layout {
    bottom: 56px;
  }

  .scene-controls,
  body.dock-expanded .scene-controls {
    right: 8px;
    bottom: 52px;
  }

  .world-dock {
    right: 10px;
    bottom: 10px;
    width: 44px;
    height: 42px;
    min-height: 42px;
  }

  .world-dock.is-collapsed {
    width: 44px;
    height: 42px;
    min-height: 42px;
  }

  .world-dock .dock-collapse {
    width: 44px;
    height: 42px;
  }

  .world-dock:not(.is-collapsed) {
    width: min(360px, calc(100vw - 20px));
    max-height: calc(100dvh - 20px);
    padding: 46px 12px 12px;
  }

  .world-dock:not(.is-collapsed) .dock-collapse {
    top: 8px;
    right: 9px;
  }

  .world-dock:not(.is-collapsed) .dock-content {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .world-dock .realm-heading strong {
    font-size: 16px;
  }

  .world-dock .step-total strong,
  .world-dock .task-count strong {
    font-size: 17px;
  }

  .world-dock .breakthrough-button {
    min-width: 0;
    padding: 10px;
  }
}
/* THIEN LO layered rendering surfaces */
#world-background-canvas,
#crystal-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#world-background-canvas {
  pointer-events: none;
  background: linear-gradient(
    180deg,
    #17343c 0%,
    #24464b 48%,
    #172f33 100%
  );
}

#crystal-canvas {
  pointer-events: none;
  background: transparent;
}
/* GLB integration: transparent foreground canvas */
#world-canvas {
  background: transparent;
}