/* ============================================================
   VEIL · 藏
   极简粗线条 / 淡紫色系
   ============================================================ */

:root {
  --bg: #08070c;
  --bg-soft: #0e0b16;
  --surface: #12101c;
  --surface-2: #171327;
  --line: rgba(196, 178, 240, 0.13);
  --line-mid: rgba(196, 178, 240, 0.26);
  --line-strong: rgba(210, 194, 250, 0.55);
  --ink: #f1edfb;
  --dim: #7d7695;
  --dim-2: #59536e;
  --violet-1: #d9c9ff;
  --violet-2: #a992e2;
  --violet-3: #6f5da3;
  --violet-4: #3b3159;
  --hunter: #e2d2ff;
  --prey: #8c7cc0;
  --danger: #ff8b8b;
  --radius: 16px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB',
    'Microsoft YaHei', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

body {
  background-image: radial-gradient(120% 90% at 50% -10%, rgba(111, 93, 163, 0.22), transparent 60%),
    radial-gradient(80% 60% at 100% 110%, rgba(80, 60, 130, 0.18), transparent 60%);
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image: linear-gradient(rgba(196, 178, 240, 0.032) 1px, transparent 1px),
    linear-gradient(90deg, rgba(196, 178, 240, 0.032) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(80% 70% at 50% 40%, #000 20%, transparent 75%);
  -webkit-mask-image: radial-gradient(80% 70% at 50% 40%, #000 20%, transparent 75%);
}

#app {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
}

.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
}

.screen.active {
  display: flex;
}

/* ---------------- 通用元件 ---------------- */

.btn {
  appearance: none;
  border: 1.5px solid var(--line-mid);
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 14px 20px;
  border-radius: var(--radius);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.18s, border-color 0.18s, transform 0.12s, color 0.18s;
  user-select: none;
}

.btn:hover {
  border-color: var(--line-strong);
  background: rgba(169, 146, 226, 0.08);
}

.btn:active {
  transform: scale(0.985);
}

.btn-primary {
  background: linear-gradient(180deg, rgba(217, 201, 255, 0.96), rgba(169, 146, 226, 0.92));
  color: #16101f;
  border-color: transparent;
  box-shadow: 0 10px 30px -12px rgba(169, 146, 226, 0.9);
}

.btn-primary:hover {
  background: linear-gradient(180deg, #e8dcff, #b9a5ea);
  border-color: transparent;
}

.btn-ghost {
  color: var(--violet-1);
}

.btn-block {
  width: 100%;
}

.btn[disabled] {
  opacity: 0.45;
  pointer-events: none;
}

.btn-icon {
  width: 19px;
  height: 19px;
  flex: none;
}

input[type='text'] {
  font: inherit;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.028);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 13px 15px;
  outline: none;
  width: 100%;
  transition: border-color 0.18s, background 0.18s;
}

input[type='text']:focus {
  border-color: var(--line-strong);
  background: rgba(169, 146, 226, 0.07);
}

input::placeholder {
  color: var(--dim-2);
}

.field {
  display: block;
  margin-bottom: 18px;
}

.field-label {
  display: block;
  font-size: 12px;
  letter-spacing: 0.14em;
  color: var(--dim);
  margin-bottom: 8px;
  text-transform: uppercase;
}

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  color: var(--dim-2);
  font-size: 12px;
  letter-spacing: 0.08em;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}

.hint {
  color: var(--dim);
  font-size: 12.5px;
  margin: 16px 0 0;
  line-height: 1.7;
}

.hint.err {
  color: var(--danger);
}

/* ---------------- 首页 ---------------- */

#screen-home {
  align-items: center;
  justify-content: center;
  padding: calc(32px + var(--safe-t)) 20px calc(32px + var(--safe-b));
}

.home-wrap {
  width: 100%;
  max-width: 400px;
  margin: auto;
}

.brand {
  text-align: center;
  margin-bottom: 30px;
}

.brand-mark {
  width: 58px;
  height: 58px;
  color: var(--violet-1);
  opacity: 0.9;
  filter: drop-shadow(0 0 16px rgba(169, 146, 226, 0.45));
}

