:root {
  --paper: #f4f1e8;
  --paper-light: #fcfaf4;
  --paper-deep: #e7e1d2;
  --ink: #15201c;
  --muted: #66706a;
  --line: rgba(21, 32, 28, 0.2);
  --line-strong: rgba(21, 32, 28, 0.42);
  --teal: #147a70;
  --teal-soft: #d8e7e4;
  --coral: #d65b3b;
  --coral-soft: #f0d6c9;
  --gold: #bd8a43;
  --gold-soft: #eadcc0;
  --night: #202828;
  --topbar-h: 60px;
  --bottom-h: 58px;
  --ease: cubic-bezier(0.2, 0.74, 0.2, 1);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
  letter-spacing: 0;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-width: 320px;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--paper);
}

body {
  min-height: 100dvh;
}

button,
input {
  font: inherit;
  letter-spacing: 0;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(20, 122, 112, 0.28);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.app-shell {
  width: 100%;
  height: 100dvh;
  overflow: hidden;
}

.topbar {
  position: relative;
  z-index: 30;
  display: grid;
  grid-template-columns: minmax(170px, 1fr) auto minmax(170px, 1fr);
  align-items: center;
  height: var(--topbar-h);
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(252, 250, 244, 0.96);
}

.brand,
.icon-button,
.text-button,
.more-button,
.quiet-button,
.move-button,
.gesture-button,
.option-button,
.condition-button,
.segment-button,
.world-node {
  appearance: none;
  border: 0;
  cursor: pointer;
}

.brand {
  display: inline-flex;
  align-items: center;
  justify-self: start;
  min-width: 0;
  height: 100%;
  padding: 0;
  background: transparent;
}

.brand img {
  width: 42px;
  height: 42px;
  object-fit: contain;
}

.brand-name {
  margin-left: 9px;
  font-size: 0.82rem;
  font-weight: 800;
}

.brand-thai {
  margin-left: 8px;
  color: var(--gold);
  font-size: 0.74rem;
}

.turn-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 0;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
}

.turn-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 7px;
  border-radius: 50%;
  background: var(--coral);
  box-shadow: 0 0 0 5px rgba(214, 91, 59, 0.1);
}

.top-actions {
  display: flex;
  justify-self: end;
  gap: 6px;
}

.icon-button {
  display: inline-grid;
  width: 40px;
  height: 40px;
  padding: 0;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 50%;
  background: transparent;
  font-size: 1.12rem;
  transition: background 180ms ease, border-color 180ms ease, color 180ms ease;
}

.icon-button:hover,
.icon-button[aria-pressed="true"] {
  border-color: var(--line);
  background: var(--paper-deep);
}

#audioToggle[aria-pressed="true"] {
  color: var(--coral);
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(350px, 430px);
  height: calc(100dvh - var(--topbar-h) - var(--bottom-h));
  min-height: 0;
  overflow: hidden;
}

.world-scene {
  position: relative;
  min-width: 0;
  min-height: 0;
  isolation: isolate;
  overflow: hidden;
  background: #f6f1e5;
  transition: background-color 700ms var(--ease), filter 700ms var(--ease);
}

.scene-sky {
  position: absolute;
  inset: 0;
  z-index: -8;
  background: #f7f2e7;
}

.scene-layer {
  position: absolute;
  display: block;
  max-width: none;
  user-select: none;
  pointer-events: none;
  transform-origin: center;
  transition: opacity 800ms var(--ease), transform 900ms var(--ease), filter 800ms var(--ease);
}

.layer-sun {
  z-index: -7;
  top: -34%;
  left: -4%;
  width: min(69vw, 870px);
  opacity: 0.58;
  mix-blend-mode: multiply;
  animation: breathe 11s ease-in-out infinite alternate;
}

.layer-moon {
  z-index: -7;
  top: -3%;
  right: -5%;
  width: min(66vw, 760px);
  opacity: 0;
  mix-blend-mode: screen;
}

