* { 
  margin: 0; 
  padding: 0; 
  box-sizing: border-box; 
  user-select: none; 
  -webkit-user-select: none; 
}

body {
  background: #070b0e;
  color: #fff;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", sans-serif;
  height: 100vh;
  height: 100dvh;
  width: 100vw;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  touch-action: manipulation;
}

#app-container {
  position: relative;
  width: 100%;
  max-width: 760px;
  height: 100%;
  max-height: 900px;
  background: #122418;
  display: flex;
  flex-direction: column;
  box-shadow: 0 12px 40px rgba(0,0,0,0.85);
  overflow: hidden;
}

/* ==========================================================================
   顶部导航与状态栏 (双行自适应设计，彻底解决手机窄屏溢出)
   ========================================================================== */
.top-bar {
  display: flex;
  flex-direction: column;
  background: rgba(0, 0, 0, 0.65);
  border-bottom: 1px solid rgba(255,255,255,0.12);
  z-index: 20;
  flex-shrink: 0;
  padding: 6px 8px;
  gap: 6px;
}

/* 第 1 行：导航、周赛、改名与设置 */
.top-nav-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  gap: 4px;
}

.bar-left, .bar-right { 
  display: flex; 
  gap: 4px; 
  align-items: center; 
}

.icon-btn {
  width: 30px; 
  height: 30px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.25);
  background: rgba(255,255,255,0.1);
  color: #fff;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  transition: transform 0.1s ease;
  flex-shrink: 0;
}
.icon-btn:active { 
  transform: scale(0.92); 
}

/* 周赛胶囊 */
.weekly-prominent-btn {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 3px !important;
  background: linear-gradient(135deg, #ffd600, #ff9100) !important;
  border: 1.5px solid #fff !important;
  border-radius: 14px !important;
  padding: 2px 8px !important;
  color: #1a1100 !important;
  font-size: 11px !important;
  font-weight: 900 !important;
  cursor: pointer !important;
  box-shadow: 0 0 10px rgba(255, 214, 0, 0.5) !important;
  transition: transform 0.1s ease !important;
  height: 28px !important;
  flex-shrink: 0 !important;
  white-space: nowrap !important;
}
.weekly-prominent-btn:active { 
  transform: scale(0.94); 
}
.weekly-prominent-btn .icon { 
  font-size: 12px; 
}

/* 玩家昵称胶囊 */
.player-name-capsule {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 14px;
  padding: 3px 6px;
  font-size: 10.5px;
  color: #cfd8dc;
  cursor: pointer;
  max-width: 95px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 1;
}
.player-name-capsule:hover {
  border-color: #69f0ae;
  color: #fff;
  background: rgba(105, 240, 174, 0.1);
}

.lang-select {
  background: rgba(0, 0, 0, 0.6);
  color: #ffd600;
  border: 1px solid #ffd600;
  border-radius: 12px;
  padding: 2px 4px;
  font-size: 11px;
  font-weight: 800;
  outline: none;
  cursor: pointer;
  height: 28px;
  flex-shrink: 0;
}
.speed-btn {
  padding: 2px 7px;
  border-radius: 12px;
  border: 1px solid #ffd600;
  background: rgba(255, 214, 0, 0.15);
  color: #ffd600;
  font-weight: 800;
  cursor: pointer;
  font-size: 11px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* 第 2 行：比赛状态数据行 (居中整洁展示) */
.top-hud-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  width: 100%;
}
.stat-pill {
  background: rgba(0,0,0,0.55);
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11.5px;
  border: 1px solid rgba(255,255,255,0.14);
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.stat-pill strong { 
  color: #ffd600; 
  font-weight: 800;
}

/* ==========================================================================
   球场战场容器
   ========================================================================== */
#stage-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 6px;
  gap: 6px;
  overflow: hidden;
  box-sizing: border-box;
}
#canvas-box {
  position: relative;
  aspect-ratio: 12 / 7;
  width: 100%;
  max-width: 720px;
  max-height: 100%;
  background: #1e5a2c;
  border: 2px solid rgba(255,255,255,0.2);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  margin: auto 0;
}
canvas { 
  width: 100%; 
  height: 100%; 
  display: block; 
  cursor: pointer; 
}

