/* ===== Base ===== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: #ece7d8;
  background: #0a0907;
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  font-size: 14px;
}

a {
  color: #f4c95d;
}

button,
input,
select {
  font: inherit;
}

/* ===== Landing / auth ===== */
.landing {
  min-height: 100vh;
  padding: 32px;
  display: grid;
  place-items: center;
}

.auth-panel {
  width: min(420px, 100%);
  max-width: 420px;
  padding: 24px;
  border: 1px solid #5d503b;
  background: rgba(25, 22, 17, 0.95);
}

.auth-panel h1 {
  margin: 0 0 4px;
  color: #f4c95d;
  text-align: center;
}

.subtitle {
  margin: 0 0 8px;
  color: #c4b797;
  text-align: center;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  margin: 16px 0 12px;
  border: 1px solid #5d503b;
  border-radius: 6px;
  overflow: hidden;
}

.auth-tab {
  border: none;
  border-radius: 0;
  background: #1a1610;
  color: #c4b797;
  font-weight: 600;
  min-height: 36px;
  cursor: pointer;
}

.auth-tab.is-active {
  background: #6b4b20;
  color: #f5efd8;
}

.auth-form {
  display: none;
  gap: 12px;
}

.auth-form.is-active {
  display: grid;
}

.auth-form[hidden] {
  display: none !important;
}

.auth-switch {
  margin: 4px 0 0;
  font-size: 0.9rem;
  color: #c4b797;
  text-align: center;
}

.form-card {
  display: grid;
  gap: 12px;
}

.form-card label {
  display: grid;
  gap: 6px;
}

.form-card input,
.form-card select,
.form-card button {
  min-height: 36px;
  border: 1px solid #7a6848;
  background: #0e0c09;
  color: #f5efd8;
  padding: 4px 10px;
}

.form-card button {
  cursor: pointer;
  background: #6b4b20;
  font-weight: 700;
}

/* ===== Game stage (原版一屏) ===== */
.page-game {
  overflow: hidden;
  min-height: 100vh;
  min-height: 100dvh;
  width: 100%;
  display: grid;
  place-items: center;
  background: #000 url('/assets/Images/web/bg/bg.jpg') center / cover no-repeat;
}

.bodybg {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  pointer-events: none;
  z-index: 0;
}

.stage {
  position: relative;
  z-index: 1;
  width: min(1140px, 100vw, calc(100dvh * 1.5405));
  height: min(740px, 100dvh, calc(100vw * 0.6492));
  background: rgba(16, 16, 16, 0.72);
  border: 1px solid #3a3228;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.6);
  overflow: hidden;
}

.stage-frame {
  pointer-events: none;
  position: absolute;
  inset: 0;
  z-index: 2;
  border: 2px solid rgba(90, 74, 50, 0.55);
}

.maintxt {
  position: relative;
  z-index: 3;
  width: 100%;
  height: 100%;
  padding: 8px 10px 0;
}

/* 顶栏按钮格 7×13 */
.main-btn-grid {
  display: grid;
  grid-template-columns: repeat(13, minmax(0, 1fr));
  grid-template-rows: repeat(7, 28px);
  gap: 4px 6px;
  width: 100%;
  max-height: 230px;
  padding: 4px 2px;
}

.main-btn {
  min-height: 26px;
  height: 26px;
  padding: 0 2px;
  border: 1px solid #5a4a30;
  background: #2a2214 url('/assets/Images/web/btn/3.jpg') center / 100% 100% no-repeat;
  color: #e8d9a8;
  font-size: 12px;
  line-height: 24px;
  text-align: center;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border-radius: 2px;
}

.main-btn:hover:not(.main-btn-header):not(.main-btn-empty) {
  background-image: url('/assets/Images/web/btn/4.jpg');
  color: #fff6d0;
  border-color: #8a7344;
}

.main-btn-header {
  background: transparent;
  border-color: transparent;
  color: #9a9080;
  cursor: default;
  font-weight: 600;
}

.main-btn-empty {
  background: transparent;
  border-color: transparent;
  cursor: default;
  pointer-events: none;
}

/* 中央场景 */
.stage-center {
  position: absolute;
  left: 50%;
  top: 48%;
  transform: translate(-50%, -50%);
  width: min(420px, 90%);
  text-align: center;
  z-index: 4;
}

.char-stage {
  display: grid;
  gap: 12px;
  justify-items: center;
}

.char-portrait {
  width: 180px;
  height: 160px;
  border: 1px solid #5d503b;
  border-radius: 8px;
  background:
    radial-gradient(ellipse at center, rgba(80, 60, 30, 0.45), transparent 70%),
    rgba(20, 16, 12, 0.85);
  display: grid;
  place-items: center;
  box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.5);
}

.char-hit {
  display: grid;
  gap: 6px;
  background: transparent;
  border: none;
  color: inherit;
  cursor: pointer;
  padding: 12px;
}

.char-name {
  font-size: 1.25rem;
  font-weight: 700;
  color: #f4c95d;
}

