* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: radial-gradient(1200px 700px at 50% 20%, #2c3e5e 0%, #121a2c 70%);
  display: flex; align-items: center; justify-content: center;
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  overflow: hidden;
  -webkit-user-select: none; user-select: none;
}

/* ===== 手机竖屏容器 ===== */
#game {
  position: relative;
  width: min(430px, 100vw);
  max-width: 100vw;
  height: 100vh; height: 100dvh;
  max-height: 900px;
  background: linear-gradient(180deg, #79b8f2 0%, #cfe9ff 34%, #a5d47f 100%);
  overflow: hidden;
  border-radius: 18px;
  box-shadow: 0 0 70px rgba(0,0,0,.55);
}
@media (min-width: 480px) {
  #game { height: min(92vh, 860px); }
}

/* ===== 顶部信息卡 ===== */
#top-info { position: absolute; top: 8px; left: 0; right: 0; z-index: 5; display: flex; justify-content: space-between; padding: 0 8px; pointer-events: none; }
.info-card {
  display: flex; align-items: center; gap: 7px;
  background: rgba(255,255,255,.88);
  border: 2px solid #5b6b8c; border-radius: 14px;
  padding: 6px 8px; box-shadow: 0 4px 10px rgba(30,45,80,.25);
  max-width: 216px;
}
.avatar {
  width: 46px; height: 46px; border-radius: 50%; flex: 0 0 46px;
  border: 3px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.25);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; background: #ddd;
}
.info-body { min-width: 0; }
.name-row { display: flex; align-items: baseline; gap: 5px; font-weight: 800; font-size: 13px; color: #24314d; }
.name-row .lv { font-size: 9px; color: #7b879e; font-weight: 600; margin-left: auto; }
.hp-bar {
  position: relative; width: 128px; height: 14px; margin-top: 3px;
  background: #39424f; border: 2px solid #4a3a24; border-radius: 8px; overflow: hidden;
}
.hp-fill {
  position: absolute; inset: 0; width: 100%;
  background: linear-gradient(180deg, #8fe87a, #3fae3f);
  border-radius: 6px; transition: width .55s ease;
}
.hp-fill.warn { background: linear-gradient(180deg, #ffd45e, #eea23a); }
.hp-fill.crit { background: linear-gradient(180deg, #ff8a6b, #e33c4d); }
.hp-text {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 800; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.85); letter-spacing: .3px;
}
.energy-row { margin-top: 2px; font-size: 10px; font-weight: 700; color: #5a4a24; display: flex; align-items: center; gap: 3px; }
.energy-row .star { color: #eab308; text-shadow: 0 1px 0 rgba(0,0,0,.25); }
.team-row { margin-top: 2px; font-size: 10px; font-weight: 800; color: #7a2f2f; display: flex; align-items: center; gap: 3px; }
.team-row .heart { color: #e05555; }
.team-row .sep { color: #b9c2d8; font-weight: 400; }

/* ===== 战斗场景 ===== */
#scene { position: absolute; inset: 0; overflow: hidden; }
.arena-ring {
  position: absolute; left: 50%; bottom: -18%; transform: translateX(-50%);
  border-radius: 50%; border: 3px solid rgba(255,214,110,.85);
}
.ring1 { width: 540px; height: 300px; background: radial-gradient(circle at 50% 35%, #f7e6b8 0%, #e7c983 55%, #cba454 100%); }
.ring2 { width: 430px; height: 240px; bottom: -12%; border-color: rgba(255,255,255,.6); }
.ring3 { width: 320px; height: 180px; bottom: -6%; border-color: rgba(255,214,110,.5); }

.model { position: absolute; z-index: 2; display: flex; flex-direction: column; align-items: center; }
.enemy-model { right: 16%; top: 28%; }
.player-model { left: 13%; bottom: 22%; }
.model-core {
  width: 92px; height: 92px; border-radius: 50%;
  background: #ddd; border: 4px solid rgba(255,255,255,.9);
  box-shadow: 0 8px 20px rgba(20,35,60,.35);
  display: flex; align-items: center; justify-content: center;
  font-size: 44px; position: relative;
  animation: idle 2.2s ease-in-out infinite;
}
.player-model .model-core { width: 108px; height: 108px; font-size: 52px; }
.model-shadow { width: 74px; height: 15px; border-radius: 50%; background: rgba(20,35,50,.28); margin-top: 7px; }
.status-badge {
  position: absolute; top: -26px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 4px; white-space: nowrap;
}
.badge {
  background: #fff; border: 1px solid #b9c2d8; border-radius: 10px;
  padding: 1px 7px; font-size: 10px; font-weight: 700; color: #2c3a5e;
  box-shadow: 0 2px 4px rgba(0,0,0,.18);
}

.model.attacking .model-core { animation: lunge .45s ease; }
.enemy-model.attacking .model-core { animation: lungeLeft .45s ease; }
.model.hit .model-core { animation: hurt .4s ease; }
.model.ko .model-core { animation: ko 1s ease forwards; }
@keyframes idle { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes lunge {
  0% { transform: translate(0,0) scale(1); }
  40% { transform: translate(28px,-12px) scale(1.08); }
  100% { transform: translate(0,0) scale(1); }
}
.player-model .model-core.lunge-left { animation: lungeLeft .45s ease; }
@keyframes lungeLeft {
  0% { transform: translate(0,0) scale(1); }
  40% { transform: translate(-28px,-12px) scale(1.08); }
  100% { transform: translate(0,0) scale(1); }
}
@keyframes hurt { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-7px); } 50% { transform: translateX(7px); } 75% { transform: translateX(-4px); } }
@keyframes ko {
  0% { transform: translateY(0) rotate(0); opacity: 1; }
  60% { transform: translateY(38px) rotate(14deg); opacity: .7; }
  100% { transform: translateY(70px) rotate(20deg); opacity: 0; }
}

/* ===== 飘字 / 回合横幅 / 日志条 ===== */
#fx-layer { position: absolute; inset: 0; z-index: 4; pointer-events: none; overflow: hidden; }
.float-dmg {
  position: absolute; font-size: 27px; font-weight: 900; color: #fff;
  text-shadow: 0 2px 0 #c1272d, 0 0 10px rgba(0,0,0,.55);
  animation: floatUp .95s ease-out forwards;
}
.float-heal { color: #b6ff9a; text-shadow: 0 2px 0 #1f7a2d, 0 0 10px rgba(0,0,0,.5); }
.float-info { font-size: 15px; color: #fff; text-shadow: 0 1px 0 #334, 0 0 8px rgba(0,0,0,.6); }
@keyframes floatUp {
  0% { transform: translateY(0) scale(.8); opacity: 0; }
  15% { transform: translateY(-10px) scale(1.15); opacity: 1; }
  100% { transform: translateY(-74px) scale(1); opacity: 0; }
}
#turn-banner {
  position: absolute; top: 46%; left: 50%; transform: translate(-50%,-50%);
  font-size: 32px; font-weight: 900; color: #fff; letter-spacing: 4px;
  text-shadow: 0 3px 0 rgba(120,70,20,.85), 0 0 22px rgba(255,190,60,.9);
  opacity: 0; z-index: 5; pointer-events: none; transition: opacity .25s ease;
}
#turn-banner.show { opacity: 1; }
#log-ticker {
  position: absolute; left: 8px; right: 8px; bottom: 150px; z-index: 5;
  background: rgba(18,26,46,.78); color: #eaf2ff; border-radius: 10px;
  padding: 6px 12px; font-size: 12px; text-align: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  box-shadow: 0 3px 8px rgba(0,0,0,.3);
}

/* ===== 右侧功能按钮 ===== */
#side-buttons {
  position: absolute; right: 6px; top: 40%; transform: translateY(-50%);
  display: flex; flex-direction: column; gap: 9px; z-index: 7;
}
.round-btn {
  width: 46px; height: 46px; border-radius: 50%;
  background: #3a4468; color: #fff; border: 2px solid #262e4d;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 16px; cursor: pointer; box-shadow: 0 3px 7px rgba(0,0,0,.3);
  transition: transform .12s ease, background .12s ease, color .12s ease;
}
.round-btn span { font-size: 9px; margin-top: 1px; line-height: 1; }
.round-btn:hover:not(:disabled) { transform: scale(1.03); }
.round-btn:active:not(:disabled) { transform: scale(.97); }
.round-btn.active { background: #fff; color: #262e4d; transform: scale(1.12); border-color: #ffd76a; }
.round-btn:disabled { opacity: .45; cursor: default; }

/* ===== 技能卡牌 ===== */
#skill-bar {
  position: absolute; left: 8px; right: 8px; bottom: 82px; z-index: 6;
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px;
  pointer-events: auto;
}
#skill-bar.locked { pointer-events: none; }
#skill-bar.locked .skill-card { opacity: .7; }
.skill-card {
  background: #fffdf2; border: 2px solid #8a7350; border-radius: 12px;
  padding: 5px 4px 4px; transform: rotate(-2deg); cursor: pointer;
  box-shadow: 0 3px 6px rgba(0,0,0,.28);
  text-align: center; transition: transform .12s ease, filter .12s ease, box-shadow .12s ease;
}
.skill-card:nth-child(2) { transform: rotate(1deg); }
.skill-card:nth-child(3) { transform: rotate(-1deg); }
.skill-card:nth-child(4) { transform: rotate(2deg); }
.skill-card .elem { display: block; height: 6px; border-radius: 4px; margin-bottom: 4px; }
.skill-card .sname { font-size: 12px; font-weight: 800; color: #2c2f45; line-height: 1.25; }
.skill-card .smeta { display: flex; justify-content: center; gap: 7px; margin-top: 3px; font-size: 10px; font-weight: 700; }
.skill-card .scost { color: #a3781c; }
.skill-card:hover:not(.disabled) { transform: translateY(-3px) scale(1.03) rotate(0); box-shadow: 0 6px 12px rgba(0,0,0,.32); }
.skill-card:active:not(.disabled) { transform: scale(.97); }
.skill-card.disabled { filter: grayscale(.85) brightness(.82); cursor: not-allowed; box-shadow: none; }
.skill-card.selected { border-color: #ffd76a; box-shadow: 0 0 0 2px #ffd76a; }
#skill-bar.highlighted .skill-card { box-shadow: 0 0 0 2px rgba(255,215,106,.7); }

/* ===== 底部操作区 ===== */
#action-bar {
  position: absolute; bottom: 0; left: 0; right: 0; z-index: 6;
  height: 74px; display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px;
  background: linear-gradient(180deg, rgba(24,34,60,.02), rgba(24,34,60,.28));
}
.gather-btn {
  width: 98px; height: 56px; border-radius: 15px; cursor: pointer;
  background: linear-gradient(180deg, #46557f, #2b3559);
  border: 2px solid #1d2440; color: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  box-shadow: 0 4px 9px rgba(0,0,0,.32);
  transition: transform .12s ease, filter .12s ease;
}
.gather-btn:hover:not(:disabled) { transform: translateY(-2px); }
.gather-btn:active:not(:disabled) { transform: scale(.97); }
.gather-btn:disabled { filter: grayscale(.6) brightness(.8); cursor: default; }
.gather-icon { font-size: 15px; color: #ffd76a; }
.gather-label { font-size: 12px; font-weight: 800; letter-spacing: 2px; }
.gather-energy { font-size: 9px; color: #9fb0dd; }
.function-buttons { display: flex; gap: 9px; align-items: center; }
.function-buttons .round-btn { width: 44px; height: 44px; font-size: 15px; }

/* ===== 战报面板 ===== */
#log-panel {
  position: absolute; top: 0; right: 0; bottom: 0; width: 74%;
  background: rgba(14,21,39,.94); color: #dce7ff; z-index: 10;
  padding: 12px; overflow-y: auto; border-left: 1px solid #35405f;
  box-shadow: -8px 0 24px rgba(0,0,0,.35);
}
#log-panel.hidden { display: none; }
.log-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 15px; font-weight: 800; margin-bottom: 8px; color: #ffd76a;
}
.log-panel-header button {
  background: #35405f; color: #fff; border: none; border-radius: 8px;
  width: 26px; height: 26px; cursor: pointer; font-size: 12px;
}
#log-list { font-size: 12px; line-height: 1.8; word-break: break-all; }
#log-list .log-entry:first-child { color: #ffd76a; }

/* ===== 换宠面板 ===== */
#switch-panel {
  position: absolute; top: 0; right: 0; bottom: 0; width: 78%;
  background: rgba(14,21,39,.95); color: #dce7ff; z-index: 12;
  padding: 12px; overflow-y: auto; border-left: 1px solid #35405f;
  box-shadow: -8px 0 24px rgba(0,0,0,.35);
}
#switch-panel.hidden { display: none; }
.switch-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 16px; font-weight: 800; color: #ffd76a;
}
.switch-panel-header button {
  background: #35405f; color: #fff; border: none; border-radius: 8px;
  width: 26px; height: 26px; cursor: pointer; font-size: 12px;
}
.switch-note { font-size: 10.5px; color: #9fb0dd; margin: 6px 0 10px; }
.switch-card {
  display: flex; align-items: center; gap: 9px;
  background: rgba(255,255,255,.08); border: 2px solid rgba(255,255,255,.18);
  border-radius: 12px; padding: 8px 9px; margin-bottom: 8px; cursor: pointer;
  transition: transform .12s ease, border-color .12s ease, background .12s ease;
}
.switch-card:hover:not(.disabled) { transform: scale(1.03); border-color: #ffd76a; }
.switch-card:active:not(.disabled) { transform: scale(.97); }
.switch-card.disabled { opacity: .45; cursor: default; }
.switch-card.selected { border-color: #ffd76a; background: rgba(255,215,106,.14); }
.sw-avatar {
  width: 42px; height: 42px; border-radius: 50%; flex: 0 0 42px;
  border: 2px solid rgba(255,255,255,.85); box-shadow: 0 2px 5px rgba(0,0,0,.3);
  display: flex; align-items: center; justify-content: center; font-size: 22px;
}
.sw-info { min-width: 0; flex: 1; }
.sw-name { font-size: 13px; font-weight: 800; display: flex; align-items: baseline; gap: 5px; }
.sw-name .sw-elem { font-size: 10px; }
.sw-hp { position: relative; height: 9px; background: #39424f; border: 1px solid #4a3a24; border-radius: 6px; margin-top: 4px; overflow: hidden; }
.sw-hp i { position: absolute; inset: 0; background: linear-gradient(180deg, #8fe87a, #3fae3f); border-radius: 5px; transition: width .4s ease; }
.sw-stats { font-size: 9.5px; color: #9fb0dd; margin-top: 3px; }

/* ===== 结算弹窗 ===== */
#result-modal {
  position: absolute; inset: 0; z-index: 20;
  background: rgba(8,14,28,.6); display: flex; align-items: center; justify-content: center;
}
#result-modal.hidden { display: none; }
.modal-card {
  width: 280px; background: linear-gradient(180deg, #fffbe8, #ffe7ab);
  border: 3px solid #d9a441; border-radius: 20px; padding: 22px 18px; text-align: center;
  box-shadow: 0 14px 40px rgba(0,0,0,.5);
}
#result-title { font-size: 30px; font-weight: 900; color: #b9741f; }
#result-title.win { color: #2e9e4f; }
#result-detail { margin: 10px 0 16px; font-size: 13px; color: #5a4a2a; line-height: 1.6; }
#btn-restart {
  background: linear-gradient(180deg, #ffd76a, #f0a83a); color: #5a3c0a;
  border: 2px solid #b9741f; border-radius: 30px; padding: 10px 30px;
  font-size: 15px; font-weight: 800; cursor: pointer; box-shadow: 0 4px 10px rgba(0,0,0,.25);
}
#btn-restart:hover { transform: scale(1.03); }

/* ===== 开场选宠 ===== */
#start-screen {
  position: absolute; inset: 0; z-index: 30;
  background: linear-gradient(165deg, #20345f 0%, #101a38 100%);
  color: #fff; display: flex; flex-direction: column; align-items: center;
  padding: 30px 20px 18px; overflow-y: auto;
  overflow-x: hidden;
}
#start-screen.hidden { display: none; }
#start-screen h1 { font-size: 30px; letter-spacing: 2px; color: #ffd76a; text-shadow: 0 2px 0 #7a5410; }
#start-screen h1 span { font-size: 16px; color: #9fc0ff; vertical-align: middle; }
.subtitle { margin-top: 4px; font-size: 12px; color: #9fb0dd; }
.rule-note { margin-top: 10px; font-size: 11px; color: #c9d6f7; background: rgba(255,255,255,.08); border-radius: 20px; padding: 5px 14px; }
#team-picker { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; margin-top: 16px; }
.pick-card {
  min-width: 0;
  background: rgba(255,255,255,.07); border: 2px solid rgba(255,255,255,.18);
  border-radius: 14px; padding: 12px 8px; text-align: center; cursor: pointer;
  transition: transform .12s ease, border-color .12s ease, background .12s ease;
}
.pick-card:hover { transform: translateY(-3px) scale(1.03); }
.pick-card.selected { border-color: #ffd76a; background: rgba(255,215,106,.14); box-shadow: 0 0 0 3px rgba(255,215,106,.3); }
.p-avatar { width: 62px; height: 62px; border-radius: 50%; margin: 0 auto 8px; display: flex; align-items: center; justify-content: center; font-size: 30px; border: 3px solid rgba(255,255,255,.85); box-shadow: 0 3px 8px rgba(0,0,0,.3); }
.p-name { font-weight: 800; font-size: 14px; }
.p-elem { margin-left: 4px; font-size: 12px; }
.p-stats { font-size: 10.5px; color: #aebde4; margin-top: 5px; line-height: 1.55; }
@media (max-width: 360px) {
  .p-stats { font-size: 9.5px; }
  .rule-note { white-space: normal; }
}
#btn-start {
  margin-top: 18px; width: 100%; padding: 13px 0; border-radius: 30px;
  background: linear-gradient(180deg, #ffd76a, #f0a83a); color: #5a3c0a;
  border: 2px solid #b9741f; font-size: 17px; font-weight: 900; cursor: pointer;
  box-shadow: 0 5px 14px rgba(0,0,0,.35);
}
#btn-start:disabled { filter: grayscale(.7) brightness(.75); cursor: default; }
.footnote { margin-top: auto; padding-top: 14px; font-size: 10.5px; color: #7382ab; }