/* 建塔/升级弹出菜单 */
.tile-menu {
  position: absolute;
  background: rgba(12, 20, 16, 0.98);
  border: 1.5px solid #69f0ae;
  border-radius: 12px;
  padding: 6px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  z-index: 30;
  box-shadow: 0 8px 24px rgba(0,0,0,0.85);
  max-width: 240px;
  max-height: calc(100% - 12px);
  overflow-y: auto;
  pointer-events: auto;
}
.tower-opt {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 8px;
  padding: 5px 3px;
  color: #fff;
  font-size: 11px;
  text-align: center;
  cursor: pointer;
  width: 68px;
  flex-shrink: 0;
  box-sizing: border-box;
  transition: all 0.15s ease;
}
.tower-opt .price { 
  color: #ffd600; 
  font-weight: bold; 
  display: block; 
  margin-top: 2px; 
}

.tower-opt.disabled {
  background: rgba(30, 36, 32, 0.7) !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
  color: #78909c !important;
  opacity: 0.42 !important;
  cursor: not-allowed !important;
}
.tower-opt.disabled .price { 
  color: #8d7b32 !important; 
}
.tower-opt.affordable {
  background: linear-gradient(135deg, rgba(0, 230, 118, 0.26), rgba(0, 176, 255, 0.2)) !important;
  border: 1.5px solid #00e676 !important;
  color: #ffffff !important;
  opacity: 1 !important;
  cursor: pointer !important;
  box-shadow: 0 0 12px rgba(0, 230, 118, 0.45) !important;
}
.tower-opt.affordable .price {
  color: #ffd600 !important;
  font-weight: 900 !important;
  text-shadow: 0 0 6px rgba(255, 214, 0, 0.5) !important;
}