.brand h1 {
  font-size: 40px;
  letter-spacing: 0.34em;
  margin: 14px 0 0 0.34em;
  font-weight: 800;
  line-height: 1;
  background: linear-gradient(180deg, #ffffff, #b9a5ea);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-sub {
  margin: 10px 0 0;
  color: var(--dim);
  font-size: 13px;
  letter-spacing: 0.22em;
}

.panel {
  background: linear-gradient(180deg, rgba(23, 19, 39, 0.92), rgba(14, 11, 22, 0.92));
  border: 1.5px solid var(--line);
  border-radius: 22px;
  padding: 22px;
  backdrop-filter: blur(12px);
}

.join-row {
  display: flex;
  gap: 10px;
}

.join-row input {
  text-transform: uppercase;
  letter-spacing: 0.28em;
  font-weight: 700;
  text-align: center;
  font-size: 16px;
}

.join-row .btn {
  flex: none;
  padding-inline: 24px;
}

.rules {
  margin-top: 26px;
  padding: 0 4px;
}

.rules-head {
  font-size: 11.5px;
  letter-spacing: 0.2em;
  color: var(--dim-2);
  margin-bottom: 10px;
  text-transform: uppercase;
}

.rules ul {
  margin: 0;
  padding-left: 16px;
  color: var(--dim);
  font-size: 12.5px;
  line-height: 1.85;
}

.rules li {
  margin-bottom: 4px;
}

.rules b {
  color: var(--violet-1);
  font-weight: 600;
}

/* ---------------- 等待房间 ---------------- */

#screen-lobby {
  align-items: center;
  justify-content: center;
  padding: calc(24px + var(--safe-t)) 20px calc(24px + var(--safe-b));
}

.lobby-wrap {
  width: 100%;
  max-width: 400px;
  margin: auto;
}

.lobby-head {
  text-align: center;
  margin-bottom: 34px;
}

.eyebrow {
  display: block;
  font-size: 11.5px;
  letter-spacing: 0.26em;
  color: var(--dim-2);
  text-transform: uppercase;
  margin-bottom: 12px;
}

.code-chip {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  background: transparent;
  border: 1.5px solid var(--line-mid);
  border-radius: 16px;
  padding: 10px 20px;
  color: var(--ink);
  cursor: pointer;
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 30px;
  letter-spacing: 0.2em;
  font-weight: 700;
  transition: border-color 0.18s, background 0.18s;
}

.code-chip:hover {
  border-color: var(--line-strong);
  background: rgba(169, 146, 226, 0.07);
}

.copy-icon {
  width: 18px;
  height: 18px;
  color: var(--dim);
  flex: none;
}

.lobby-tip {
  color: var(--dim);
  font-size: 12.5px;
  margin: 14px 0 0;
}

.seats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 22px;
}

.seat {
  border: 1.5px solid var(--line);
  border-radius: 18px;
  padding: 20px 14px;
  text-align: center;
  background: rgba(255, 255, 255, 0.02);
  transition: border-color 0.25s, background 0.25s;
  position: relative;
  overflow: hidden;
}

.seat.filled {
  border-color: var(--line-mid);
  background: rgba(169, 146, 226, 0.07);
}

.seat.me::after {
  content: '你';
  position: absolute;
  top: 8px;
  right: 9px;
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--violet-2);
  border: 1px solid var(--line-mid);
  border-radius: 6px;
  padding: 0 5px;
  line-height: 15px;
}

.seat-avatar {
  width: 46px;
  height: 46px;
  margin: 0 auto 10px;
  border-radius: 50%;
  border: 2px solid var(--line-mid);
  display: grid;
  place-items: center;
  color: var(--violet-2);
  font-weight: 700;
  font-size: 15px;
  font-family: ui-monospace, Menlo, monospace;
}

.seat.filled .seat-avatar {
  border-color: var(--violet-2);
  color: var(--violet-1);
  box-shadow: 0 0 18px -4px rgba(169, 146, 226, 0.7);
}

.seat-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.seat.filled .seat-name {
  color: var(--ink);
}

.seat-tag {
  font-size: 11px;
  color: var(--dim-2);
  letter-spacing: 0.12em;
  margin-top: 3px;
}

.seat.filled .seat-tag {
  color: var(--violet-2);
}

.lobby-status {
  text-align: center;
  color: var(--dim);
  font-size: 13px;
  margin-bottom: 22px;
  min-height: 22px;
}

.lobby-status .pulse {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--violet-2);
  margin-right: 8px;
  vertical-align: middle;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.25;
    transform: scale(0.8);
  }
  50% {
    opacity: 1;
    transform: scale(1.15);
  }
}