.layer-mountains {
  z-index: -5;
  right: -12%;
  bottom: 13%;
  width: 126%;
  opacity: 0.88;
  filter: saturate(0.7) contrast(0.92);
  animation: mountain-drift 24s ease-in-out infinite alternate;
}

.layer-water {
  z-index: -4;
  right: -8%;
  bottom: -12%;
  width: 118%;
  opacity: 0.78;
  mix-blend-mode: multiply;
  animation: water-breathe 9s ease-in-out infinite alternate;
}

.layer-elephant {
  z-index: -2;
  right: 19%;
  bottom: -6%;
  width: clamp(250px, 35vw, 500px);
  height: min(83%, 650px);
  object-fit: contain;
  object-position: bottom center;
  filter: saturate(0.78) contrast(1.02);
  animation: elephant-breathe 6.5s ease-in-out infinite alternate;
}

.layer-naga {
  z-index: -1;
  left: 10%;
  bottom: -11%;
  width: min(49vw, 650px);
  opacity: 0;
  filter: saturate(0.76);
  transform: translate3d(-4%, 12%, 0) rotate(-2deg);
}

.layer-mist {
  z-index: -1;
  left: -10%;
  bottom: 2%;
  width: 123%;
  opacity: 0;
  animation: mist-drift 14s ease-in-out infinite alternate;
}

.layer-lotus {
  z-index: -1;
  left: 2%;
  bottom: -18%;
  width: min(37vw, 470px);
  opacity: 0;
  transform: translateY(12%);
}

.layer-birds {
  z-index: -3;
  top: 2%;
  right: -4%;
  width: min(66vw, 820px);
  opacity: 0;
  transform: translateX(4%);
}

body.has-naga .layer-naga,
body.has-lotus .layer-lotus,
body.has-birds .layer-birds,
body.has-mist .layer-mist {
  opacity: 0.72;
  transform: translate3d(0, 0, 0);
}

body.has-lotus .layer-lotus {
  opacity: 0.78;
}

body.has-birds .layer-birds {
  opacity: 0.48;
}

body.has-mist .layer-mist {
  opacity: 0.42;
}

body[data-scene="night"] .world-scene {
  background: var(--night);
}

body[data-scene="night"] .layer-sun {
  opacity: 0;
}

body[data-scene="night"] .layer-moon {
  opacity: 0.74;
}

body[data-scene="night"] .layer-mountains,
body[data-scene="night"] .layer-water,
body[data-scene="night"] .layer-elephant {
  filter: grayscale(0.35) brightness(0.58) saturate(0.65) hue-rotate(110deg);
}

body[data-scene="night"] .scene-copy,
body[data-scene="night"] .gravity-label {
  color: var(--paper-light);
}

body[data-scene="night"] .scene-copy {
  color: #172621;
}

body[data-scene="dusk"] .layer-sun {
  opacity: 0.34;
  filter: saturate(1.35);
}

body[data-scene="still"] .scene-layer {
  animation-play-state: paused;
}

