/* ═══════════════════════════════════════
   西幻地牢 · 高对比明亮主题
   容器: <ai>，避免全局污染
   ═══════════════════════════════════════ */

/* ── 容器 & 变量 ── */
ai {
  --gold: #FFD700;
  --gold-dark: #B8860B;
  --gold-light: #FFF8DC;
  --royal-blue: #1a2a6c;
  --deep-purple: #2d1b69;
  --crimson: #DC143C;
  --hp-red: #e74c3c;
  --sp-green: #2ecc71;
  --mp-blue: #3498db;
  --lust-pink: #ff69b4;
  --expose-orange: #ff8c00;
  --parchment: #fdf6e3;
  --parchment-dark: #f0e6d2;
  --ink: #1a1a2e;
  --text-main: #2c2c3a;
  --text-light: #f5f5f0;
  display: block;
  font-family: 'Georgia', 'Times New Roman', 'Noto Serif SC', serif;
  font-size: 18px;
  line-height: 1.7;
  color: var(--text-main);
  background:
    linear-gradient(135deg, rgba(253,246,227,0.95), rgba(240,230,210,0.95)),
    url("data:image/svg+xml,%3Csvg width='60' height='60' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.08'/%3E%3C/svg%3E");
  padding: 6px 10px;
  border-radius: 4px;
  border: 1px solid var(--gold-dark);
  box-shadow: 0 0 12px rgba(255,215,0,0.3), inset 0 0 30px rgba(184,134,11,0.08);
  position: relative;
  max-width: 100%;
  overflow-x: hidden;
}

/* ── 顶部/底部装饰线 ── */
ai::before,
ai::after {
  content: "⚜ ━━━━━━━━━━━━━━━━━━━━━━━━━━ ⚜";
  display: block;
  text-align: center;
  color: var(--gold-dark);
  font-size: 12px;
  letter-spacing: 2px;
  opacity: 0.6;
  padding: 2px 0;
  overflow: hidden;
  white-space: nowrap;
}

/* ── COT 隐藏 ── */
ai cot {
  display: none;
}

/* ── 头部地牢信息 ── */
ai hd {
  display: block;
  text-align: center;
  font-size: 20px;
  font-weight: bold;
  color: var(--royal-blue);
  background: linear-gradient(90deg, transparent, rgba(26,42,108,0.08) 50%, transparent);
  padding: 6px 10px;
  margin: 4px 0 8px;
  letter-spacing: 3px;
  border-bottom: 2px solid var(--gold);
  border-top: 2px solid var(--gold);
  text-shadow: 0 1px 2px rgba(26,42,108,0.15);
}

ai hd::before {
  content: "🏰";
  margin-right: 6px;
}

/* ── 正文区域 ── */
ai text {
  display: block;
  padding: 8px 4px;
  margin: 4px 0;
  font-size: 18px;
  line-height: 1.85;
  color: var(--text-main);
  border-bottom: 1px dashed var(--gold-dark);
}

ai text p {
  margin: 4px 0;
  text-indent: 2em;
}

/* ═══════════════════════════════════════
   悬浮提示 tip + box（点击focus居中弹窗）
   关键：tip 本身不设 position:relative
   box 用 position:fixed 脱离一切父容器
   ═══════════════════════════════════════ */

/* 重要：所有包含tip的祖先容器不能阻止fixed定位
   details 和 ai 的 overflow 需要允许fixed子元素逃逸
   fixed定位本身就相对于viewport，不受overflow限制
   但 transform/filter/will-change 会创建新包含块，需避免 */

