:root {
  --glass-bg: rgba(12, 16, 30, 0.55);
  --glass-line: rgba(255, 255, 255, 0.14);
  --text: #f2f4fa;
  --text-dim: rgba(242, 244, 250, 0.68);
  --up: #ff6b6b; /* 국장 상승 = 빨강 */
  --down: #5aa9ff; /* 국장 하락 = 파랑 */
  --accent: #ffb454;
  --accent-soft: #ffd08a;
  --font: 'Pretendard', 'Apple SD Gothic Neo', 'Malgun Gothic', 'Noto Sans KR', system-ui, sans-serif;
}

[hidden] {
  display: none !important;
}

* {
  box-sizing: border-box;
}

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

body {
  background: #0a1026;
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
  color: inherit;
}

.glass {
  background: var(--glass-bg);
  border: 1px solid var(--glass-line);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
  color: var(--text);
}

.ui {
  transition: opacity 0.6s ease;
}

body.zen .ui {
  opacity: 0;
  pointer-events: none;
}

/* ── 첫 로딩 화면 ─────────────────────────────────── */

.loading {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(ellipse 90% 45% at 50% 108%, rgba(242, 113, 74, 0.45), transparent 70%),
    linear-gradient(180deg, #070b1d 0%, #141b48 62%, #43357a 100%);
  transition: opacity 0.7s ease;
}

.loading--done {
  opacity: 0;
  pointer-events: none;
}

.loading__card {
  width: min(360px, 100%);
  text-align: center;
}

.loading__title {
  margin: 0;
  font-size: 30px;
  font-weight: 900;
}

.loading__subtitle {
  margin: 4px 0 26px;
  color: var(--accent-soft);
  font-size: 14px;
  font-weight: 700;
}

/* 난간 달린 다리 한 칸 — 그 위를 개미가 걸어서 건넌다. */
.loading__bridge {
  position: relative;
  height: 64px;
  margin: 0 auto 18px;
  border-bottom: 3px solid rgba(255, 255, 255, 0.35);
  background:
    linear-gradient(rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0.28)) 0 18px / 100% 2px no-repeat,
    repeating-linear-gradient(90deg, transparent 0 22px, rgba(255, 255, 255, 0.16) 22px 24px) 0 18px / 100% 46px no-repeat;
  overflow: hidden;
}

.loading__ant {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 34px;
  height: 48px;
  overflow: visible;
  animation: loading-walk 3.4s linear infinite;
}

.loading__shell {
  fill: #e2535f;
}

.loading__antenna,
.loading__leg {
  fill: none;
  stroke: #5b1d24;
  stroke-width: 2.4;
  stroke-linecap: round;
}

.loading__leg {
  transform-box: fill-box;
  transform-origin: 50% 0;
  animation: loading-step 0.32s ease-in-out infinite alternate;
}

.loading__leg--back {
  animation-direction: alternate-reverse;
}

.loading__bar {
  height: 4px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
}

.loading__fill {
  display: block;
  width: 8%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #ffbe5c, #f2714a);
  transition: width 0.6s ease;
}

.loading__step {
  margin: 12px 0 0;
  font-size: 14px;
  font-weight: 600;
}

.loading__tip {
  min-height: 2.8em;
  margin: 18px 0 0;
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1.4;
  transition: opacity 0.3s;
}

@keyframes loading-walk {
  from {
    translate: -40px 0;
  }
  to {
    translate: 380px 0;
  }
}

@keyframes loading-step {
  from {
    rotate: -18deg;
  }
  to {
    rotate: 18deg;
  }
}

/* ── 3D 장면 · 이름표 ─────────────────────────────── */

.world {
  position: fixed;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
  -webkit-touch-callout: none;
}

.world:active {
  cursor: grabbing;
}

/* 3D 개미 머리 위를 따라다니는 이름표 · 말풍선. 위치는 app.js 가 매 프레임 transform 으로 옮긴다. */
.labels {
  position: fixed;
  inset: 0;
  z-index: 5;
  overflow: hidden;
  pointer-events: none;
}

.label {
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  will-change: transform, opacity;
}

.label.is-leaving {
  opacity: 0 !important;
  transition: opacity 0.4s;
}

.label.is-far .ant__tag {
  pointer-events: none;
}

.ant__tag {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 2px 9px 2px 6px;
  border: 0;
  border-radius: 999px;
  background: rgba(10, 14, 26, 0.6);
  color: #fff;
  font-size: 12px;
  white-space: nowrap;
  cursor: pointer;
  pointer-events: auto;
  transition: opacity 0.6s;
}