.world-lines {
  position: absolute;
  inset: 0;
  z-index: 3;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.world-lines line,
.world-lines path {
  fill: none;
  stroke: rgba(20, 122, 112, 0.36);
  stroke-width: 1.2;
  vector-effect: non-scaling-stroke;
  stroke-dasharray: 3 8;
  animation: thread-flow 16s linear infinite;
}

.world-lines .thread-active {
  stroke: var(--coral);
  stroke-width: 1.8;
  stroke-dasharray: none;
}

.world-nodes {
  position: absolute;
  inset: 0;
  z-index: 6;
}

.world-node {
  --node-color: var(--teal);
  position: absolute;
  left: var(--x);
  top: var(--y);
  display: grid;
  width: 76px;
  height: 76px;
  padding: 7px;
  place-content: center;
  gap: 1px;
  border: 1px solid rgba(21, 32, 28, 0.26);
  border-radius: 50%;
  background: rgba(252, 250, 244, 0.88);
  box-shadow: 0 10px 28px rgba(21, 32, 28, 0.11);
  transform: translate(-50%, -50%);
  backdrop-filter: blur(7px);
  transition: transform 180ms var(--ease), border-color 180ms ease, background 180ms ease;
}

.world-node:hover,
.world-node.is-active {
  border-color: var(--node-color);
  background: var(--paper-light);
  transform: translate(-50%, -50%) scale(1.06);
}

.world-node.is-protected {
  box-shadow: 0 0 0 4px rgba(189, 138, 67, 0.18), 0 10px 28px rgba(21, 32, 28, 0.11);
}

.world-node.is-satiated {
  opacity: 0.72;
}

.node-icon {
  color: var(--node-color);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.35rem;
  line-height: 1;
}

.node-label {
  max-width: 64px;
  overflow: hidden;
  font-size: 0.62rem;
  font-weight: 850;
  line-height: 1.12;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.node-pulse {
  position: absolute;
  top: 5px;
  right: 7px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--coral);
  opacity: var(--pulse, 0.35);
}

.scene-copy {
  position: absolute;
  z-index: 7;
  top: clamp(28px, 7vh, 74px);
  left: clamp(22px, 4vw, 58px);
  max-width: min(43ch, 45%);
  pointer-events: none;
}

.scene-kicker,
.deck-kicker,
.field-label,
.echo-flow span,
.consent-line span {
  margin: 0;
  font-size: 0.68rem;
  font-weight: 850;
  line-height: 1.25;
  text-transform: uppercase;
}

.scene-kicker {
  color: var(--teal);
}

.scene-copy h1 {
  margin: 7px 0 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 3.3rem;
  font-weight: 400;
  line-height: 0.94;
}

.scene-return {
  max-width: 34ch;
  margin: 12px 0 0;
  padding-top: 10px;
  border-top: 1px solid currentColor;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.08rem;
  line-height: 1.25;
}

.gravity-label {
  position: absolute;
  z-index: 7;
  left: clamp(22px, 4vw, 58px);
  bottom: 19px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 800;
}

.gravity-line {
  width: 34px;
  height: 1px;
  background: currentColor;
  transform-origin: left;
}

body.audio-playing .gravity-line {
  animation: gravity-pulse 1.4s ease-in-out infinite;
}

.control-deck {
  position: relative;
  z-index: 20;
  min-width: 0;
  min-height: 0;
  padding: clamp(24px, 4vh, 42px) clamp(22px, 2.8vw, 38px) 28px;
  overflow: auto;
  border-left: 1px solid var(--line-strong);
  background: var(--paper-light);
  scrollbar-width: thin;
  scrollbar-color: var(--gold) transparent;
}

.deck-handle,
.deck-close {
  display: none;
}

.deck-empty,
.deck-active {
  min-height: 100%;
}

.deck-empty {
  display: flex;
  flex-direction: column;
}

.deck-kicker {
  color: var(--coral);
}

.deck-empty h2,
.echo-panel h2,
.modal-sheet h2 {
  margin: 7px 0 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.9rem;
  font-weight: 400;
  line-height: 1.02;
}

.world-signals {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0;
  margin-top: 28px;
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}

.signal-item {
  min-height: 86px;
  padding: 14px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.signal-item strong {
  display: block;
  color: var(--teal);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.65rem;
  font-weight: 400;
}

.signal-item span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 750;
  line-height: 1.25;
  text-transform: uppercase;
}

.trace-river {
  display: grid;
  gap: 10px;
  margin-top: auto;
  padding-top: 28px;
}

.river-item {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 10px;
  align-items: start;
  color: var(--muted);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.94rem;
  line-height: 1.25;
}

.river-item::before {
  width: 8px;
  height: 8px;
  margin: 4px auto 0;
  border: 1px solid var(--teal);
  border-radius: 50%;
  content: "";
}

.target-heading {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
}

.target-glyph {
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  color: var(--teal);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.45rem;
}

.target-heading h2 {
  margin: 2px 0 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2.35rem;
  font-weight: 400;
  line-height: 1;
}

.carrier-thread {
  display: grid;
  gap: 7px;
  margin: 22px 0 26px;
}

.carrier-line {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 42px;
  gap: 9px;
  align-items: center;
}

.carrier-symbol {
  color: var(--gold);
  text-align: center;
}

.carrier-name {
  overflow: hidden;
  font-size: 0.76rem;
  font-weight: 740;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.carrier-track {
  position: relative;
  width: 42px;
  height: 3px;
  overflow: hidden;
  background: var(--paper-deep);
}

.carrier-track i {
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--weight);
  background: var(--teal);
}

.carrier-line.is-protected .carrier-name::after {
  margin-left: 6px;
  color: var(--gold);
  content: "RESTE";
  font-size: 0.58rem;
}

.gesture-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.gesture-button {
  display: grid;
  min-height: 66px;
  padding: 9px 5px;
  place-content: center;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: transparent;
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease;
}

.gesture-button:hover,
.gesture-button.is-active {
  border-color: var(--teal);
  background: var(--teal-soft);
  color: var(--teal);
}

.gesture-button.is-secondary {
  display: none;
}

.gesture-row.is-expanded .gesture-button.is-secondary {
  display: grid;
}

.gesture-button strong {
  font-size: 1.15rem;
  line-height: 1;
}

.gesture-button span {
  overflow: hidden;
  font-size: 0.59rem;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.more-button {
  display: flex;
  width: 100%;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 6px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 800;
}

.gesture-config {
  margin-top: 26px;
  padding-top: 22px;
  border-top: 1px solid var(--line-strong);
}

.config-heading {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.gesture-symbol {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 50%;
  background: var(--coral);
  color: white;
  font-size: 1.15rem;
}

.config-heading h3 {
  margin: 3px 0 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.35rem;
  font-weight: 400;
}

.config-block {
  margin-top: 20px;
}

.field-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
}

.option-strip {
  display: grid;
  grid-auto-columns: minmax(86px, 1fr);
  grid-auto-flow: column;
  gap: 5px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}

.option-strip::-webkit-scrollbar {
  display: none;
}

.option-button,
.condition-button,
.segment-button {
  min-height: 44px;
  padding: 8px 9px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: transparent;
  font-size: 0.68rem;
  font-weight: 780;
  line-height: 1.15;
}

.option-button.is-active,
.condition-button.is-active,
.segment-button.is-active {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--paper-light);
}

.option-button small {
  display: block;
  margin-bottom: 3px;
  color: var(--gold);
  font-size: 0.78rem;
}

.novel-choice {
  display: flex;
  min-width: 126px;
  min-height: 44px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--coral);
  border-radius: 4px;
  color: var(--coral);
  font-size: 0.68rem;
  font-weight: 780;
  line-height: 1.2;
}

