/* ========== Time Beat Web · screens.css ========== */

/* ============ Splash ============ */
#screen-splash {
  background: #000;
  align-items: center;
  justify-content: center;
}

#screen-splash img {
  width: min(220px, 60vw);
  height: min(220px, 60vw);
  object-fit: contain;
}

/* ============ Home ============ */
#screen-home {
  padding: calc(var(--safe-top) + 8px) 24px calc(var(--safe-bottom) + 8px);
}

.home-spacer {
  flex: 1;
}

.home-title-block {
  text-align: center;
}

.home-title {
  font-size: 48px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 1px;
  line-height: 1.1;
}

.home-subtitle {
  margin-top: 10px;
  font-size: 16px;
  color: var(--text-secondary);
}

.home-best {
  text-align: center;
  padding: 24px 0;
}

.home-best .label {
  font-size: 14px;
  color: var(--text-secondary);
}

.home-best .value {
  margin-top: 8px;
  font-size: 36px;
  font-weight: 700;
  color: var(--text-primary);
}

.home-start-wrap {
  display: flex;
  justify-content: center;
}

.home-tabs {
  display: flex;
  justify-content: center;
  gap: 36px;
  padding-bottom: 40px;
}

.home-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  font-size: 11px;
}

.home-tab span {
  white-space: nowrap;
}

.home-tab .tab-icon {
  width: 24px;
  height: 24px;
}

.home-tab:active {
  opacity: 0.5;
}

/* ============ Game ============ */
#screen-game {
  background: var(--bg);
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

.game-close {
  position: absolute;
  top: calc(var(--safe-top) + 14px);
  left: 18px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
  transition: opacity 0.2s ease;
}

.game-close:active {
  background: rgba(255, 255, 255, 0.32);
}

.game-close.hidden {
  opacity: 0;
  visibility: hidden;
}

.game-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding-bottom: 10vh;
}

.game-target {
  font-size: 20px;
  color: var(--text-secondary);
}

.game-timer {
  font-size: clamp(92px, 30vw, 120px);
  font-weight: 700;
  line-height: 1.05;
  color: var(--text-primary);
  padding: 0 8px;
}

.game-timer.running {
  color: var(--primary);
}

.game-seconds {
  font-size: 16px;
  color: var(--text-secondary);
}

.game-instruction {
  margin-top: 34px;
  font-size: 18px;
  color: var(--text-secondary);
  text-align: center;
}

.game-instruction.running {
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
  animation: blink 0.5s ease-in-out infinite;
}

@keyframes blink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.3;
  }
}

/* 倒计时遮罩 */
.countdown-overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  opacity: 0;
  visibility: hidden;
}

.countdown-overlay.active {
  opacity: 1;
  visibility: visible;
}

.countdown-number {
  font-size: 200px;
  font-weight: 700;
  color: var(--primary);
  line-height: 1;
  will-change: transform, opacity;
}

/* ============ Result ============ */
#screen-result {
  padding: calc(var(--safe-top) + 24px) 24px calc(var(--safe-bottom) + 16px);
  align-items: center;
  text-align: center;
}

.result-grade {
  font-size: 48px;
  font-weight: 700;
  margin-top: 18px;
  transform-origin: center;
}

.result-feedback {
  margin-top: 10px;
  font-size: 16px;
  font-weight: 500;
}

.result-direction {
  margin-top: 20px;
}

.result-deviation {
  margin-top: 22px;
  font-size: 72px;
  font-weight: 700;
  line-height: 1.05;
}

.result-deviation-unit {
  font-size: 16px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.result-detail {
  margin-top: 24px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.result-detail .label {
  font-size: 20px;
  color: var(--text-secondary);
}

.result-detail .actual {
  font-size: 30px;
  font-weight: 500;
  color: var(--primary);
}

.result-detail .target {
  margin-top: 6px;
  font-size: 20px;
  color: var(--text-secondary);
}

.result-submit {
  margin-top: 26px;
  min-height: 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  justify-content: center;
}

.result-submit .status-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
}

.result-submit .status-line.success {
  color: var(--primary);
}

.result-submit .status-icon {
  width: 16px;
  height: 16px;
}

.result-retry-wrap {
  margin-top: 22px;
  display: flex;
  justify-content: center;
}

.result-bottom {
  margin-top: auto;
  padding-top: 20px;
  padding-bottom: 26px;
  display: flex;
  gap: 40px;
}

.result-bottom .bottom-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  color: var(--text-secondary);
  font-size: 12px;
}

.result-bottom .bottom-icon {
  width: 24px;
  height: 24px;
}

.result-bottom .bottom-btn:active {
  opacity: 0.5;
}

/* ============ 排行榜 / 我的成绩 ============ */
.record-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  -webkit-overflow-scrolling: touch;
}

.record-row {
  background: var(--secondary);
  border-radius: 12px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.record-rank {
  width: 40px;
  flex-shrink: 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-secondary);
  text-align: left;
}

.record-rank.top3 {
  color: var(--perfect);
}

