.overlay-root {
  position: fixed;
  inset: 0;
  z-index: 40;
  pointer-events: none;
}

.overlay-root.has-modal {
  pointer-events: auto;
  background: rgba(10, 16, 12, 0.55);
  backdrop-filter: blur(3px);
}

/* —— 标准对话框 —— */
.modal {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(0.92);
  width: min(92vw, 420px);
  background: var(--panel);
  color: var(--panel-ink);
  border-radius: 6px;
  box-shadow: var(--shadow);
  opacity: 0;
  animation: modal-in 0.35s var(--ease) forwards;
  overflow: hidden;
}

.modal.is-out {
  animation: modal-out 0.25s ease forwards;
}

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

@keyframes modal-out {
  to {
    opacity: 0;
    transform: translate(-50%, -48%) scale(0.96);
  }
}

.modal-titlebar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 0.85rem;
  background: #e4ebe4;
  border-bottom: 1px solid #c9d4cb;
  font-family: var(--mono);
  font-size: 0.75rem;
}

.modal-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #c45c4a;
}

.modal-body {
  padding: 1.15rem 1.2rem 0.5rem;
}

.modal-body h2 {
  margin: 0 0 0.55rem;
  font-size: 1.2rem;
  font-family: var(--display);
  font-weight: 400;
}

.modal-body p {
  margin: 0;
  color: #4a5a50;
  line-height: 1.5;
  font-size: 0.95rem;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
  padding: 1rem 1.2rem 1.15rem;
}

.modal-actions.asymmetric .btn:first-child {
  margin-right: auto;
  opacity: 0.75;
  font-size: 0.85rem;
  padding: 0.55rem 0.8rem;
}

/* —— 底部抽屉 —— */
.drawer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  max-width: none;
  border-radius: 16px 16px 0 0;
  transform: translateY(100%);
  animation: drawer-in 0.4s var(--ease) forwards;
  background: var(--panel);
  color: var(--panel-ink);
  box-shadow: var(--shadow);
}

.drawer.is-out {
  animation: drawer-out 0.3s ease forwards;
}

@keyframes drawer-in {
  to {
    transform: translateY(0);
  }
}

@keyframes drawer-out {
  to {
    transform: translateY(110%);
  }
}

.drawer-handle {
  width: 42px;
  height: 4px;
  border-radius: 999px;
  background: #c5d0c7;
  margin: 0.75rem auto 0;
}

.drawer .modal-body {
  text-align: center;
  padding-top: 1rem;
}

.drawer .modal-actions {
  justify-content: center;
  padding-bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px));
}

.countdown {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--accent);
  margin-top: 0.75rem;
}

/* —— 协议全屏 —— */
.contract {
  position: absolute;
  inset: 4vh 4vw;
  width: auto;
  max-width: none;
  transform: none;
  left: auto;
  top: auto;
  display: flex;
  flex-direction: column;
  animation: contract-in 0.45s var(--ease) forwards;
  opacity: 0;
}