.condition-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px;
}

.condition-button {
  min-height: 58px;
  text-align: left;
}

.segment-control {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
}

.segment-button {
  border-radius: 0;
}

.segment-button:first-child {
  border-radius: 4px 0 0 4px;
}

.segment-button:last-child {
  border-radius: 0 4px 4px 0;
}

.segment-button + .segment-button {
  border-left: 0;
}

.move-button {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 10px;
  width: 100%;
  min-height: 54px;
  margin-top: 24px;
  margin-bottom: 14px;
  padding: 10px 16px;
  align-items: center;
  border-radius: 4px;
  background: var(--coral);
  color: white;
  font-size: 0.72rem;
  font-weight: 850;
  text-align: left;
}

.move-button:hover {
  background: #bb472d;
}

.move-button:disabled {
  cursor: wait;
  opacity: 0.56;
}

.move-button > span:first-child {
  font-size: 1.15rem;
  text-align: center;
}

.echo-panel {
  animation: rise 380ms var(--ease) both;
}

.echo-panel h2 {
  margin-bottom: 22px;
}

.model-reading {
  margin: -8px 0 20px;
  padding: 12px 0 12px 14px;
  border-left: 3px solid var(--teal);
}

.model-reading[data-status="INFEASIBLE_IN_MODEL"] {
  border-left-color: var(--coral);
}