.ant__tag:hover {
  background: rgba(10, 14, 26, 0.8);
}

.label.is-me .ant__tag {
  background: color-mix(in srgb, var(--ant) 55%, rgba(10, 14, 26, 0.75));
  box-shadow: 0 0 0 1.5px var(--accent-soft);
}

.label.is-me .ant__name::before {
  content: '나 · ';
  opacity: 0.8;
}

body.zen .ant__tag {
  opacity: 0;
  pointer-events: none;
}

.ant__bubble {
  position: relative;
  width: max-content;
  max-width: 230px;
  padding: 7px 11px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.95);
  color: #1d2230;
  font-size: 13px;
  line-height: 1.4;
  overflow-wrap: anywhere;
  word-break: keep-all;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.22);
  animation: bubble-in 0.25s ease-out;
}

.ant__bubble::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  translate: -50% 0;
  border: 6px solid transparent;
  border-top-color: rgba(255, 255, 255, 0.95);
}

.ant__bubble--hold {
  background: #fff0d4;
}
.ant__bubble--hold::after {
  border-top-color: #fff0d4;
}

.ant__bubble--cheer {
  background: #ffe4ee;
}
.ant__bubble--cheer::after {
  border-top-color: #ffe4ee;
}

.ant__bubble--soft {
  background: rgba(255, 255, 255, 0.78);
  font-size: 12px;
}
.ant__bubble--soft::after {
  border-top-color: rgba(255, 255, 255, 0.78);
}

.float {
  position: absolute;
  z-index: 3000;
  font-size: 24px;
  translate: -50% -50%;
  pointer-events: none;
  animation: float-up 1.8s ease-out forwards;
}

.float--big {
  font-size: 40px;
}

@keyframes bubble-in {
  from {
    opacity: 0;
    scale: 0.85;
  }
  to {
    opacity: 1;
    scale: 1;
  }
}

@keyframes float-up {
  0% {
    opacity: 0;
    translate: -50% -30%;
    scale: 0.6;
  }
  20% {
    opacity: 1;
    scale: 1.1;
  }
  100% {
    opacity: 0;
    translate: -50% -260%;
    scale: 1;
  }
}

.hint {
  position: fixed;
  top: 38px;
  left: 50%;
  z-index: 10;
  margin: 0;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(10, 14, 26, 0.42);
  color: rgba(242, 244, 250, 0.78);
  font-size: 12px;
  white-space: nowrap;
  translate: -50% 0;
  pointer-events: none;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* ── 상단 ─────────────────────────────────────────── */

.ticker {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  height: 28px;
  overflow: hidden;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(6, 8, 16, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  font-size: 12px;
  font-weight: 600;
}

.ticker__track {
  display: flex;
  gap: 34px;
  width: max-content;
  padding-left: 34px;
  white-space: nowrap;
  animation: ticker 52s linear infinite;
}

.ticker__item--up {
  color: var(--up);
}

.ticker__item--down {
  color: var(--down);
}

@keyframes ticker {
  to {
    translate: -50% 0;
  }
}

.status {
  position: fixed;
  top: 40px;
  left: 16px;
  z-index: 10;
  max-width: calc(100vw - 230px);
  padding: 10px 14px;
  border-radius: 16px;
}

.status__title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 16px;
  font-weight: 800;
}

.status__count {
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  font-size: 12px;
  font-weight: 600;
}

.status__line {
  margin: 4px 0 0;
  color: var(--text-dim);
  font-size: 12px;
}

.status__line:empty {
  display: none;
}

.status__badge {
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(255, 180, 84, 0.2);
  color: var(--accent-soft);
  font-size: 11px;
}

.status__badge--warn {
  background: rgba(255, 90, 95, 0.2);
  color: #ffb3b5;
}

.tools {
  position: fixed;
  top: 40px;
  right: 16px;
  z-index: 10;
  display: flex;
  gap: 8px;
}

.tool {
  position: relative;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
  font-size: 17px;
  cursor: pointer;
}

.tool:hover {
  background: rgba(30, 36, 60, 0.72);
}

.tool__dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--up);
}

.panel {
  position: fixed;
  top: 92px;
  right: 16px;
  z-index: 10;
  width: min(320px, calc(100vw - 32px));
  padding: 14px 16px;
  border-radius: 16px;
}

.panel__title {
  margin: 0 0 10px;
  font-size: 14px;
  font-weight: 700;
}

.panel__note {
  margin: 10px 0 0;
  color: var(--text-dim);
  font-size: 11px;
}