@keyframes contract-in {
  from {
    opacity: 0;
    transform: scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.contract.is-out {
  animation: modal-out 0.25s ease forwards;
}

.contract-scroll {
  flex: 1;
  overflow: auto;
  padding: 1rem 1.25rem;
  font-size: 0.88rem;
  line-height: 1.55;
  color: #3d4a42;
  border-top: 1px solid #d5ddd6;
  border-bottom: 1px solid #d5ddd6;
  max-height: min(48vh, 360px);
}

.contract-scroll h3 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
}

.contract-scroll ol {
  margin: 0;
  padding-left: 1.2rem;
}

.contract-scroll li {
  margin-bottom: 0.55rem;
}

.contract-check {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  padding: 0.85rem 1.25rem;
  font-size: 0.9rem;
}

.contract-check input {
  margin-top: 0.2rem;
  width: 1rem;
  height: 1rem;
  accent-color: var(--accent);
}

.drag-zone {
  margin: 0 1.25rem 0.75rem;
  padding: 0.85rem;
  border: 2px dashed #a8b8ae;
  border-radius: 6px;
  text-align: center;
  font-family: var(--mono);
  font-size: 0.8rem;
  color: #5a6b60;
  min-height: 52px;
  display: grid;
  place-items: center;
  transition: border-color 0.2s, background 0.2s;
}

.drag-zone.is-ready {
  border-color: var(--accent);
  background: rgba(61, 124, 255, 0.08);
  color: var(--accent);
}

.drag-token {
  display: inline-block;
  padding: 0.45rem 0.8rem;
  background: var(--accent-hot);
  color: #fff;
  border-radius: 4px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: grab;
  user-select: none;
  margin: 0 1.25rem 0.5rem;
}

.drag-token:active {
  cursor: grabbing;
}

.contract .modal-actions .btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* —— 系统通知 —— */
.notify-root {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 50;
  display: flex;
  flex-direction: column-reverse;
  gap: 0.65rem;
  width: min(92vw, 340px);
  pointer-events: none;
}

.notify {
  pointer-events: auto;
  background: #1e2622;
  color: #e8efe8;
  border: 1px solid rgba(232, 239, 232, 0.15);
  border-radius: 8px;
  padding: 0.85rem 1rem;
  box-shadow: var(--shadow);
  transform: translateX(110%);
  animation: notify-in 0.4s var(--ease) forwards;
}

.notify.is-out {
  animation: notify-out 0.3s ease forwards;
}

@keyframes notify-in {
  to {
    transform: none;
  }
}

@keyframes notify-out {
  to {
    transform: translateX(120%);
    opacity: 0;
  }
}

.notify-app {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: #9aafa3;
  margin-bottom: 0.25rem;
}

.notify h3 {
  margin: 0 0 0.35rem;
  font-size: 0.95rem;
  font-weight: 600;
}

.notify p {
  margin: 0 0 0.75rem;
  font-size: 0.85rem;
  color: #9aafa3;
  line-height: 1.4;
}

.notify-actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.notify-actions .btn-ghost {
  color: #e8efe8;
  border-color: rgba(232, 239, 232, 0.28);
}

/* —— 终端 —— */
.terminal {
  background: #0d1210;
  color: #b8e0c4;
  font-family: var(--mono);
  border: 1px solid #2a3a30;
  border-radius: 6px;
  width: min(94vw, 520px);
  box-shadow: var(--shadow);
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  animation: modal-in 0.35s var(--ease) forwards;
  opacity: 0;
}

.terminal.is-out {
  animation: modal-out 0.25s ease forwards;
}

.terminal-bar {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.75rem;
  background: #151c18;
  border-bottom: 1px solid #2a3a30;
  font-size: 0.72rem;
  color: #7a9a84;
}

.terminal-body {
  padding: 1rem;
  min-height: 180px;
  font-size: 0.82rem;
  line-height: 1.55;
  white-space: pre-wrap;
}

.terminal-body .err {
  color: #ff7a6e;
}

.terminal-body .ok {
  color: #7dffb0;
}

.terminal-body .warn {
  color: var(--accent-warn);
}

.terminal-cursor {
  display: inline-block;
  width: 0.55ch;
  height: 1em;
  background: #b8e0c4;
  vertical-align: text-bottom;
  animation: blink 0.7s step-end infinite;
}

.terminal-actions {
  display: flex;
  gap: 0.5rem;
  padding: 0 1rem 1rem;
  flex-wrap: wrap;
}

.terminal .btn {
  font-family: var(--mono);
  font-size: 0.78rem;
}

/* —— 追鼠 / 权限 —— */
.chase-stage {
  position: absolute;
  inset: 0;
}

.chase-card {
  position: absolute;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%);
  width: min(92vw, 400px);
  background: var(--panel);
  color: var(--panel-ink);
  border-radius: 6px;
  box-shadow: var(--shadow);
  padding: 1.25rem;
  animation: modal-in 0.35s var(--ease) forwards;
  opacity: 0;
}

.chase-card h2 {
  margin: 0 0 0.5rem;
  font-family: var(--display);
  font-weight: 400;
}

.chase-card p {
  margin: 0 0 1.25rem;
  color: #4a5a50;
  line-height: 1.5;
}

.chase-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  min-height: 3rem;
  position: relative;
}

/* —— 碎裂 —— */
.shatter-root {
  position: fixed;
  inset: 0;
  z-index: 55;
  pointer-events: none;
}

.shatter-root.is-active {
  pointer-events: auto;
}

