/* ============================================================
   冰火守门人 —— 界面样式（/guardian/css/guardian.css）
   暗色拟真 + 火/水双色点缀，桌面与手机同一套布局（自适应）
   ============================================================ */
* { box-sizing: border-box; margin: 0; padding: 0; }

/* 逻辑视口：--vph/--vpw 是设备真实的竖/横尺寸（不变），--vh/--vw 是游戏画面
   可用的竖/横。竖屏时 html.rot90 把 --vh/--vw 互换并旋转 #stage，
   于是横屏游戏在竖屏设备上自动变成横屏版面（开着竖屏锁定的手机也能玩）。
   注意必须由 --vph/--vpw 中转：直接写 --vw: var(--vh) 会撞上循环引用失效。
   用 dvh 而非 vh：移动端地址栏收放时 vh 不变，会导致画面被裁。 */
:root { --vpw: 100vw; --vph: 100vh; --vw: var(--vpw); --vh: var(--vph); }
@supports (height: 100dvh) { :root { --vph: 100dvh; } }
html.rot90 { --vw: var(--vph); --vh: var(--vpw); }

html, body {
  height: 100%; background: #0d0a10; color: #f3ead9;
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent;
}
body {
  display: flex; align-items: center; justify-content: center; overflow: hidden;
  background: radial-gradient(120% 90% at 50% 0%, #1d1622 0%, #0b0810 70%);
}
/* 游戏舞台：尺寸用 --vw/--vh，竖屏时两者互换 + 整体旋转 90°，
   旋转后的落地范围正好等于整屏，边缘元素（触摸键 / 提示条）不会跑出屏幕 */
#stage {
  position: fixed; left: 50%; top: 50%;
  width: var(--vw); height: var(--vh);
  transform: translate(-50%, -50%);
  overflow: hidden;
}
html.rot90 #stage { transform: translate(-50%, -50%) rotate(90deg); }
#cv {
  position: absolute; inset: 0; margin: auto;
  width: min(var(--vw), calc(var(--vh) * 1.5), 1100px); height: auto; aspect-ratio: 3 / 2;
  border-radius: 14px; display: block; box-shadow: 0 20px 70px rgba(0, 0, 0, .6);
  touch-action: none;   /* 手机上拖动 = 虚拟摇杆，别让浏览器抢去滚动/缩放 */
}
.hidden { display: none !important; }