/* 底部战术提示栏 */
.tactical-bar {
  width: 100%;
  max-width: 720px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(0,0,0,0.4);
  padding: 5px 10px;
  border-radius: 10px;
  font-size: 11.5px;
  color: #cfd8dc;
  gap: 8px;
  flex-shrink: 0;
}
.panic-btn {
  background: linear-gradient(135deg, #ff9100, #ff3d00);
  border: none;
  color: #fff;
  padding: 5px 10px;
  border-radius: 14px;
  font-size: 11px;
  font-weight: bold;
  cursor: pointer;
  white-space: nowrap;
}

/* 弹窗遮罩通用 */
.overlay {
  position: absolute;
  inset: 0;
  background: rgba(6, 12, 10, 0.94);
  backdrop-filter: blur(5px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 12px;
  z-index: 40;
}
.hidden { 
  display: none !important; 
}
.modal-card {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 18px;
  padding: 14px 16px;
  width: 100%;
  max-width: 480px;
  text-align: center;
}
.subtitle { 
  font-size: 11.5px; 
  color: #90a4ae; 
  margin: 3px 0 10px 0; 
}

/* 关卡弹窗内的周赛直达横幅大卡 */
.weekly-banner-card {
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
  background: linear-gradient(135deg, #183d25 0%, #0d2215 100%) !important;
  border: 1.5px solid #ffd600 !important;
  border-radius: 14px !important;
  padding: 8px 12px !important;
  margin-bottom: 10px !important;
  text-align: left !important;
  box-shadow: 0 4px 16px rgba(255, 214, 0, 0.25) !important;
  cursor: pointer !important;
  transition: transform 0.15s ease, border-color 0.15s ease !important;
}
.weekly-banner-card:hover {
  border-color: #69f0ae !important;
  transform: translateY(-1px) !important;
}
.weekly-banner-card:active { 
  transform: scale(0.98) !important; 
}
.w-banner-left {
  display: flex !important;
  flex-direction: column !important;
  align-items: flex-start !important;
  gap: 2px !important;
}
.w-badge {
  font-size: 9px !important;
  font-weight: 900 !important;
  color: #1a1100 !important;
  background: #ffd600 !important;
  border-radius: 4px !important;
  padding: 1px 5px !important;
  display: inline-block !important;
}
.w-banner-left strong { 
  font-size: 13px !important; 
  color: #ffffff !important; 
  font-weight: 800 !important; 
}
.w-desc { 
  font-size: 10.5px !important; 
  color: #a5d6a7 !important; 
}

.btn-banner-go {
  background: linear-gradient(135deg, #ffd600, #ff9100) !important;
  border: none !important;
  color: #1a1100 !important;
  font-weight: 900 !important;
  font-size: 11.5px !important;
  padding: 6px 12px !important;
  border-radius: 16px !important;
  cursor: pointer !important;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4) !important;
  white-space: nowrap !important;
  flex-shrink: 0 !important;
  margin-left: 8px !important;
}

/* 玩法说明手册 */
.guide-card {
  max-width: 520px;
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  padding: 12px 14px;
}
.guide-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
  max-height: 58vh;
  padding-right: 4px;
  margin: 4px 0 8px 0;
  text-align: left;
  -webkit-overflow-scrolling: touch;
}
.guide-item {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 6px 8px;
  gap: 8px;
}
.guide-icon-box {
  font-size: 22px;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 8px;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.guide-info { 
  flex: 1; 
  font-size: 10.5px; 
  color: #cfd8dc; 
  line-height: 1.35; 
}
.guide-info h4 { 
  font-size: 12.5px; 
  color: #ffd600; 
  margin-bottom: 2px; 
  display: flex; 
  justify-content: space-between; 
  align-items: center; 
}
.guide-tag { 
  font-size: 9.5px; 
  padding: 1px 6px; 
  border-radius: 10px; 
  background: rgba(255, 255, 255, 0.15); 
  color: #fff; 
  font-weight: normal; 
}

/* 周赛参赛记录卡与 7 天打卡轨道 */
.weekly-card {
  max-width: 500px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  padding: 12px 14px;
}
.weekly-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  text-align: left;
  border-bottom: 1px solid rgba(255,255,255,0.12);
  padding-bottom: 6px;
}
.weekly-header h2 { 
  font-size: 15px; 
  font-weight: 900; 
  color: #ffd600; 
}
.weekly-tier-tag {
  display: inline-block;
  background: rgba(255, 214, 0, 0.15);
  border: 1px solid #ffd600;
  color: #ffd600;
  font-size: 10.5px;
  font-weight: 800;
  border-radius: 10px;
  padding: 2px 7px;
  margin-top: 3px;
}
.close-x-btn {
  background: none;
  border: none;
  color: #90a4ae;
  font-size: 17px;
  cursor: pointer;
  padding: 0 4px;
}
.close-x-btn:hover { 
  color: #fff; 
}

/* 7 天打卡日程轨道 */
.weekly-days-tracker {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin: 8px 0 6px 0;
  background: rgba(0, 0, 0, 0.35);
  padding: 6px 4px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.day-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 6px;
  padding: 4px 1px;
  position: relative;
  transition: all 0.15s ease;
  cursor: default;
}
.day-node .day-name {
  font-size: 9.5px;
  color: #90a4ae;
  margin-bottom: 1px;
  font-weight: 600;
}
.day-node .day-badge {
  font-size: 11px;
  margin: 1px 0;
}
.day-node .day-score {
  font-size: 9px;
  font-weight: 800;
  color: #cfd8dc;
}

.day-node.played {
  background: rgba(0, 230, 118, 0.12);
  border: 1px solid rgba(0, 230, 118, 0.4);
}
.day-node.played .day-score { 
  color: #69f0ae; 
}

.day-node.today {
  border: 1.5px solid #ffd600 !important;
  background: rgba(255, 214, 0, 0.15) !important;
  box-shadow: 0 0 8px rgba(255, 214, 0, 0.3);
}
.day-node.today .day-name { 
  color: #ffd600; 
  font-weight: 900; 
}

.day-node.missed {
  border: 1px dashed rgba(255, 145, 0, 0.6) !important;
  background: rgba(255, 145, 0, 0.1) !important;
  cursor: pointer !important;
}
.day-node.missed:hover {
  background: rgba(255, 145, 0, 0.22) !important;
  transform: translateY(-1px);
}
.day-node.missed .day-score {
  color: #ff9100 !important;
  font-weight: 900 !important;
}

.day-node.future {
  opacity: 0.45;
}

.weekly-my-card {
  display: flex;
  justify-content: space-between;
  background: rgba(0, 0, 0, 0.45);
  border: 1.5px solid rgba(255, 214, 0, 0.35);
  border-radius: 10px;
  padding: 6px 12px;
  margin-bottom: 6px;
}
.my-stat-box { 
  display: flex; 
  flex-direction: column; 
  align-items: center; 
}
.my-stat-box .lbl { 
  font-size: 9.5px; 
  color: #90a4ae; 
  margin-bottom: 2px; 
}
.my-stat-box strong { 
  font-size: 15px; 
  color: #ffd600; 
  font-weight: 900; 
}

.weekly-action-bar { 
  display: flex; 
  gap: 6px; 
  margin-bottom: 6px; 
}

.weekly-table-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.table-legend {
  display: flex;
  justify-content: space-between;
  font-size: 9.5px;
  color: #b0bec5;
  padding: 3px 6px;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 6px;
  margin-bottom: 4px;
}
.weekly-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 10.5px;
  text-align: left;
}
.weekly-table thead th {
  padding: 4px 6px;
  color: #90a4ae;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  font-weight: 700;
}
.weekly-table thead th:last-child, .weekly-table tbody td:last-child { 
  text-align: right; 
}
.weekly-table tbody {
  display: block;
  overflow-y: auto;
  max-height: 28vh;
  -webkit-overflow-scrolling: touch;
}
.weekly-table thead, .weekly-table tbody tr {
  display: table;
  width: 100%;
  table-layout: fixed;
}
.weekly-table tbody tr { 
  border-bottom: 1px solid rgba(255,255,255,0.05); 
}
.weekly-table tbody td { 
  padding: 5px 6px; 
}

.tr-promote { 
  background: rgba(0, 230, 118, 0.08); 
  border-left: 3px solid #00e676; 
}
.tr-safe { 
  background: transparent; 
}
.tr-relegate { 
  background: rgba(255, 82, 82, 0.08); 
  border-left: 3px solid #ff5252; 
}
.tr-me {
  background: rgba(255, 214, 0, 0.2) !important;
  font-weight: 900;
  border: 1.5px solid #ffd600;
  box-shadow: 0 0 8px rgba(255, 214, 0, 0.25);
}

/* 章节选项卡 Tabs */
.chapter-tabs {
  display: flex;
  justify-content: center;
  gap: 5px;
  margin: 5px 0;
  width: 100%;
}
.ch-tab {
  flex: 1;
  padding: 6px 3px;
  border-radius: 8px;
  border: 1.5px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.06);
  color: #cfd8dc;
  font-size: 10.5px;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.15s ease;
}
.ch-tab.active {
  border-color: #ffd600;
  background: rgba(255, 214, 0, 0.2);
  color: #ffd600;
}

