/* CSS Reset - 移动端优先 Premium */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
  /* 视口高度修复（解决移动端地址栏问题） */
  height: 100%;
  height: -webkit-fill-available;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  line-height: 1.5;
  color: #1a1a2e;
  background: #e8eaed;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  min-height: 100vh;
  min-height: -webkit-fill-available;
  /* 防止 iOS 弹性滚动 */
  overscroll-behavior: none;
}

img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }

button {
  font: inherit; cursor: pointer; border: none; background: none;
  outline: none; -webkit-user-select: none; user-select: none;
}

input, select, textarea { font: inherit; outline: none; }
ul, ol { list-style: none; }
table { border-collapse: collapse; border-spacing: 0; }

.hidden {
  display: none !important;
}

/* ========== App Shell ========== */
/* 移动端：全屏宽度 / 桌面端：居中414px带两侧留白 */
#app {
  width: 100%;
  max-width: var(--app-max-width);
  margin: 0 auto;
  min-height: 100vh;
  min-height: -webkit-fill-available;
  background: var(--bg-page);
  position: relative;
  overflow-x: hidden;
  box-shadow: 0 0 40px rgba(0,0,0,0.08);
}

/* ========== Header ========== */
/* 固定在顶部，宽度跟随#app */
#header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  margin: 0 auto;
  max-width: var(--app-max-width);
  background: var(--green-gradient);
  color: white;
  z-index: 100;
  box-shadow: 0 2px 16px rgba(0,0,0,0.2);
  overflow: hidden;
  /* 安全区域适配 */
  padding-top: env(safe-area-inset-top, 0);
}

/* 信息栏容器 */
.info-bar {
  display: flex;
  flex-direction: column;
  padding: 10px var(--sp-4) 10px;
  gap: 8px;
}

/* 第一行：球队名 + 资金/通知 */
.info-bar-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.info-bar-team {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.info-bar-team-icon {
  font-size: 18px;
  flex-shrink: 0;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.2));
}

.info-bar-team-name {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  text-shadow: 0 1px 3px rgba(0,0,0,0.15);
  transition: opacity var(--duration-fast);
}

.info-bar-team-name:active { opacity: 0.7; }

.info-bar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* 资金 */
.info-bar-funds {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(255,255,255,0.15);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  backdrop-filter: blur(4px);
  cursor: default;
  transition: background 0.3s ease;
}
.info-bar-funds.negative {
  background: rgba(229, 62, 53, 0.25);
  animation: funds-negative-pulse 2s ease-in-out infinite;
}
@keyframes funds-negative-pulse {
  0%, 100% { background: rgba(229, 62, 53, 0.25); }
  50% { background: rgba(229, 62, 53, 0.4); }
}

.funds-icon { font-size: 13px; }
.funds-value { font-size: 13px; font-weight: 700; }
.info-bar-funds.negative .funds-value { color: #ffcdd2; }

/* 通知铃铛 */
.info-bar-notif {
  cursor: pointer;
  position: relative;
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: rgba(255,255,255,0.12);
  transition: background var(--duration-fast);
}

.info-bar-notif:active { background: rgba(255,255,255,0.25); }

.notif-icon { font-size: 16px; }

.notif-badge {
  position: absolute;
  top: 1px; right: 1px;
  min-width: 15px; height: 15px;
  background: #ff5252;
  color: white;
  font-size: 9px;
  font-weight: 700;
  border-radius: var(--radius-full);
  display: flex; align-items: center; justify-content: center;
  padding: 0 3px;
  border: 1.5px solid var(--green-dark);
  box-shadow: 0 1px 4px rgba(255,82,82,0.4);
}

/* 第二行：联赛 / 排名 / 赛季 */
.info-bar-detail {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.info-bar-league {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.league-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-xs);
  background: rgba(255,255,255,0.2);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--duration-fast);
  border: 1px solid rgba(255,255,255,0.15);
}

.league-badge:active { background: rgba(255,255,255,0.3); }

/* 联赛层级颜色 */
.league-badge.tier-city { background: rgba(107,114,128,0.3); border-color: rgba(107,114,128,0.2); }
.league-badge.tier-province { background: rgba(59,130,246,0.3); border-color: rgba(59,130,246,0.2); }
.league-badge.tier-division1 { background: rgba(168,85,247,0.3); border-color: rgba(168,85,247,0.2); }
.league-badge.tier-super { background: rgba(245,158,11,0.35); border-color: rgba(245,158,11,0.25); }

.league-round {
  font-size: 11px;
  opacity: 0.75;
  font-weight: 500;
  white-space: nowrap;
}

.info-bar-stats {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.info-bar-rank {
  display: flex;
  align-items: center;
  gap: 4px;
}

.rank-num {
  font-size: 13px;
  font-weight: 800;
  text-shadow: 0 1px 2px rgba(0,0,0,0.15);
}

.rank-pts {
  font-size: 11px;
  opacity: 0.85;
  font-weight: 600;
}

.info-bar-record {
  font-size: 10px;
  opacity: 0.7;
  font-weight: 500;
  letter-spacing: 0.2px;
  padding-left: 8px;
  border-left: 1px solid rgba(255,255,255,0.2);
}

.info-bar-season {
  font-size: 10px;
  opacity: 0.7;
  font-weight: 600;
  letter-spacing: 0.5px;
  padding-left: 8px;
  border-left: 1px solid rgba(255,255,255,0.2);
}

/* ========== Bottom Nav ========== */
#bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  margin: 0 auto;
  max-width: var(--app-max-width);
  height: var(--bottomnav-height);
  background: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 100;
  box-shadow: 0 -2px 12px rgba(0,0,0,0.06);
  border-top: 1px solid var(--gray-200);
  /* 安全区域适配（iPhone底部横条） */
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.nav-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 6px 0;
  cursor: pointer;
  position: relative;
  transition: all var(--duration-normal);
  -webkit-user-select: none;
  user-select: none;
}

