/* ============================================================================
   冒险岛 Web · 界面样式
   深色玻璃拟态 + 枫叶暖色点缀，全部手写，无外部依赖。
   ========================================================================== */

:root {
  --ink: #0d0a17;
  --ink-2: #171226;
  --panel: rgba(24, 19, 40, 0.92);
  --panel-solid: #1b1630;
  --line: rgba(255, 255, 255, 0.1);
  --line-strong: rgba(255, 255, 255, 0.22);
  --text: #f3eefc;
  --muted: #a79fc2;
  --brand: #ff9f43;
  --brand-2: #ffd166;
  --leaf: #ff6b6b;
  --hp: linear-gradient(180deg, #ff7b7b, #d43a3a);
  --mp: linear-gradient(180deg, #79b8ff, #2f6fd0);
  --exp: linear-gradient(180deg, #ffe08a, #e0a020);
  --good: #5ddb9a;
  --warn: #ffc857;
  --bad: #ff6b6b;
  --radius: 14px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --font: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", "Segoe UI", system-ui, sans-serif;
  --mono: "Cascadia Code", "Consolas", "Menlo", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: var(--ink);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

button, input, select { font-family: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.18); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.3); }
::-webkit-scrollbar-track { background: transparent; }

.screen { position: fixed; inset: 0; }

/* --------------------------------------------------------------- 启动画面 */
.boot-screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
  justify-content: center;
  background: radial-gradient(120% 80% at 50% 0%, #2b1f4d 0%, #120d20 55%, #090711 100%);
  z-index: 100;
  transition: opacity 0.45s ease, visibility 0.45s;
}
.boot-screen.done { opacity: 0; visibility: hidden; }
.boot-logo { font-size: 40px; font-weight: 800; letter-spacing: 4px; }
.boot-logo span { color: var(--brand); font-size: 16px; letter-spacing: 6px; margin-left: 8px; vertical-align: middle; }
.boot-tip { color: var(--muted); font-size: 13px; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 0.45; } 50% { opacity: 1; } }

/* ------------------------------------------------------------------ 登录页 */
.auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #1a2b52 0%, #37345f 42%, #6d4a63 74%, #b5633f 100%);
  overflow: hidden;
}
.sky { position: absolute; inset: 0; overflow: hidden; }
.cloud {
  position: absolute;
  height: 46px;
  border-radius: 60px;
  background: rgba(255, 255, 255, 0.16);
  filter: blur(2px);
  animation: drift linear infinite;
}
.cloud::before, .cloud::after {
  content: "";
  position: absolute;
  background: inherit;
  border-radius: 50%;
}
.cloud::before { width: 60px; height: 60px; top: -26px; left: 22px; }
.cloud::after { width: 44px; height: 44px; top: -18px; right: 26px; }
.cloud.c1 { width: 150px; top: 12%; left: -20%; animation-duration: 68s; }
.cloud.c2 { width: 220px; top: 24%; left: -30%; animation-duration: 96s; animation-delay: -30s; opacity: 0.7; }
.cloud.c3 { width: 110px; top: 6%; left: -15%; animation-duration: 82s; animation-delay: -55s; opacity: 0.5; }
@keyframes drift { to { transform: translateX(160vw); } }
.hill {
  position: absolute;
  bottom: -12vh;
  border-radius: 50% 50% 0 0;
  filter: blur(1px);
}
.hill.h1 { left: -10vw; width: 75vw; height: 42vh; background: #2c4a3a; opacity: 0.85; }
.hill.h2 { right: -14vw; width: 80vw; height: 34vh; background: #22393a; opacity: 0.9; }

.auth-card {
  position: relative;
  width: min(420px, 92vw);
  padding: 28px 28px 18px;
  border-radius: 22px;
  background: linear-gradient(160deg, rgba(30, 24, 52, 0.94), rgba(17, 13, 30, 0.96));
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(14px);
  animation: rise 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes rise { from { transform: translateY(18px); opacity: 0; } }

.brand { display: flex; gap: 14px; align-items: center; margin-bottom: 20px; }
.brand-mark {
  width: 54px; height: 54px;
  display: grid; place-items: center;
  font-size: 30px;
  border-radius: 16px;
  background: radial-gradient(circle at 30% 25%, #ffd08a, #ff8a3d 60%, #c9502c);
  box-shadow: 0 10px 24px rgba(255, 138, 61, 0.35);
  transform: rotate(-6deg);
}
.brand h1 { margin: 0; font-size: 24px; letter-spacing: 2px; }
.brand h1 em { font-style: normal; font-size: 11px; letter-spacing: 4px; color: var(--brand); vertical-align: super; }
.brand p { margin: 4px 0 0; font-size: 12px; color: var(--muted); }

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 5px;
  margin-bottom: 16px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--line);
}
.auth-tabs button {
  padding: 9px 0;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  transition: 0.18s;
}
.auth-tabs button.active { background: linear-gradient(180deg, #ffb35c, #f08a2c); color: #2a1402; font-weight: 700; }

.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; letter-spacing: 1px; }
.field > span i { font-style: normal; opacity: 0.6; }
.field input, .field select {
  width: 100%;
  padding: 11px 13px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: rgba(8, 6, 16, 0.6);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: 0.18s;
}
.field input:focus, .field select:focus {
  border-color: rgba(255, 159, 67, 0.8);
  box-shadow: 0 0 0 3px rgba(255, 159, 67, 0.16);
}
.field select option { background: #1b1630; }

.primary {
  border: 0;
  padding: 11px 20px;
  border-radius: 10px;
  background: linear-gradient(180deg, #ffb45f, #ef8628);
  color: #2a1402;
  font-weight: 800;
  letter-spacing: 1px;
  box-shadow: 0 8px 22px rgba(239, 134, 40, 0.32);
  transition: transform 0.12s, filter 0.18s;
}
.primary:hover { filter: brightness(1.06); }
.primary:active { transform: translateY(1px) scale(0.995); }
.primary:disabled { filter: grayscale(0.7) brightness(0.8); cursor: not-allowed; }
.primary.wide { width: 100%; margin-top: 6px; padding: 13px; }

.ghost {
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  border-radius: 10px;
  padding: 9px 14px;
  transition: 0.18s;
}
.ghost:hover { background: rgba(255, 255, 255, 0.1); }
.ghost.small { padding: 6px 12px; font-size: 12px; }

.link { border: 0; background: none; color: var(--brand-2); font-size: 12px; text-decoration: underline; }

.form-error { min-height: 18px; margin: 8px 2px 0; font-size: 12px; color: var(--bad); }

.auth-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: #888; box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.05); }
.dot.online { background: var(--good); box-shadow: 0 0 10px rgba(93, 219, 154, 0.8); }
.dot.offline { background: var(--bad); box-shadow: 0 0 10px rgba(255, 107, 107, 0.6); }
.auth-foot .link { margin-left: auto; }

/* ------------------------------------------------------------------ 选角页 */
.char-screen {
  padding: 34px clamp(16px, 5vw, 64px);
  overflow-y: auto;
  background:
    radial-gradient(80% 60% at 15% 0%, rgba(255, 159, 67, 0.12), transparent 60%),
    radial-gradient(70% 60% at 85% 10%, rgba(94, 91, 255, 0.16), transparent 60%),
    linear-gradient(180deg, #14101f, #0a0812);
}
.char-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; max-width: 1100px; margin: 0 auto 22px; }
.char-top h2 { margin: 0 0 6px; font-size: 26px; letter-spacing: 2px; }
.char-top p { margin: 0; color: var(--muted); font-size: 13px; }
.char-top-actions { display: flex; align-items: center; gap: 10px; }
.chip { padding: 6px 12px; border-radius: 999px; background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line); font-size: 12px; color: var(--muted); }

.character-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
  max-width: 1100px;
  margin: 0 auto 26px;
}
.char-card {
  position: relative;
  padding: 18px;
  border-radius: 18px;
  background: linear-gradient(165deg, rgba(38, 30, 62, 0.9), rgba(19, 15, 33, 0.95));
  border: 1px solid var(--line);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
  transition: transform 0.18s, border-color 0.18s;
}
.char-card:hover { transform: translateY(-3px); border-color: rgba(255, 159, 67, 0.5); }
.char-card .char-avatar {
  width: 62px; height: 62px;
  border-radius: 16px;
  display: grid; place-items: center;
  font-size: 22px; font-weight: 800;
  margin-bottom: 12px;
}
.char-card h3 { margin: 0 0 4px; font-size: 18px; }
.char-card .char-meta { margin: 0 0 12px; font-size: 12px; color: var(--muted); }
.char-card .char-stats { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; font-size: 12px; color: var(--muted); }
.char-card .char-stats b { color: var(--text); }
.char-card.empty {
  display: grid;
  place-items: center;
  min-height: 190px;
  border-style: dashed;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  background: rgba(255, 255, 255, 0.02);
}

.create-card {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
}
.create-card h3 { margin: 0 0 14px; font-size: 15px; letter-spacing: 1px; color: var(--muted); }
.create-row { display: grid; grid-template-columns: 1.2fr 1fr auto; gap: 14px; align-items: end; }
.create-row .field { margin: 0; }
.create-row .primary { height: 42px; }
.hint { min-height: 16px; margin: 10px 2px 0; font-size: 12px; color: var(--warn); }

/* -------------------------------------------------------------------- 游戏 */
.game-screen { background: #0b0913; }
#game-canvas { display: block; width: 100%; height: 100%; cursor: crosshair; }

.hud {
  position: absolute;
  top: 14px; left: 14px; right: 14px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
}
.hud-left, .hud-right { display: flex; align-items: center; gap: 12px; pointer-events: auto; }
.hud-left {
  padding: 10px 16px 10px 10px;
  border-radius: 16px;
  background: linear-gradient(120deg, rgba(26, 20, 44, 0.86), rgba(14, 11, 24, 0.72));
  border: 1px solid var(--line);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
}
.portrait {
  width: 48px; height: 48px;
  border-radius: 13px;
  display: grid; place-items: center;
  font-weight: 800; font-size: 17px;
  color: #26130a;
  background: linear-gradient(160deg, #ffd58f, #ff9130);
  box-shadow: inset 0 -6px 12px rgba(0, 0, 0, 0.2);
}
.hud-id { min-width: 210px; }
.hud-name-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; font-weight: 700; font-size: 14px; }
.tag { padding: 2px 8px; border-radius: 999px; font-size: 10px; font-weight: 700; letter-spacing: 1px; }
.tag.guild { background: rgba(110, 160, 255, 0.2); color: #9dc0ff; border: 1px solid rgba(110, 160, 255, 0.35); }
.tag.pk { background: rgba(255, 90, 90, 0.18); color: #ff9d9d; border: 1px solid rgba(255, 90, 90, 0.4); }

.bars { display: grid; gap: 4px; }
.bar {
  position: relative;
  height: 13px;
  width: 210px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.5);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.bar i { position: absolute; inset: 0 auto 0 0; width: 100%; border-radius: inherit; transition: width 0.22s ease; }
.bar.hp i { background: var(--hp); }
.bar.mp i { background: var(--mp); }
.bar.exp { height: 8px; width: 210px; }
.bar.exp i { background: var(--exp); }
.bar span {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-size: 9px; font-family: var(--mono);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9);
  letter-spacing: 0.4px;
}
.level-badge {
  width: 42px; height: 42px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: radial-gradient(circle at 35% 25%, #4b3d78, #221a3a);
  border: 1px solid rgba(255, 209, 102, 0.5);
  box-shadow: 0 0 18px rgba(255, 209, 102, 0.22);
  line-height: 1;
}
.level-badge span { font-size: 8px; color: var(--brand-2); letter-spacing: 1px; }
.level-badge b { font-size: 16px; }
.level-badge { grid-auto-flow: row; }
.level-badge span, .level-badge b { grid-area: 1 / 1; }
.level-badge span { transform: translateY(-9px); }
.level-badge b { transform: translateY(4px); }

.hud-right { flex-wrap: wrap; justify-content: flex-end; }
.map-chip {
  padding: 8px 14px;
  border-radius: 12px;
  background: rgba(14, 11, 24, 0.78);
  border: 1px solid var(--line);
  font-size: 13px;
  letter-spacing: 1px;
  backdrop-filter: blur(8px);
}
.currency {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  border-radius: 12px;
  background: rgba(14, 11, 24, 0.78);
  border: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 13px;
}
.currency .coin { color: var(--brand-2); }
.currency .point { color: #b79bff; margin-left: 8px; }
.hud-buttons { display: flex; gap: 6px; }
.hud-buttons button {
  position: relative;
  width: 36px; height: 36px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(14, 11, 24, 0.78);
  font-size: 15px;
  transition: 0.16s;
}
.hud-buttons button:hover { background: rgba(255, 159, 67, 0.2); border-color: rgba(255, 159, 67, 0.5); transform: translateY(-1px); }
.hud-buttons button.on { background: rgba(255, 90, 90, 0.25); border-color: rgba(255, 90, 90, 0.6); }
.hud-badge {
  position: absolute;
  top: -5px; right: -5px;
  min-width: 15px; height: 15px;
  padding: 0 3px;
  border-radius: 999px;
  background: #ff5a5a;
  color: #fff;
  font-size: 10px;
  line-height: 15px;
  text-align: center;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}

.minimap-wrap {
  position: absolute;
  right: 14px; bottom: 208px;
  padding: 6px;
  border-radius: 12px;
  background: rgba(10, 8, 18, 0.72);
  border: 1px solid var(--line);
  backdrop-filter: blur(6px);
}
#minimap { display: block; border-radius: 8px; }
.minimap-label {
  position: absolute; left: 10px; bottom: 8px;
  font-size: 10px; color: var(--muted); letter-spacing: 1px;
  text-shadow: 0 1px 3px #000;
}

.tutorial-tracker, .quest-tracker {
  position: absolute;
  right: 14px;
  width: 236px;
  padding: 12px 14px;
  border-radius: 13px;
  background: rgba(16, 12, 28, 0.82);
  border: 1px solid rgba(255, 209, 102, 0.28);
  backdrop-filter: blur(8px);
  font-size: 12px;
}
.tutorial-tracker { top: 86px; }
.tutorial-tracker header { display: flex; justify-content: space-between; color: var(--brand-2); font-weight: 700; margin-bottom: 6px; }
.tutorial-tracker p { margin: 0; color: var(--muted); line-height: 1.5; }
.quest-tracker { top: 200px; border-color: var(--line); }
.quest-tracker header { font-weight: 700; color: #9dc0ff; margin-bottom: 6px; }
.quest-tracker ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.quest-tracker li { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); }
.quest-tracker li b { color: var(--text); font-weight: 600; }
.quest-tracker li.done { opacity: 0.55; text-decoration: line-through; }

.toast-stack {
  position: absolute;
  left: 50%; top: 84px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  z-index: 60;
}
.toast {
  padding: 9px 18px;
  border-radius: 999px;
  background: rgba(18, 14, 30, 0.92);
  border: 1px solid var(--line-strong);
  font-size: 13px;
  box-shadow: var(--shadow);
  animation: toast-in 0.25s ease, toast-out 0.35s ease 2.6s forwards;
  max-width: 70vw;
}
.toast.success { border-color: rgba(93, 219, 154, 0.5); color: #b6ffd8; }
.toast.warn { border-color: rgba(255, 200, 87, 0.5); color: #ffe4a8; }
.toast.danger { border-color: rgba(255, 107, 107, 0.55); color: #ffc0c0; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-8px); } }

.float-layer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 40; }
.float-text {
  position: absolute;
  font-family: var(--mono);
  font-weight: 800;
  font-size: 15px;
  color: #fff;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.7), 0 0 12px rgba(0, 0, 0, 0.6);
  animation: float-up 0.9s ease-out forwards;
  will-change: transform, opacity;
}
.float-text.crit { color: #ffd166; font-size: 19px; }
.float-text.immune { color: #9aa0b8; font-size: 13px; }
.float-text.heal { color: #7dffb1; }
.float-text.gain { color: #ffdf8a; }
@keyframes float-up {
  from { transform: translateY(0) scale(0.92); opacity: 0; }
  18% { opacity: 1; transform: translateY(-6px) scale(1.04); }
  to { transform: translateY(-46px) scale(1); opacity: 0; }
}

.quickbar {
  position: absolute;
  left: 50%; bottom: 18px;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  padding: 8px;
  border-radius: 16px;
  background: rgba(12, 9, 22, 0.8);
  border: 1px solid var(--line);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
}
.slot {
  position: relative;
  width: 54px; height: 54px;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: linear-gradient(170deg, rgba(60, 48, 94, 0.7), rgba(22, 17, 38, 0.9));
  display: grid;
  place-items: center;
  transition: 0.15s;
  overflow: hidden;
}
.slot:hover { border-color: rgba(255, 159, 67, 0.6); transform: translateY(-2px); }
.slot .key {
  position: absolute; top: 2px; left: 5px;
  font-size: 9px; color: var(--muted); font-family: var(--mono);
}
.slot .icon { font-size: 22px; line-height: 1; }
.slot .name { position: absolute; bottom: 3px; left: 0; right: 0; text-align: center; font-size: 9px; color: var(--muted); }
.slot .cd {
  position: absolute; inset: 0;
  background: rgba(8, 6, 14, 0.72);
  display: grid; place-items: center;
  font-family: var(--mono); font-size: 14px; color: #fff;
  opacity: 0;
}
.slot.cooling .cd { opacity: 1; }
.slot.no-mp { filter: grayscale(0.6) brightness(0.75); }
.slot.interact { border-color: rgba(255, 209, 102, 0.75); box-shadow: 0 0 18px rgba(255, 209, 102, 0.3); animation: pulse 1.2s infinite; }

.chat-panel {
  position: absolute;
  left: 14px; bottom: 88px;
  width: 304px;
  border-radius: 14px;
  background: rgba(11, 9, 20, 0.62);
  border: 1px solid var(--line);
  backdrop-filter: blur(8px);
  overflow: hidden;
}
.chat-tabs { display: flex; gap: 2px; padding: 6px 6px 0; }
.chat-tabs button {
  flex: 1;
  padding: 5px 0;
  border: 0;
  border-radius: 7px 7px 0 0;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
}
.chat-tabs button.active { background: rgba(255, 255, 255, 0.08); color: var(--text); }
.chat-log {
  height: 104px;
  overflow-y: auto;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 12px;
  line-height: 1.45;
}
.chat-line { color: #d9d2ea; word-break: break-word; }
.chat-line .who { color: var(--brand-2); font-weight: 600; }
.chat-line.world .who { color: #9dc0ff; }
.chat-line.party .who { color: #7dffb1; }
.chat-line.guild .who { color: #ffb0e0; }
.chat-line.system { color: var(--muted); font-style: italic; }
.chat-form { border-top: 1px solid var(--line); }
.chat-form input {
  width: 100%;
  padding: 9px 11px;
  border: 0;
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  font-size: 12px;
  outline: none;
}
.chat-form input:focus { background: rgba(0, 0, 0, 0.55); }

/* -------------------------------------------------------------------- 邮件 */
.mail-list { display: grid; gap: 10px; }
.mail-card {
  border: 1px solid var(--line);
  background: rgba(12, 9, 22, 0.6);
  border-radius: 10px;
  padding: 10px 12px;
}
.mail-card.unread { border-color: rgba(255, 159, 67, 0.5); background: rgba(255, 159, 67, 0.06); }
.mail-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.mail-head b { font-size: 14px; }
.mail-meta { margin-top: 3px; font-size: 11px; color: var(--muted); }
.mail-body { margin-top: 7px; font-size: 12px; color: #d9d2ea; line-height: 1.6; white-space: pre-wrap; word-break: break-word; }
.mail-attach { margin-top: 7px; font-size: 12px; color: var(--brand-2); }
.mail-tag { font-size: 10px; padding: 1px 7px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.mail-tag.unread { color: #ffb35c; border-color: rgba(255, 159, 67, 0.5); }
.mail-tag.expired { color: #ff7b7b; border-color: rgba(255, 90, 90, 0.45); }
.mail-tag.claimed { color: #7dffb1; border-color: rgba(125, 255, 177, 0.35); }

/* -------------------------------------------------------------------- 面板 */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  background: rgba(5, 4, 10, 0.62);
  backdrop-filter: blur(3px);
  animation: fade-in 0.18s ease;
}
@keyframes fade-in { from { opacity: 0; } }
/* 面板始终盖在 NPC 对话之上，避免强化/商店被对话框遮挡 */
#panel-layer { z-index: 72; }
.panel {
  width: min(760px, 94vw);
  max-height: min(720px, 88vh);
  display: flex;
  flex-direction: column;
  border-radius: 18px;
  background: linear-gradient(170deg, rgba(32, 25, 54, 0.98), rgba(16, 12, 28, 0.99));
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
  animation: rise 0.22s ease;
  overflow: hidden;
}
.panel.wide { width: min(940px, 96vw); }
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
}
.panel-head h3 { margin: 0; font-size: 16px; letter-spacing: 1px; }
.panel-close {
  width: 30px; height: 30px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font-size: 18px;
  line-height: 1;
}
.panel-close:hover { background: rgba(255, 107, 107, 0.25); border-color: rgba(255, 107, 107, 0.5); }
.panel-body { padding: 16px 18px 20px; overflow-y: auto; font-size: 13px; }

.panel-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.panel-toolbar .spacer { flex: 1; }
.panel-toolbar input[type="text"] {
  padding: 8px 11px;
  border-radius: 9px;
  border: 1px solid var(--line-strong);
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  font-size: 12px;
  outline: none;
  min-width: 150px;
}
.panel-toolbar input[type="number"] {
  width: 110px;
  padding: 8px 11px;
  border-radius: 9px;
  border: 1px solid var(--line-strong);
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  font-size: 12px;
  outline: none;
}
.panel-toolbar select {
  padding: 8px 10px;
  border-radius: 9px;
  border: 1px solid var(--line-strong);
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  font-size: 12px;
  outline: none;
}

.money-row { display: flex; gap: 14px; margin-bottom: 12px; font-family: var(--mono); font-size: 12px; color: var(--muted); }
.money-row b { color: var(--brand-2); }

.tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.tabs button {
  padding: 7px 14px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  font-size: 12px;
}
.tabs button.active { background: rgba(255, 159, 67, 0.18); border-color: rgba(255, 159, 67, 0.45); color: var(--text); }

.grid-items {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(212px, 1fr));
  gap: 10px;
}
.item-card {
  display: flex;
  gap: 10px;
  padding: 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  transition: 0.15s;
}
.item-card:hover { border-color: rgba(255, 255, 255, 0.28); background: rgba(255, 255, 255, 0.07); }
.item-card.equipped { border-color: rgba(255, 209, 102, 0.35); background: rgba(255, 209, 102, 0.06); }
.item-icon {
  width: 42px; height: 42px;
  flex: 0 0 42px;
  border-radius: 10px;
  display: grid; place-items: center;
  font-size: 22px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--line);
}
.item-main { flex: 1; min-width: 0; }
.item-title { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; }
.item-title .lv { font-size: 10px; color: var(--brand-2); font-family: var(--mono); }
.item-sub { margin-top: 3px; font-size: 11px; color: var(--muted); line-height: 1.4; }
.item-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.item-actions button {
  padding: 4px 9px;
  border-radius: 7px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font-size: 11px;
}
.item-actions button:hover { background: rgba(255, 159, 67, 0.2); border-color: rgba(255, 159, 67, 0.5); }
.item-actions button.danger:hover { background: rgba(255, 107, 107, 0.25); border-color: rgba(255, 107, 107, 0.6); }
.item-actions button:disabled { opacity: 0.4; cursor: not-allowed; }

.list-rows { display: grid; gap: 8px; }
.row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--line);
}
.row:hover { background: rgba(255, 255, 255, 0.06); }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-weight: 600; font-size: 13px; }
.row .sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.row .price { font-family: var(--mono); color: var(--brand-2); font-size: 13px; white-space: nowrap; }
.row button {
  padding: 5px 11px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 11px;
  white-space: nowrap;
}
.row button:hover { background: rgba(255, 159, 67, 0.2); border-color: rgba(255, 159, 67, 0.5); }
.row button:disabled { opacity: 0.4; cursor: not-allowed; }
.row.me { border-color: rgba(255, 209, 102, 0.35); }

.rank-row { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 10px; background: rgba(255, 255, 255, 0.03); border: 1px solid var(--line); }
.rank-row + .rank-row { margin-top: 6px; }
.rank-no { width: 30px; font-family: var(--mono); font-size: 14px; color: var(--muted); text-align: center; }
.rank-row.top1 .rank-no { color: #ffd166; }
.rank-row.top2 .rank-no { color: #cfd8e3; }
.rank-row.top3 .rank-no { color: #e0a06a; }
.rank-row .grow { flex: 1; min-width: 0; }
.rank-row .score { font-family: var(--mono); color: var(--brand-2); }
.rank-row.self { border-color: rgba(110, 160, 255, 0.45); background: rgba(110, 160, 255, 0.1); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
.stat-cell { padding: 9px 12px; border-radius: 10px; background: rgba(255, 255, 255, 0.035); border: 1px solid var(--line); }
.stat-cell .k { font-size: 10px; color: var(--muted); letter-spacing: 1px; }
.stat-cell .v { font-family: var(--mono); font-size: 15px; margin-top: 3px; }

.progress { height: 9px; border-radius: 999px; background: rgba(0, 0, 0, 0.45); overflow: hidden; border: 1px solid var(--line); }
.progress i { display: block; height: 100%; background: var(--exp); }
.progress.guild i { background: linear-gradient(180deg, #9dc0ff, #4b6fdd); }

.empty-tip { padding: 26px 10px; text-align: center; color: var(--muted); font-size: 12px; border: 1px dashed var(--line); border-radius: 12px; }

.section-title { margin: 18px 0 10px; font-size: 12px; letter-spacing: 2px; color: var(--muted); text-transform: uppercase; }
.section-title:first-child { margin-top: 0; }

.rule-list { display: grid; gap: 6px; margin-top: 8px; }
.rule-row { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); padding: 7px 10px; border-radius: 8px; background: rgba(255, 255, 255, 0.03); }
.rule-row b { color: var(--text); font-family: var(--mono); }

.help-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.help-cell { padding: 12px; border-radius: 11px; background: rgba(255, 255, 255, 0.035); border: 1px solid var(--line); font-size: 12px; color: var(--muted); line-height: 1.7; }
.help-cell b { display: block; color: var(--text); margin-bottom: 4px; font-size: 12px; }
kbd {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text);
}

/* ------------------------------------------------------------------ 对话框 */
.dialog-overlay { align-items: end; background: rgba(5, 4, 10, 0.35); }
.dialog-box {
  width: min(620px, 94vw);
  margin-bottom: 92px;
  padding: 16px 20px 14px;
  border-radius: 16px;
  background: linear-gradient(170deg, rgba(36, 28, 60, 0.98), rgba(18, 14, 32, 0.99));
  border: 1px solid rgba(255, 209, 102, 0.28);
  box-shadow: var(--shadow);
  animation: rise 0.2s ease;
}
.dialog-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 14px; }
.dialog-head span { font-size: 20px; }
.dialog-box p { margin: 0 0 12px; font-size: 13px; line-height: 1.7; color: #e5dcf7; white-space: pre-wrap; }
.dialog-options { display: grid; gap: 6px; margin-bottom: 10px; }
.dialog-options button {
  text-align: left;
  padding: 9px 13px;
  border-radius: 9px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font-size: 13px;
  transition: 0.15s;
}
.dialog-options button:hover { background: rgba(255, 159, 67, 0.18); border-color: rgba(255, 159, 67, 0.5); padding-left: 17px; }

/* ------------------------------------------------------------------ 死亡层 */
.death-overlay { background: rgba(30, 4, 8, 0.55); z-index: 80; }
.death-card { text-align: center; animation: rise 0.25s ease; }
.death-card h2 { margin: 0 0 6px; font-size: 40px; letter-spacing: 8px; color: #ffb0b0; text-shadow: 0 4px 24px rgba(255, 0, 0, 0.5); }
.death-card p { margin: 0 0 18px; color: var(--muted); font-size: 13px; }

/* ---------------------------------------------------------------- 断线提示 */
.net-banner {
  position: fixed;
  left: 50%; top: 12px;
  transform: translateX(-50%);
  z-index: 120;
  padding: 8px 18px;
  border-radius: 999px;
  background: rgba(255, 107, 107, 0.16);
  border: 1px solid rgba(255, 107, 107, 0.5);
  color: #ffc4c4;
  font-size: 12px;
  backdrop-filter: blur(6px);
  animation: pulse 1.4s infinite;
}

/* ------------------------------------------------------------------ 响应式 */
@media (max-width: 900px) {
  .hud { flex-direction: column; align-items: stretch; }
  .hud-right { justify-content: flex-start; }
  .chat-panel { width: 260px; }
  .minimap-wrap { display: none; }
  .tutorial-tracker, .quest-tracker { display: none; }
  .bar, .bar.exp { width: 150px; }
  .hud-id { min-width: 150px; }
  .create-row { grid-template-columns: 1fr; }
  .quickbar { bottom: 10px; }
}

@media (max-width: 560px) {
  .hud-buttons button { width: 32px; height: 32px; font-size: 13px; }
  .hud-left { padding: 8px 10px; }
  .hud-id { min-width: 120px; }
  .bar, .bar.exp { width: 118px; }
  .chat-panel { width: calc(100vw - 28px); bottom: 78px; }
  .chat-log { height: 78px; }
  .slot { width: 44px; height: 44px; }
  .panel { max-height: 92vh; }
}

/* --------------------------------------------------------------- 触屏适配 */
html, body { overscroll-behavior: none; }
#game-canvas { touch-action: none; }
.touch-controls, .rotate-tip { display: none; }

.touch-device .touch-controls {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 45;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 0 calc(14px + env(safe-area-inset-right)) calc(14px + env(safe-area-inset-bottom)) calc(14px + env(safe-area-inset-left));
  pointer-events: none;
}
.touch-move { display: flex; gap: 10px; pointer-events: auto; }
.touch-btn {
  width: 58px; height: 58px;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(20, 15, 36, 0.58);
  color: var(--text);
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
  backdrop-filter: blur(6px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.touch-btn.pressed, .touch-btn:active {
  background: rgba(255, 159, 67, 0.36);
  border-color: rgba(255, 159, 67, 0.8);
  transform: scale(0.94);
}
.touch-btn.jump {
  width: 72px; height: 72px;
  font-size: 17px;
  letter-spacing: 1px;
  pointer-events: auto;
  border-color: rgba(255, 209, 102, 0.5);
}

.touch-device .hud {
  top: calc(8px + env(safe-area-inset-top));
  left: calc(8px + env(safe-area-inset-left));
  right: calc(8px + env(safe-area-inset-right));
}
.touch-device .hud-buttons button { width: 34px; height: 34px; }
.touch-device .quickbar {
  bottom: calc(96px + env(safe-area-inset-bottom));
  touch-action: manipulation;
}
.touch-device .slot { touch-action: manipulation; }
.touch-device .chat-panel {
  top: calc(172px + env(safe-area-inset-top));
  left: calc(10px + env(safe-area-inset-left));
  bottom: auto;
  width: 220px;
}
.touch-device .chat-log { height: 56px; }
.touch-device input, .touch-device select, .touch-device textarea { font-size: 16px; }
.touch-device .panel-body { -webkit-overflow-scrolling: touch; }
.touch-device .dialog-box { width: calc(100vw - 24px); margin-bottom: calc(12px + env(safe-area-inset-bottom)); }

.touch-device .rotate-tip {
  display: block;
  position: absolute;
  left: 50%; top: 44%;
  transform: translate(-50%, -50%);
  z-index: 55;
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(18, 14, 30, 0.86);
  border: 1px solid var(--line-strong);
  color: var(--text);
  font-size: 13px;
  letter-spacing: 1px;
  box-shadow: var(--shadow);
  pointer-events: none;
  animation: rotate-tip 6s ease forwards;
}
@keyframes rotate-tip {
  0%, 75% { opacity: 1; }
  100% { opacity: 0; visibility: hidden; }
}

@media (orientation: landscape) {
  .touch-device .rotate-tip { display: none; }
  .touch-device .chat-panel { top: calc(120px + env(safe-area-inset-top)); }
}

@media (max-width: 720px) {
  .touch-device .panel {
    width: 100vw;
    max-width: 100vw;
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
  }
}

@media (orientation: landscape) and (max-height: 520px) {
  .touch-device .hud { flex-direction: row; align-items: center; gap: 8px; }
  .touch-device .hud-left { padding: 6px 10px 6px 6px; }
  .touch-device .portrait { width: 36px; height: 36px; font-size: 13px; }
  .touch-device .level-badge { width: 34px; height: 34px; }
  .touch-device .hud-id { min-width: 130px; }
  .touch-device .bar, .touch-device .bar.exp { width: 130px; }
  .touch-device .bar { height: 10px; }
  .touch-device .bar.exp { height: 6px; }
  .touch-device .map-chip { display: none; }
  .touch-device .hud-right { flex-wrap: nowrap; justify-content: flex-end; }
  .touch-device .hud-buttons { gap: 4px; }
  .touch-device .hud-buttons button { width: 30px; height: 30px; font-size: 13px; }
  .touch-device .chat-panel { top: calc(82px + env(safe-area-inset-top)); }
  .touch-device .chat-tabs { display: none; }
  .touch-device .chat-log { height: 46px; }
  .touch-device .quickbar { bottom: calc(96px + env(safe-area-inset-bottom)); }
}

@media (orientation: landscape) and (max-height: 520px) and (max-width: 620px) {
  .touch-device .currency { display: none; }
}

/* 竖屏窄屏 HUD 会折行，聊天面板下移避让 */
@media (max-width: 560px) and (orientation: portrait) {
  .touch-device .chat-panel { top: calc(200px + env(safe-area-inset-top)); }
}