.model-reading[data-status="UNKNOWN"] {
  border-left-color: var(--gold);
}

.model-reading[data-status="MODEL_CONTESTED"] {
  border-left-color: var(--ink);
}

.model-status {
  display: block;
  color: var(--teal);
  font-size: 0.62rem;
  font-weight: 900;
  letter-spacing: 0;
}

.model-reading[data-status="INFEASIBLE_IN_MODEL"] .model-status {
  color: var(--coral);
}

.model-reading[data-status="UNKNOWN"] .model-status {
  color: #9b6810;
}

.model-reading[data-status="MODEL_CONTESTED"] .model-status {
  color: var(--ink);
}

.model-reading p {
  margin: 5px 0 0;
  color: var(--ink-soft);
  font-size: 0.72rem;
  line-height: 1.38;
}

.model-reading ul {
  display: grid;
  gap: 6px;
  margin: 11px 0 0;
  padding: 0;
  list-style: none;
}

.model-reading li {
  position: relative;
  padding-left: 14px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.86rem;
  line-height: 1.28;
}

.model-reading li::before {
  position: absolute;
  top: 0.52em;
  left: 0;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  content: "";
}

.echo-flow {
  border-top: 1px solid var(--line-strong);
}

.echo-flow > div {
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.echo-flow span {
  color: var(--teal);
}

.echo-flow p {
  margin: 5px 0 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1rem;
  line-height: 1.32;
}

.echo-return {
  color: var(--coral);
}

.echo-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
  margin-top: 22px;
}

.quiet-button {
  min-height: 42px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: transparent;
  font-size: 0.63rem;
  font-weight: 850;
}

.quiet-button:hover {
  border-color: var(--teal);
  color: var(--teal);
}

.quiet-button.danger:hover {
  border-color: var(--coral);
  color: var(--coral);
}

.bottom-bar {
  position: relative;
  z-index: 32;
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto;
  height: var(--bottom-h);
  padding: 0 14px;
  align-items: center;
  border-top: 1px solid var(--line-strong);
  background: var(--paper-light);
}

.bottom-state {
  min-width: 0;
  padding: 0 12px;
}

.bottom-state strong,
.bottom-state span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bottom-state strong {
  font-size: 0.67rem;
}

.bottom-state span {
  margin-top: 2px;
  color: var(--muted);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.74rem;
}

.text-button {
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: transparent;
  font-size: 0.65rem;
  font-weight: 850;
}

.scrim {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(21, 32, 28, 0.44);
  backdrop-filter: blur(3px);
}

.modal-sheet {
  position: fixed;
  z-index: 80;
  top: 50%;
  left: 50%;
  width: min(520px, calc(100vw - 28px));
  max-height: calc(100dvh - 28px);
  padding: 30px;
  overflow: auto;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--paper-light);
  box-shadow: 0 28px 80px rgba(21, 32, 28, 0.24);
  transform: translate(-50%, -50%);
  animation: rise-centered 300ms var(--ease) both;
}

.modal-sheet > p:not(.deck-kicker):not(.trace-status) {
  color: var(--muted);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1rem;
  line-height: 1.35;
}

.modal-actions,
.finish-actions {
  display: grid;
  gap: 7px;
  margin-top: 24px;
}

.modal-actions button {
  min-height: 48px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: transparent;
  font-size: 0.7rem;
  font-weight: 850;
}

.modal-actions button:hover {
  border-color: var(--teal);
  background: var(--teal-soft);
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
}