ai tip {
  /* 注意：不设 position:relative，让 box 的 fixed 定位相对于 viewport */
  display: inline;
  color: var(--royal-blue);
  font-weight: bold;
  border-bottom: 2px dotted var(--gold);
  cursor: pointer;
  transition: color 0.2s, text-shadow 0.2s;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

ai tip:hover,
ai tip:active {
  color: var(--crimson);
  text-shadow: 0 0 6px rgba(220,20,60,0.3);
}

/* 弹窗默认隐藏 */
ai tip box {
  display: none;
}

/* 点击(focus)高亮触发词 */
ai tip:focus {
  color: var(--crimson);
}

/* 点击后：fixed居中弹窗，脱离所有父容器约束 */
ai tip:focus box {
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  min-width: 260px;
  max-width: 85vw;
  max-height: 70vh;
  overflow-y: auto;
  background: linear-gradient(145deg, #1a1a2e, #16213e 50%, #1a1a2e);
  color: var(--text-light);
  font-size: 16px;
  font-weight: normal;
  padding: 16px 18px;
  border-radius: 8px;
  border: 2px solid var(--gold);
  box-shadow:
    0 0 0 100vmax rgba(0,0,0,0.55),
    0 8px 32px rgba(0,0,0,0.6),
    0 0 20px rgba(255,215,0,0.25);
  z-index: 9999;
  line-height: 1.65;
  text-indent: 0;
  white-space: normal;
  text-align: left;
  animation: modalIn 0.25s ease-out;
}

@keyframes modalIn {
  from { opacity: 0; transform: translate(-50%,-50%) scale(0.85); }
  to { opacity: 1; transform: translate(-50%,-50%) scale(1); }
}

/* 弹窗顶部装饰 */
ai tip:focus box::before {
  content: "━━ ⚜ ━━";
  display: block;
  text-align: center;
  color: var(--gold);
  font-size: 12px;
  letter-spacing: 2px;
  margin-bottom: 8px;
  opacity: 0.7;
}

/* grid内的tip卡片样式 —— 同样不设position:relative */
ai g tip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, rgba(26,42,108,0.06), rgba(255,215,0,0.06));
  border: 1px solid rgba(184,134,11,0.3);
  border-radius: 4px;
  padding: 6px 8px;
  font-size: 15px;
  text-align: center;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
  outline: none;
}

ai g tip:hover {
  border-color: var(--gold);
  box-shadow: 0 0 10px rgba(255,215,0,0.3);
  transform: translateY(-1px);
}

/* grid内tip聚焦态：高亮边框但不设transform（避免创建包含块） */
ai g tip:focus {
  border-color: var(--gold);
  box-shadow: 0 0 10px rgba(255,215,0,0.3);
}

/* ═══════════════════════════════════════
   Details / Summary 通用美化
   注意：details 不设 transform/filter/will-change
   确保内部 tip box 的 fixed 定位不受干扰
   ═══════════════════════════════════════ */
ai details {
  margin: 4px 0;
  border: 1px solid rgba(184,134,11,0.4);
  border-radius: 4px;
  background: linear-gradient(180deg, rgba(253,246,227,0.6), rgba(240,230,210,0.4));
  overflow: visible; /* 关键：允许fixed子元素不被裁切 */
}

ai details details {
  margin: 4px 6px;
  border-color: rgba(184,134,11,0.25);
  background: rgba(253,246,227,0.3);
  overflow: visible; /* 嵌套details也需要 */
}

ai summary {
  display: block;
  font-size: 19px;
  font-weight: bold;
  color: var(--royal-blue);
  background: linear-gradient(90deg, rgba(26,42,108,0.12), rgba(255,215,0,0.1) 50%, rgba(26,42,108,0.12));
  padding: 6px 12px;
  cursor: pointer;
  user-select: none;
  border-bottom: 1px solid rgba(184,134,11,0.3);
  transition: background 0.2s, color 0.2s;
  list-style: none;
  position: relative;
  letter-spacing: 1px;
}

ai summary::-webkit-details-marker {
  display: none;
}

/* 折叠箭头 */
ai summary::after {
  content: "▸";
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 16px;
  color: var(--gold-dark);
  transition: transform 0.3s;
}

ai details[open] > summary::after {
  transform: translateY(-50%) rotate(90deg);
}

ai summary:hover {
  background: linear-gradient(90deg, rgba(26,42,108,0.18), rgba(255,215,0,0.18) 50%, rgba(26,42,108,0.18));
  color: var(--crimson);
}

ai details[open] > summary {
  border-bottom-color: var(--gold);
  animation: goldPulse 3s ease-in-out infinite;
}

ai details + details {
  margin-top: 3px;
}

/* details 内部间距 */
ai details > p,
ai details > g,
ai details > d,
ai details > bar {
  margin-left: 8px;
  margin-right: 8px;
}

ai details p {
  margin: 3px 8px;
  font-size: 17px;
}

/* ═══════════════════════════════════════
   字段标签 <f> 与 值 <v>（非bar内的v）
   ═══════════════════════════════════════ */
ai f {
  display: inline;
  color: var(--gold-dark);
  font-weight: bold;
  font-size: 17px;
}

ai v {
  display: inline;
  color: var(--royal-blue);
  font-weight: bold;
}

