/* ============================================
   元素 VS 符号 - 主样式表
   Black & Gold Theme
   ============================================ */

/* --- Reset & Base --- */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

body {
  background: #0a0a0a;
  color: #ffd700;
  font-family: "Microsoft YaHei", "SimHei", sans-serif;
  overflow: hidden;
  position: relative;
  width: 100vw;
  height: 100vh;
}

/* --- Canvas Layers --- */
#bgCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  opacity: 0.30;
}

#gameContainer {
  position: relative;
  width: 100%;
  height: 100%;
  z-index: 1;
  display: flex;
  justify-content: center;
  align-items: center;
}

#particleCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 50;
}

/* --- Animations --- */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(30px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes scoreFlash {
  0%   { transform: scale(1); filter: brightness(1); }
  50%  { transform: scale(1.2); filter: brightness(1.5); text-shadow: 0 0 40px rgba(255,215,0,0.8); }
  100% { transform: scale(1); filter: brightness(1); }
}

@keyframes shake {
  0%, 100% { transform: translate(-50%, -50%) rotate(0deg); }
  25%      { transform: translate(-50%, -50%) rotate(-5deg); }
  75%      { transform: translate(-50%, -50%) rotate(5deg); }
}

@keyframes ringRotate {
  to { transform: rotate(360deg); }
}

@keyframes ringRotateReverse {
  to { transform: rotate(-360deg); }
}

@keyframes innerSpin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

@keyframes collectAnim {
  0%   { transform: scale(1); opacity: 1; }
  100% { transform: scale(0); opacity: 0; }
}

@keyframes wrongShake {
  0%, 100% { transform: rotate(0deg); }
  25%      { transform: rotate(-10deg); }
  75%      { transform: rotate(10deg); }
}

@keyframes correctPulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.2); }
}

@keyframes rippleEffect {
  to { transform: scale(4); opacity: 0; }
}

@keyframes timerPulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.6; }
}

@keyframes milestonePop {
  0%   { transform: translate(-50%, -50%) scale(0) rotate(-10deg); opacity: 0; }
  20%  { transform: translate(-50%, -50%) scale(1.2) rotate(5deg); opacity: 1; }
  80%  { transform: translate(-50%, -50%) scale(1) rotate(0deg); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(0.8) rotate(0deg); opacity: 0; }
}

@keyframes explodeScale {
  0%   { transform: translate(-50%, -50%) scale(0); opacity: 1; }
  50%  { transform: translate(-50%, -50%) scale(1.5); opacity: 0.8; }
  100% { transform: translate(-50%, -50%) scale(3); opacity: 0; }
}

@keyframes ringExpand {
  to { width: 200%; height: 200%; opacity: 0; }
}

@keyframes trailFade {
  to { opacity: 0; transform: scale(0.3); }
}

@keyframes burstExpand {
  0%   { transform: scale(0.5); opacity: 1; }
  100% { transform: scale(2); opacity: 0; }
}

@keyframes modalSlideIn {
  from { transform: translateY(-20px) scale(0.95); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}

@keyframes shuffleFlash {
  0%  { box-shadow: 0 0 0 0 rgba(255,215,0,0.6); }
  50% { box-shadow: 0 0 20px 5px rgba(255,215,0,0.4); }
  100%{ box-shadow: 0 5px 20px rgba(0,0,0,0.4), 0 0 0 1px rgba(255,215,0,0.2); }
}

/* ============================================
   Menu Screen
   ============================================ */
#menu {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
  animation: fadeIn 0.8s ease-out;
  background: rgba(20, 20, 20, 0.8);
  backdrop-filter: blur(10px);
  padding: 40px 60px;
  border-radius: 20px;
  border: 1px solid rgba(255, 215, 0, 0.2);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  max-height: 92vh;
  overflow-y: auto;
}

.game-title {
  font-size: 56px;
  font-weight: bold;
  letter-spacing: 15px;
  background: linear-gradient(135deg, #ffd700 0%, #ffec8b 50%, #b8860b 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 20px rgba(255, 215, 0, 0.5));
  margin-bottom: 10px;
  position: relative;
}

.game-title::after {
  content: '黑金典藏版';
  position: absolute;
  bottom: -25px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 16px;
  letter-spacing: 6px;
  color: #b8860b;
  -webkit-text-fill-color: #b8860b;
  background: none;
  white-space: nowrap;
}

.mode-select-label {
  margin-top: 30px;
  margin-bottom: 10px;
  font-size: 16px;
  color: #888;
  letter-spacing: 3px;
}

.mode-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  justify-content: center;
}