.finish-river {
  display: grid;
  gap: 8px;
  margin: 22px 0;
  padding: 16px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.consent-line {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  cursor: pointer;
}

.consent-line input {
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--teal);
}

.consent-line span {
  color: var(--muted);
  line-height: 1.4;
}

.trace-status {
  min-height: 18px;
  margin: 10px 0 0;
  color: var(--teal);
  font-size: 0.72rem;
}

.toast {
  position: fixed;
  z-index: 100;
  left: 50%;
  bottom: calc(var(--bottom-h) + 16px);
  max-width: calc(100vw - 28px);
  padding: 10px 14px;
  border: 1px solid rgba(252, 250, 244, 0.18);
  border-radius: 4px;
  background: var(--ink);
  color: white;
  font-size: 0.72rem;
  font-weight: 750;
  transform: translateX(-50%);
  box-shadow: 0 10px 34px rgba(21, 32, 28, 0.22);
}

@keyframes breathe {
  from { transform: scale(0.98); }
  to { transform: scale(1.025); }
}

@keyframes mountain-drift {
  from { transform: translateX(-0.8%); }
  to { transform: translateX(0.8%); }
}

@keyframes water-breathe {
  from { transform: translateY(0); }
  to { transform: translateY(1.5%); }
}

@keyframes elephant-breathe {
  from { transform: translateY(0) rotate(-0.25deg); }
  to { transform: translateY(-0.8%) rotate(0.25deg); }
}

@keyframes mist-drift {
  from { transform: translateX(-2%); }
  to { transform: translateX(2%); }
}

@keyframes thread-flow {
  to { stroke-dashoffset: -64; }
}

@keyframes gravity-pulse {
  0%, 100% { transform: scaleX(0.45); }
  50% { transform: scaleX(1); }
}

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes rise-centered {
  from { opacity: 0; transform: translate(-50%, calc(-50% + 12px)); }
  to { opacity: 1; transform: translate(-50%, -50%); }
}

@media (max-width: 1080px) {
  .game-layout {
    grid-template-columns: minmax(0, 1fr) 360px;
  }

  .world-node {
    width: 68px;
    height: 68px;
  }

  .node-label {
    max-width: 56px;
    font-size: 0.56rem;
  }

  .layer-elephant {
    right: 14%;
  }

  .scene-copy h1 {
    font-size: 2.75rem;
  }
}