/* ═══════════════════════════════════════
   进度条 <bar>（属性选择器映射宽度）
   w="0"~"10" 对应 0%~100%
   ═══════════════════════════════════════ */
ai bar {
  display: block;
  position: relative;
  width: calc(100% - 16px);
  height: 26px;
  background: #ddd;
  border-radius: 13px;
  margin: 5px 8px;
  overflow: hidden;
  border: 1px solid rgba(0,0,0,0.15);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.15);
}

ai bar::before {
  content: "";
  display: block;
  height: 100%;
  border-radius: 13px;
  transition: width 0.6s ease;
  position: absolute;
  top: 0;
  left: 0;
}

/* 宽度档位映射 */
ai bar[w="0"]::before  { width: 2%; }
ai bar[w="1"]::before  { width: 10%; }
ai bar[w="2"]::before  { width: 20%; }
ai bar[w="3"]::before  { width: 30%; }
ai bar[w="4"]::before  { width: 40%; }
ai bar[w="5"]::before  { width: 50%; }
ai bar[w="6"]::before  { width: 60%; }
ai bar[w="7"]::before  { width: 70%; }
ai bar[w="8"]::before  { width: 80%; }
ai bar[w="9"]::before  { width: 90%; }
ai bar[w="10"]::before { width: 100%; }