.mode-tab {
  padding: 8px 20px;
  border: 1px solid #444;
  background: rgba(0, 0, 0, 0.5);
  color: #666;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.3s;
  border-radius: 20px;
}

.mode-tab.active {
  border-color: #ffd700;
  color: #ffd700;
  background: rgba(255, 215, 0, 0.1);
  box-shadow: 0 0 15px rgba(255, 215, 0, 0.2);
}

.difficulty-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 15px;
  width: 100%;
  max-width: 400px;
}

/* --- Shared Button --- */
.btn {
  height: 50px;
  border: 2px solid rgba(255, 215, 0, 0.3);
  background: rgba(0, 0, 0, 0.6);
  color: #ffd700;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
  letter-spacing: 4px;
  border-radius: 8px;
}

.btn:hover {
  background: rgba(255, 215, 0, 0.15);
  border-color: #ffd700;
  transform: translateY(-3px);
  box-shadow: 0 10px 30px rgba(255, 215, 0, 0.2);
}

.btn:focus-visible {
  outline: 2px solid #ffd700;
  outline-offset: 2px;
}

.btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 215, 0, 0.2), transparent);
  transition: left 0.6s;
  pointer-events: none;
}

.btn:hover::before {
  left: 100%;
}

.btn-collection {
  margin-top: 15px;
  width: 100%;
  max-width: 400px;
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.1) 0%, rgba(184, 134, 11, 0.1) 100%);
}

/* --- Sound Control --- */
.sound-control {
  position: absolute;
  bottom: 15px;
  right: 15px;
  z-index: 100;
}

.sound-toggle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid #ffd700;
  background: rgba(0, 0, 0, 0.6);
  color: #ffd700;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s;
}

.sound-toggle:hover {
  background: rgba(255, 215, 0, 0.2);
  transform: scale(1.1);
}

.sound-toggle:focus-visible {
  outline: 2px solid #ffd700;
  outline-offset: 2px;
}

.sound-toggle.active {
  background: rgba(255, 215, 0, 0.25);
}

.sound-panel {
  position: absolute;
  bottom: 50px;
  right: 0;
  width: 240px;
  background: rgba(10, 10, 10, 0.95);
  border: 1px solid rgba(255, 215, 0, 0.3);
  border-radius: 12px;
  padding: 14px;
  display: none;
  flex-direction: column;
  gap: 12px;
  backdrop-filter: blur(12px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.sound-panel.show {
  display: flex;
}

.sound-panel-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sound-panel-label {
  font-size: 12px;
  color: #999;
  width: 32px;
  letter-spacing: 1px;
  flex-shrink: 0;
}

.sound-mini-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid rgba(255, 215, 0, 0.3);
  background: rgba(0, 0, 0, 0.4);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
}

.sound-mini-btn:hover {
  border-color: #ffd700;
  background: rgba(255, 215, 0, 0.15);
}

.sound-mini-icon {
  font-size: 13px;
  line-height: 1;
}

.sound-mini-icon.off {
  opacity: 0.4;
}

.sound-slider {
  flex: 1;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

.sound-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ffd700;
  border: none;
  cursor: pointer;
  transition: transform 0.15s;
}

.sound-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.sound-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ffd700;
  border: none;
  cursor: pointer;
}

.sound-val {
  font-size: 11px;
  color: #888;
  width: 32px;
  text-align: right;
  flex-shrink: 0;
  letter-spacing: 0.5px;
}

.collection-progress {
  font-size: 12px;
  color: #888;
  margin-top: 10px;
  letter-spacing: 2px;
}

.collection-progress span {
  color: #ffd700;
  font-weight: bold;
}

.credits {
  margin-top: 20px;
  font-size: 12px;
  color: #555;
  text-align: center;
  line-height: 1.8;
  letter-spacing: 2px;
}

/* ============================================
   Game Area
   ============================================ */
#gameArea {
  display: none;
  position: relative;
  width: 100%;
  height: 100%;
}

/* --- Top HUD --- */
.topUI {
  position: absolute;
  top: 20px;
  left: 0;
  width: 100%;
  padding: 0 30px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  z-index: 10;
  pointer-events: none;
}