/* ---------------- 游戏 ---------------- */

#screen-game {
  overflow: hidden;
  background: transparent;
}

#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.hud {
  position: absolute;
  top: calc(10px + var(--safe-t));
  left: calc(12px + var(--safe-l));
  right: calc(12px + var(--safe-r));
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none;
  z-index: 6;
}

.hud-left,
.hud-right {
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
}

.hud-right {
  flex-direction: row;
}

.role-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 13px;
  border-radius: 999px;
  border: 1.5px solid var(--line-mid);
  background: rgba(10, 8, 16, 0.72);
  backdrop-filter: blur(8px);
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--prey);
  transition: color 0.3s, border-color 0.3s, box-shadow 0.3s;
}

.role-chip .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 10px currentColor;
}

.role-chip.hunter {
  color: var(--hunter);
  border-color: rgba(226, 210, 255, 0.5);
  box-shadow: 0 0 24px -8px rgba(226, 210, 255, 0.8);
}

.timer {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 13px;
  font-weight: 600;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
  background: rgba(10, 8, 16, 0.72);
  border: 1.5px solid var(--line);
  border-radius: 999px;
  padding: 7px 12px;
  backdrop-filter: blur(8px);
}

.timer.warn {
  color: var(--violet-1);
  border-color: var(--line-mid);
}

/* 链路指示：直连亮紫、中转灰紫。放在计时器旁边，玩家一眼能看出
   这一局的数据到底有没有绕开中转。 */
.link-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 11px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: rgba(10, 8, 16, 0.72);
  backdrop-filter: blur(8px);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--dim);
  transition: color 0.3s, border-color 0.3s;
}

.link-chip i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.link-chip.p2p {
  color: var(--violet-1);
  border-color: var(--line-mid);
}

.link-chip.p2p i {
  box-shadow: 0 0 8px currentColor;
}

.link-chip.hide {
  display: none;
}

.oppo {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: rgba(10, 8, 16, 0.72);
  backdrop-filter: blur(8px);
  font-size: 12px;
  max-width: 46vw;
}

.oppo-name {
  color: var(--dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 26vw;
}

.oppo-role {
  color: var(--hunter);
  font-weight: 700;
  letter-spacing: 0.06em;
}

.oppo-role.prey {
  color: var(--prey);
}

.icon-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: rgba(10, 8, 16, 0.72);
  color: var(--violet-2);
  cursor: pointer;
  backdrop-filter: blur(8px);
}

.icon-btn svg {
  width: 17px;
  height: 17px;
}

.icon-btn.on {
  color: #16101f;
  background: var(--violet-1);
  border-color: transparent;
}

/* 方向键 */
.pad {
  position: absolute;
  left: 50%;
  bottom: calc(16px + var(--safe-b));
  transform: translateX(-50%);
  display: none;
  grid-template-columns: repeat(3, 54px);
  grid-template-rows: repeat(3, 54px);
  gap: 4px;
  z-index: 6;
  opacity: 0.6;
  transition: opacity 0.2s;
}

body.touch .pad {
  display: grid;
}

.pad-btn {
  appearance: none;
  border: 1.5px solid var(--line-mid);
  background: rgba(18, 16, 28, 0.7);
  color: var(--violet-1);
  border-radius: 16px;
  display: grid;
  place-items: center;
  padding: 0;
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition: background 0.1s, transform 0.1s;
}

.pad-btn svg {
  width: 24px;
  height: 24px;
}

.pad-btn:active {
  background: rgba(169, 146, 226, 0.32);
  transform: scale(0.94);
}

.pad-up {
  grid-area: 1 / 2;
}
.pad-left {
  grid-area: 2 / 1;
}
.pad-right {
  grid-area: 2 / 3;
}
.pad-down {
  grid-area: 3 / 2;
}

@media (hover: none) and (pointer: coarse) {
  .pad {
    display: grid;
    opacity: 0.62;
  }
}

/* 聊天 */
.chat-toggle {
  position: absolute;
  right: calc(12px + var(--safe-r));
  bottom: calc(20px + var(--safe-b));
  width: 46px;
  height: 46px;
  border-radius: 999px;
  border: 1.5px solid var(--line-mid);
  background: rgba(18, 16, 28, 0.82);
  color: var(--violet-1);
  display: grid;
  place-items: center;
  cursor: pointer;
  z-index: 8;
  backdrop-filter: blur(8px);
}