/* 选关卡片 */
.level-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.lvl-btn {
  position: relative;
  background: rgba(255,255,255,0.08);
  border: 1.5px solid rgba(255,255,255,0.2);
  border-radius: 10px;
  padding: 6px 2px;
  color: #fff;
  cursor: pointer;
  transition: all 0.15s;
}
.lvl-btn:active { 
  transform: scale(0.95); 
}
.lvl-btn .num { 
  font-size: 15px; 
  font-weight: 900; 
  color: #69f0ae; 
}
.lvl-btn .name { 
  font-size: 10px; 
  color: #cfd8dc; 
  margin-top: 2px; 
  display: block; 
  white-space: nowrap; 
  overflow: hidden; 
  text-overflow: ellipsis; 
}
.lvl-btn.locked {
  opacity: 0.42;
  filter: grayscale(0.85);
  cursor: not-allowed;
  border-color: rgba(255,255,255,0.1);
}
.lvl-btn.perfect {
  border: 1.5px solid #ffd600;
  box-shadow: 0 0 12px rgba(255, 214, 0, 0.45);
  background: rgba(255, 214, 0, 0.08);
}
.lvl-btn .badges {
  margin-top: 3px;
  font-size: 11px;
  display: flex;
  justify-content: center;
  gap: 3px;
}
.badge-dim { 
  opacity: 0.22; 
  filter: grayscale(1); 
}