.score-section {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.score-label {
  font-size: 12px;
  color: #888;
  letter-spacing: 2px;
}

.score-value {
  font-size: 42px;
  font-weight: bold;
  color: #ffd700;
  text-shadow: 0 0 20px rgba(255, 215, 0, 0.5);
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
}

.trophy-icon {
  width: 28px;
  height: 28px;
  background: linear-gradient(135deg, #ffd700, #b8860b);
  clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
}

.score-value.scored {
  animation: scoreFlash 0.5s ease-out;
}

.lives-display {
  display: flex;
  gap: 8px;
  align-items: center;
}

.heart {
  width: 24px;
  height: 24px;
  transition: all 0.3s;
}

.heart.active {
  filter: drop-shadow(0 0 8px rgba(255, 100, 100, 0.8));
}

.heart.lost {
  opacity: 0.2;
  transform: scale(0.8);
}

.combo-display {
  text-align: right;
  opacity: 0;
  transform: scale(0.8);
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.combo-display.active {
  opacity: 1;
  transform: scale(1);
}

.combo-count {
  font-size: 36px;
  font-weight: bold;
  color: #ff6b35;
  text-shadow: 0 0 20px rgba(255, 107, 53, 0.6);
}

.combo-text {
  font-size: 12px;
  color: #ff6b35;
  letter-spacing: 3px;
}

/* --- Mode Badge & Progress --- */
.mode-badge {
  position: absolute;
  top: 105px;
  left: 30px;
  padding: 6px 18px;
  background: rgba(255, 215, 0, 0.12);
  border: 1px solid rgba(255, 215, 0, 0.4);
  border-radius: 15px;
  font-size: 14px;
  font-weight: bold;
  color: #ffd700;
  letter-spacing: 3px;
  z-index: 10;
  pointer-events: none;
  text-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
}

.hud-player {
  position: absolute;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 16px;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.6);
  letter-spacing: 2px;
  z-index: 10;
  pointer-events: none;
  white-space: nowrap;
}

.progress-indicator {
  position: absolute;
  top: 105px;
  right: 30px;
  padding: 5px 15px;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(255, 215, 0, 0.2);
  border-radius: 15px;
  font-size: 12px;
  color: #888;
  z-index: 10;
  pointer-events: none;
}

.progress-indicator span {
  color: #ffd700;
}

/* --- Game Timer --- */
.game-timer {
  position: absolute;
  bottom: 20px;
  left: 30px;
  font-size: 14px;
  color: #999;
  letter-spacing: 2px;
  z-index: 12;
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 6px;
}

.game-timer-icon {
  font-size: 16px;
  opacity: 0.6;
}

.game-timer-value {
  color: #ffd700;
  font-weight: bold;
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  min-width: 48px;
  text-align: left;
}

/* --- Pause --- */
.pause-btn {
  position: absolute;
  bottom: 20px;
  left: 50%;
  margin-left: -22px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid rgba(255, 215, 0, 0.4);
  background: rgba(0, 0, 0, 0.5);
  color: #ffd700;
  font-size: 18px;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  transition: all 0.3s;
  z-index: 15;
  pointer-events: auto;
}

.pause-btn:hover {
  background: rgba(255, 215, 0, 0.2);
  border-color: #ffd700;
  transform: scale(1.1);
}

.pause-btn:focus-visible {
  outline: 2px solid #ffd700;
  outline-offset: 2px;
}

.pause-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  z-index: 25;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 25px;
  animation: fadeIn 0.3s ease-out;
}

.pause-overlay.show {
  display: flex;
}

.pause-title {
  font-size: 48px;
  font-weight: bold;
  color: #ffd700;
  letter-spacing: 10px;
  text-shadow: 0 0 30px rgba(255, 215, 0, 0.5);
}

.pause-subtitle {
  font-size: 14px;
  color: #999;
  letter-spacing: 3px;
}

.pause-buttons {
  display: flex;
  gap: 20px;
  margin-top: 10px;
}

.pause-buttons .btn {
  width: 140px;
  height: 48px;
  font-size: 16px;
  letter-spacing: 3px;
}

/* --- Timer Bar (Nightmare mode) --- */
.timer-bar {
  position: absolute;
  top: 145px;
  left: 50%;
  transform: translateX(-50%);
  width: 300px;
  height: 8px;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid rgba(255, 215, 0, 0.2);
}

.timer-fill {
  height: 100%;
  background: linear-gradient(90deg, #ff6b35, #ffd700);
  transition: width 0.1s linear;
  border-radius: 4px;
}

.timer-fill.warning {
  background: linear-gradient(90deg, #ff4444, #ff6b35);
  animation: timerPulse 0.5s ease-in-out infinite;
}

.timer-text {
  position: absolute;
  top: 157px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 14px;
  color: #999;
}

/* --- Milestone Pop --- */
.milestone {
  position: absolute;
  top: 30%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  font-size: 48px;
  font-weight: bold;
  color: #ffd700;
  text-shadow: 0 0 40px rgba(255, 215, 0, 0.8);
  pointer-events: none;
  z-index: 100;
  white-space: nowrap;
}

.milestone.show {
  animation: milestonePop 1.5s ease-out forwards;
}

/* --- Center Display (Orbit) --- */
.center-area {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 5;
}

.center-orbit {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  position: relative;
}

.category-ring {
  position: absolute;
  top: -10px;
  left: -10px;
  right: -10px;
  bottom: -10px;
  border-radius: 50%;
  border: 3px solid transparent;
  border-top-color: var(--category-color, #ffd700);
  border-right-color: var(--category-color, #ffd700);
  opacity: 0.6;
  animation: ringRotate 10s linear infinite;
}

.category-ring::before {
  content: '';
  position: absolute;
  top: 5px;
  left: 5px;
  right: 5px;
  bottom: 5px;
  border-radius: 50%;
  border: 2px solid transparent;
  border-bottom-color: var(--category-color, #ffd700);
  border-left-color: var(--category-color, #ffd700);
  animation: ringRotateReverse 15s linear infinite;
}

.center-display {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 130px;
  height: 130px;
  background: radial-gradient(circle at 30% 30%, #2a2a2a 0%, #000 70%);
  border: 3px solid var(--center-border-color, #ffd700);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  font-weight: bold;
  color: var(--center-text-color, #ffd700);
  box-shadow: 0 0 50px rgba(255, 215, 0, 0.3), inset 0 0 30px rgba(0, 0, 0, 0.8);
  transition: all 0.3s;
}

.center-display.shake {
  animation: shake 0.5s ease-in-out;
}

.center-category-tag {
  margin-top: 12px;
  padding: 4px 16px;
  border-radius: 12px;
  font-size: 12px;
  letter-spacing: 2px;
  border: 1px solid;
  opacity: 0;
  transition: all 0.4s;
  white-space: nowrap;
}

.center-category-tag.show {
  opacity: 1;
}

/* --- Orbit Track & Options --- */
.orbit-container {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 320px;
  height: 320px;
  z-index: 4;
  pointer-events: none;
}

.orbit-track {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 1px dashed rgba(255, 215, 0, 0.1);
  border-radius: 50%;
}

/* --- Learn Hint --- */
.learn-hint {
  position: absolute;
  top: calc(50% + 110px);
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  padding: 8px 24px;
  background: rgba(255, 68, 68, 0.12);
  border: 1px solid rgba(255, 68, 68, 0.4);
  border-radius: 20px;
  font-size: 15px;
  letter-spacing: 3px;
  opacity: 0;
  transition: all 0.4s;
  z-index: 20;
  pointer-events: none;
  white-space: nowrap;
}

.learn-hint.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.learn-hint .hint-arrow {
  color: #ff6b6b;
  margin: 0 8px;
}

.learn-hint .hint-correct {
  color: #81C784;
  font-weight: bold;
}

/* --- Option Wrapper --- */
.option-wrapper {
  position: absolute;
  left: 50%;
  top: 50%;
  margin-left: -35px;
  margin-top: -35px;
  width: 70px;
  height: 70px;
  pointer-events: auto;
  will-change: transform;
}

.option-inner {
  width: 70px;
  height: 70px;
  background: linear-gradient(135deg, #f5f5dc 0%, #e8e4c9 100%);
  border: 3px solid #ffd700;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: bold;
  color: #000;
  cursor: pointer;
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 215, 0, 0.2), inset 0 -3px 10px rgba(0, 0, 0, 0.1);
  transition: box-shadow 0.2s, background 0.2s, border-color 0.2s, color 0.2s;
  position: relative;
  overflow: hidden;
}

.option-inner.color-hint::after {
  content: '';
  position: absolute;
  bottom: 6px;
  left: 22%;
  right: 22%;
  height: 3px;
  background: var(--category-color, #ffd700);
  border-radius: 2px;
  opacity: 0.7;
}

.option-inner::before {
  content: '';
  position: absolute;
  top: -5px;
  left: -5px;
  right: -5px;
  bottom: -5px;
  border-radius: 50%;
  border: 2px solid transparent;
  border-top-color: var(--category-color, transparent);
  opacity: 0;
  transition: opacity 0.3s;
  animation: ringRotate 2s linear infinite;
}

.option-wrapper:hover .option-inner {
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5), 0 0 30px rgba(255, 215, 0, 0.3);
  z-index: 10;
}

.option-wrapper:hover .option-inner::before {
  opacity: 1;
}

.option-inner.spinning {
  animation: innerSpin 2s linear infinite;
}

.option-wrapper.collected .option-inner {
  animation: collectAnim 0.3s ease-out forwards !important;
}

.option-wrapper.wrong .option-inner {
  background: linear-gradient(135deg, #ff4444 0%, #cc0000 100%);
  border-color: #ff6666;
  color: #fff;
  animation: wrongShake 0.4s ease-in-out !important;
}

.option-wrapper.correct-highlight .option-inner {
  background: linear-gradient(135deg, #4CAF50 0%, #2E7D32 100%);
  border-color: #81C784;
  color: #fff;
  animation: correctPulse 0.5s ease-in-out !important;
}

.option-wrapper.hidden .option-inner {
  color: transparent;
  background: rgba(200, 200, 200, 0.15);
  border-color: rgba(255, 215, 0, 0.3);
  animation: none !important;
}

.option-wrapper.hidden .option-inner::before,
.option-wrapper.hidden .option-inner::after {
  display: none;
}

.option-wrapper.shuffle-warn .option-inner {
  box-shadow: 0 0 25px 5px rgba(255, 165, 0, 0.5) !important;
  border-color: #ffa500 !important;
}

.option-wrapper.shuffle-flash .option-inner {
  animation: shuffleFlash 0.3s ease-out !important;
}

/* --- Ripple Effect --- */
.ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 215, 0, 0.6);
  transform: scale(0);
  animation: rippleEffect 0.6s ease-out;
  pointer-events: none;
  z-index: 99;
}

/* --- Explosion --- */
.explosion {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 300px;
  height: 300px;
  pointer-events: none;
  display: none;
  z-index: 100;
}

.explosion.active {
  display: block;
  animation: explodeScale 1s ease-out forwards;
}

.explosion-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 100%;
  height: 100%;
  border: 5px solid #ffd700;
  border-radius: 50%;
  box-shadow: 0 0 50px #ffd700, inset 0 0 50px #ffd700;
  animation: ringExpand 0.8s ease-out forwards;
}

/* --- Flying Coin --- */
.flying-coin {
  position: fixed;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #fff8dc, #ffd700 40%, #b8860b 100%);
  border: 2px solid #fff8dc;
  box-shadow: 0 0 20px rgba(255, 215, 0, 0.9), inset 0 0 10px rgba(255, 255, 255, 0.5);
  pointer-events: none;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: bold;
  color: #b8860b;
}

.flying-coin::before {
  content: '$';
  text-shadow: 0 1px 1px rgba(255, 255, 255, 0.8);
}

.coin-trail {
  position: fixed;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: radial-gradient(circle, #ffd700, transparent);
  pointer-events: none;
  z-index: 999;
  animation: trailFade 0.3s ease-out forwards;
}

.coin-burst {
  position: fixed;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 215, 0, 0.8), transparent);
  pointer-events: none;
  z-index: 1001;
  animation: burstExpand 0.4s ease-out forwards;
}

/* ============================================
   Collection Panel
   ============================================ */
#collectionPanel {
  display: none;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(5, 5, 5, 0.98);
  backdrop-filter: blur(20px);
  z-index: 30;
  overflow-y: auto;
  animation: fadeIn 0.5s ease-out;
}

.collection-header {
  position: sticky;
  top: 0;
  background: linear-gradient(180deg, rgba(10, 10, 10, 1) 0%, rgba(10, 10, 10, 0.95) 100%);
  padding: 20px 30px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 215, 0, 0.2);
  z-index: 10;
}

.collection-title {
  font-size: 28px;
  font-weight: bold;
  color: #ffd700;
  letter-spacing: 5px;
}

.collection-stats {
  font-size: 14px;
  color: #999;
}

.collection-stats span {
  color: #ffd700;
  font-size: 20px;
  font-weight: bold;
}

.btn-back {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid #ffd700;
  background: transparent;
  color: #ffd700;
  font-size: 20px;
  cursor: pointer;
  transition: all 0.3s;
}

.btn-back:hover {
  background: rgba(255, 215, 0, 0.2);
  transform: scale(1.1);
}

.btn-back:focus-visible {
  outline: 2px solid #ffd700;
  outline-offset: 2px;
}

.collection-filter {
  display: flex;
  gap: 8px;
  padding: 15px 30px 5px;
  flex-wrap: wrap;
  justify-content: center;
}

.filter-tag {
  padding: 4px 14px;
  border: 1px solid #444;
  border-radius: 12px;
  font-size: 12px;
  color: #999;
  cursor: pointer;
  transition: all 0.3s;
  background: transparent;
}

.filter-tag.active {
  border-color: #ffd700;
  color: #ffd700;
  background: rgba(255, 215, 0, 0.1);
}

.filter-tag:hover {
  border-color: #aaa;
  color: #ccc;
}

.filter-tag:focus-visible {
  outline: 2px solid #ffd700;
  outline-offset: 1px;
}

.collection-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 12px;
  padding: 20px 30px 40px;
  max-width: 900px;
  margin: 0 auto;
}

.element-card {
  border-radius: 12px;
  border: 2px solid #444;
  background: rgba(30, 30, 30, 0.8);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s;
  position: relative;
  overflow: hidden;
  padding: 10px 6px;
}

.element-card:focus-visible {
  outline: 2px solid #ffd700;
  outline-offset: 2px;
}

.element-card.locked {
  opacity: 0.35;
  cursor: default;
}

.element-card.locked .card-symbol {
  filter: blur(4px);
  color: #666;
}

.element-card.locked .card-lock {
  display: flex;
}

.element-card.unlocked {
  border-color: var(--card-color, #ffd700);
  box-shadow: 0 0 15px rgba(255, 215, 0, 0.15);
}

.element-card.unlocked:hover {
  transform: scale(1.08);
  box-shadow: 0 0 25px rgba(255, 215, 0, 0.3);
}

.card-number {
  font-size: 10px;
  color: #777;
  position: absolute;
  top: 4px;
  left: 8px;
}

.card-symbol {
  font-size: 32px;
  font-weight: bold;
  color: #ccc;
  transition: all 0.3s;
  line-height: 1.2;
}

.element-card.unlocked .card-symbol {
  color: var(--card-color, #ffd700);
}

.card-name {
  font-size: 13px;
  color: #999;
  margin-top: 4px;
  font-weight: bold;
}

.element-card.unlocked .card-name {
  color: #ccc;
}

.card-english {
  font-size: 9px;
  color: #777;
  margin-top: 2px;
  font-style: italic;
  letter-spacing: 0.5px;
}

.element-card.unlocked .card-english {
  color: #999;
}

.card-cat-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-top: 5px;
  opacity: 0.6;
}

.card-lock {
  display: none;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 16px;
  color: #777;
  opacity: 0.8;
}

/* --- Element Detail Popup --- */
.element-detail-popup {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.8);
  background: rgba(20, 20, 20, 0.98);
  border: 2px solid var(--detail-color, #ffd700);
  border-radius: 20px;
  padding: 30px 40px;
  z-index: 100;
  min-width: 300px;
  text-align: center;
  opacity: 0;
  transition: all 0.3s ease;
}

.element-detail-popup.show {
  display: block;
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.detail-top {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  margin-bottom: 15px;
}

.detail-symbol-big {
  font-size: 80px;
  font-weight: bold;
  color: var(--detail-color, #ffd700);
  text-shadow: 0 0 30px rgba(255, 215, 0, 0.5);
  line-height: 1;
}

.detail-number-big {
  font-size: 14px;
  color: #999;
  text-align: left;
  line-height: 1.6;
}

.detail-number-big span {
  display: block;
  font-size: 36px;
  color: #fff;
  font-weight: bold;
  line-height: 1.2;
}

.detail-name {
  font-size: 28px;
  color: #fff;
  margin-top: 5px;
  letter-spacing: 5px;
}

.detail-english {
  font-size: 16px;
  color: #999;
  margin-top: 4px;
  font-style: italic;
}

.detail-category {
  display: inline-block;
  margin-top: 12px;
  padding: 5px 15px;
  border: 1px solid var(--detail-color, #ffd700);
  border-radius: 15px;
  font-size: 12px;
  color: var(--detail-color, #ffd700);
  letter-spacing: 2px;
}

.popup-close {
  position: absolute;
  top: 10px;
  right: 15px;
  background: none;
  border: none;
  color: #999;
  font-size: 24px;
  cursor: pointer;
  transition: color 0.3s;
}

.popup-close:hover {
  color: #ffd700;
}

.popup-close:focus-visible {
  outline: 2px solid #ffd700;
  outline-offset: 2px;
}

/* ============================================
   Game Over Screen
   ============================================ */
#gameOver {
  display: none;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(10px);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  z-index: 20;
  animation: fadeIn 0.5s;
}

.gameover-title {
  font-size: 64px;
  font-weight: bold;
  background: linear-gradient(to bottom, #ff4444, #cc0000);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 40px rgba(255, 68, 68, 0.5);
  letter-spacing: 10px;
  margin-bottom: 10px;
}

.level-complete-title {
  font-size: 48px;
  font-weight: bold;
  background: linear-gradient(135deg, #ffd700 0%, #ffec8b 50%, #b8860b 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 40px rgba(255, 215, 0, 0.5);
  letter-spacing: 8px;
  margin-bottom: 10px;
}

.level-complete-subtitle {
  font-size: 16px;
  color: #999;
  letter-spacing: 3px;
  margin-top: -10px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  margin: 20px 0;
  text-align: center;
}

.stat-box {
  background: rgba(255, 255, 255, 0.05);
  padding: 20px 30px;
  border-radius: 10px;
  border: 1px solid rgba(255, 215, 0, 0.2);
}

.stat-value {
  font-size: 32px;
  font-weight: bold;
  color: #ffd700;
  margin-bottom: 5px;
}

.stat-label {
  font-size: 12px;
  color: #999;
  letter-spacing: 2px;
}

.wrong-count-box {
  border-color: rgba(255, 107, 53, 0.3);
}

.wrong-count-box .stat-value {
  color: #ff6b35;
}

.action-buttons {
  display: flex;
  gap: 20px;
  margin-top: 20px;
}

.btn-action {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 90px;
  height: auto;
  padding: 15px 10px;
  border-radius: 12px;
  border: 2px solid rgba(255, 215, 0, 0.3);
  background: rgba(0, 0, 0, 0.6);
  color: #ffd700;
  cursor: pointer;
  transition: all 0.3s;
}

.btn-action:hover {
  background: rgba(255, 215, 0, 0.15);
  border-color: #ffd700;
  transform: translateY(-3px);
  box-shadow: 0 10px 30px rgba(255, 215, 0, 0.2);
}

.btn-action:focus-visible {
  outline: 2px solid #ffd700;
  outline-offset: 2px;
}

.action-icon {
  font-size: 28px;
}

.action-text {
  font-size: 12px;
  letter-spacing: 2px;
  color: #b8860b;
}

/* ============================================
   Modal Overlay
   ============================================ */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.show {
  display: flex;
}

.modal-box {
  background: rgba(25, 25, 25, 0.98);
  border: 2px solid #ffd700;
  border-radius: 20px;
  padding: 30px 35px;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 25px 80px rgba(0, 0, 0, 0.9), 0 0 60px rgba(255, 215, 0, 0.1);
  animation: modalSlideIn 0.3s ease-out;
}

.modal-title {
  font-size: 22px;
  font-weight: bold;
  color: #ffd700;
  margin-bottom: 15px;
  letter-spacing: 3px;
  text-align: center;
}

.modal-content {
  font-size: 14px;
  color: #ccc;
  line-height: 1.8;
  margin-bottom: 20px;
  text-align: center;
  white-space: pre-line;
}

.modal-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.modal-btn {
  height: 44px;
  border: 2px solid rgba(255, 215, 0, 0.3);
  background: rgba(0, 0, 0, 0.6);
  color: #ffd700;
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s;
  letter-spacing: 2px;
  border-radius: 8px;
  flex: 1;
  max-width: 150px;
}

.modal-btn:hover {
  background: rgba(255, 215, 0, 0.15);
  border-color: #ffd700;
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(255, 215, 0, 0.2);
}

.modal-btn:focus-visible {
  outline: 2px solid #ffd700;
  outline-offset: 2px;
}

.modal-btn-secondary {
  border-color: rgba(255, 255, 255, 0.2);
  color: #999;
}

.modal-btn-secondary:hover {
  border-color: #ccc;
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.modal-btn-danger {
  border-color: rgba(255, 68, 68, 0.4);
  color: #ff6b6b;
}

.modal-btn-danger:hover {
  border-color: #ff4444;
  background: rgba(255, 68, 68, 0.15);
}

/* ============================================
   Player Name
   ============================================ */
.player-name {
  font-size: 14px;
  color: #999;
  letter-spacing: 2px;
  margin-bottom: 8px;
}

/* ============================================
   Leaderboard
   ============================================ */
.leaderboard-box {
  max-width: 420px;
  width: 90%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.leaderboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

.leaderboard-header .modal-title {
  margin-bottom: 0;
  text-align: left;
}

.leaderboard-header .popup-close {
  position: static;
  width: 36px;
  height: 36px;
  font-size: 24px;
  line-height: 36px;
  background: none;
  border: none;
  color: #888;
  cursor: pointer;
  transition: color 0.3s;
}

.leaderboard-header .popup-close:hover {
  color: #ffd700;
}

.leaderboard-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 15px;
  justify-content: center;
}

.leaderboard-tab {
  padding: 6px 16px;
  border: 1px solid rgba(255, 215, 0, 0.2);
  background: rgba(0, 0, 0, 0.4);
  color: #999;
  border-radius: 20px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.3s;
  letter-spacing: 1px;
}

.leaderboard-tab.active {
  border-color: #ffd700;
  color: #ffd700;
  background: rgba(255, 215, 0, 0.1);
}

.leaderboard-tab:hover:not(.active) {
  border-color: rgba(255, 215, 0, 0.4);
  color: #ccc;
}

.leaderboard-my-rank {
  margin-bottom: 12px;
  text-align: center;
}

.my-rank-info {
  font-size: 13px;
  color: #bbb;
  letter-spacing: 1px;
  padding: 8px 12px;
  background: rgba(255, 215, 0, 0.05);
  border: 1px solid rgba(255, 215, 0, 0.15);
  border-radius: 8px;
}

.my-rank-info strong {
  color: #ffd700;
}

.leaderboard-list {
  flex: 1;
  overflow-y: auto;
  min-height: 120px;
}

.leaderboard-items {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.leaderboard-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: rgba(30, 30, 30, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  transition: all 0.2s;
}

.leaderboard-item:hover {
  background: rgba(40, 40, 40, 0.7);
  border-color: rgba(255, 215, 0, 0.15);
}

.leaderboard-rank {
  width: 28px;
  text-align: center;
  font-size: 16px;
  font-weight: bold;
  color: #888;
}

.leaderboard-item.top-1 .leaderboard-rank {
  color: #ffd700;
}

.leaderboard-item.top-2 .leaderboard-rank {
  color: #c0c0c0;
}

.leaderboard-item.top-3 .leaderboard-rank {
  color: #cd7f32;
}

.leaderboard-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.3);
}

.leaderboard-info {
  flex: 1;
  min-width: 0;
}

.leaderboard-nickname {
  font-size: 14px;
  color: #ddd;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.leaderboard-score {
  font-size: 16px;
  font-weight: bold;
  color: #ffd700;
  min-width: 50px;
  text-align: right;
}

.leaderboard-empty {
  text-align: center;
  padding: 40px 20px;
  color: #777;
  font-size: 14px;
  letter-spacing: 1px;
}

.leaderboard-loading {
  text-align: center;
  padding: 30px;
  color: #999;
  font-size: 14px;
  letter-spacing: 2px;
}

/* ============================================
   Responsive Design
   ============================================ */
@media (max-height: 700px) {
  .center-display {
    width: 110px;
    height: 110px;
    font-size: 40px;
  }
  .center-orbit {
    width: 120px;
    height: 120px;
  }
  .option-wrapper {
    width: 60px;
    height: 60px;
    margin-left: -30px;
    margin-top: -30px;
  }
  .option-inner {
    width: 60px;
    height: 60px;
    font-size: 18px;
  }
  .orbit-container {
    width: 280px;
    height: 280px;
  }
  .game-title {
    font-size: 40px;
  }
  .timer-bar {
    top: 135px;
    width: 250px;
  }
  .timer-text {
    top: 147px;
  }
  .mode-badge {
    top: 95px;
    font-size: 12px;
  }
  .progress-indicator {
    top: 95px;
  }
}

@media (max-width: 480px) {
  #menu {
    padding: 25px 20px;
  }
  .game-title {
    font-size: 36px;
    letter-spacing: 8px;
  }
  .game-title::after {
    font-size: 12px;
    letter-spacing: 4px;
    bottom: -20px;
  }
  .difficulty-grid {
    max-width: 300px;
  }
  .btn-collection {
    max-width: 300px;
  }
  .collection-grid {
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    padding: 15px;
  }
  .mode-badge {
    font-size: 12px;
    letter-spacing: 2px;
    left: 15px;
  }
}

/* --- Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  #bgCanvas,
  #particleCanvas {
    display: none;
  }
}

/* ============================================
   Accessibility Enhancements
   ============================================ */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Focus ring for keyboard navigation */
*:focus-visible {
  outline: 2px solid #ffd700;
  outline-offset: 2px;
}

/* High contrast mode support */
@media (forced-colors: active) {
  .btn,
  .mode-tab,
  .filter-tag,
  .element-card,
  .modal-btn,
  .btn-action,
  .btn-back,
  .sound-toggle,
  .pause-btn {
    border: 2px solid ButtonText;
  }
  .option-inner {
    border: 2px solid ButtonText;
  }
}