.chat-toggle svg {
  width: 20px;
  height: 20px;
}

.chat-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  min-width: 17px;
  height: 17px;
  border-radius: 999px;
  background: var(--violet-1);
  color: #16101f;
  font-size: 10px;
  font-weight: 800;
  display: none;
  place-items: center;
  padding: 0 4px;
}

.chat-badge.show {
  display: grid;
}

.chat-panel {
  position: absolute;
  right: calc(12px + var(--safe-r));
  bottom: calc(76px + var(--safe-b));
  width: min(340px, calc(100vw - 24px));
  max-height: min(58vh, 420px);
  background: rgba(14, 11, 22, 0.96);
  border: 1.5px solid var(--line-mid);
  border-radius: 18px;
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 9;
  backdrop-filter: blur(16px);
  box-shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.9);
}

.chat-panel.open {
  display: flex;
}

.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  letter-spacing: 0.12em;
  color: var(--dim);
  text-transform: uppercase;
  flex: none;
}

.chat-close {
  background: none;
  border: none;
  color: var(--dim);
  cursor: pointer;
  padding: 2px;
  display: grid;
  place-items: center;
}

.chat-close svg {
  width: 16px;
  height: 16px;
}

.chat-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 80px;
}

.chat-msg {
  font-size: 13px;
  line-height: 1.55;
  max-width: 88%;
  padding: 7px 11px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.045);
  color: var(--ink);
  align-self: flex-start;
  word-break: break-word;
}

.chat-msg.mine {
  align-self: flex-end;
  background: rgba(169, 146, 226, 0.2);
}

.chat-msg .who {
  display: block;
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--dim-2);
  margin-bottom: 2px;
}

.chat-empty {
  color: var(--dim-2);
  font-size: 12px;
  text-align: center;
  margin: auto;
}

.chat-form {
  display: flex;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid var(--line);
  flex: none;
}

.chat-form input {
  padding: 9px 12px;
  font-size: 13px;
  border-radius: 10px;
}

.chat-form button {
  flex: none;
  border: 1.5px solid var(--line-mid);
  background: transparent;
  color: var(--violet-1);
  border-radius: 10px;
  padding: 0 14px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

/* 浮层 */
.overlay {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 7;
  background: rgba(6, 5, 10, 0.38);
  padding: 24px;
  transition: background 0.3s;
}

.overlay.deep {
  background: rgba(6, 5, 10, 0.86);
}

.overlay.show {
  display: flex;
}

.countdown {
  display: none;
  font-size: 108px;
  font-weight: 800;
  color: #f0e6ff;
  text-shadow: 0 0 40px rgba(169, 146, 226, 0.95), 0 0 90px rgba(140, 110, 220, 0.6);
  font-family: ui-monospace, Menlo, monospace;
  line-height: 1;
}

.countdown.show {
  display: block;
  animation: cdScale 0.4s cubic-bezier(0.2, 0.9, 0.3, 1);
}

@keyframes cdScale {
  0% {
    transform: scale(1.45);
  }
  65% {
    transform: scale(0.96);
  }
  100% {
    transform: scale(1);
  }
}

.result {
  display: none;
  width: 100%;
  max-width: 360px;
  text-align: center;
  background: linear-gradient(180deg, rgba(23, 19, 39, 0.97), rgba(14, 11, 22, 0.97));
  border: 1.5px solid var(--line-mid);
  border-radius: 22px;
  padding: 28px 22px;
  box-shadow: 0 30px 80px -30px rgba(0, 0, 0, 1);
}

.result.show {
  display: block;
  animation: cdScale 0.3s cubic-bezier(0.2, 0.9, 0.3, 1);
}

.result-kicker {
  font-size: 11px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--dim-2);
}

.result-title {
  font-size: 26px;
  font-weight: 800;
  margin: 10px 0 6px;
  color: var(--violet-1);
  letter-spacing: 0.04em;
}

.result-desc {
  color: var(--dim);
  font-size: 13px;
  margin: 0 0 22px;
}

.result-actions {
  display: flex;
  gap: 10px;
}

.result-actions .btn {
  flex: 1;
}

.result-wait {
  margin: 14px 0 0;
  font-size: 12px;
  color: var(--dim);
  min-height: 18px;
}