.shard {
  position: absolute;
  background: var(--panel);
  color: var(--panel-ink);
  border: 1px solid #c9d4cb;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  display: grid;
  place-items: center;
  font-size: 0.75rem;
  font-family: var(--mono);
  cursor: pointer;
  user-select: none;
  animation: shard-fly 0.55s var(--ease) both;
  transition: transform 0.15s ease, opacity 0.2s ease;
}

.shard:hover {
  transform: scale(1.05);
  z-index: 2;
}

.shard.is-gone {
  opacity: 0;
  transform: scale(0.6);
  pointer-events: none;
}

@keyframes shard-fly {
  from {
    opacity: 0;
    transform: translate(0, 0) rotate(0) scale(0.4);
  }
}

/* —— 终局三栏 —— */
.finale {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(94vw, 640px);
  display: grid;
  gap: 0.75rem;
  animation: land-in 0.5s var(--ease) both;
}

@media (min-width: 640px) {
  .finale {
    grid-template-columns: repeat(3, 1fr);
  }
}

.finale-card {
  background: var(--panel);
  color: var(--panel-ink);
  border-radius: 6px;
  padding: 1.15rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  transition: transform 0.2s var(--ease);
}

.finale-card:hover {
  transform: translateY(-4px);
}

.finale-card h3 {
  margin: 0;
  font-family: var(--display);
  font-weight: 400;
  font-size: 1.25rem;
}

.finale-card p {
  margin: 0;
  flex: 1;
  font-size: 0.88rem;
  color: #4a5a50;
  line-height: 1.45;
}

.finale-intro {
  grid-column: 1 / -1;
  text-align: center;
  color: #e8efe8;
  margin-bottom: 0.25rem;
}

.finale-intro h2 {
  margin: 0 0 0.4rem;
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(1.6rem, 4vw, 2.2rem);
}

.finale-intro p {
  margin: 0;
  color: #9aafa3;
}

/* 闸门 / 清算 / 客服 / 工单 */
.gate-finale .finale-card {
  cursor: default;
}

.debt-list {
  max-height: 220px;
  overflow: auto;
  margin: 0 16px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.debt-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 10px;
  background: #f6f6f6;
  border-radius: 8px;
  font-size: 0.85rem;
  opacity: 0;
  transform: translateX(-8px);
  transition: 0.25s ease;
}

.debt-row.is-in {
  opacity: 1;
  transform: none;
}

.debt-row.is-neg em {
  color: #e11d48;
  font-weight: 700;
  font-style: normal;
}

.debt-total {
  margin: 0 16px 12px;
  padding: 10px;
  background: #111;
  color: #fff;
  border-radius: 8px;
  font-size: 0.85rem;
  opacity: 0;
  transition: 0.3s ease;
}

.debt-total.is-on {
  opacity: 1;
}

.hijack-input {
  width: calc(100% - 32px);
  margin: 0 16px 12px;
  box-sizing: border-box;
  border: 1px solid #ddd;
  border-radius: 10px;
  padding: 10px;
  font-size: 0.9rem;
  resize: vertical;
}

.cs-modal {
  padding: 0 !important;
  overflow: hidden;
  max-width: 400px;
}

.cs-head {
  background: #ff4d8f;
  color: #fff;
  padding: 12px 16px;
  font-weight: 700;
}

.cs-body {
  background: #f5f5f5;
  min-height: 200px;
  max-height: 280px;
  overflow: auto;
  padding: 12px 14px;
}

.cs-typing {
  font-size: 0.8rem;
  color: #999;
  margin: 6px 0;
}

.cs-bubble {
  background: #fff;
  border-radius: 10px;
  padding: 8px 10px;
  margin: 8px 0;
  max-width: 85%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.cs-bubble strong {
  display: block;
  font-size: 0.72rem;
  color: #ff4d8f;
  margin-bottom: 2px;
}

.cs-modal .modal-actions {
  padding: 10px 12px 14px;
  margin: 0;
}

.notify.is-toss {
  animation: notify-in 0.35s ease;
}

.notify.is-in {
  animation: notify-in 0.35s ease;
}

@keyframes notify-in {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.blackout.is-warn {
  background: #3b0a0a;
}

.blackout.is-warn .blackout-text {
  color: #ffb4b4;
}