.nav-tab::before {
  content: '';
  position: absolute;
  top: 0; left: 50%;
  transform: translateX(-50%) scaleX(0);
  width: 32px; height: 3px;
  border-radius: 0 0 3px 3px;
  background: var(--green-primary);
  transition: transform var(--duration-normal) var(--ease-bounce);
}

.nav-tab.active::before { transform: translateX(-50%) scaleX(1); }

.nav-icon { font-size: 20px; transition: transform var(--duration-normal) var(--ease-bounce); }
.nav-tab.active .nav-icon { transform: scale(1.15) translateY(-2px); }
.nav-label { font-size: 10px; font-weight: 500; color: var(--gray-500); transition: color var(--duration-normal); }
.nav-tab.active .nav-label { color: var(--green-primary); font-weight: 700; }
.nav-tab.has-event .nav-icon::after {
  content: '';
  position: absolute;
  top: -2px; right: 50%;
  width: 6px; height: 6px;
  background: #ff5252;
  border-radius: 50%;
}

/* ========== Page Container ========== */
#page-container {
  padding-top: var(--header-height);
  padding-bottom: var(--bottomnav-height);
  min-height: 100vh;
}

.page {
  display: none;
  padding: var(--sp-4);
  animation: pageEnter var(--duration-slow) var(--ease-spring);
  min-height: calc(100vh - var(--header-height) - var(--bottomnav-height));
}

.page.active { display: block; }

.page-content {
  max-width: 100%;
  overflow-x: hidden;
}

@keyframes pageEnter {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ========== 响应式多机型适配 ========== */

/* 小屏手机 (≤359px) - iPhone SE 1代/小米红米极小屏 */
@media (max-width: 359px) {
  :root {
    --header-height: 70px;
    --bottomnav-height: 56px;
    --sp-4: 12px;
    --sp-3: 10px;
  }
  .info-bar { padding: 8px 12px 8px; gap: 6px; }
  .info-bar-team-name { font-size: 14px; }
  .funds-value { font-size: 12px; }
  .league-badge { font-size: 10px; padding: 2px 6px; }
  .league-round { font-size: 10px; }
  .nav-icon { font-size: 18px; }
  .nav-label { font-size: 9px; }
}

/* 标准手机 (360-413px) - 主力机型区间 */
@media (min-width: 360px) and (max-width: 413px) {
  /* 默认样式已覆盖此区间，无需额外调整 */
}

/* 大屏手机 (414-479px) - iPhone Plus/Pro Max/安卓大屏 */
@media (min-width: 414px) {
  :root {
    --app-max-width: 100%;
  }
  #app {
    max-width: 480px;
    box-shadow: 0 0 60px rgba(0,0,0,0.1);
    border-radius: 0;
  }
  #header, #bottom-nav {
    max-width: 480px;
  }
}

/* 超大屏手机 (480px+) - 折叠屏/小平板竖屏 */
@media (min-width: 480px) {
  #app {
    max-width: 520px;
  }
  #header, #bottom-nav {
    max-width: 520px;
  }
  .info-bar { padding: 12px 20px 12px; gap: 10px; }
  .info-bar-team-name { font-size: 17px; }
}

/* 平板/桌面 (768px+) - iPad横屏/桌面浏览器 */
@media (min-width: 768px) {
  #app {
    max-width: 414px;
    border-radius: 24px;
    margin-top: 20px;
    margin-bottom: 20px;
    min-height: calc(100vh - 40px);
    box-shadow: 0 8px 60px rgba(0,0,0,0.15);
  }
  #header {
    max-width: 414px;
    border-radius: 24px 24px 0 0;
    /* 桌面端跟随#app的偏移 */
    top: 20px;
  }
  #bottom-nav {
    max-width: 414px;
    border-radius: 0 0 24px 24px;
  }
  body {
    background: #d4d7dc;
  }
}

/* 超小高度屏幕（横屏手机等） */
@media (max-height: 580px) {
  :root {
    --header-height: 64px;
    --bottomnav-height: 52px;
  }
  .info-bar { padding: 6px var(--sp-3) 6px; gap: 4px; }
  .info-bar-team-name { font-size: 14px; }
  .nav-icon { font-size: 18px; }
  .nav-label { font-size: 9px; }
}

/* iPhone X+ 刘海屏安全区域 */
@supports (padding-top: env(safe-area-inset-top)) {
  #header {
    padding-top: env(safe-area-inset-top);
  }
  #bottom-nav {
    padding-bottom: env(safe-area-inset-bottom);
  }
  #page-container {
    padding-top: calc(var(--header-height) + env(safe-area-inset-top));
  }
}

/* 暗色模式适配（跟随系统，仅微调不影响设计） */
@media (prefers-color-scheme: dark) {
  /* 暂不启用暗色模式，保持原版亮色设计 */
}