/* toast */
.toast-stack {
  position: absolute;
  top: calc(58px + var(--safe-t));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 10;
  pointer-events: none;
  width: max-content;
  max-width: calc(100vw - 32px);
}

.toast {
  background: rgba(23, 19, 39, 0.94);
  border: 1.5px solid var(--line-mid);
  border-radius: 999px;
  padding: 8px 18px;
  font-size: 12.5px;
  color: var(--violet-1);
  backdrop-filter: blur(10px);
  animation: toastIn 0.28s ease-out;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.toast.fade {
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 0.35s, transform 0.35s;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.conn-banner {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: calc(6px + var(--safe-t)) 12px 6px;
  background: rgba(255, 139, 139, 0.14);
  border-bottom: 1px solid rgba(255, 139, 139, 0.3);
  color: #ffbdbd;
  font-size: 12px;
  text-align: center;
  z-index: 12;
  display: none;
}

.conn-banner.show {
  display: block;
}

/* 对手掉线 · 等待重连
   和结算浮层刻意区分开：这里游戏没有结束，只是暂停，
   所以背景只压到 72%，底下那盘残局还能看见。 */
.wait-layer {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9;
  padding: 24px;
  background: rgba(6, 5, 10, 0.72);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

.wait-layer.show {
  display: flex;
}

.wait-card {
  width: 100%;
  max-width: 330px;
  text-align: center;
  background: linear-gradient(180deg, rgba(23, 19, 39, 0.96), rgba(14, 11, 22, 0.96));
  border: 1.5px solid var(--line-mid);
  border-radius: 22px;
  padding: 30px 22px 22px;
  box-shadow: 0 30px 80px -30px rgba(0, 0, 0, 1);
  animation: cdScale 0.3s cubic-bezier(0.2, 0.9, 0.3, 1);
}

.wait-glyph {
  width: 46px;
  height: 46px;
  margin: 0 auto 14px;
  color: var(--violet-2);
}

.wait-glyph svg {
  width: 100%;
  height: 100%;
  display: block;
  animation: waitSpin 5.5s linear infinite;
}

@keyframes waitSpin {
  to {
    transform: rotate(360deg);
  }
}

.wait-kicker {
  font-size: 11px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--dim-2);
}

.wait-title {
  font-size: 21px;
  font-weight: 800;
  margin: 8px 0;
  color: var(--violet-1);
  letter-spacing: 0.03em;
}

.wait-desc {
  font-size: 13px;
  color: var(--dim);
  margin: 0 0 16px;
  line-height: 1.65;
}

.wait-note {
  font-size: 12px;
  color: var(--dim-2);
  margin: 0 0 18px;
  font-variant-numeric: tabular-nums;
  min-height: 18px;
}

.wait-card .btn {
  width: 100%;
}

/* ============================================================
   外观自定义面板
   ============================================================ */

.btn-quiet {
  margin-top: 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--dim);
  border-color: var(--line);
  padding: 11px 16px;
}

.btn-quiet:hover {
  color: var(--ink);
  border-color: var(--line-mid);
}

.btn-icon {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
}

.sheet {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(4, 3, 8, 0.74);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.sheet.show {
  display: flex;
}

.sheet-card {
  width: 100%;
  max-width: 520px;
  max-height: min(88vh, 780px);
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #15111f, #0b0912);
  border: 1px solid var(--line-mid);
  border-radius: 22px;
  box-shadow: 0 30px 80px -30px rgba(0, 0, 0, 0.92);
  overflow: hidden;
  animation: sheetIn 0.22s ease-out;
}

@keyframes sheetIn {
  from {
    transform: translateY(14px) scale(0.986);
    opacity: 0;
  }
  to {
    transform: none;
    opacity: 1;
  }
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 17px 20px 13px;
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}

.sheet-head h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.sheet-x {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--dim);
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.16s, color 0.16s;
}

.sheet-x svg {
  width: 18px;
  height: 18px;
}

.sheet-x:hover {
  color: var(--ink);
  background: rgba(169, 146, 226, 0.1);
}

.sheet-scroll {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px 20px 6px;
  flex: 1 1 auto;
  -webkit-overflow-scrolling: touch;
}

.sheet-foot {
  display: flex;
  gap: 10px;
  padding: 14px 20px calc(15px + var(--safe-b));
  border-top: 1px solid var(--line);
  flex: 0 0 auto;
}

.sheet-foot .btn {
  flex: 1;
  padding: 12px 14px;
  font-size: 14px;
}

.preview-wrap {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: #08070c;
  line-height: 0;
}

#themePreview {
  display: block;
  width: 100%;
  height: 140px;
}