.log__list {
  display: flex;
  flex-direction: column;
  gap: 7px;
  max-height: min(40vh, 360px);
  margin: 0;
  padding: 0;
  overflow-y: auto;
  font-size: 13px;
  line-height: 1.45;
  list-style: none;
  user-select: text;
}

.log__list:empty::before {
  content: '아직 조용한 강물이에요';
  color: var(--text-dim);
  font-size: 12px;
}

.log__time {
  margin-right: 6px;
  color: var(--text-dim);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.log__name {
  margin-right: 6px;
  color: color-mix(in srgb, var(--ant) 55%, white);
}

.log__item--hold span,
.log__item--cheer span {
  color: #ffd9a8;
}

.time__label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  color: var(--text-dim);
  font-size: 12px;
}

.time__label b {
  color: var(--text);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.time__range {
  width: 100%;
  margin: 10px 0;
  accent-color: var(--accent);
}

.time__buttons {
  display: flex;
  gap: 8px;
}

/* ── 버튼 · 입력 ──────────────────────────────────── */

.btn {
  height: 38px;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.1);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition:
    background 0.15s,
    translate 0.1s;
}

.btn:hover {
  background: rgba(255, 255, 255, 0.18);
}

.btn:active {
  translate: 0 1px;
}

.btn--accent {
  border-color: transparent;
  background: linear-gradient(180deg, #ffbe5c, #f59a3a);
  color: #3a2205;
}

.btn--accent:hover {
  background: linear-gradient(180deg, #ffc977, #f7a64d);
}

.btn--ghost {
  background: transparent;
}

.btn--active {
  border-color: rgba(255, 180, 84, 0.55);
  background: rgba(255, 180, 84, 0.25);
}

.btn--wide {
  flex: 1;
}

.actions {
  position: fixed;
  bottom: 26px;
  left: 50%;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(760px, calc(100vw - 24px));
  padding: 8px;
  border-radius: 18px;
  translate: -50% 0;
}

/* 터치 기기의 한탄 시트에서만 보인다(아래 pointer: coarse 참고). */
.actions__close {
  display: none;
  flex: none;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--text-dim);
  font-size: 16px;
  cursor: pointer;
}

.touch-controls {
  display: none;
}

.actions__mood {
  flex: none;
  width: 42px;
  height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.1);
  font-size: 18px;
  cursor: pointer;
}

.actions__input,
.entry__input,
.popover__form input {
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  outline: none;
  background: rgba(0, 0, 0, 0.24);
  color: var(--text);
  font: inherit;
  user-select: text;
}

.actions__input:focus,
.entry__input:focus,
.popover__form input:focus {
  border-color: rgba(255, 190, 92, 0.7);
}

.actions__input::placeholder,
.entry__input::placeholder,
.popover__form input::placeholder {
  color: rgba(242, 244, 250, 0.45);
}

.actions__input {
  flex: 1;
  height: 38px;
  padding: 0 12px;
  font-size: 14px;
}

.hand-chip {
  position: fixed;
  bottom: 92px;
  left: 50%;
  z-index: 10;
  padding: 7px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  translate: -50% 0;
  cursor: pointer;
}

.hand-chip:hover {
  background: rgba(30, 36, 60, 0.75);
}

.actions--spectator {
  justify-content: space-between;
  width: min(460px, calc(100vw - 24px));
  padding-left: 16px;
  color: var(--text-dim);
  font-size: 13px;
}

.care {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 6px;
  z-index: 10;
  margin: 0;
  color: rgba(242, 244, 250, 0.62);
  font-size: 11px;
  text-align: center;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
  pointer-events: none;
}

.care b {
  color: var(--accent-soft);
}

/* ── 팝오버 · 토스트 · 카드 ───────────────────────── */

.popover {
  position: fixed;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 260px;
  padding: 12px;
  border-radius: 16px;
}

.popover__title {
  margin: 0;
  font-size: 14px;
  font-weight: 800;
}

.popover__subtitle {
  margin: -2px 0 4px;
  color: var(--text-dim);
  font-size: 11px;
}

.popover__label {
  margin: 6px 0 0;
  color: var(--text-dim);
  font-size: 11px;
}

.popover__note {
  margin: 4px 0;
  color: var(--text-dim);
  font-size: 12px;
}

.popover__action,
.popover__chip {
  padding: 8px 11px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.08);
  text-align: left;
  cursor: pointer;
}

.popover__action {
  font-size: 13px;
  font-weight: 600;
}

.popover__action:hover,
.popover__chip:hover {
  background: rgba(255, 255, 255, 0.16);
}