@media (max-width: 850px) {
  :root {
    --topbar-h: 56px;
    --bottom-h: 58px;
  }

  .topbar {
    grid-template-columns: minmax(116px, 1fr) auto minmax(88px, 1fr);
    padding: 0 10px;
  }

  .brand img {
    width: 38px;
    height: 38px;
  }

  .brand-name {
    margin-left: 5px;
    font-size: 0.72rem;
  }

  .brand-thai {
    display: none;
  }

  .turn-mark {
    gap: 6px;
    font-size: 0.58rem;
  }

  .turn-dot {
    width: 6px;
    height: 6px;
    flex-basis: 6px;
  }

  .icon-button {
    width: 38px;
    height: 38px;
  }

  .game-layout {
    display: block;
    position: relative;
  }

  .world-scene {
    width: 100%;
    height: 100%;
  }

  .scene-copy {
    top: 24px;
    left: 18px;
    max-width: 68%;
  }

  .scene-copy h1 {
    font-size: 2.05rem;
  }

  .scene-return {
    max-width: 27ch;
    font-size: 0.92rem;
  }

  .gravity-label {
    left: 18px;
    bottom: 72px;
    font-size: 0.54rem;
  }

  .layer-sun {
    top: -13%;
    left: -48%;
    width: 150vw;
  }

  .layer-moon {
    top: -2%;
    right: -46%;
    width: 142vw;
  }

  .layer-mountains {
    right: -63%;
    bottom: 18%;
    width: 220%;
  }

  .layer-water {
    right: -64%;
    bottom: -1%;
    width: 220%;
  }

  .layer-elephant {
    right: -3%;
    bottom: 1%;
    width: min(70vw, 340px);
    height: 66%;
  }

  .layer-naga {
    left: -18%;
    bottom: -5%;
    width: 96vw;
  }

  .layer-mist {
    left: -50%;
    bottom: 10%;
    width: 210%;
  }

  .layer-lotus {
    left: -14%;
    bottom: -7%;
    width: 72vw;
  }

  .layer-birds {
    top: 5%;
    right: -58%;
    width: 170vw;
  }

  .world-node {
    left: var(--mx);
    top: var(--my);
    width: 64px;
    height: 64px;
    padding: 5px;
  }

  .node-icon {
    font-size: 1.18rem;
  }

  .node-label {
    max-width: 53px;
    font-size: 0.54rem;
  }

  .control-deck {
    position: fixed;
    z-index: 50;
    right: 0;
    bottom: var(--bottom-h);
    left: 0;
    height: auto;
    max-height: min(72dvh, 640px);
    min-height: 0;
    padding: 34px 18px calc(18px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line-strong);
    border-left: 0;
    border-radius: 8px 8px 0 0;
    box-shadow: 0 -18px 52px rgba(21, 32, 28, 0.15);
    transform: translateY(calc(100% + var(--bottom-h)));
    transition: transform 360ms var(--ease);
    scroll-padding-bottom: 22px;
  }

  .control-deck.is-open {
    transform: translateY(0);
  }

  .deck-handle {
    position: absolute;
    top: 10px;
    left: 50%;
    display: block;
    width: 38px;
    height: 3px;
    border-radius: 2px;
    background: var(--line-strong);
    transform: translateX(-50%);
  }

  .deck-close {
    position: absolute;
    top: 8px;
    right: 9px;
    display: grid;
  }

  .deck-empty,
  .deck-active {
    min-height: auto;
  }

  .target-heading h2 {
    font-size: 2rem;
  }

  .carrier-thread {
    margin: 17px 0;
  }

  .gesture-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .gesture-button {
    min-height: 58px;
  }

  .gesture-config {
    margin-top: 18px;
    padding-top: 17px;
  }

  .config-block {
    margin-top: 15px;
  }

  .echo-actions {
    padding-bottom: 4px;
  }

  .bottom-bar {
    padding-bottom: env(safe-area-inset-bottom);
  }

  .modal-sheet {
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    max-height: min(82dvh, 720px);
    padding: 30px 20px calc(20px + env(safe-area-inset-bottom));
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 8px 8px 0 0;
    transform: none;
    animation-name: rise-mobile;
  }

  .modal-sheet h2 {
    padding-right: 38px;
    font-size: 1.65rem;
  }

  .toast {
    bottom: calc(var(--bottom-h) + 10px + env(safe-area-inset-bottom));
  }

  @keyframes rise-mobile {
    from { opacity: 0; transform: translateY(18px); }
    to { opacity: 1; transform: translateY(0); }
  }
}

