/* ============ 基础 ============ */
* { margin:0; padding:0; box-sizing:border-box; -webkit-tap-highlight-color:transparent; }
html, body { height:100%; overflow:hidden; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background:#7ec8e8; color:#3a2a18; user-select:none; -webkit-user-select:none;
}
.hidden { display:none !important; }

#app {
  display:flex; flex-direction:column; height:100%; height:100dvh;
  max-width:1200px; margin:0 auto;
}

/* ============ 顶部栏 ============ */
#topbar {
  display:flex; align-items:center; justify-content:space-between;
  gap:8px; padding:8px 12px; padding-top:calc(8px + env(safe-area-inset-top));
  background:linear-gradient(180deg, #6db9e0, #8fd4f8);
  border-bottom:3px solid #2e2119;
  z-index:5; flex-wrap:wrap;
}
.tb-left { display:flex; align-items:center; gap:8px; min-width:0; }
.avatar {
  width:42px; height:42px; border-radius:50%; flex:none;
  background:radial-gradient(circle at 35% 30%, #ffd54f, #f57c00);
  display:flex; align-items:center; justify-content:center; font-size:22px;
  border:2.5px solid #2e2119;
  box-shadow:0 2px 0 rgba(46,33,25,.45);
}
.lv-box { display:flex; flex-direction:column; gap:3px; }
.lv-row { display:flex; gap:10px; font-size:13px; font-weight:800; color:#2e2119; text-shadow:0 1px 0 rgba(255,255,255,.5); }
#powerText { color:#7a3a00; }
.exp-bar {
  width:110px; height:9px; background:#fdf3dc;
  border:2px solid #2e2119; border-radius:6px; overflow:hidden;
}
#expFill { height:100%; width:0%; background:linear-gradient(90deg,#66bb4a,#a6e22e); transition:width .3s; }
.tb-res { display:flex; gap:6px; flex-wrap:wrap; }
.res {
  display:flex; align-items:center; gap:4px;
  background:#fdf3dc; border:2px solid #2e2119;
  border-radius:20px; padding:3px 10px; font-size:13px; font-weight:800;
  box-shadow:0 2px 0 rgba(46,33,25,.45);
}
.res .ri { font-size:14px; }

/* ============ 主场景 ============ */
#stage { position:relative; flex:1; overflow:hidden; }
#game { display:block; width:100%; height:100%; touch-action:none; cursor:pointer; }

#eventBanner {
  position:absolute; top:14px; left:50%; transform:translateX(-50%);
  background:#fdf3dc; border:2.5px solid #2e2119; color:#3a2a18;
  border-radius:14px; padding:9px 18px; font-size:14px; font-weight:800;
  text-align:center; z-index:6; max-width:92%;
  box-shadow:0 3px 0 rgba(46,33,25,.5);
  animation:pop .25s ease;
}
#eventBanner.danger { background:#ffd9d0; border-color:#8a2a1a; color:#8a2a1a; }
#eventBanner.good { background:#dff3c8; border-color:#3f6b1f; color:#3f6b1f; }
@keyframes pop { from { transform:translateX(-50%) scale(.7); opacity:0; } }

#hint {
  position:absolute; bottom:14px; left:50%; transform:translateX(-50%);
  background:rgba(46,33,25,.82); color:#fdf3dc; border-radius:20px; padding:7px 16px;
  font-size:13px; font-weight:700; z-index:6; white-space:nowrap;
}

