/* 基础变量与重置 */
:root {
  --ink: #14100c;
  --ink-2: #241c15;
  --wood: #2b1e15;
  --wood-2: #3a2819;
  --paper: #e9dcc2;
  --paper-2: #dccbaa;
  --paper-3: #cbb68d;
  --gold: #c2a03c;
  --gold-2: #e6c96b;
  --gold-3: #8a6d1e;
  --cinnabar: #a8332a;
  --cinnabar-2: #c9483a;
  --jade: #2f7d63;
  --azure: #2f6f8f;
  --violet: #5a4a7a;
  --text: #f0e4c8;
  --text-dim: #b7a685;
  --text-ink: #241c15;
  --radius: 10px;
  --shadow-lg: 0 18px 40px rgba(0, 0, 0, 0.55);
  --shadow-md: 0 8px 20px rgba(0, 0, 0, 0.4);
  --font-serif: "Songti SC", "STSong", "SimSun", "Noto Serif SC", Georgia, serif;
  --font-sans: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* ── 触摸端手感 ──
   - tap-highlight 透明：去掉 iOS 点击时那块灰色方块
   - manipulation：去掉 300ms 点击延迟和双击缩放（双指缩放仍可用，不做无障碍伤害）
   - 长按卡牌不要弹出 iOS 的选择菜单 / 放大镜 */
button, .card, .lord-opt, .seg button, .seat, summary, [role='button'] {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
body {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}
/* 需要选文字的地方（规则说明、战报）仍然可以选中 */
#modal-body, .menu__paper, .log, input, textarea {
  -webkit-user-select: text;
  user-select: text;
}

[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  font-family: var(--font-sans);
  color: var(--text);
  background: #100c09;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  /* 下拉刷新 / 橡皮筋回弹会让整页在浏览器条后面晃，看起来像卡死 */
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;        /* iOS 横屏别偷偷放大字号 */
  text-size-adjust: 100%;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select { font-family: inherit; }

/* 高度不能用 100vh：手机上 vh 取的是地址栏收起时的最大高度，
   页面底部（出牌区、按钮）会被浏览器工具条盖住点不到。
   100dvh = 地址栏展开/收起时实时变化的视口高度，正好是我们要的。 */
.app {
  height: 100vh;
  height: 100dvh;
  height: var(--app-h, 100dvh);   /* visualViewport 写入的真实高度，最准 */
  width: 100%;
  position: relative;
  overflow: hidden;
}
/* 刘海 / home indicator 安全区。env() 在不支持的浏览器上整条声明会被丢弃，正好是降级。 */
.app {
  padding-top: env(safe-area-inset-top, 0px);
  padding-right: env(safe-area-inset-right, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-left: env(safe-area-inset-left, 0px);
  box-sizing: border-box;
}
@supports (height: 100dvh) {
  .app { height: 100dvh; }
}

.screen { position: absolute; inset: 0; display: none; }
.screen.is-active { display: block; }

/* 背景：宣纸质感 + 暗角 */
.screen--table {
  background:
    radial-gradient(ellipse at 50% 42%, rgba(88, 62, 36, 0.95) 0%, rgba(38, 26, 17, 1) 68%),
    var(--wood);
}
.screen--table::before {
  content: "";
  position: absolute; inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px);
  background-size: 3px 3px;
  pointer-events: none;
}

/* 通用按钮 */
.btn {
  padding: 11px 26px;
  border-radius: 999px;
  font-size: 15px;
  letter-spacing: 0.12em;
  border: 1px solid var(--gold-3);
  background: linear-gradient(180deg, rgba(194, 160, 60, 0.16), rgba(0, 0, 0, 0.25));
  color: var(--gold-2);
  transition: transform 0.12s ease, box-shadow 0.2s ease, background 0.2s;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45); }
.btn:active { transform: translateY(0); }
.btn--primary {
  background: linear-gradient(180deg, #d3ac3f, #96731c);
  color: #2a1d08;
  font-weight: 700;
  border-color: #e8cf7e;
}
.btn--ghost { background: rgba(255, 255, 255, 0.04); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.icon-btn {
  width: 34px; height: 34px;
  border-radius: 8px;
  border: 1px solid rgba(194, 160, 60, 0.35);
  color: var(--gold-2);
  font-size: 14px;
  display: grid; place-items: center;
  background: rgba(0, 0, 0, 0.25);
}
.icon-btn:hover { background: rgba(194, 160, 60, 0.18); }
.icon-btn.is-off { opacity: 0.4; }
.icon-btn--danger:hover { background: rgba(168, 51, 42, 0.4); color: #ffd9d3; }

/* 模态 */
.modal {
  position: absolute; inset: 0;
  background: rgba(10, 7, 5, 0.82);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  /* safe：内容比屏幕高时不会把顶部裁掉，滚上去能看到 */
  align-content: safe center;
  justify-items: center;
  z-index: 60;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px;
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
}
.modal__box {
  position: relative;
  width: min(920px, 92vw);
  max-height: calc(100vh - 24px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  max-height: calc(100dvh - 24px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  background: linear-gradient(160deg, #f1e7d2, #ddcbaa);
  color: var(--text-ink);
  border: 2px solid var(--gold-3);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  padding: 30px 34px 34px;
}
.modal__close {
  position: absolute; top: 10px; right: 14px;
  font-size: 24px; color: #6b5a42; line-height: 1;
}
.modal__body h2 {
  font-family: var(--font-serif);
  font-size: 25px; letter-spacing: 0.16em;
  border-bottom: 2px solid rgba(138, 109, 30, 0.35);
  padding-bottom: 10px; margin-bottom: 16px;
}
.modal__body h3 {
  font-family: var(--font-serif);
  font-size: 17px; margin: 20px 0 8px; color: #6b4a12;
}
.modal__body p, .modal__body li { font-size: 14px; line-height: 1.85; }
.modal__body ul { padding-left: 20px; }
.modal__body + * { margin-top: 10px; }

/* 弹窗在小屏/横屏上收一收，不然标题比正文还大 */
@media (max-width: 620px) {
  .modal__box { padding: 22px 18px 24px; }
  .modal__body h2 { font-size: 20px; letter-spacing: 0.1em; padding-bottom: 8px; margin-bottom: 12px; }
  .modal__body h3 { font-size: 15px; margin: 14px 0 6px; }
  .modal__body p, .modal__body li { font-size: 13.5px; line-height: 1.7; }
  .modal__close { font-size: 22px; top: 8px; right: 12px; }
}
@media (max-height: 520px) and (orientation: landscape) {
  .modal__box { padding: 18px 22px; }
  .modal__body h2 { font-size: 18px; letter-spacing: 0.08em; padding-bottom: 6px; margin-bottom: 10px; }
  .modal__body h3 { font-size: 14px; margin: 10px 0 4px; }
  .modal__body p, .modal__body li { font-size: 12.5px; line-height: 1.6; }
  .modal__body ul { padding-left: 16px; }
}

/* 图鉴网格 */
.hero-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.hero-card {
  background: rgba(255, 255, 255, 0.35);
  border: 1px solid rgba(138, 109, 30, 0.3);
  border-radius: 8px; overflow: hidden;
  text-align: center;
  padding-bottom: 8px;
}
.hero-card img { width: 100%; display: block; }
.hero-card b { display: block; font-family: var(--font-serif); font-size: 14px; margin-top: 4px; }
.hero-card span { display: block; font-size: 11px; color: #7a6a52; }
.hero-card--lord { box-shadow: 0 0 0 2px var(--gold) inset; }

.skill-chip {
  display: inline-block; font-size: 11px; padding: 1px 6px; margin: 2px 2px 0;
  border: 1px solid rgba(138, 109, 30, 0.4); border-radius: 4px; background: rgba(194, 160, 60, 0.15);
}

/* 提示条 */
.toast {
  position: absolute; left: 50%; bottom: 96px; transform: translateX(-50%);
  background: rgba(20, 14, 9, 0.94);
  border: 1px solid var(--gold-3);
  color: var(--gold-2);
  padding: 9px 20px; border-radius: 999px; font-size: 13px;
  z-index: 50; box-shadow: var(--shadow-md);
}

/* 滚动条 */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: rgba(0, 0, 0, 0.2); }
::-webkit-scrollbar-thumb { background: rgba(194, 160, 60, 0.35); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(194, 160, 60, 0.55); }