.record-mid {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.record-name-line {
  display: flex;
  align-items: center;
  gap: 6px;
}

.record-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.country-tag {
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 600;
  color: var(--primary);
  background: rgba(11, 255, 179, 0.15);
  border-radius: 4px;
  padding: 2px 6px;
  line-height: 1.3;
}

.country-tag.pc-tag {
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.12);
  letter-spacing: 0.5px;
}

.record-time {
  font-size: 11px;
  color: var(--text-secondary);
}

.record-dev {
  flex-shrink: 0;
  font-size: 18px;
  font-weight: 700;
}

/* 我的成绩行 */
.my-score-main {
  display: flex;
  align-items: center;
  gap: 6px;
}

.dir-pill {
  font-size: 11px;
  font-weight: 600;
  border-radius: 4px;
  padding: 1px 6px;
  line-height: 1.4;
}

.grade-badge {
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 700;
}

.list-footer {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 14px 0 6px;
  min-height: 44px;
}

.list-retry {
  margin: 10px auto 4px;
}

/* ============ Settings ============ */
.settings-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 4px 16px calc(var(--safe-bottom) + 20px);
}

.settings-group {
  margin-top: 18px;
}

.settings-group-label {
  font-size: 13px;
  color: var(--text-secondary);
  padding: 0 12px 8px;
}

.settings-card {
  background: var(--secondary);
  border-radius: 12px;
  overflow: hidden;
}

.settings-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  min-height: 50px;
  width: 100%;
  text-align: left;
}

.settings-row + .settings-row {
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.settings-row:active {
  background: rgba(255, 255, 255, 0.04);
}

.settings-row .row-icon {
  width: 22px;
  height: 22px;
  color: var(--primary);
  flex-shrink: 0;
}

.settings-row .row-label {
  flex: 1;
  font-size: 16px;
}

.settings-row .row-value {
  font-size: 14px;
  color: var(--text-secondary);
  max-width: 45%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chevron {
  width: 14px;
  height: 14px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.settings-row-content {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.settings-row-content .row-label {
  flex: 1;
  font-size: 16px;
}

.about-extra {
  padding: 6px 14px 0;
}

/* 语言弹层列表 */
.lang-list {
  overflow-y: auto;
  padding-bottom: 8px;
}

.lang-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 14px 6px;
  font-size: 16px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.lang-item:active {
  opacity: 0.6;
}

.lang-item .check {
  width: 18px;
  height: 18px;
  color: var(--primary);
}

.sheet-hint {
  font-size: 12px;
  color: var(--text-secondary);
  padding: 10px 4px 2px;
  line-height: 1.6;
}

.default-nick {
  font-size: 13px;
  color: var(--primary);
  padding: 2px 4px 12px;
}

.nick-input-row {
  padding: 8px 0 0;
}

/* ============ 宽屏顶 bar（默认隐藏，仅 >800px 显示） ============ */
#top-bar {
  display: none;
}

/* ============ 宽屏双栏（宽度 >800px）：左首页 + 右榜单 ============ */
@media (min-width: 801px) {
  /* 左栏 440 + 右栏 384（右栏为原宽 480 的 80%） */
  #app {
    max-width: 824px;
  }

  /* ---- 顶 bar ---- */
  #top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    padding: 0 20px;
    background: #000;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
    z-index: 40;
  }

  .top-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: flex-start;
    flex-shrink: 0;
  }

  .top-logo {
    width: 26px;
    height: 26px;
    border-radius: 6px;
    object-fit: contain;
  }

  .top-name {
    font-size: 17px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: var(--primary);
    white-space: nowrap;
  }

  .top-actions {
    display: flex;
    align-items: stretch;
    justify-content: flex-end;
    height: 100%;
  }

  .top-link {
    position: relative;
    display: flex;
    align-items: center;
    padding: 0 14px;
    font-size: 14px;
    color: var(--text-secondary);
    white-space: nowrap;
    transition: color 0.15s ease;
  }

  .top-link:hover {
    color: var(--text-primary);
  }

  .top-link.active {
    color: var(--text-primary);
    font-weight: 600;
  }

  .top-link.active::after {
    content: "";
    position: absolute;
    left: 14px;
    right: 14px;
    bottom: 0;
    height: 2px;
    border-radius: 1px;
    background: var(--primary);
  }

  /* 沉浸屏（启动/游戏/结算）隐藏顶 bar */
  #app[data-screen="splash"] #top-bar,
  #app[data-screen="game"] #top-bar,
  #app[data-screen="result"] #top-bar {
    display: none;
  }

  /* 左栏：固定 440 手机宽，与右栏细分隔线；内容在顶 bar 之下 */
  #screen-home {
    top: 56px;
    left: 0;
    right: auto;
    width: 440px;
    border-right: 1px solid rgba(255, 255, 255, 0.07);
  }

  /* 右栏：排行榜 / 我的成绩 / 设置，内容在顶 bar 之下 */
  #screen-leaderboard,
  #screen-myscores,
  #screen-settings {
    top: 56px;
    left: 440px;
    right: 0;
  }

  /* 排行榜是右栏默认页：隐藏返回按钮，保留居中标题 */
  #screen-leaderboard .nav-btn {
    visibility: hidden;
  }
}