.preview-label {
  position: absolute;
  right: 11px;
  top: 9px;
  font-size: 9.5px;
  letter-spacing: 0.2em;
  color: rgba(240, 235, 255, 0.4);
  text-transform: uppercase;
  line-height: 1;
}

.tgroup {
  margin-top: 18px;
}

.tgroup-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.tgroup-head h4 {
  margin: 0;
  font-size: 12.5px;
  font-weight: 650;
  letter-spacing: 0.1em;
  color: var(--ink);
}

.tgroup-hint {
  font-size: 11px;
  color: var(--dim-2);
  letter-spacing: 0.02em;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chips-inline {
  flex: 1 1 auto;
  min-width: 0;
}

.chip {
  appearance: none;
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 11px;
  border-radius: 10px;
  border: 1.5px solid var(--line);
  background: transparent;
  color: var(--dim);
  transition: border-color 0.16s, color 0.16s, background 0.16s;
  white-space: nowrap;
}

.chip:hover {
  border-color: var(--line-mid);
  color: var(--ink);
}

.chip.on {
  border-color: var(--violet-2);
  color: var(--ink);
  background: rgba(169, 146, 226, 0.14);
}

.chip-swatch {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  flex: 0 0 auto;
}

.chip-swatch.dual {
  background: linear-gradient(135deg, var(--sw1) 0 50%, var(--sw2) 50% 100%);
}

.color-row {
  display: flex;
  gap: 10px;
}

.color-field {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 8px 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 0.16s;
}

.color-field:hover {
  border-color: var(--line-mid);
}

.color-field input[type='color'] {
  width: 100%;
  height: 30px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  appearance: none;
}

.color-field input[type='color']::-webkit-color-swatch-wrapper {
  padding: 0;
}

.color-field input[type='color']::-webkit-color-swatch {
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 7px;
}

.color-field input[type='color']::-moz-color-swatch {
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 7px;
}

.color-field span {
  font-size: 11px;
  color: var(--dim);
  letter-spacing: 0.04em;
}

.color-field.sm {
  flex: 0 0 66px;
}

.color-field.sm input[type='color'] {
  height: 26px;
}

.shape-line {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

@media (max-width: 430px) {
  .sheet {
    padding: 0;
    align-items: flex-end;
  }

  .sheet-card {
    max-width: none;
    max-height: 94vh;
    border-radius: 22px 22px 0 0;
    border-bottom: 0;
  }

  .sheet-scroll {
    padding: 14px 16px 4px;
  }

  .sheet-head,
  .sheet-foot {
    padding-left: 16px;
    padding-right: 16px;
  }

  #themePreview {
    height: 118px;
  }

  .chip {
    padding: 7px 10px;
    font-size: 12px;
  }
}

/* 构建版本号 —— 极低调，只为了确认浏览器跑的是哪一版 */
.build-tag {
  margin-top: 16px;
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--dim-2);
  opacity: 0.72;
  text-align: center;
  font-family: ui-monospace, Menlo, monospace;
  user-select: text;
}

/* 版本自检提示条 —— 浏览器缓存里跑着旧前端时提醒一下 */
.update-bar {
  position: fixed;
  left: 50%;
  top: calc(10px + var(--safe-t));
  transform: translate(-50%, -180%);
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 8px 15px;
  border-radius: 999px;
  background: rgba(26, 20, 40, 0.97);
  border: 1.5px solid var(--line-mid);
  color: var(--ink);
  font-size: 12.5px;
  letter-spacing: 0.02em;
  box-shadow: 0 14px 34px -14px rgba(0, 0, 0, 0.9);
  transition: transform 0.32s cubic-bezier(0.2, 0.9, 0.3, 1);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.update-bar.show {
  transform: translate(-50%, 0);
}

.update-bar button {
  appearance: none;
  border: 0;
  background: var(--violet-2);
  color: #0f0b18;
  font: inherit;
  font-weight: 650;
  padding: 5px 12px;
  border-radius: 999px;
  cursor: pointer;
}