@media (max-width: 420px) {
  .topbar {
    grid-template-columns: minmax(102px, 1fr) auto minmax(80px, 1fr);
  }

  .turn-mark span:last-child {
    max-width: 88px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .scene-copy {
    max-width: 74%;
  }

  .world-node {
    width: 60px;
    height: 60px;
  }

  .condition-grid {
    grid-template-columns: 1fr;
  }

  .echo-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.scene-copy h1 { font-size: 2.5rem; line-height: 1.08; }
.target-heading h2 { font-size: 1.8rem; }
.target-glyph { width: 44px; height: 44px; flex: 0 0 44px; }
.everyday-panel { margin-top: 18px; }
#situation { margin: 0 0 22px; font-size: 1rem; line-height: 1.5; color: var(--ink); }
.everyday-choices { display: grid; gap: 10px; }
.everyday-choice, .moment-button {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  width: 100%; min-height: 62px; padding: 16px; border: 1px solid var(--line-strong);
  border-radius: 6px; background: #fff; color: var(--ink); text-align: left;
  font: inherit; font-size: 0.98rem; font-weight: 600; line-height: 1.4; cursor: pointer;
}
.everyday-choice span:last-child, .moment-button span { flex-shrink: 0; color: var(--teal); }
.everyday-choice:hover, .moment-button:hover { background: #e9f4f1; border-color: var(--teal); }
.everyday-choice:disabled { opacity: 0.55; cursor: progress; }
.custom-move { margin-top: 18px; text-transform: none; font-size: 0.85rem; }
.world-signals { grid-template-columns: 1fr; gap: 8px; border: 0; margin-top: 22px; }
.moment-button { min-height: 46px; padding: 11px 14px; }
.echo-panel { margin-top: 20px; }
.echo-panel h2 { font-size: 1.7rem; line-height: 1.15; }
.echo-plain { font-size: 1rem; line-height: 1.6; margin: 18px 0; }
.game-scope { font-size: 0.75rem; line-height: 1.45; color: var(--muted); margin: 18px 0; }
.echo-details { border-top: 1px solid var(--line); padding-top: 16px; margin: 20px 0; }
.echo-details summary { cursor: pointer; font-size: 0.85rem; color: var(--teal); padding: 6px 0; }
.echo-actions { gap: 8px; }
.echo-actions button { font-size: 0.8rem; text-transform: none; }
.gesture-button span { text-transform: none; }
.node-label { white-space: normal; text-overflow: clip; }

@media (max-width: 850px) {
  .scene-copy h1 { font-size: 1.85rem; }
  .target-heading h2 { font-size: 1.6rem; }
  .everyday-panel { margin-top: 14px; }
  #situation { margin-bottom: 16px; font-size: 0.95rem; }
  .everyday-choice { min-height: 54px; padding: 13px 14px; font-size: 0.94rem; }
  .echo-panel h2 { font-size: 1.55rem; }
  .bottom-state span { font-size: 0.6rem; }
  .bottom-bar .text-button { font-size: 0.65rem; }
  .node-label { max-width: 58px; font-size: 0.54rem; }
  body:has(.control-deck.is-open) .world-nodes,
  body:has(.control-deck.is-open) .world-lines { visibility: hidden; }
  body:has(.control-deck.is-open) .layer-elephant {
    right: 6%; bottom: 48%; height: 35%; width: 54%;
  }
}

.top-actions .icon-button { flex: 0 0 44px; width: 44px; height: 44px; text-decoration: none; }
.top-actions .icon-button img { width: 22px; height: 22px; object-fit: contain; }
.top-actions .crystal-link img { width: 32px; height: 32px; border-radius: 50%; }
.top-actions .support-link { background: var(--coral-soft); }
.icon-button:focus-visible, textarea:focus-visible { outline: 3px solid var(--teal); outline-offset: 2px; }
.feedback-label { display: block; margin: 18px 0 8px; font-size: 0.95rem; font-weight: 650; }
.feedback-label span { color: var(--muted); font-weight: 400; }
.feedback-input { display: block; width: 100%; resize: vertical; min-height: 80px; max-height: 220px; padding: 12px; border: 1px solid var(--line-strong); border-radius: 6px; font: inherit; font-size: 16px; line-height: 1.5; color: var(--ink); background: var(--paper-light); }
.feedback-help { font-size: 0.85rem; line-height: 1.5; color: var(--muted); }
.bug-sheet .move-button { width: 100%; }
.bug-sheet .consent-line { margin-top: 20px; }
@media (max-width: 650px) {
  .topbar { grid-template-columns: minmax(0, 1fr) auto; padding: 0 8px; }
  .topbar .turn-mark { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .top-actions { gap: 0; }
}
@media (max-width: 380px) {
  .top-actions .icon-button { flex-basis: 40px; width: 40px; }
  .brand img { width: 32px; height: 32px; }
  .brand-name { font-size: 0.66rem; }
}

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