/* ---------------- 通用屏幕层 ---------------- */
.screen {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(var(--vw), calc(var(--vh) * 1.5), 1100px);
  max-height: min(calc(var(--vh) * .92), calc(var(--vw) / 1.5));
  background: rgba(16, 12, 20, .9);
  backdrop-filter: blur(6px);
  border-radius: 14px; padding: 18px 22px;
  display: flex; flex-direction: column; gap: 12px;
  overflow: auto; z-index: 6;
}
.screen.compact { width: min(calc(var(--vw) * .92), 420px); max-height: none; align-items: center; text-align: center; gap: 14px; }
.screen h2 { font-size: clamp(17px, 2.2vw, 22px); letter-spacing: 2px; font-weight: 700; }
.screen h2 small { font-size: 12px; color: #8f8574; font-weight: 400; letter-spacing: 0; }
.screen .lead { font-size: 13px; line-height: 1.85; color: #cbbfae; }
.screen .tip { font-size: 12.5px; color: #9d9280; line-height: 1.8; }

/* ---------------- 菜单头 ---------------- */
.mhead { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.brand h1 { font-size: clamp(22px, 3.4vw, 34px); letter-spacing: 5px; }
.brand h1 .f { color: #ff7a3c; }
.brand h1 .w { color: #54c8ff; }
.brand em { font-size: 11.5px; letter-spacing: 3px; color: #8f8574; font-style: normal; }
.wallet { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12.5px; color: #bdb098; }
.wallet .lv { display: inline-flex; align-items: center; gap: 6px; }
.wallet .lv b { color: #ffd9a8; font-size: 15px; }
.wallet .lv em { color: #cbbfae; font-style: normal; }
.xpbar { display: inline-block; width: 74px; height: 6px; border-radius: 4px; background: rgba(255, 255, 255, .13); overflow: hidden; }
.xpbar u { display: block; height: 100%; width: 0%; background: linear-gradient(90deg, #ffb347, #ff7a3c); border-radius: 4px; transition: width .3s; }
.chip {
  cursor: pointer; border: 1px solid rgba(255, 255, 255, .16); background: rgba(255, 255, 255, .05);
  color: #d8cdb8; border-radius: 9px; padding: 5px 10px; font-size: 12.5px; font-family: inherit;
}
.chip:hover { background: rgba(255, 255, 255, .1); }
.chip.cloud b { color: #9fdc9f; }
.chip.cloud.off b { color: #d8a06a; }

/* ---------------- 菜单主体 ---------------- */
.mbody { display: flex; gap: 18px; flex: 1; min-height: 0; }
.mcol { flex: 1; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.mcol.narrow { flex: 0 0 232px; }
.mcol h2 { font-size: 14px; letter-spacing: 1px; color: #e2d6c4; font-weight: 600; }

.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.cards.vertical { grid-template-columns: 1fr; }
.card {
  position: relative; cursor: pointer; border-radius: 11px; padding: 10px 11px;
  background: rgba(255, 255, 255, .045); border: 1px solid rgba(255, 255, 255, .1);
  transition: .15s; min-width: 0;
}
.card:hover { background: rgba(255, 255, 255, .09); }
.card.sel { border-color: #ff9a4c; background: rgba(255, 122, 60, .16); box-shadow: 0 0 0 1px rgba(255, 154, 76, .4) inset; }
.card.locked { opacity: .42; cursor: not-allowed; }
.card .cname { font-size: 13.5px; font-weight: 700; display: flex; align-items: center; gap: 5px; }
.card .csub { font-size: 11.5px; color: #9d9280; margin-top: 3px; line-height: 1.5; }
.card .clv { position: absolute; right: 8px; top: 8px; font-size: 10.5px; color: #ffd24a; }
.scene-desc { font-size: 12px; color: #9d9280; line-height: 1.7; min-height: 34px; }
.best { font-size: 12px; color: #ffd9a8; }

.btn-main {
  cursor: pointer; border: none; border-radius: 12px; padding: 13px 20px;
  font-size: 16px; font-weight: 700; color: #fff; letter-spacing: 3px; font-family: inherit;
  background: linear-gradient(180deg, #ff8a4c, #f0511a);
  box-shadow: 0 5px 0 #a33208, 0 10px 22px rgba(240, 81, 26, .35);
}
.btn-main:active { transform: translateY(3px); box-shadow: 0 2px 0 #a33208; }
.btn-ghost {
  cursor: pointer; border: 1px solid rgba(255, 255, 255, .2); border-radius: 11px;
  padding: 11px 18px; font-size: 14px; color: #d8cdb8; background: rgba(255, 255, 255, .05); font-family: inherit;
}
.btn-ghost:hover { background: rgba(255, 255, 255, .11); }
.btn-ghost.duel { border-color: rgba(127, 216, 255, .45); color: #bfe8ff; }
.btnrow { display: flex; gap: 10px; flex-wrap: wrap; }

.mfoot { display: flex; gap: 8px; flex-wrap: wrap; }
.mfoot button {
  cursor: pointer; border: 1px solid rgba(255, 255, 255, .14); background: rgba(255, 255, 255, .05);
  color: #d8cdb8; border-radius: 10px; padding: 8px 13px; font-size: 12.5px; font-family: inherit;
}
.mfoot button:hover { background: rgba(255, 255, 255, .11); }
.mfoot .dot { color: #ffd24a; }

/* ---------------- 结算 ---------------- */
#over { align-items: center; text-align: center; }
.gradebox { display: flex; align-items: baseline; gap: 8px; }
.grade { font-size: clamp(40px, 7vw, 62px); font-weight: 800; color: #ffd24a; line-height: 1; text-shadow: 0 3px 0 rgba(0, 0, 0, .45); }
.gradelab { font-size: 12px; color: #8f8574; letter-spacing: 2px; }
.stat { font-size: clamp(13px, 1.8vw, 16px); color: #ffd9a8; line-height: 1.9; }
.rewards { font-size: 13px; color: #cbbfae; line-height: 1.9; }
.rewards b { color: #9fdc9f; }
.medals { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.medal-chip {
  display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: #ffd24a;
  background: rgba(255, 210, 74, .13); border: 1px solid rgba(255, 210, 74, .35);
  border-radius: 999px; padding: 4px 11px;
}

/* ---------------- 对战大厅 ---------------- */
.lobby-grid { display: flex; gap: 14px; flex-wrap: wrap; }
.lobby-card {
  flex: 1 1 220px; background: rgba(255, 255, 255, .045); border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 9px;
}
.lobby-card h3 { font-size: 14px; color: #e2d6c4; font-weight: 600; }
.lobby-card p { font-size: 12px; color: #9d9280; line-height: 1.7; }
.lobby-card input {
  width: 100%; padding: 11px 12px; font-size: 20px; letter-spacing: 8px; text-align: center; font-family: inherit;
  background: rgba(0, 0, 0, .35); border: 1px solid rgba(255, 255, 255, .18); border-radius: 10px; color: #ffd9a8;
  text-transform: uppercase;
}
.lobby-status { font-size: 13px; color: #cbbfae; min-height: 20px; line-height: 1.7; }
.lobby-status .code { font-size: 22px; letter-spacing: 6px; color: #ffd24a; font-weight: 700; }

/* ---------------- 局内对战 HUD ---------------- */
#duelBar {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: max(10px, calc(var(--vh) * .02));
  width: min(calc(var(--vw) * .96), 900px); z-index: 4;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: rgba(14, 12, 18, .82); border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 12px; padding: 7px 12px; font-size: 12.5px; color: #cfd6e6;
}
#duelBar .impairs { display: flex; gap: 7px; margin-left: auto; flex-wrap: wrap; }
.imp-btn {
  cursor: pointer; border: 1px solid rgba(255, 154, 143, .45); background: rgba(255, 122, 60, .14);
  color: #ffcbb0; border-radius: 9px; padding: 6px 10px; font-size: 12px; font-family: inherit;
}
.imp-btn:disabled { opacity: .38; cursor: not-allowed; }
.imp-btn.shield { border-color: rgba(159, 220, 159, .45); background: rgba(120, 200, 130, .14); color: #b8e8b8; }

/* ---------------- 通用面板 ---------------- */
.modal {
  position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center;
  background: rgba(6, 4, 8, .68); padding: 16px;
}
.sheet {
  width: min(calc(var(--vw) * .94), 620px); max-height: calc(var(--vh) * .86); display: flex; flex-direction: column;
  background: #17131f; border: 1px solid rgba(255, 255, 255, .12); border-radius: 16px; overflow: hidden;
}
.sh-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid rgba(255, 255, 255, .09); }
.sh-head h3 { font-size: 15px; letter-spacing: 1px; }
.sh-head button { cursor: pointer; background: none; border: none; color: #9d9280; font-size: 17px; padding: 2px 6px; }
.sh-body { padding: 14px 18px 20px; overflow: auto; font-size: 13px; color: #cbbfae; line-height: 1.85; }

.rank-row { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-bottom: 1px solid rgba(255, 255, 255, .06); }
.rank-row .no { width: 26px; text-align: center; color: #8f8574; font-weight: 700; }
.rank-row.top1 .no { color: #ffd24a; } .rank-row.top2 .no { color: #cfd6e6; } .rank-row.top3 .no { color: #d8a06a; }
.rank-row .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-row .sc { color: #ffd9a8; font-weight: 700; }
.rank-row .sub { font-size: 11.5px; color: #8f8574; }
.mode-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.mode-tabs button {
  cursor: pointer; border: 1px solid rgba(255, 255, 255, .14); background: rgba(255, 255, 255, .05);
  color: #cbbfae; border-radius: 8px; padding: 5px 9px; font-size: 12px; font-family: inherit;
}
.mode-tabs button.on { border-color: #ff9a4c; color: #ffd9a8; background: rgba(255, 122, 60, .16); }

.medal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 9px; }
.medal-card { border-radius: 11px; padding: 10px; background: rgba(255, 255, 255, .04); border: 1px solid rgba(255, 255, 255, .09); }
.medal-card.got { border-color: rgba(255, 210, 74, .45); background: rgba(255, 210, 74, .1); }
.medal-card .mi { font-size: 19px; }
.medal-card .mn { font-size: 13px; font-weight: 700; margin-top: 3px; }
.medal-card .md { font-size: 11.5px; color: #9d9280; line-height: 1.5; }

.task-row { display: flex; align-items: center; gap: 10px; padding: 9px 4px; border-bottom: 1px solid rgba(255, 255, 255, .06); }
.task-row .tt { flex: 1; }
.task-row .tp { font-size: 11.5px; color: #8f8574; }
.task-row button {
  cursor: pointer; border: none; border-radius: 9px; padding: 7px 12px; font-size: 12px; font-family: inherit;
  background: linear-gradient(180deg, #ffb347, #f0511a); color: #fff; font-weight: 700;
}
.task-row button:disabled { background: rgba(255, 255, 255, .1); color: #8f8574; cursor: default; }
.tier-row { display: flex; align-items: center; gap: 10px; padding: 8px 4px; border-bottom: 1px solid rgba(255, 255, 255, .06); }

#toast {
  position: absolute; left: 50%; top: 12%; transform: translateX(-50%);
  background: rgba(14, 12, 18, .9); border: 1px solid rgba(255, 255, 255, .14);
  color: #ffd9a8; font-size: 13px; padding: 9px 16px; border-radius: 10px;
  z-index: 30; opacity: 0; transition: opacity .25s; pointer-events: none; max-width: calc(var(--vw) * .86); text-align: center;
}
#toast.on { opacity: 1; }

/* ---------------- 窄屏 ---------------- */
@media (max-width: 720px) {
  .screen { padding: 14px; gap: 10px; }
  .mbody { flex-direction: column; }
  .mcol.narrow { flex: none; }
  .cards { grid-template-columns: repeat(2, 1fr); }
  #touchBar { bottom: 78px; right: 10px; }
  #touchBar button { width: 56px; height: 56px; font-size: 21px; }
  #touchBar #tb-pause { width: 44px; height: 44px; font-size: 17px; }
}
/* 竖屏自动转横屏时，可用宽度其实等于"屏幕的高"（够宽），恢复横向菜单布局。
   媒体查询量的是设备视口宽，量不到旋转后的逻辑宽度，所以这里要单独兜回来。 */
html.rot90 .screen { padding: 18px 22px; gap: 12px; }
html.rot90 .mbody { flex-direction: row; }
html.rot90 .mcol.narrow { flex: 0 0 210px; }
html.rot90 .cards { grid-template-columns: repeat(3, 1fr); }
html.rot90 #touchBar { bottom: 56px; right: 22px; }

/* ---------------- 移动端触摸控件 ---------------- */
#touchBar {
  position: absolute; right: 14px; bottom: 96px; z-index: 8;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
#touchBar button {
  cursor: pointer; border: 1px solid rgba(255, 255, 255, .28); font-family: inherit;
  background: rgba(16, 12, 20, .74); color: #ffd9a8; border-radius: 50%;
  width: 62px; height: 62px; font-size: 24px; line-height: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  box-shadow: 0 6px 16px rgba(0, 0, 0, .5); -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
}
#touchBar button:active { transform: scale(.94); background: rgba(255, 122, 60, .32); }
#touchBar button i { font-size: 10px; font-style: normal; letter-spacing: 1px; margin-top: 1px; }
#touchBar #tb-pause { width: 50px; height: 50px; font-size: 19px; }
#touchBar #tb-pause i { display: none; }

/* ---------------- 新手引导 ---------------- */
.guide-body { font-size: 13.5px; line-height: 1.9; color: #cbbfae; text-align: left; min-height: 96px; }
.guide-body .gicon { font-size: 34px; display: block; text-align: center; margin-bottom: 8px; }
.guide-body b { color: #ffd9a8; }
.guide-dots { display: flex; gap: 7px; justify-content: center; }
.guide-dots i { width: 8px; height: 8px; border-radius: 50%; background: rgba(255, 255, 255, .22); }
.guide-dots i.on { background: #ff8a4c; }

/* ---------------- 结算补充信息 ---------------- */
.extrastat { font-size: 12.5px; color: #9d9280; line-height: 1.8; }

/* ---------------- 每日挑战按钮 ---------------- */
.btn-ghost.daily { border-color: rgba(255, 210, 74, .45); color: #ffe4a0; }
.btn-ghost.daily b { color: #ffd24a; font-size: 11.5px; font-weight: 600; margin-left: 4px; }

/* ---------------- 排行榜：高亮自己 ---------------- */
.rank-row.me { background: rgba(255, 122, 60, .15); border-radius: 8px; }
.rank-row.me .nm { color: #ffd9a8; font-weight: 700; }
.rank-row .tagme { font-size: 10.5px; color: #ff9a4c; margin-left: 6px; }

/* ---------------- 手机竖屏：已自动转横屏的一次性提示 ---------------- */
#rotateHint { display: none; }
html.rot90.hint #rotateHint {
  display: block; position: absolute; bottom: 6px; left: 50%; transform: translateX(-50%);
  font-size: 11.5px; color: #a2977f; z-index: 9; white-space: nowrap; pointer-events: none;
  background: rgba(14, 12, 18, .72); padding: 3px 12px; border-radius: 999px;
  transition: opacity .5s; opacity: 1;
}
html.rot90.hint.fade #rotateHint { opacity: 0; }

/* ============================================================
   矮横屏适配（手机横持 ~375-470px 高）：收紧行距、收起次要信息，
   保证「选择战场 / 难度 / 开始守门 / 底部功能条」一屏全可见。
   根因：.screen 宽度被 --vh*1.5 锁死，场景卡被挤窄后描述文字
   竖向长高（单卡 130px+），position:relative 的卡片按层叠规则
   盖住了页脚按钮。
   ============================================================ */
.mfoot { position: relative; z-index: 5; }

@media (max-height: 480px) and (orientation: landscape) {
  .screen { padding: 10px 14px; gap: 8px; }
  .brand h1 { font-size: 20px; letter-spacing: 3px; }
  .brand em { display: none; }
  .wallet { font-size: 11.5px; }
  .mcol { gap: 6px; }
  .mcol h2 { font-size: 12.5px; }
  .card { padding: 7px 9px; border-radius: 9px; }
  .card .cname { font-size: 12px; }
  .card .csub { font-size: 10px; margin-top: 2px; line-height: 1.35; }
  .mcol.narrow .cards { grid-template-columns: repeat(2, 1fr); }
  .scene-desc, .best { display: none; }
  .btn-main { padding: 10px 16px; font-size: 15px; border-radius: 10px; }
  .btn-ghost { padding: 8px 12px; font-size: 12.5px; border-radius: 9px; }
  .mfoot button { padding: 6px 10px; font-size: 11.5px; border-radius: 8px; }
}