#floatTexts { position:absolute; inset:0; pointer-events:none; z-index:6; overflow:hidden; }
#fortBtn {
  position:absolute; top:12px; right:12px; z-index:7;
  background:#ffd54f; border:2.5px solid #2e2119; color:#3a2a18;
  border-radius:14px; padding:8px 14px; font-size:13px; font-weight:800;
  font-family:inherit; cursor:pointer;
  box-shadow:0 3px 0 rgba(46,33,25,.5);
  animation:pop .25s ease;
}
#fortBtn span { display:block; font-size:11px; }
#fortBtn:active { transform:translateY(2px); box-shadow:0 1px 0 rgba(46,33,25,.5); }
#crewTip {
  position:absolute; z-index:7; transform:translate(-50%,-100%);
  background:#fdf3dc; border:2px solid #2e2119; border-radius:12px;
  padding:6px 12px; font-size:12px; pointer-events:none;
  box-shadow:0 2px 0 rgba(46,33,25,.45);
  display:flex; flex-direction:column; align-items:center; white-space:nowrap;
  animation:pop .18s ease;
}
#crewTip b { font-size:13px; }
#crewTip span { color:#7a6248; font-weight:700; }
#crewTip::after {
  content:''; position:absolute; left:50%; bottom:-7px; transform:translateX(-50%);
  border-left:6px solid transparent; border-right:6px solid transparent;
  border-top:7px solid #2e2119;
}
.ftext {
  position:absolute; font-weight:800; font-size:15px;
  text-shadow:0 1px 0 #2e2119, 0 -1px 0 #2e2119, 1px 0 0 #2e2119, -1px 0 0 #2e2119;
  animation:floatUp 1.2s ease-out forwards;
}
@keyframes floatUp {
  0% { opacity:0; transform:translateY(6px) scale(.8); }
  15% { opacity:1; transform:translateY(0) scale(1.1); }
  100% { opacity:0; transform:translateY(-46px) scale(1); }
}

/* ============ 底部操作栏（木板条） ============ */
#actionbar {
  display:flex;
  background:
    repeating-linear-gradient(90deg, rgba(46,33,25,.18) 0 2px, transparent 2px 86px),
    linear-gradient(0deg, #a06c2f, #b8823e);
  border-top:3px solid #2e2119;
  padding:6px 6px; padding-bottom:calc(6px + env(safe-area-inset-bottom));
  z-index:5; gap:6px;
}
.abtn {
  flex:1; display:flex; flex-direction:column; align-items:center; gap:1px;
  background:#fdf3dc; border:2px solid #2e2119; color:#3a2a18;
  font-size:12px; font-weight:800;
  padding:6px 0 5px; border-radius:14px; cursor:pointer; position:relative;
  font-family:inherit;
  box-shadow:0 3px 0 rgba(46,33,25,.5);
  transition:transform .05s;
}
.abtn .ai { font-size:21px; }
.abtn:active { transform:translateY(2px); box-shadow:0 1px 0 rgba(46,33,25,.5); }
.abtn.active {
  background:#ffd54f;
  transform:translateY(2px); box-shadow:0 1px 0 rgba(46,33,25,.5);
}
.abtn .dot {
  position:absolute; top:3px; right:calc(50% - 20px);
  width:9px; height:9px; border-radius:50%; background:#ff5252;
  border:1.5px solid #2e2119;
}

/* ============ 弹出面板（纸板） ============ */
#panelMask {
  position:fixed; inset:0; background:rgba(20,40,60,.45); z-index:8;
}
#panel {
  position:fixed; left:50%; transform:translateX(-50%);
  bottom:0; width:100%; max-width:640px; max-height:72%;
  background:#fdf3dc;
  border:3px solid #2e2119; border-bottom:none;
  border-radius:20px 20px 0 0; z-index:9;
  display:flex; flex-direction:column;
  box-shadow:0 -4px 0 rgba(46,33,25,.3);
  animation:slideUp .22s ease;
}
@keyframes slideUp { from { transform:translate(-50%, 40px); opacity:0; } }
.panel-head {
  display:flex; align-items:center; justify-content:space-between;
  padding:13px 16px 9px; font-size:17px; font-weight:800;
  border-bottom:2.5px solid #2e2119;
}
#panelClose {
  background:#ff8a65; border:2px solid #2e2119; color:#3a2a18;
  width:30px; height:30px; border-radius:50%; font-size:14px; font-weight:800; cursor:pointer;
  box-shadow:0 2px 0 rgba(46,33,25,.5);
}
#panelClose:active { transform:translateY(1px); box-shadow:none; }
#panelBody { overflow-y:auto; padding:12px 14px; -webkit-overflow-scrolling:touch; }

