:root {
  --bg-top: #cfefff;
  --bg-bottom: #fff6dc;
  --card-bg: rgba(255, 255, 255, 0.78);
  --card-border: rgba(255, 255, 255, 0.9);
  --text-main: #2c2520;
  --text-sub: #6c6157;
  --accent: #ffb800;
  --accent-deep: #ff7a00;
  --shadow: 0 12px 32px rgba(44, 37, 32, 0.12);
}

* {
  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;
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  background: linear-gradient(180deg, var(--bg-top) 0%, var(--bg-bottom) 100%);
  color: var(--text-main);
  touch-action: none;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

/* 顶部 HUD */
.hud-top {
  position: absolute;
  top: 18px;
  left: 20px;
  right: 20px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none;
  z-index: 10;
  gap: 12px;
}

.score-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
  font-weight: 700;
  font-size: 14px;
  color: var(--text-main);
}

.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #ffe97d, #ff9900);
  box-shadow: 0 0 8px rgba(255, 168, 0, 0.7);
}

.score-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.score-card {
  display: flex;
  flex-direction: column;
  padding: 10px 16px;
  min-width: 104px;
  border-radius: 16px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
}

.score-card .label {
  font-size: 11px;
  color: var(--text-sub);
  font-weight: 600;
}

.score-card .value {
  font-size: 28px;
  line-height: 1.15;
  font-weight: 800;
  color: var(--text-main);
  font-variant-numeric: tabular-nums;
}

.combo-pill {
  padding: 8px 14px;
  border-radius: 999px;
  background: linear-gradient(135deg, #ffcf33, #ff8800);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  box-shadow: 0 8px 20px rgba(255, 136, 0, 0.35);
  animation: popIn 0.25s ease-out;
}

.hud-actions {
  display: flex;
  gap: 8px;
  pointer-events: auto;
}

.icon-btn {
  border: 1px solid var(--card-border);
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
  color: var(--text-main);
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.14s ease, background 0.14s ease;
}

.icon-btn:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.94);
}

.icon-btn:active {
  transform: scale(0.96);
}

/* 飘字 */
.floating-feedback {
  position: absolute;
  top: 28%;
  left: 50%;
  transform: translateX(-50%);
  pointer-events: none;
  z-index: 12;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.float-item {
  padding: 6px 16px;
  border-radius: 999px;
  font-size: 20px;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, #ffb800, #ff6d00);
  box-shadow: 0 8px 22px rgba(255, 122, 0, 0.38);
  animation: floatUp 0.95s ease-out forwards;
}

.float-item.perfect {
  font-size: 24px;
  background: linear-gradient(135deg, #ff6b6b, #ffa502);
}

/* 底部蓄力条 */
.hud-bottom {
  position: absolute;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  width: min(380px, calc(100% - 32px));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  pointer-events: none;
  z-index: 10;
}

.charge-panel {
  width: 100%;
  padding: 12px 16px;
  border-radius: 18px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
  transition: transform 0.15s ease;
}

.charge-panel.active {
  transform: scale(1.03);
}

.charge-header {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-sub);
  margin-bottom: 8px;
}

.charge-track {
  width: 100%;
  height: 12px;
  border-radius: 999px;
  background: rgba(44, 37, 32, 0.1);
  overflow: hidden;
}

.charge-fill {
  width: 0%;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #ffd84d 0%, #ff9800 60%, #ff4757 100%);
  transition: width 0.03s linear;
}

.controls-hint {
  font-size: 12px;
  color: var(--text-sub);
  background: rgba(255, 255, 255, 0.65);
  padding: 6px 14px;
  border-radius: 999px;
  backdrop-filter: blur(8px);
  text-align: center;
}

/* 游戏结束弹窗 */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(26, 22, 18, 0.35);
  backdrop-filter: blur(6px);
  z-index: 30;
  padding: 20px;
}

.modal-card {
  width: min(400px, 100%);
  background: rgba(255, 252, 245, 0.96);
  border: 2px solid #ffffff;
  border-radius: 28px;
  padding: 28px 24px 24px;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.24);
  animation: popIn 0.26s ease-out;
}

.modal-emoji {
  font-size: 46px;
  margin-bottom: 8px;
}

.modal-card h2 {
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 6px;
}

.fail-reason {
  font-size: 13px;
  color: var(--text-sub);
  margin-bottom: 20px;
}

.modal-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 22px;
}

.stat-box {
  background: rgba(255, 216, 59, 0.14);
  border: 1px solid rgba(255, 184, 0, 0.25);
  border-radius: 16px;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-label {
  font-size: 11px;
  color: var(--text-sub);
  font-weight: 600;
}

.stat-num {
  font-size: 24px;
  font-weight: 800;
  color: var(--text-main);
}

.stat-num.highlight {
  color: var(--accent-deep);
}

.primary-btn {
  width: 100%;
  border: none;
  border-radius: 16px;
  padding: 14px 20px;
  font-size: 16px;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, #ffc400, #ff7a00);
  box-shadow: 0 10px 24px rgba(255, 122, 0, 0.35);
  cursor: pointer;
  transition: transform 0.14s ease, filter 0.14s ease;
}

.primary-btn:hover {
  transform: translateY(-2px);
  filter: brightness(1.04);
}

.primary-btn:active {
  transform: scale(0.98);
}

.modal-tip {
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-sub);
}

.hidden {
  display: none !important;
}

@keyframes popIn {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(8px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes floatUp {
  0% {
    opacity: 0;
    transform: translateY(10px) scale(0.85);
  }
  20% {
    opacity: 1;
    transform: translateY(0) scale(1.05);
  }
  100% {
    opacity: 0;
    transform: translateY(-56px) scale(0.98);
  }
}

@media (max-width: 600px) {
  .hud-top {
    top: 12px;
    left: 12px;
    right: 12px;
  }

  .score-card {
    min-width: 82px;
    padding: 8px 12px;
  }

  .score-card .value {
    font-size: 22px;
  }

  .icon-btn {
    padding: 8px 10px;
    font-size: 12px;
  }
}