.popover__action--hold {
  border-color: transparent;
  background: linear-gradient(180deg, #ffbe5c, #f59a3a);
  color: #3a2205;
  font-weight: 800;
}

.popover__action--hold:hover {
  background: linear-gradient(180deg, #ffc977, #f7a64d);
}

.popover__action--selected {
  border-color: rgba(255, 190, 92, 0.8);
  background: rgba(255, 180, 84, 0.18);
}

.popover__chip {
  font-size: 12px;
  line-height: 1.35;
}

.popover__form {
  display: flex;
  gap: 6px;
  margin-top: 2px;
}

.popover__form input {
  flex: 1;
  height: 34px;
  padding: 0 10px;
  font-size: 13px;
}

.popover__form .btn {
  height: 34px;
  padding: 0 10px;
}

.toasts {
  position: fixed;
  top: 96px;
  left: 50%;
  z-index: 40;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  translate: -50% 0;
  pointer-events: none;
}

.toast {
  max-width: 90vw;
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 13px;
  text-align: center;
  animation: bubble-in 0.3s ease-out;
  transition:
    opacity 0.4s,
    translate 0.4s;
}

.toast--out {
  opacity: 0;
  translate: 0 -8px;
}

.zen-exit {
  position: fixed;
  bottom: 26px;
  left: 50%;
  z-index: 20;
  padding: 8px 16px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  background: rgba(10, 14, 26, 0.35);
  color: rgba(255, 255, 255, 0.75);
  font-size: 12px;
  opacity: 0.35;
  translate: -50% 0;
  cursor: pointer;
  transition: opacity 0.3s;
}

.zen-exit:hover {
  opacity: 1;
}

.care-card {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 50;
  width: min(360px, calc(100vw - 32px));
  padding: 22px 20px 18px;
  border-radius: 20px;
  font-size: 14px;
  line-height: 1.6;
  text-align: center;
  translate: -50% -50%;
}

.care-card p {
  margin: 0;
}

.care-card__title {
  margin-bottom: 8px !important;
  font-size: 18px;
  font-weight: 800;
}

.care-card__call {
  margin: 14px 0 !important;
  color: var(--accent-soft);
  font-size: 28px;
  font-weight: 900;
}

.care-card__call span {
  display: block;
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 500;
}

/* ── 입장 ─────────────────────────────────────────── */

.entry {
  width: min(440px, calc(100vw - 32px));
  margin: auto;
  padding: 24px;
  border-radius: 22px;
}

.entry::backdrop {
  background: rgba(4, 6, 14, 0.35);
}

.entry__title {
  margin: 0;
  font-size: 26px;
  font-weight: 900;
}

.entry__subtitle {
  margin: 2px 0 12px;
  color: var(--accent-soft);
  font-size: 14px;
  font-weight: 700;
}

.entry__text {
  margin: 0 0 6px;
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.65;
}

.entry__label {
  display: block;
  margin: 16px 0 8px;
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 700;
}

.entry__input {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  font-size: 14px;
}

.entry__colors,
.entry__moods {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.entry__moods {
  gap: 6px;
}

.entry__swatch {
  width: 30px;
  height: 30px;
  padding: 0;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-radius: 50%;
  background: var(--ant);
  cursor: pointer;
}

.entry__swatch[aria-checked='true'] {
  border-color: #fff;
  box-shadow: 0 0 0 3px rgba(255, 208, 138, 0.6);
}

.entry__mood {
  height: 32px;
  padding: 0 11px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  font-size: 12px;
  cursor: pointer;
}

.entry__mood[aria-checked='true'] {
  border-color: rgba(255, 190, 92, 0.8);
  background: rgba(255, 180, 84, 0.22);
}

.entry__buttons {
  display: flex;
  gap: 8px;
  margin-top: 22px;
}

.entry__note {
  margin: 14px 0 0;
  color: rgba(242, 244, 250, 0.5);
  font-size: 11px;
  text-align: center;
}

/* ── 작은 화면 ────────────────────────────────────── */

@media (max-width: 640px) {
  .status {
    top: 88px;
    left: 12px;
    max-width: calc(100vw - 24px);
  }

  .tools {
    top: 38px;
    right: 12px;
  }

  .panel {
    top: 168px;
    right: 12px;
  }

  .toasts {
    top: 168px;
  }

  .hint {
    display: none;
  }

  .btn__label,
  .actions .btn[type='submit'] {
    display: none;
  }

  .actions .btn {
    padding: 0 12px;
    font-size: 16px;
  }
}

@media (max-width: 1100px) {
  .hint {
    display: none;
  }
}

/*
 * 터치 기기(폰 · 태블릿). 마우스 화면은 건드리지 않는다.
 * --keyboard 는 화면 키보드가 가린 높이(app.js 가 visualViewport 로 잰다) — 한탄 시트를 그 바로 위에 띄운다.
 */
@media (pointer: coarse) {
  button {
    touch-action: manipulation;
  }

  .hint {
    display: none;
  }

  .status {
    cursor: pointer;
  }

  .status:not(.status--open) .status__line {
    display: none;
  }

  .ant__tag {
    padding: 5px 12px 5px 9px;
    font-size: 13px;
  }

  .care {
    bottom: calc(4px + env(safe-area-inset-bottom));
    font-size: 10px;
  }

  .hand-chip {
    bottom: calc(176px + env(safe-area-inset-bottom));
    max-width: calc(100vw - 32px);
  }

  /* 한탄 입력줄은 평소엔 숨기고, 💬 를 누르면 키보드 위에 붙는 시트로 연다. 상태 · 폴짝은 엄지 버튼이 맡는다. */
  body:not(.chat-open) #action-bar {
    display: none;
  }

  .actions {
    /* 맨 아래 109 안내 문구 위로 띄운다. */
    bottom: calc(24px + var(--keyboard, 0px) + env(safe-area-inset-bottom));
    width: calc(100vw - 16px);
    gap: 6px;
  }

  #action-bar .actions__mood,
  #action-bar #btn-jump {
    display: none;
  }

  .actions__close {
    display: grid;
  }

  /* 좁은 화면 규칙(max-width: 640px)이 숨긴 말하기 · 띄우기 글자를 시트에선 다시 보인다 — 상태 · 폴짝이 빠져 자리가 있다. */
  .actions .btn[type='submit'] {
    display: block;
  }

  .actions .btn__label {
    display: inline;
  }

  /* 16px 미만이면 iPhone 이 입력칸을 누를 때 화면을 확대해 버린다. */
  .actions__input,
  .entry__input,
  .popover__form input {
    font-size: 16px;
  }

  .actions .btn {
    height: 42px;
  }

  .touch-controls:not([hidden]) {
    position: fixed;
    left: 0;
    right: 0;
    bottom: calc(26px + env(safe-area-inset-bottom));
    z-index: 10;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    padding: 0 max(16px, env(safe-area-inset-left)) 0 max(16px, env(safe-area-inset-right));
    pointer-events: none;
  }

  body.chat-open .touch-controls {
    visibility: hidden;
  }

  .joystick {
    position: relative;
    width: 124px;
    height: 124px;
    border: 1.5px solid rgba(255, 255, 255, 0.28);
    border-radius: 50%;
    background: radial-gradient(circle, rgba(10, 14, 26, 0.15), rgba(10, 14, 26, 0.45));
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    touch-action: none;
    pointer-events: auto;
  }

  .joystick__knob {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.82);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
    translate: calc(-50% + var(--dx, 0px)) calc(-50% + var(--dy, 0px));
    transition: translate 0.15s ease-out;
  }

  .joystick--active .joystick__knob {
    background: #ffd08a;
    transition: none;
  }

  .touch-buttons {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    pointer-events: auto;
  }

  .touch-button {
    display: grid;
    place-items: center;
    width: 58px;
    height: 58px;
    padding: 0;
    border-radius: 50%;
    font-size: 24px;
    cursor: pointer;
  }

  .touch-button--small {
    width: 46px;
    height: 46px;
    font-size: 20px;
  }

  .touch-button--big {
    width: 76px;
    height: 76px;
    border: 0;
    background: linear-gradient(180deg, #ffbe5c, #f59a3a);
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.3);
    font-size: 32px;
  }

  .touch-button:active {
    scale: 0.94;
  }

  /* 개미 · 상태 메뉴는 엄지가 닿는 하단 시트로 연다. */
  .popover {
    top: auto !important;
    right: 8px;
    bottom: calc(8px + var(--keyboard, 0px) + env(safe-area-inset-bottom)) !important;
    left: 8px !important;
    width: auto;
    max-height: 70vh;
    padding: 16px;
    overflow-y: auto;
    border-radius: 20px;
  }

  .popover__action,
  .popover__chip {
    min-height: 46px;
    font-size: 15px;
  }

  .popover__form input,
  .popover__form .btn {
    height: 44px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ticker__track,
  .loading__ant,
  .loading__leg {
    animation: none;
  }
}