/* HP红 */
ai bar[c="h"]::before {
  background: linear-gradient(90deg, #c0392b, #e74c3c 40%, #f39c9c);
  box-shadow: 0 0 8px rgba(231,76,60,0.4);
}

/* SP绿 */
ai bar[c="s"]::before {
  background: linear-gradient(90deg, #27ae60, #2ecc71 40%, #82e0aa);
  box-shadow: 0 0 8px rgba(46,204,113,0.4);
}

/* MP蓝 */
ai bar[c="m"]::before {
  background: linear-gradient(90deg, #2471a3, #3498db 40%, #85c1e9);
  box-shadow: 0 0 8px rgba(52,152,219,0.4);
}

/* 淫乱度粉 */
ai bar[c="l"]::before {
  background: linear-gradient(90deg, #c2185b, #ff69b4 40%, #f8bbd0);
  box-shadow: 0 0 8px rgba(255,105,180,0.4);
}

/* 露出度橙 */
ai bar[c="e"]::before {
  background: linear-gradient(90deg, #e65100, #ff8c00 40%, #ffcc80);
  box-shadow: 0 0 8px rgba(255,140,0,0.4);
}

/* 进度条上方文字层 */
ai bar v {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: bold;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,0.7);
  z-index: 1;
  letter-spacing: 0.5px;
}

/* 低血量闪烁（HP w=0~2） */
ai bar[c="h"][w="0"]::before,
ai bar[c="h"][w="1"]::before,
ai bar[c="h"][w="2"]::before {
  animation: hpCritical 0.8s ease-in-out infinite;
}

@keyframes hpCritical {
  0%, 100% { box-shadow: 0 0 8px rgba(231,76,60,0.4); }
  50% { box-shadow: 0 0 20px rgba(231,76,60,0.9), inset 0 0 10px rgba(255,0,0,0.3); }
}

/* ═══════════════════════════════════════
   网格容器 <g>（部位/装备/技能/物品）
   ═══════════════════════════════════════ */
ai g {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 4px 8px;
  padding: 4px 8px;
  margin: 4px 8px;
  overflow: visible; /* 确保不裁切fixed弹窗 */
}

ai g d {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: linear-gradient(145deg, rgba(26,42,108,0.06), rgba(255,215,0,0.06));
  border: 1px solid rgba(184,134,11,0.3);
  border-radius: 4px;
  padding: 4px 6px;
  font-size: 15px;
  text-align: center;
  transition: border-color 0.2s, box-shadow 0.2s;
}

ai g d:hover {
  border-color: var(--gold);
  box-shadow: 0 0 8px rgba(255,215,0,0.25);
}

ai g d f {
  font-size: 14px;
  color: var(--gold-dark);
  margin-bottom: 1px;
}

ai g d v {
  font-size: 15px;
  color: var(--crimson);
}

/* ═══════════════════════════════════════
   属性标记 [t] 分区标题
   ═══════════════════════════════════════ */
ai p[t="body"] f,
ai p[t="equip"] f,
ai p[t="skill"] f,
ai p[t="item"] f {
  display: block;
  font-size: 16px;
  color: var(--deep-purple);
  border-left: 3px solid var(--gold);
  padding-left: 6px;
  margin: 6px 0 3px;
}

/* 当前状态标签 */
ai p[t="buff"] {
  background: rgba(255,215,0,0.08);
  border-radius: 4px;
  padding: 4px 8px;
  border-left: 3px solid var(--sp-green);
}

ai p[t="buff"] v {
  display: inline-block;
  background: linear-gradient(135deg, #27ae60, #2ecc71);
  color: #fff;
  font-size: 13px;
  padding: 1px 8px;
  border-radius: 10px;
  margin: 2px;
  font-weight: normal;
}

/* 记忆区标题 */
ai p[t="mem"] {
  margin-bottom: 1px !important;
}

ai p[t="mem"] f {
  display: block;
  border-left: 3px solid var(--gold);
  padding-left: 6px;
  color: var(--deep-purple);
}

/* 记忆区条目 */
ai details:nth-of-type(4) > d {
  display: block;
  font-size: 15px;
  padding: 2px 8px 2px 18px;
  position: relative;
  color: var(--text-main);
}

ai details:nth-of-type(4) > d::before {
  content: "◆";
  position: absolute;
  left: 6px;
  color: var(--gold-dark);
  font-size: 10px;
  top: 6px;
}

/* ═══════════════════════════════════════
   行动抉择区
   ═══════════════════════════════════════ */
ai p[t="act"] {
  padding: 4px 0;
}

ai p[t="act"] d {
  display: block;
  font-size: 17px;
  padding: 6px 12px;
  margin: 3px 0;
  background: linear-gradient(90deg, rgba(26,42,108,0.08), transparent);
  border-left: 3px solid var(--gold);
  border-radius: 0 4px 4px 0;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text-main);
}

ai p[t="act"] d:hover {
  background: linear-gradient(90deg, rgba(26,42,108,0.18), rgba(255,215,0,0.1));
  border-left-color: var(--crimson);
  color: var(--crimson);
  padding-left: 18px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

/* 第3选项（色情）特殊色 */
ai p[t="act"] d:nth-child(3) {
  border-left-color: var(--lust-pink);
  background: linear-gradient(90deg, rgba(255,105,180,0.08), transparent);
}

ai p[t="act"] d:nth-child(3):hover {
  border-left-color: var(--lust-pink);
  color: #c2185b;
  background: linear-gradient(90deg, rgba(255,105,180,0.18), rgba(255,105,180,0.05));
}

/* 第4选项（技能）特殊色 */
ai p[t="act"] d:nth-child(4) {
  border-left-color: var(--mp-blue);
  background: linear-gradient(90deg, rgba(52,152,219,0.08), transparent);
}

ai p[t="act"] d:nth-child(4):hover {
  border-left-color: var(--mp-blue);
  color: #2471a3;
  background: linear-gradient(90deg, rgba(52,152,219,0.18), rgba(52,152,219,0.05));
}

/* ═══════════════════════════════════════
   通用 <d>（非grid内）
   ═══════════════════════════════════════ */
ai details > d {
  display: block;
  padding: 2px 8px;
  font-size: 16px;
}

/* ═══════════════════════════════════════
   金色脉动动画
   ═══════════════════════════════════════ */
@keyframes goldPulse {
  0%, 100% { box-shadow: 0 0 8px rgba(255,215,0,0.2); }
  50% { box-shadow: 0 0 16px rgba(255,215,0,0.4); }
}

/* ═══════════════════════════════════════
   响应式
   ═══════════════════════════════════════ */
@media (max-width: 380px) {
  ai {
    font-size: 16px;
    padding: 4px 6px;
  }
  ai hd {
    font-size: 17px;
    letter-spacing: 1px;
  }
  ai summary {
    font-size: 17px;
    padding: 5px 8px;
  }
  ai g {
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  }
  ai bar {
    height: 22px;
  }
  ai bar v {
    font-size: 12px;
  }
}

/* ═══════════════════════════════════════
   滚动条美化（webkit）
   ═══════════════════════════════════════ */
ai::-webkit-scrollbar {
  width: 6px;
}

ai::-webkit-scrollbar-track {
  background: var(--parchment-dark);
}

ai::-webkit-scrollbar-thumb {
  background: var(--gold-dark);
  border-radius: 3px;
}

ai::-webkit-scrollbar-thumb:hover {
  background: var(--gold);
}