/* ============================================================
   鳗潮防线 · 视觉层
   ============================================================ */
:root {
  --bg-0: #051018;
  --bg-1: #0a2030;
  --panel: rgba(13, 32, 48, .88);
  --edge: rgba(125, 200, 235, .16);
  --ink: #e8f2fa;
  --dim: #8fa8bd;
  --gold: #f0c75e;
  --teal: #2dd4bf;
  --red: #f87171;
  --serif: 'Noto Serif SC', 'Songti SC', serif;
  --sans: 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--sans); color: var(--ink); overflow: hidden;
  background:
    radial-gradient(900px 500px at 75% -5%, rgba(45, 212, 191, .12), transparent 60%),
    radial-gradient(700px 500px at 10% 110%, rgba(122, 63, 192, .14), transparent 55%),
    linear-gradient(180deg, var(--bg-1), var(--bg-0));
}
button { font-family: inherit; color: inherit; background: none; border: none; cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .4; }
.hidden { display: none !important; }
.icn { vertical-align: -2px; }
.screen { height: 100vh; display: flex; flex-direction: column; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 20px; border-radius: 12px; font-size: 15px; font-weight: 700;
  background: linear-gradient(180deg, #1d4258, #14303f);
  border: 1px solid rgba(125, 200, 235, .3);
  box-shadow: 0 4px 14px rgba(0, 0, 0, .4), inset 0 1px 0 rgba(255, 255, 255, .08);
  transition: transform .12s, filter .12s;
}
.btn:hover:not(:disabled) { transform: translateY(-2px); filter: brightness(1.15); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn.big { padding: 14px 34px; font-size: 18px; border-radius: 14px; }
.btn-gold {
  background: linear-gradient(180deg, #f3d27c, #cf9d2e);
  border-color: #8a6a1a; color: #2c2002;
  text-shadow: 0 1px 0 rgba(255, 255, 255, .35);
  box-shadow: 0 4px 18px rgba(240, 199, 94, .4), inset 0 1px 0 rgba(255, 255, 255, .5);
}
.btn-ghost { background: rgba(255, 255, 255, .05); border-color: rgba(255, 255, 255, .15); font-weight: 500; }

/* ============================================================
   主菜单
   ============================================================ */
#menu { align-items: center; justify-content: center; }
.menu-inner { text-align: center; padding: 20px; animation: fadeUp .5s ease; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(20px); } }
.game-title {
  font-family: var(--serif); font-weight: 900; letter-spacing: .06em;
  font-size: clamp(52px, 9vw, 88px); line-height: 1.05;
  background: linear-gradient(180deg, #b9f5ec 5%, var(--teal) 45%, #0f7d6e 95%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 6px 22px rgba(45, 212, 191, .35));
}
.game-sub { margin: 8px 0 22px; color: var(--dim); font-size: 13px; letter-spacing: .4em; text-indent: .4em; }
#menu-parade { display: flex; justify-content: center; gap: 12px; margin-bottom: 26px; }
.parade-card {
  width: 86px; height: 86px; border-radius: 16px; overflow: hidden;
  background: linear-gradient(180deg, #11334a, #0a2334);
  border: 1.5px solid var(--edge); box-shadow: 0 8px 20px rgba(0, 0, 0, .4);
  display: flex; align-items: center; justify-content: center;
  animation: bobble 3.2s ease-in-out infinite;
}
.parade-card:nth-child(2n) { animation-delay: -1.1s; }
.parade-card:nth-child(3n) { animation-delay: -2.2s; }
@keyframes bobble { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }
.parade-card canvas { width: 78px; height: 78px; }
.menu-btns { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-bottom: 18px; }
.menu-stats { color: var(--dim); font-size: 13px; margin-bottom: 6px; }
.menu-stats .icn { color: var(--gold); }
.menu-foot { color: rgba(143, 168, 189, .55); font-size: 11.5px; letter-spacing: .1em; }

/* ============================================================
   子页面公共
   ============================================================ */
.sub-head {
  display: flex; align-items: center; gap: 16px; padding: 14px 22px;
  border-bottom: 1px solid var(--edge); background: rgba(5, 16, 24, .6); flex: 0 0 auto;
}
.sub-head h2 { font-family: var(--serif); font-size: 20px; color: var(--gold); letter-spacing: .08em; }

/* 选关 */
#level-grid {
  flex: 1; overflow-y: auto; padding: 36px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 18px;
  align-content: start;
}
.level-node {
  position: relative; padding: 20px 16px 14px; border-radius: 18px; text-align: center;
  background: var(--panel); border: 1.5px solid var(--edge);
  display: flex; flex-direction: column; gap: 8px; align-items: center;
  transition: transform .15s, border-color .15s, box-shadow .15s;
}
.level-node:hover:not(.locked) { transform: translateY(-4px); border-color: var(--teal); box-shadow: 0 12px 28px rgba(0, 0, 0, .45), 0 0 22px rgba(45, 212, 191, .15); }
.level-node.bossnode { border-color: rgba(248, 113, 113, .4); }
.level-node.bossnode:hover:not(.locked) { border-color: var(--red); box-shadow: 0 12px 28px rgba(0, 0, 0, .45), 0 0 22px rgba(248, 113, 113, .2); }
.level-node.locked { opacity: .45; filter: grayscale(.7); }
.ln-num {
  width: 46px; height: 46px; border-radius: 50%; font-family: var(--serif); font-size: 22px; font-weight: 900;
  background: linear-gradient(180deg, #1d4258, #14303f); border: 2px solid var(--edge);
  display: flex; align-items: center; justify-content: center; color: var(--teal);
}
.bossnode .ln-num { color: var(--red); border-color: rgba(248, 113, 113, .4); }
.ln-name { font-size: 15px; font-weight: 700; }
.ln-stars { display: flex; gap: 3px; }
.ln-stars i { color: rgba(255, 255, 255, .15); }
.ln-stars i.on { color: var(--gold); filter: drop-shadow(0 0 5px rgba(240, 199, 94, .6)); }

/* 卡组选择 */
.deck-count { margin-left: auto; font-size: 16px; font-weight: 800; color: var(--gold); }
#deck-grid {
  flex: 1; overflow-y: auto; padding: 26px 36px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 14px;
  align-content: start;
}
.deck-card {
  position: relative; padding: 12px 8px 10px; border-radius: 14px; text-align: center;
  background: var(--panel); border: 2px solid var(--edge);
  display: flex; flex-direction: column; gap: 4px; align-items: center;
  transition: all .14s; font-size: 14px;
}
.deck-card:hover { transform: translateY(-3px); }
.deck-card.sel { border-color: var(--gold); background: rgba(240, 199, 94, .1); box-shadow: 0 0 18px rgba(240, 199, 94, .2); }
.deck-card canvas { width: 64px; height: 64px; }
.dc-cost { font-size: 12px; color: var(--gold); }
.dc-spell { position: absolute; top: 7px; right: 7px; font-size: 10px; font-style: normal; color: #c4b0ec; border: 1px solid #6a55c0; padding: 1px 6px; border-radius: 10px; }
.deck-foot { padding: 14px; text-align: center; border-top: 1px solid var(--edge); background: rgba(5, 16, 24, .6); }

/* ============================================================
   战斗
   ============================================================ */
#battle { background: #06141f; }
#bt-head {
  display: flex; align-items: center; gap: 18px; padding: 8px 16px; flex: 0 0 auto;
  background: rgba(4, 12, 20, .85); border-bottom: 1px solid var(--edge); z-index: 5;
}
#bt-title { font-family: var(--serif); font-weight: 700; color: var(--gold); font-size: 15px; letter-spacing: .06em; white-space: nowrap; }
.bt-stat { font-size: 13.5px; font-weight: 700; display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
#base-hp { color: #ff9f9f; }
#base-hp .icn { color: var(--red); }
#wave-info { color: var(--dim); }
.energy { display: flex; align-items: center; gap: 8px; flex: 1; max-width: 360px; }
.energy-bar {
  flex: 1; height: 14px; border-radius: 8px; overflow: hidden;
  background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .12);
}
#energy-fill {
  height: 100%; width: 0; border-radius: 8px;
  background: linear-gradient(90deg, #2dd4bf, #7af0dc);
  box-shadow: 0 0 12px rgba(45, 212, 191, .7);
  transition: width .15s linear;
}
.energy b { font-size: 17px; color: var(--teal); min-width: 22px; text-align: center; }
.bt-btns { display: flex; gap: 8px; margin-left: auto; }
.tbtn {
  min-width: 34px; height: 34px; border-radius: 9px; padding: 0 8px;
  background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .14);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800; transition: all .13s;
}
.tbtn:hover { background: rgba(255, 255, 255, .14); }
.tbtn.active { background: rgba(240, 199, 94, .22); border-color: var(--gold); color: var(--gold); }

#field-wrap { flex: 1; position: relative; min-height: 0; }
#field { display: block; width: 100%; height: 100%; cursor: crosshair; }

/* 药水架 */
#potions {
  position: absolute; right: 12px; top: 12px; display: flex; flex-direction: column; gap: 8px;
}
.potion {
  width: 44px; height: 44px; border-radius: 12px; color: var(--pc);
  background: rgba(8, 18, 28, .85); border: 2px solid var(--pc);
  box-shadow: 0 0 14px color-mix(in srgb, var(--pc) 50%, transparent);
  display: flex; align-items: center; justify-content: center;
  animation: potionPop .3s cubic-bezier(.2, 1.6, .5, 1);
  transition: transform .12s;
}
.potion:hover { transform: scale(1.12); }
@keyframes potionPop { from { transform: scale(.2); opacity: 0; } }

/* 手牌 */
#hand-bar {
  flex: 0 0 auto; padding: 8px 12px 11px;
  background: rgba(4, 12, 20, .9); border-top: 1px solid var(--edge);
}
#hand { display: flex; gap: 9px; justify-content: center; flex-wrap: nowrap; overflow-x: auto; }
.card {
  position: relative; flex: 0 0 86px; padding: 6px 4px 6px; border-radius: 12px; text-align: center;
  background: linear-gradient(180deg, #15374d, #0e2536);
  border: 2px solid rgba(125, 200, 235, .25);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  transition: transform .12s, border-color .12s, box-shadow .12s;
  overflow: hidden;
}
.card:hover { transform: translateY(-5px); }
.card.sel { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(240, 199, 94, .35), 0 0 20px rgba(240, 199, 94, .3); transform: translateY(-7px); }
.card.off { opacity: .55; filter: saturate(.45); }
.card canvas { width: 52px; height: 52px; pointer-events: none; }
.card-name { font-size: 11.5px; font-weight: 700; pointer-events: none; white-space: nowrap; }
.card-cost {
  position: absolute; top: 4px; left: 4px; width: 20px; height: 20px; border-radius: 50%;
  background: linear-gradient(180deg, #f3d27c, #cf9d2e); color: #2c2002;
  font-size: 12px; font-weight: 900; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .4); pointer-events: none;
}
.card-key {
  position: absolute; top: 4px; right: 5px; font-size: 10px; color: var(--dim);
  border: 1px solid rgba(255, 255, 255, .2); border-radius: 4px; padding: 0 4px; pointer-events: none;
}
.card-cd {
  position: absolute; left: 0; right: 0; bottom: 0; height: 0;
  background: rgba(8, 14, 24, .72); pointer-events: none;
  border-radius: 0 0 10px 10px;
}

/* P2 手牌 */
#hand2 {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  display: flex; flex-direction: column; gap: 6px; z-index: 4;
}
#hand2 .card { flex: 0 0 auto; width: 70px; padding: 4px 2px; border-color: rgba(248, 113, 113, .35); }
#hand2 .card canvas { width: 40px; height: 40px; }
#hand2 .card-name { font-size: 10px; }
#hand2 .card-key { color: #ffb09c; border-color: rgba(248, 113, 113, .5); }

