/* 瓶盖激流大冲关 - 清新水彩手绘风全局样式 */

:root {
  --watercolor-paper: #fbfbf2;
  --watercolor-teal: #4895a0;
  --watercolor-dark: #2b2d42;
  --watercolor-accent: #e63946;
  --watercolor-gold: #ffb703;
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: #2b535d;
  font-family: var(--font-family);
  touch-action: none;
}

#gameCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* UI 遮罩通用样式 */
.ui-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10;
}

.interactive {
  pointer-events: auto;
}

.hidden {
  display: none !important;
}

.loading-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(18, 48, 58, 0.72);
  backdrop-filter: blur(8px);
  z-index: 30;
}

.loading-card {
  padding: 26px 24px;
  max-width: 360px;
}

.loading-leaf {
  font-size: 34px;
  margin-bottom: 4px;
  animation: loadingFloat 1.6s ease-in-out infinite;
}

.loading-text {
  min-height: 22px;
  color: #457b9d;
  font-size: 13px;
  font-weight: 700;
  margin: 10px 0 14px;
}

.loading-bar {
  height: 12px;
  padding: 2px;
  background: #e7e1d6;
  border-radius: 12px;
  overflow: hidden;
}

.loading-bar-fill {
  width: 0;
  height: 100%;
  border-radius: 10px;
  background: linear-gradient(90deg, #52b788, #2a9d8f, #48cae4);
  transition: width 0.2s ease-out;
}

.loading-hint {
  margin-top: 12px;
  color: #8a8175;
  font-size: 11px;
}

@keyframes loadingFloat {
  0%, 100% { transform: translateY(0) rotate(-4deg); }
  50% { transform: translateY(-5px) rotate(4deg); }
}

/* 顶部 HUD 状态栏 */
.hud-container {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 16px 20px;
}

.hud-left {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rank-badge {
  background: linear-gradient(135deg, #ffd166, #ffb703);
  color: #5c3d00;
  font-weight: 800;
  font-size: 26px;
  padding: 6px 16px;
  border-radius: 20px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18), inset 0 2px 0 rgba(255, 255, 255, 0.6);
  border: 2px solid #fff;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
  display: inline-block;
  width: fit-content;
}

.distance-box {
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(8px);
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  color: #333;
  border: 1px solid rgba(255, 255, 255, 0.5);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.hud-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.energy-bar-wrap {
  width: 150px;
  height: 14px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 10px;
  padding: 2px;
  border: 2px solid rgba(255, 255, 255, 0.8);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  overflow: hidden;
}

.energy-fill {
  width: 20%;
  height: 100%;
  background: linear-gradient(90deg, #48cae4, #00b4d8);
  border-radius: 8px;
  transition: width 0.15s ease-out;
  box-shadow: 0 0 6px rgba(0, 180, 216, 0.8);
}

.energy-label {
  font-size: 11px;
  font-weight: 700;
  color: #ffffff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
  letter-spacing: 0.5px;
}

.hud-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
}

.mute-btn {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  transition: transform 0.1s;
}

.mute-btn:active {
  transform: scale(0.92);
}

/* 赛道小地图微缩进度条 (Mini Track) */
.track-progress {
  position: relative;
  width: 18px;
  height: 180px;
  background: rgba(255, 255, 255, 0.25);
  backdrop-filter: blur(6px);
  border-radius: 12px;
  border: 2px solid rgba(255, 255, 255, 0.7);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
}

.track-pin {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1.5px solid #fff;
  transition: top 0.1s linear;
}

.track-pin.player {
  background: #e63946;
  width: 15px;
  height: 15px;
  box-shadow: 0 0 6px #e63946;
  z-index: 3;
}

.track-pin.ai-0 { background: #ffb703; }
.track-pin.ai-1 { background: #0077b6; }
.track-pin.ai-2 { background: #d4a373; }
.track-pin.ai-3 { background: #2ec4b6; }

/* 移动端虚拟冲刺按钮 (Mobile Boost Button) */
.mobile-controls {
  position: absolute;
  bottom: 24px;
  right: 24px;
  display: flex;
  pointer-events: auto;
}

.boost-action-btn {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: linear-gradient(135deg, #00b4d8, #0077b6);
  border: 3px solid #ffffff;
  color: #ffffff;
  font-weight: 800;
  font-size: 15px;
  box-shadow: 0 6px 16px rgba(0, 119, 182, 0.4), inset 0 2px 2px rgba(255, 255, 255, 0.6);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.1s, opacity 0.2s;
}

.boost-action-btn:active {
  transform: scale(0.92);
}

.boost-action-btn.disabled {
  opacity: 0.55;
  filter: grayscale(40%);
}

.boost-icon {
  font-size: 20px;
}

/* 水彩纸质感弹窗卡片 (Watercolor Paper Card) */
.paper-card {
  background: #fdfbf7;
  border-radius: 24px;
  padding: 32px 28px;
  box-shadow: 0 16px 40px rgba(10, 30, 45, 0.28), 0 0 0 4px rgba(255, 255, 255, 0.85);
  text-align: center;
  max-width: 400px;
  width: 88%;
  position: relative;
  border: 2px dashed #d8c3a5;
}

.menu-screen, .finish-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(18, 48, 58, 0.55);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.game-title {
  font-size: 32px;
  color: #1d3557;
  font-weight: 900;
  margin-bottom: 6px;
  letter-spacing: 1px;
}

.game-subtitle {
  font-size: 14px;
  color: #457b9d;
  margin-bottom: 22px;
  font-weight: 600;
}

.guide-box {
  background: #f4ede2;
  border-radius: 16px;
  padding: 14px 16px;
  margin-bottom: 24px;
  text-align: left;
  font-size: 13px;
  color: #4a4e69;
  line-height: 1.6;
}

.guide-box p {
  margin-bottom: 6px;
}

.guide-box p:last-child {
  margin-bottom: 0;
}

.primary-btn {
  background: linear-gradient(135deg, #e63946, #d90429);
  color: #ffffff;
  font-size: 19px;
  font-weight: 800;
  padding: 14px 38px;
  border-radius: 30px;
  border: none;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(230, 57, 70, 0.4), inset 0 2px 2px rgba(255, 255, 255, 0.5);
  transition: transform 0.15s, box-shadow 0.15s;
}

.primary-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 22px rgba(230, 57, 70, 0.5);
}

.primary-btn:active {
  transform: translateY(1px);
}

.primary-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* 倒计时动画提示 */
.countdown-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.countdown-number {
  font-size: 96px;
  font-weight: 900;
  color: #ffffff;
  text-shadow: 0 4px 20px rgba(0, 0, 0, 0.4), 0 0 30px rgba(255, 209, 102, 0.8);
  animation: popCount 0.9s infinite ease-out;
}

@keyframes popCount {
  0% { transform: scale(0.6); opacity: 0.3; }
  45% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1.0); opacity: 0.95; }
}

/* 结算面板样式 */
.finish-title {
  font-size: 28px;
  color: #e63946;
  font-weight: 900;
  margin-bottom: 6px;
}

.finish-rank {
  font-size: 20px;
  color: #1d3557;
  font-weight: 700;
  margin-bottom: 4px;
}

.finish-time {
  font-size: 14px;
  color: #6c757d;
  margin-bottom: 16px;
}

.leaderboard-list {
  list-style: none;
  background: #f8f5f0;
  border-radius: 14px;
  padding: 8px 12px;
  margin-bottom: 22px;
}

.leaderboard-list li {
  display: flex;
  align-items: center;
  padding: 8px 10px;
  font-size: 14px;
  color: #333;
  border-bottom: 1px solid #ebe5dc;
}

.leaderboard-list li:last-child {
  border-bottom: none;
}

.leaderboard-list li.player-row {
  background: #ffe8d6;
  border-radius: 8px;
  font-weight: 800;
  color: #9d0208;
}

.rank-idx {
  width: 32px;
  font-weight: 800;
}

.cap-color-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  margin-right: 10px;
  border: 1px solid rgba(0, 0, 0, 0.2);
}

.cap-name {
  flex: 1;
  text-align: left;
}

.cap-time {
  font-family: monospace;
  font-weight: 700;
}

/* PC 端操作小贴士 */
.pc-hint {
  position: absolute;
  bottom: 16px;
  left: 20px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
  background: rgba(0, 0, 0, 0.25);
  padding: 6px 12px;
  border-radius: 12px;
  pointer-events: none;
}

@media (max-width: 768px) {
  .pc-hint {
    display: none;
  }
  .hud-container {
    padding: 8px 10px;
  }
  .energy-bar-wrap {
    width: 95px;
    height: 12px;
  }
  .energy-label {
    font-size: 9px;
  }
  .rank-badge {
    font-size: 20px;
    padding: 3px 12px;
  }
  .distance-box {
    font-size: 11px;
    padding: 2px 8px;
  }
  .hud-badges {
    flex-direction: column;
    gap: 3px;
    align-items: flex-end;
  }
  .room-badge, .ping-badge {
    padding: 2px 7px;
    font-size: 10px;
  }
  .mute-btn {
    width: 32px;
    height: 32px;
    font-size: 15px;
  }
  .track-progress {
    width: 14px;
    height: 140px;
  }
  .track-pin {
    width: 10px;
    height: 10px;
  }
  .track-pin.player {
    width: 12px;
    height: 12px;
  }
}

/* 多人联机专属 HUD 徽章 */
.hud-badges {
  display: flex;
  gap: 8px;
  align-items: center;
}

.room-badge, .ping-badge {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(6px);
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  color: #1d3557;
  border: 1px solid rgba(255, 255, 255, 0.6);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.ping-badge {
  color: #2a9d8f;
}

/* 主菜单多模式按钮与昵称输入 */
.main-menu-card {
  max-width: 440px;
}

.nickname-box {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 16px;
  font-size: 14px;
  font-weight: 700;
  color: #1d3557;
}

.nickname-input {
  background: #ffffff;
  border: 2px solid #a8dadc;
  border-radius: 16px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 700;
  color: #1d3557;
  outline: none;
  width: 140px;
  text-align: center;
  transition: border-color 0.2s;
}

.nickname-input:focus {
  border-color: #457b9d;
  box-shadow: 0 0 8px rgba(69, 123, 157, 0.25);
}

.menu-action-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.secondary-btn {
  background: linear-gradient(135deg, #457b9d, #1d3557);
  color: #ffffff;
  font-size: 16px;
  font-weight: 800;
  padding: 12px 28px;
  border-radius: 26px;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(29, 53, 87, 0.3), inset 0 2px 2px rgba(255, 255, 255, 0.4);
  transition: transform 0.15s, box-shadow 0.15s;
}

.secondary-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(29, 53, 87, 0.4);
}

.secondary-btn:active {
  transform: translateY(1px);
}

.text-btn {
  background: transparent;
  border: none;
  color: #457b9d;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline;
  padding: 6px;
  transition: color 0.15s;
}

.text-btn:hover {
  color: #1d3557;
}

.pulse-glow {
  animation: pulseGlow 1.8s infinite;
}

@keyframes pulseGlow {
  0% { box-shadow: 0 4px 14px rgba(230, 57, 70, 0.4); }
  50% { box-shadow: 0 4px 24px rgba(230, 57, 70, 0.8), 0 0 16px rgba(255, 209, 102, 0.6); }
  100% { box-shadow: 0 4px 14px rgba(230, 57, 70, 0.4); }
}

/* 匹配中大厅卡片 */
.matching-screen, .custom-screen {
  background: rgba(18, 48, 58, 0.65);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.matching-card {
  max-width: 420px;
}

.matching-spinner {
  font-size: 40px;
  animation: spinWave 1.2s infinite ease-in-out;
  display: inline-block;
  margin-bottom: 6px;
}

@keyframes spinWave {
  0% { transform: scale(0.9) rotate(0deg); }
  50% { transform: scale(1.15) rotate(15deg); }
  100% { transform: scale(0.9) rotate(0deg); }
}

.match-room-info {
  font-size: 14px;
  font-weight: 700;
  color: #457b9d;
  margin-bottom: 16px;
}

.match-player-list {
  list-style: none;
  background: #f8f5f0;
  border-radius: 16px;
  padding: 10px 14px;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.match-player-item {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  background: #ffffff;
  border-radius: 10px;
  border: 1px solid #ebe5dc;
  font-size: 13px;
  font-weight: 700;
  color: #2b2d42;
}

.match-player-item.is-me {
  background: #ffe8d6;
  border-color: #ffd166;
  color: #d90429;
}

.match-player-item.is-empty {
  background: rgba(240, 240, 240, 0.6);
  color: #adb5bd;
  border-style: dashed;
}

.match-slot-num {
  width: 24px;
  color: #6c757d;
  font-family: monospace;
}

.match-hint {
  font-size: 12px;
  color: #6c757d;
  margin-bottom: 20px;
  line-height: 1.4;
}

.matching-btn-group, .finish-btn-group {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 16px;
}

/* 好友开黑弹窗 */
.custom-card {
  max-width: 380px;
}

.custom-section {
  margin: 16px 0;
}

.custom-divider {
  display: flex;
  align-items: center;
  text-align: center;
  margin: 16px 0;
  color: #adb5bd;
  font-size: 12px;
}

.custom-divider::before, .custom-divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px dashed #d8c3a5;
}

.custom-divider span {
  padding: 0 10px;
}

.custom-join-box {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 20px;
}

.room-code-input {
  background: #ffffff;
  border: 2px solid #a8dadc;
  border-radius: 18px;
  padding: 10px 14px;
  font-size: 16px;
  font-weight: 800;
  color: #1d3557;
  letter-spacing: 2px;
  outline: none;
  width: 140px;
  text-align: center;
}

.room-code-input:focus {
  border-color: #1d3557;
}
