/* ============================================
   MiniGame 共用遊戲樣式 v1.0
   所有遊戲引用: <link rel="stylesheet" href="../assets/css/game-common.css">
   ============================================ */

/* Reset */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

/* Base */
body {
  background: linear-gradient(135deg, #0a0f1e 0%, #1a1a2e 40%, #16213e 100%);
  color: #e2e8f0;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 16px 80px;
  user-select: none;
  -webkit-user-select: none;
  overflow-x: hidden;
}

/* Game Title */
.game-title {
  font-size: 1.8rem;
  font-weight: 800;
  text-align: center;
  margin-bottom: 8px;
  background: linear-gradient(135deg, #00e5a0, #00d4ff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: none;
  filter: drop-shadow(0 0 20px rgba(0,229,160,0.3));
}

.game-subtitle {
  color: #64748b;
  font-size: 0.85rem;
  text-align: center;
  margin-bottom: 12px;
}

/* Score Board */
.score-board {
  display: flex;
  gap: 16px;
  margin-bottom: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.score-box {
  background: rgba(0, 212, 255, 0.1);
  border: 1px solid rgba(0, 212, 255, 0.3);
  border-radius: 12px;
  padding: 6px 18px;
  text-align: center;
  min-width: 80px;
}

.score-box .label {
  display: block;
  font-size: 0.65rem;
  color: #00d4ff;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.score-box .value {
  font-size: 1.4rem;
  font-weight: 700;
  color: #ffd700;
  text-shadow: 0 0 10px rgba(255, 215, 0, 0.4);
}

/* Canvas Container */
.game-container {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 0 30px rgba(0, 229, 160, 0.15);
  border: 2px solid rgba(0, 229, 160, 0.2);
  margin: 8px 0;
}

.game-container canvas {
  display: block;
  background: #0d1117;
  touch-action: none;
}

/* Overlay (Menu / Game Over) */
.game-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 10;
  backdrop-filter: blur(4px);
  transition: opacity 0.3s;
}

.game-overlay.hidden { display: none; }

.game-overlay h2 {
  font-size: 1.8rem;
  margin-bottom: 12px;
  text-shadow: 0 0 20px currentColor;
}

.game-overlay p {
  color: #94a3b8;
  font-size: 0.95rem;
  margin-bottom: 6px;
}

.game-overlay .hint {
  color: #475569;
  font-size: 0.8rem;
  margin-top: 12px;
}

/* Buttons */
.btn {
  padding: 10px 28px;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: 25px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  font-family: inherit;
  margin: 4px;
}

.btn:active { transform: scale(0.95); }

.btn-primary {
  background: linear-gradient(135deg, #00e5a0, #00b87a);
  color: #0a0f1e;
  box-shadow: 0 4px 20px rgba(0, 229, 160, 0.4);
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 25px rgba(0, 229, 160, 0.6);
}

.btn-secondary {
  background: linear-gradient(135deg, #334155, #1e293b);
  color: #e2e8f0;
  border: 1px solid #475569;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}
.btn-secondary:hover {
  transform: translateY(-2px);
  border-color: #00e5a0;
}

.btn-danger {
  background: linear-gradient(135deg, #ef4444, #b91c1c);
  color: #fff;
  box-shadow: 0 4px 20px rgba(239, 68, 68, 0.4);
}

.btn-sm { padding: 6px 16px; font-size: 0.85rem; }
.btn-lg { padding: 14px 36px; font-size: 1.15rem; }

/* Button Row */
.btn-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  margin: 8px 0;
}

/* Difficulty Selector */
.difficulty-row {
  display: flex;
  gap: 8px;
  margin: 8px 0;
  justify-content: center;
}

.diff-btn {
  padding: 8px 20px;
  font-size: 0.85rem;
  border-radius: 20px;
  border: 1.5px solid #334155;
  background: #1e293b;
  color: #94a3b8;
  cursor: pointer;
  transition: all 0.15s;
}

.diff-btn:hover { border-color: #00e5a0; color: #e2e8f0; }

.diff-btn.active {
  background: rgba(0, 229, 160, 0.15);
  border-color: #00e5a0;
  color: #00e5a0;
}

/* Health Bar */
.health-bar-container {
  width: 100%;
  max-width: 200px;
  height: 16px;
  background: #1e293b;
  border-radius: 8px;
  border: 1px solid #334155;
  overflow: hidden;
  position: relative;
}

.health-bar-fill {
  height: 100%;
  border-radius: 8px;
  transition: width 0.3s;
  background: linear-gradient(90deg, #ef4444, #f97316, #22c55e);
}

/* Toast / Notification */
.game-toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(-100px);
  background: rgba(0, 229, 160, 0.9);
  color: #0a0f1e;
  padding: 10px 24px;
  border-radius: 25px;
  font-weight: 600;
  font-size: 0.9rem;
  z-index: 100;
  transition: transform 0.3s;
  box-shadow: 0 4px 20px rgba(0, 229, 160, 0.4);
}

.game-toast.show { transform: translateX(-50%) translateY(0); }

/* Mobile Controls */
.mobile-controls {
  display: none;
  margin-top: 12px;
  gap: 8px;
}

.mobile-controls button {
  width: 52px;
  height: 52px;
  font-size: 1.3rem;
  background: #1e293b;
  color: #00e5a0;
  border: 2px solid #00e5a0;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.1s;
}

.mobile-controls button:active {
  background: #00e5a0;
  color: #0a0f1e;
}

@media (pointer: coarse) {
  .mobile-controls {
    display: grid;
    grid-template-columns: repeat(3, 52px);
    grid-template-rows: repeat(2, 52px);
    justify-content: center;
  }
}

/* Instructions */
.game-instructions {
  margin-top: 12px;
  font-size: 0.78rem;
  color: #475569;
  text-align: center;
  max-width: 400px;
  line-height: 1.5;
}

.game-instructions strong { color: #00d4ff; }

/* AdSense Container */
.ad-container {
  text-align: center;
  max-width: 728px;
  margin: 12px auto;
  min-height: 50px;
}

/* Combo Text */
.combo-text {
  position: absolute;
  font-weight: 800;
  pointer-events: none;
  animation: comboFloat 0.8s ease-out forwards;
}

@keyframes comboFloat {
  0% { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-40px) scale(1.5); }
}

/* Achievement Badge */
.achievement {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: linear-gradient(135deg, #ffd700, #f59e0b);
  color: #0a0f1e;
  padding: 12px 20px;
  border-radius: 12px;
  font-weight: 600;
  z-index: 100;
  transform: translateX(300px);
  transition: transform 0.3s;
  box-shadow: 0 4px 20px rgba(255, 215, 0, 0.4);
}

.achievement.show { transform: translateX(0); }

/* Responsive */
@media (max-width: 480px) {
  .game-title { font-size: 1.4rem; }
  .score-box { padding: 4px 12px; min-width: 60px; }
  .score-box .value { font-size: 1.1rem; }
  .btn { padding: 8px 20px; font-size: 0.9rem; }
}

/* Back to Home Link */
.back-link {
  position: fixed;
  top: 12px;
  left: 12px;
  color: #64748b;
  text-decoration: none;
  font-size: 0.85rem;
  z-index: 50;
  padding: 4px 12px;
  border-radius: 8px;
  background: rgba(0,0,0,0.3);
  transition: color 0.15s;
}

.back-link:hover { color: #00e5a0; }