.char-lv {
  color: #ff9a3c;
  font-weight: 700;
}

.hud-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  justify-content: center;
  padding: 8px 12px;
  background: rgba(12, 10, 8, 0.82);
  border: 1px solid #413727;
  border-radius: 6px;
  font-size: 12px;
  color: #c4b797;
}

.hud-bar b {
  color: #f4c95d;
  font-weight: 600;
}

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.shell-btn {
  min-height: 30px;
  padding: 4px 14px;
  border: 1px solid #8a7344;
  background: #3a2f1d;
  color: #f4e4b0;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 600;
}

.shell-btn:hover {
  background: #56452a;
}

/* 左下头像 */
.avatar-card {
  position: absolute;
  left: 12px;
  bottom: 78px;
  width: 180px;
  padding: 12px;
  border: 1px solid #5d503b;
  border-radius: 6px;
  background: rgba(18, 14, 10, 0.9) url('/assets/Images/role/txpicbg.png') center / cover no-repeat;
  cursor: pointer;
  z-index: 5;
}

.avatar-meta {
  display: grid;
  gap: 2px;
  padding: 8px;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 4px;
}

.avatar-meta strong {
  color: #d99b29;
}

.avatar-meta span {
  font-size: 12px;
  color: #c4b797;
}

.avatar-acc {
  opacity: 0.75;
}

/* 底栏聊天 */
.chat-dock {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 8px;
  height: 64px;
  display: grid;
  grid-template-columns: 1fr minmax(220px, 320px);
  gap: 8px;
  z-index: 5;
}

.chat-log {
  overflow: auto;
  padding: 6px 10px;
  border: 1px solid #413727;
  background: rgba(8, 7, 5, 0.88);
  font-size: 12px;
  line-height: 1.4;
  border-radius: 4px;
}

.chat-line {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-line b {
  color: #5ddea0;
}

.chat-send {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 4px;
  align-items: center;
}

.chat-send input {
  min-height: 32px;
  border: 1px solid #5d503b;
  background: #0e0c09;
  color: #f5efd8;
  padding: 4px 8px;
  border-radius: 4px;
}

.chat-send button {
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid #8a7344;
  background: #3a2f1d;
  color: #f4e4b0;
  border-radius: 4px;
  cursor: pointer;
}

.chat-all-btn {
  min-width: 32px;
  color: #14fd6c !important;
  font-weight: 700;
}

/* ===== Modals ===== */
.modal-mask {
  position: absolute;
  inset: 0;
  z-index: 90;
  background: rgba(0, 0, 0, 0.58);
}

.shell-modal {
  position: absolute;
  z-index: 100;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(760px, calc(100% - 48px));
  max-height: calc(100% - 92px);
  display: none;
  flex-direction: column;
  border: 1px solid rgb(58, 44, 35);
  background: rgb(21, 19, 17);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
  border-radius: 4px;
}

.shell-modal.is-open {
  display: flex;
}

.modal-mask[hidden],
.shell-modal[hidden],
.shell-toast[hidden] {
  display: none !important;
}

.shell-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid #3a2c23;
  background: rgba(0, 0, 0, 0.35);
}

.shell-modal-title {
  margin: 0;
  font-size: 1rem;
  color: #f4c95d;
  font-weight: 700;
}

.shell-modal-close {
  width: 28px;
  height: 28px;
  border: 1px solid #5d503b;
  background: #2a2218;
  color: #f4e4b0;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  border-radius: 4px;
}

.shell-modal-close:hover {
  background: #4a3820;
}

.shell-modal-body {
  padding: 12px;
  overflow: auto;
  flex: 1;
  min-height: 0;
}

/* 战斗弹层稍宽 */
#modal-vs {
  width: min(860px, calc(100% - 36px));
  max-height: calc(100% - 72px);
}

/* Toast */
.shell-toast {
  position: absolute;
  left: 50%;
  bottom: 90px;
  transform: translateX(-50%);
  z-index: 200;
  padding: 10px 18px;
  border: 1px solid #5d503b;
  background: rgba(0, 0, 0, 0.9);
  color: #14fd6c;
  font-size: 15px;
  border-radius: 4px;
  pointer-events: none;
  white-space: nowrap;
}

/* ===== Shared panel content ===== */
.panel-msg {
  min-height: 1.2em;
  font-size: 0.9rem;
  color: #f4c95d;
  white-space: pre-wrap;
}

.panel-msg.ok {
  color: #5ddea0;
}

.panel-msg.err {
  color: #f07178;
}

.panel-body {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.panel-card {
  padding: 10px;
  border: 1px solid #5d503b;
  border-radius: 6px;
  background: rgba(30, 24, 16, 0.85);
  display: grid;
  gap: 4px;
}

.panel-card strong {
  color: #f4c95d;
}

.panel-card span {
  font-size: 0.88rem;
  color: #c8b896;
}

.panel-sub {
  margin: 10px 0 4px;
  font-size: 0.95rem;
  color: #e0c878;
}

.compact-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.compact-list li {
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid #413727;
  background: #12100c;
  position: relative;
}

.compact-list strong,
.compact-list span,
.compact-list small {
  overflow-wrap: anywhere;
}

.compact-list small,
.empty {
  color: #c4b797;
}

.role-dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 8px 16px;
  margin: 0 0 12px;
}