.btn-group { 
  display: flex; 
  flex-direction: column; 
  gap: 6px; 
  align-items: center; 
  margin-top: 12px; 
}
.btn {
  width: 100%; 
  max-width: 250px; 
  padding: 10px;
  border-radius: 22px; 
  border: none; 
  font-weight: 800; 
  font-size: 12.5px; 
  cursor: pointer; 
  color: #fff;
}
.btn-primary { 
  background: linear-gradient(135deg, #00e676, #00b0ff); 
  color: #000; 
}
.btn-ad { 
  background: linear-gradient(135deg, #ff9100, #ff3d00); 
}
.btn-sub { 
  background: rgba(255,255,255,0.15); 
}

.btn.btn-disabled {
  background: rgba(255, 255, 255, 0.08) !important;
  color: #78909c !important;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
  cursor: not-allowed !important;
  box-shadow: none !important;
}

/* 广告槽位 */
.ad-top-indicator {
  width: 300px; 
  display: flex; 
  justify-content: space-between;
  background: rgba(255,255,255,0.1); 
  padding: 4px 10px; 
  border-radius: 12px;
  font-size: 10.5px; 
  color: #ffd600; 
  margin-bottom: 6px;
}
.banner-300x250-box {
  width: 300px; 
  height: 250px; 
  background: #0d131a;
  border: 1px solid rgba(255,255,255,0.2); 
  border-radius: 10px;
  display: flex; 
  justify-content: center; 
  align-items: center; 
  overflow: hidden; 
  margin-bottom: 10px;
}

/* 横屏紧凑响应式 */
@media (orientation: landscape) and (max-height: 520px) {
  #app-container { 
    max-width: 100vw; 
    max-height: 100vh; 
    border-radius: 0; 
    box-shadow: none; 
  }
  .top-bar { 
    padding: 2px 6px; 
    gap: 2px;
  }
  .top-nav-row {
    gap: 2px;
  }
  .icon-btn { 
    width: 24px; 
    height: 24px; 
    font-size: 11px; 
  }
  .weekly-prominent-btn {
    height: 24px !important;
    padding: 1px 6px !important;
    font-size: 10px !important;
  }
  .player-name-capsule {
    padding: 2px 5px;
    font-size: 9.5px;
    max-width: 80px;
  }
  .lang-select, .speed-btn { 
    height: 24px;
    padding: 1px 4px; 
    font-size: 9.5px; 
  }
  .top-hud-row {
    gap: 4px;
  }
  .stat-pill { 
    padding: 1px 6px; 
    font-size: 9.5px; 
  }
  #stage-wrap { 
    padding: 2px 4px; 
    gap: 2px; 
  }
  #canvas-box { 
    width: auto; 
    height: 100%; 
    max-width: 100%; 
    aspect-ratio: 12 / 7; 
  }
  .tactical-bar { 
    padding: 2px 6px; 
    font-size: 9.5px; 
  }
  .panic-btn { 
    padding: 2px 6px; 
    font-size: 9.5px; 
  }
  .modal-card { 
    padding: 6px 10px; 
    max-height: 96vh; 
    overflow-y: auto; 
  }
  .chapter-tabs { 
    gap: 3px; 
    margin: 2px 0; 
  }
  .ch-tab { 
    padding: 3px 2px; 
    font-size: 9.5px; 
  }
  .level-grid { 
    gap: 4px; 
  }
  .lvl-btn { 
    padding: 3px 1px; 
  }
  .lvl-btn .num { 
    font-size: 12px; 
  }
  .lvl-btn .name { 
    font-size: 8.5px; 
  }
  .btn-group { 
    margin-top: 4px; 
    gap: 4px; 
  }
  .btn { 
    padding: 5px 8px; 
    font-size: 10.5px; 
  }
  .weekly-card { 
    max-height: 98vh; 
    padding: 4px 8px; 
  }
  .weekly-days-tracker { 
    padding: 2px 2px; 
    margin: 2px 0; 
  }
  .day-node { 
    padding: 1px 1px; 
  }
  .weekly-my-card { 
    padding: 2px 6px; 
    margin-bottom: 2px; 
  }
  .weekly-table tbody { 
    max-height: 18vh; 
  }
  .weekly-banner-card { 
    padding: 4px 8px; 
    margin-bottom: 4px; 
  }
}