/* ============================================================
   图鉴
   ============================================================ */
#codex-grid {
  flex: 1; overflow-y: auto; padding: 26px 36px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(225px, 1fr)); gap: 16px;
  align-content: start;
}
.codex-card {
  background: var(--panel); border: 1.5px solid var(--edge); border-radius: 16px;
  padding: 14px; display: flex; flex-direction: column; gap: 6px;
}
.codex-card.locked { opacity: .5; filter: grayscale(.8); }
.cx-top { display: flex; gap: 10px; align-items: center; }
.cx-top canvas { width: 78px; height: 78px; flex: 0 0 auto; background: rgba(255, 255, 255, .04); border-radius: 12px; }
.cx-sketch {
  width: 78px; height: 78px; object-fit: cover; border-radius: 10px;
  border: 2px solid #d9bd78; transform: rotate(2.5deg);
  box-shadow: 0 4px 12px rgba(0, 0, 0, .4);
}
.codex-card b { font-size: 16px; font-family: var(--serif); }
.cx-rar { font-size: 11px; font-style: normal; color: var(--gold); border: 1px solid rgba(240, 199, 94, .4); padding: 1px 7px; border-radius: 10px; margin-left: 5px; }
.cx-cost { font-size: 12px; color: var(--dim); }
.cx-cost .icn { color: var(--teal); }
.codex-card p { font-size: 12.5px; line-height: 1.6; color: #c2d4e2; }
.cx-origin { font-size: 11px; color: #b8a472; line-height: 1.5; border-top: 1px dashed rgba(217, 189, 120, .25); padding-top: 6px; }

/* ============================================================
   图鉴详情（原稿档案）
   ============================================================ */
.cx-more { font-size: 11px; color: var(--teal); opacity: .8; }
.codex-card:not(.locked) { cursor: pointer; transition: transform .14s, border-color .14s; }
.codex-card:not(.locked):hover { transform: translateY(-3px); border-color: var(--gold); }

#detail {
  position: fixed; inset: 0; z-index: 110;
  background: rgba(3, 8, 14, .8); backdrop-filter: blur(7px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  animation: fadeUp .22s ease;
}
#detail-card {
  position: relative; width: min(880px, 100%); max-height: 92vh; overflow-y: auto;
  background: linear-gradient(180deg, #12344a, #0a2334);
  border: 1px solid var(--edge); border-radius: 22px; padding: 26px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .6);
  animation: popIn .28s cubic-bezier(.2, 1.4, .5, 1);
}
.dt-close {
  position: absolute; top: 14px; right: 14px; width: 36px; height: 36px;
  border-radius: 10px; background: rgba(255, 255, 255, .07);
  border: 1px solid rgba(255, 255, 255, .15); font-size: 15px; z-index: 2;
}
.dt-grid { display: grid; grid-template-columns: 290px 1fr; gap: 22px; }
.dt-left { display: flex; flex-direction: column; gap: 10px; align-items: center; }
.dt-sketch {
  width: 100%; border-radius: 12px; transform: rotate(-1.6deg);
  border: 5px solid #f3ead2;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .55), 0 0 0 1px rgba(0, 0, 0, .3);
}
.dt-credit { font-size: 11.5px; color: #d9bd78; text-align: center; letter-spacing: .05em; }
.dt-head { display: flex; gap: 16px; align-items: center; margin-bottom: 6px; }
#dt-live {
  width: 132px; height: 132px; flex: 0 0 auto; border-radius: 16px;
  background: radial-gradient(circle at 50% 38%, #14405c, #0a2334 75%);
  border: 1px solid var(--edge);
}
.dt-head h3 { font-family: var(--serif); font-size: 24px; margin-bottom: 8px; }
.dt-stats { display: flex; flex-wrap: wrap; gap: 6px; }
.dt-stats span {
  font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 8px;
  background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .1);
}
.dt-stats i { font-style: normal; color: var(--dim); font-weight: 400; margin-right: 5px; }
.dt-desc { font-size: 13.5px; line-height: 1.7; color: #cfe0ec; margin: 8px 0 4px; }
.dt-section { font-size: 12px; letter-spacing: .2em; color: var(--gold); margin: 14px 0 8px; }
.dt-text {
  white-space: pre-wrap; font-family: var(--serif); font-size: 14px; line-height: 1.9;
  color: #3a3325; background: #f3ead2; border-radius: 10px; padding: 12px 16px;
  box-shadow: inset 0 0 18px rgba(120, 90, 30, .18); transform: rotate(.4deg);
}
.dt-map { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.dt-map td { padding: 7px 8px; border-bottom: 1px dashed rgba(255, 255, 255, .08); vertical-align: top; line-height: 1.55; }
.dt-map td:first-child { color: #ffd9a0; width: 42%; font-family: var(--serif); }
.dt-map td:last-child { color: #c2d4e2; }
@media (max-width: 760px) { .dt-grid { grid-template-columns: 1fr; } }

/* ============================================================
   结算
   ============================================================ */
#result {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(3, 8, 14, .78); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  animation: fadeUp .25s ease;
}
#result-card {
  width: min(560px, 100%); max-height: 90vh; overflow-y: auto;
  background: linear-gradient(180deg, #12344a, #0a2334);
  border: 1px solid var(--edge); border-radius: 22px; padding: 30px 34px;
  text-align: center; box-shadow: 0 24px 60px rgba(0, 0, 0, .6);
  animation: popIn .3s cubic-bezier(.2, 1.4, .5, 1);
}
@keyframes popIn { from { transform: translateY(26px) scale(.95); opacity: 0; } }
#result-card h2 { font-family: var(--serif); font-size: 34px; font-weight: 900; letter-spacing: .1em; margin-bottom: 10px; }
.r-win { color: var(--gold); filter: drop-shadow(0 0 18px rgba(240, 199, 94, .4)); }
.r-lose { color: #9fb4c8; }
.r-stars { display: flex; justify-content: center; gap: 10px; margin: 6px 0 10px; }
.r-stars i { color: rgba(255, 255, 255, .14); }
.r-stars i.on { color: var(--gold); filter: drop-shadow(0 0 10px rgba(240, 199, 94, .7)); animation: starPop .4s cubic-bezier(.2, 1.8, .5, 1) backwards; }
.r-stars i.on:nth-child(2) { animation-delay: .15s; }
.r-stars i.on:nth-child(3) { animation-delay: .3s; }
@keyframes starPop { from { transform: scale(0) rotate(-90deg); } }
.r-sub { color: var(--dim); font-size: 14px; margin-bottom: 14px; }
.r-unlock { margin: 12px 0 4px; padding: 14px; border-radius: 14px; background: rgba(240, 199, 94, .07); border: 1px solid rgba(240, 199, 94, .3); }
.r-unlock > span { font-size: 13px; color: var(--gold); letter-spacing: .25em; }
.r-cards { display: flex; gap: 14px; justify-content: center; margin-top: 10px; flex-wrap: wrap; }
.r-card { width: 150px; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.r-card canvas { width: 72px; height: 72px; background: rgba(255, 255, 255, .05); border-radius: 14px; animation: bobble 2.6s ease-in-out infinite; }
.r-card b { font-size: 14px; }
.r-card small { font-size: 10.5px; color: var(--dim); line-height: 1.45; }
.r-btns { display: flex; gap: 12px; justify-content: center; margin-top: 18px; flex-wrap: wrap; }

/* ============================================================
   联机大厅
   ============================================================ */
.lobby-body { flex: 1; overflow-y: auto; padding: 36px; display: flex; flex-direction: column; align-items: center; gap: 20px; }
#lobby-main { width: min(860px, 100%); }
.lobby-hint { color: var(--dim); font-size: 13.5px; text-align: center; margin-bottom: 18px; }
.lobby-hint b { color: var(--teal); font-size: 16px; letter-spacing: .03em; }
.lobby-row { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.lobby-card {
  background: var(--panel); border: 1.5px solid var(--edge); border-radius: 18px;
  padding: 24px; display: flex; flex-direction: column; gap: 12px; align-items: flex-start;
}
.lobby-card h3 { font-family: var(--serif); font-size: 19px; color: var(--gold); }
.lobby-card p { font-size: 13px; color: var(--dim); line-height: 1.7; }
.lobby-card pre {
  background: rgba(0, 0, 0, .4); border: 1px solid var(--edge); border-radius: 10px;
  padding: 10px 16px; font-size: 14px; color: #9ef5e4; width: 100%;
}
.lobby-code-label { font-size: 12px; color: var(--dim); letter-spacing: .3em; }
.lobby-code {
  font-family: var(--serif); font-size: 56px; font-weight: 900; letter-spacing: .25em; text-indent: .25em;
  color: var(--gold); text-shadow: 0 0 24px rgba(240, 199, 94, .45);
  animation: bobble 2.4s ease-in-out infinite;
}
#host-wait { width: 100%; text-align: center; display: flex; flex-direction: column; gap: 6px; align-items: center; }
#join-code {
  width: 100%; padding: 12px; font-size: 30px; text-align: center; letter-spacing: .4em; text-indent: .4em;
  font-family: var(--serif); font-weight: 900; color: var(--ink);
  background: rgba(0, 0, 0, .35); border: 1.5px solid var(--edge); border-radius: 12px; outline: none;
}
#join-code:focus { border-color: var(--teal); box-shadow: 0 0 14px rgba(45, 212, 191, .25); }
.lobby-err { color: var(--red); font-size: 13px; min-height: 18px; }
.qr-box {
  background: #fff; padding: 6px; border-radius: 14px; margin: 6px auto;
  box-shadow: 0 6px 22px rgba(0, 0, 0, .45), 0 0 0 3px rgba(240, 199, 94, .5);
  line-height: 0;
}
#qr-canvas { width: 188px; height: 188px; image-rendering: pixelated; border-radius: 8px; }
#qr-hint small, .lobby-hint small { color: rgba(143, 168, 189, .7); }

/* 触屏优化（平板） */
body { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
@media (pointer: coarse) {
  .card { flex-basis: 100px; }
  .card canvas { width: 60px; height: 60px; }
  .card-name { font-size: 13px; }
  .tbtn { min-width: 44px; height: 44px; }
}

/* ============================================================
   纸面主题「作业本上的战争」—— 整体换肤
   ============================================================ */
:root {
  --bg-0: #e9dec0;
  --bg-1: #f4eeda;
  --panel: #fbf7ec;
  --edge: rgba(140, 110, 60, .35);
  --ink: #3a2f1c;
  --dim: #8a795c;
  --gold: #b8821a;
  --teal: #1d8a7a;
  --red: #c0392b;
}
body {
  background:
    repeating-linear-gradient(0deg, transparent 0 31px, rgba(90, 125, 180, .14) 31px 32px),
    radial-gradient(1100px 600px at 70% -10%, rgba(255, 250, 230, .9), transparent 60%),
    linear-gradient(160deg, #f4eeda, #e9dec0);
  color: var(--ink);
}
.btn {
  background: linear-gradient(180deg, #fffdf4, #f0e8d2);
  border: 1.5px solid rgba(140, 110, 60, .45);
  color: #4a3b22;
  box-shadow: 0 3px 0 rgba(140, 110, 60, .35), 0 6px 14px rgba(120, 90, 40, .18);
}
.btn:active:not(:disabled) { box-shadow: 0 1px 0 rgba(140, 110, 60, .35); transform: translateY(2px); }
.btn-gold {
  background: linear-gradient(180deg, #ffe082, #f4c542);
  border-color: #a8821a; color: #4a3505;
  box-shadow: 0 3px 0 #a8821a, 0 8px 18px rgba(190, 140, 30, .3);
}
.btn-ghost { background: rgba(255, 255, 255, .5); border-color: rgba(140, 110, 60, .3); }

/* 标题：蜡笔字 */
.game-title {
  background: none; color: #1d8a7a; -webkit-text-fill-color: currentColor;
  text-shadow: 3px 3px 0 rgba(240, 170, 60, .55), 6px 6px 0 rgba(192, 57, 43, .25);
  filter: none;
  transform: rotate(-1.2deg);
}
.game-sub { color: #8a795c; }
.parade-card {
  background: #fffdf4;
  border: 1.5px solid rgba(140, 110, 60, .35);
  box-shadow: 0 5px 0 rgba(140, 110, 60, .25), 0 10px 20px rgba(120, 90, 40, .2);
}
.parade-card:nth-child(odd) { transform: rotate(-2deg); }
.parade-card:nth-child(even) { transform: rotate(1.6deg); }
.menu-stats, .menu-foot { color: #8a795c; }

/* 子页头 */
.sub-head { background: rgba(251, 247, 236, .85); border-bottom: 2px dashed rgba(140, 110, 60, .35); }
.sub-head h2 { color: #8a3324; }

/* 选关：便签卡 */
.level-node { background: var(--panel); border: 1.5px solid var(--edge); box-shadow: 0 4px 0 rgba(140, 110, 60, .2), 0 10px 18px rgba(120, 90, 40, .15); }
.level-node:nth-child(odd) { transform: rotate(-.8deg); }
.level-node:nth-child(even) { transform: rotate(.7deg); }
.level-node:hover:not(.locked) { transform: translateY(-4px) rotate(0); border-color: var(--teal); box-shadow: 0 8px 0 rgba(140, 110, 60, .15), 0 16px 26px rgba(120, 90, 40, .25); }
.ln-num { background: #fffdf4; border-color: var(--edge); color: var(--teal); }
.bossnode .ln-num { color: var(--red); }
.ln-stars i { color: rgba(140, 110, 60, .25); }

/* 卡组/图鉴卡 */
.deck-card, .codex-card { background: var(--panel); border-color: var(--edge); box-shadow: 0 3px 0 rgba(140, 110, 60, .18), 0 8px 14px rgba(120, 90, 40, .12); }
.deck-card.sel { border-color: #b8821a; background: #fff6d8; box-shadow: 0 3px 0 #b8821a, 0 0 0 3px rgba(244, 197, 66, .35); }
.codex-card p { color: #5d4d32; }
.cx-cost { color: #8a795c; }
.cx-sketch { border-color: #e8d9b0; }

/* 战斗 HUD：牛皮纸条 */
#battle { background: #efe6cc; }
#bt-head {
  background: linear-gradient(180deg, #e8d9b4, #ddcb9e);
  border-bottom: 2px solid rgba(140, 110, 60, .4);
}
#bt-title { color: #8a3324; }
#base-hp { color: #c0392b; }
#wave-info { color: #6a5a3c; }
.energy-bar { background: rgba(255, 255, 255, .55); border-color: rgba(140, 110, 60, .4); }
#energy-fill { background: linear-gradient(90deg, #1d8a7a, #35b89f); box-shadow: none; }
.energy b { color: #15806e; }
.tbtn { background: rgba(255, 255, 255, .6); border-color: rgba(140, 110, 60, .4); color: #5a4a30; }
.tbtn.active { background: #ffe082; border-color: #a8821a; color: #6a4d08; }

/* 手牌：白贴纸 */
#hand-bar { background: linear-gradient(180deg, #e2d3ab, #d8c898); border-top: 2px solid rgba(140, 110, 60, .4); }
.card {
  background: #fffdf4;
  border: 1.5px solid rgba(140, 110, 60, .4);
  box-shadow: 0 3px 0 rgba(140, 110, 60, .3), 0 7px 12px rgba(120, 90, 40, .2);
  transition: transform .14s cubic-bezier(.2, 1.4, .5, 1), box-shadow .14s, border-color .14s;
}
.card:nth-child(odd) { transform: rotate(-1deg); }
.card:nth-child(even) { transform: rotate(.8deg); }
.card:hover { transform: translateY(-7px) rotate(0) scale(1.04); }
.card.sel {
  border-color: #b8821a;
  box-shadow: 0 3px 0 #b8821a, 0 0 0 3px rgba(244, 197, 66, .45), 0 12px 20px rgba(120, 90, 40, .3);
  transform: translateY(-9px) rotate(0) scale(1.05);
}
.card-name { color: #4a3b22; }
.card-cost { background: linear-gradient(180deg, #ffe082, #f4c542); color: #4a3505; box-shadow: 0 1.5px 0 #a8821a; }
.card-key { color: #8a795c; border-color: rgba(140, 110, 60, .4); }
.card-cd { background: rgba(120, 95, 50, .45); }
#hand2 .card { border-color: rgba(192, 57, 43, .45); }

/* 药水架 */
.potion { background: #fffdf4; box-shadow: 0 3px 0 rgba(140, 110, 60, .3), 0 0 12px color-mix(in srgb, var(--pc) 35%, transparent); }

/* 弹窗：纸卡 */
#result, #detail { background: rgba(90, 70, 40, .35); }
#result-card, #detail-card {
  background: #fbf7ec;
  border: 1.5px solid var(--edge);
  box-shadow: 0 6px 0 rgba(140, 110, 60, .25), 0 26px 50px rgba(90, 65, 30, .35);
}
.r-win { color: #b8821a; filter: none; text-shadow: 2px 2px 0 rgba(192, 57, 43, .25); }
.r-lose { color: #8a795c; }
.r-sub { color: #8a795c; }
.r-unlock { background: #fff6d8; border-color: rgba(184, 130, 26, .45); }
.r-card canvas { background: rgba(255, 255, 255, .6); }
.dt-stats span { background: rgba(255, 255, 255, .65); border-color: rgba(140, 110, 60, .3); }
.dt-desc { color: #5d4d32; }
.dt-map td:first-child { color: #8a3324; }
.dt-map td:last-child { color: #5d4d32; }
.dt-section { color: #b8821a; }
#dt-live { background: #f4eeda; border-color: var(--edge); }
.dt-close { background: rgba(255, 255, 255, .7); border-color: var(--edge); color: #5a4a30; }

/* 联机大厅 */
.lobby-card { box-shadow: 0 4px 0 rgba(140, 110, 60, .2), 0 12px 22px rgba(120, 90, 40, .15); }
.lobby-card h3 { color: #8a3324; }
.lobby-card pre { background: #f0e8d2; color: #15806e; border-color: var(--edge); }
.lobby-hint b { color: #15806e; }
.lobby-code { color: #b8821a; text-shadow: 2px 2px 0 rgba(192, 57, 43, .2); }
#join-code { background: #fffdf4; color: #4a3b22; border-color: var(--edge); }
#join-code:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(29, 138, 122, .2); }
.qr-box { box-shadow: 0 4px 0 rgba(140, 110, 60, .3), 0 10px 22px rgba(120, 90, 40, .25), 0 0 0 3px rgba(244, 197, 66, .5); }

/* UI 动效：能量条流动 + 按钮按压已含；卡牌入场 */
@keyframes cardIn { from { transform: translateY(26px) rotate(3deg); opacity: 0; } }
#hand .card { animation: cardIn .35s cubic-bezier(.2, 1.4, .5, 1) backwards; }
#hand .card:nth-child(2) { animation-delay: .04s; } #hand .card:nth-child(3) { animation-delay: .08s; }
#hand .card:nth-child(4) { animation-delay: .12s; } #hand .card:nth-child(5) { animation-delay: .16s; }
#hand .card:nth-child(6) { animation-delay: .2s; } #hand .card:nth-child(7) { animation-delay: .24s; }
#energy-fill {
  background: repeating-linear-gradient(45deg, #1d8a7a 0 10px, #27a08c 10px 20px);
  background-size: 28px 100%;
  animation: energyFlow 1.2s linear infinite;
}
@keyframes energyFlow { from { background-position: 0 0; } to { background-position: 28px 0; } }

/* ============================================================
   响应式
   ============================================================ */
@media (max-width: 900px) {
  .menu-btns .big { padding: 12px 20px; font-size: 15px; }
  #bt-head { flex-wrap: wrap; gap: 8px 14px; }
  .energy { max-width: none; order: 5; flex-basis: 100%; }
  #level-grid, #deck-grid, #codex-grid { padding: 18px; }
  .card { flex-basis: 74px; }
  .card canvas { width: 44px; height: 44px; }
}