.role-dl dt {
  color: #d2b572;
}

.skill-actions,
.monster-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

button.btn-fight,
button.btn-skill,
button.btn-replay,
button.btn-panel,
a.btn-panel {
  cursor: pointer;
  border: 1px solid #8a7344;
  background: #3a2f1d;
  color: #f4e4b0;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 0.85rem;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  min-height: 28px;
}

button.btn-fight:hover,
button.btn-skill:hover,
button.btn-replay:hover,
button.btn-panel:hover,
a.btn-panel:hover {
  background: #56452a;
}

/* ===== Battle ===== */
.battle-arena {
  display: grid;
  gap: 12px;
}

.battle-fighters {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  align-items: center;
}

.battle-fighter {
  padding: 12px;
  border: 1px solid #6a5a3f;
  background: rgba(40, 32, 22, 0.9);
  border-radius: 6px;
}

.battle-fighter h3 {
  margin: 0 0 8px;
  font-size: 1rem;
  color: #f4c95d;
}

.hp-track {
  height: 14px;
  background: #2a2218;
  border: 1px solid #5d503b;
  border-radius: 8px;
  overflow: hidden;
}

.hp-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #8b1e1e, #d64545);
  transition: width 0.25s ease;
}

.hp-fill.ally {
  background: linear-gradient(90deg, #1e5b2a, #3ecf5b);
}

.battle-vs {
  font-weight: bold;
  color: #c9a227;
  text-align: center;
}

.battle-log {
  max-height: 180px;
  overflow: auto;
  padding: 10px;
  border: 1px solid #5d503b;
  background: #120f0c;
  font-size: 0.92rem;
  line-height: 1.45;
}

.battle-log-line {
  padding: 2px 0;
  border-bottom: 1px solid rgba(93, 80, 59, 0.35);
}

.battle-log-line.round {
  color: #9aa0a6;
}
.battle-log-line.crit {
  color: #ffb347;
  font-weight: bold;
}
.battle-log-line.win {
  color: #5ddea0;
}
.battle-log-line.lose {
  color: #f07178;
}
.battle-log-line.muted {
  color: #888;
}

.battle-status {
  min-height: 1.2em;
  color: #f4c95d;
  font-weight: bold;
  margin: 0;
}

/* ===== Item / cultivation icons ===== */
.item-grid .item-row,
.icon-card {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 10px;
  align-items: center;
}

.item-icon {
  width: 48px;
  height: 48px;
  object-fit: contain;
  background: rgba(20, 16, 10, 0.9);
  border: 1px solid #5d503b;
  border-radius: 4px;
  padding: 2px;
}

.item-meta {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.icon-grid {
  display: grid;
  gap: 8px;
}

.icon-card {
  padding: 8px;
  border: 1px solid #5d503b;
  border-radius: 6px;
  background: rgba(30, 24, 16, 0.85);
}

/* ===== Responsive ===== */
@media (max-width: 900px) {
  .page-game {
    overflow: hidden;
  }

  .stage {
    width: min(1140px, 100vw, calc(100dvh * 1.5405));
    height: min(740px, 100dvh, calc(100vw * 0.6492));
  }

  .main-btn-grid {
    grid-template-columns: repeat(13, minmax(0, 1fr));
    grid-template-rows: repeat(7, clamp(18px, 3.4vw, 28px));
    gap: clamp(1px, 0.55vw, 4px) clamp(2px, 0.65vw, 6px);
  }

  .main-btn-header {
    grid-column: auto;
    text-align: center;
    padding-left: 0;
    margin-top: 0;
  }

  .main-btn-empty {
    display: block;
  }

  .stage-center {
    position: absolute;
    left: 50%;
    top: 48%;
    transform: translate(-50%, -50%);
    width: min(420px, 90%);
    margin: 0;
  }

  .avatar-card {
    position: absolute;
    left: 12px;
    bottom: 78px;
    width: min(180px, 24%);
  }

  .chat-dock {
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: 8px;
    height: clamp(46px, 8.6vw, 64px);
    grid-template-columns: 1fr minmax(180px, 30%);
    margin-top: 0;
    padding-bottom: 0;
  }

  .shell-modal {
    top: 50%;
    width: min(760px, calc(100% - 24px));
    max-height: calc(100% - 48px);
  }
}

@media (max-width: 640px) {
  .main-btn {
    font-size: 10px;
    line-height: 18px;
    min-height: 18px;
    height: 18px;
  }

  .char-portrait {
    width: 128px;
    height: 112px;
  }

  .hud-bar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .avatar-card {
    display: none;
  }

  .chat-dock {
    grid-template-columns: 1fr;
  }
}