/* 列表卡片（建造/英雄/任务通用） */
.card {
  display:flex; align-items:center; gap:12px;
  background:#fffaf0; border:2px solid #2e2119;
  border-radius:14px; padding:11px 12px; margin-bottom:10px;
  box-shadow:0 2px 0 rgba(46,33,25,.35);
}
.card .icon {
  width:46px; height:46px; flex:none; border-radius:12px; font-size:26px;
  background:#ffe9b8; border:2px solid #2e2119;
  display:flex; align-items:center; justify-content:center;
}
.card .info { flex:1; min-width:0; }
.card .name { font-size:15px; font-weight:800; }
.card .name .lv { color:#4e8a1f; font-size:12px; margin-left:6px; }
.card .desc { font-size:12px; color:#7a6248; margin-top:2px; line-height:1.45; }
.card .desc .buff { color:#c26f00; font-weight:700; }
.btn {
  flex:none; border:2px solid #2e2119; border-radius:12px; padding:8px 14px;
  font-size:13px; font-weight:800; cursor:pointer; font-family:inherit;
  background:linear-gradient(180deg,#4fc3f7,#1e9fe0); color:#fff;
  text-shadow:0 1px 0 rgba(46,33,25,.4);
  box-shadow:0 3px 0 rgba(46,33,25,.5);
}
.btn:active { transform:translateY(2px); box-shadow:0 1px 0 rgba(46,33,25,.5); }
.btn:disabled { background:#c9c2b4; color:#8a8070; cursor:not-allowed; box-shadow:none; text-shadow:none; }
.btn .cost { display:block; font-size:11px; font-weight:700; margin-top:1px; }
.btn.locked { background:#c9c2b4; color:#8a8070; text-shadow:none; }
.btn.gold { background:linear-gradient(180deg,#ffc233,#f58a00); }

/* 任务 */
.card.quest.done { opacity:.55; }
.card.quest .reward { color:#c26f00; font-size:12px; font-weight:700; }

/* 子页签 */
.subtabs { display:flex; gap:6px; margin-bottom:12px; }
.subtab {
  flex:1; border:2px solid #2e2119; background:#fffaf0;
  color:#7a6248; border-radius:12px; padding:7px 0; font-size:13px; font-weight:800;
  cursor:pointer; font-family:inherit;
  box-shadow:0 2px 0 rgba(46,33,25,.35);
}
.subtab.on { background:#ffd54f; color:#3a2a18; }

/* ============ 开局引导 ============ */
#intro {
  position:fixed; inset:0; z-index:20;
  background:linear-gradient(180deg, #8fd4f8 0%, #c9ecfd 30%, #6fd8e0 55%, #18a2c2 100%);
  display:flex; align-items:center; justify-content:center; padding:20px;
}
.intro-card {
  text-align:center; max-width:400px;
  background:rgba(253,243,220,.92);
  border:3px solid #2e2119; border-radius:24px;
  padding:28px 26px 30px;
  box-shadow:0 5px 0 rgba(46,33,25,.4);
  animation:pop .4s ease;
}
.intro-card h1 {
  font-size:38px; letter-spacing:4px; color:#ffd54f;
  text-shadow:
    -2.5px -2.5px 0 #2e2119, 2.5px -2.5px 0 #2e2119,
    -2.5px 2.5px 0 #2e2119, 2.5px 2.5px 0 #2e2119,
    0 5px 0 rgba(46,33,25,.35);
  margin-bottom:10px;
}
.intro-sub { color:#4e8a1f; margin-bottom:14px; font-weight:800; }
.intro-card p { line-height:2; color:#5e4a30; font-size:14px; font-weight:700; margin-bottom:22px; }
#startBtn {
  border:3px solid #2e2119; border-radius:30px; padding:13px 58px; font-size:18px; font-weight:800;
  background:linear-gradient(180deg,#ffc233,#f58a00); color:#fff; cursor:pointer;
  text-shadow:0 2px 0 rgba(46,33,25,.4);
  box-shadow:0 5px 0 #a35a00, 0 8px 20px rgba(245,138,0,.4);
  font-family:inherit; letter-spacing:6px;
}
#startBtn:active { transform:translateY(3px); box-shadow:0 2px 0 #a35a00; }

/* ============ 大屏适配 ============ */
@media (min-width: 900px) {
  #panel { bottom:auto; top:50%; left:auto; right:24px; transform:translateY(-50%);
    border-radius:20px; border-bottom:3px solid #2e2119;
    width:420px; max-height:80%; animation:none; }
  #actionbar { justify-content:center; gap:10px; }
  .abtn { flex:0 0 100px; }
  .intro-card h1 { font-size:52px; }
}
