/* =====================================================
   ROPE HERO SWING — Ultra Premium CSS
   ===================================================== */

@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&family=Inter:wght@300;400;600;700&display=swap');

:root {
  --primary: #00d4ff;
  --secondary: #ff6b35;
  --accent: #a855f7;
  --gold: #ffd700;
  --danger: #ff3b3b;
  --success: #00ff88;
  --bg-dark: #0a0a1a;
  --bg-mid: #0d1233;
  --panel-bg: rgba(10, 15, 40, 0.85);
  --glass: rgba(255,255,255,0.06);
  --glass-border: rgba(255,255,255,0.12);
  --shadow-blue: 0 0 30px rgba(0,212,255,0.4);
  --shadow-purple: 0 0 30px rgba(168,85,247,0.4);
  --font-game: 'Orbitron', sans-serif;
  --font-ui: 'Inter', sans-serif;
  --ui-h: 70px;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--bg-dark);
  font-family: var(--font-ui);
  user-select: none;
}

/* ─── Canvas ─────────────────────────────────────── */
#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  background: transparent;
  image-rendering: auto;
  will-change: transform;
}

/* ─── Screens ─────────────────────────────────────── */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 100;
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.screen.hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.96);
}

/* ─── Start / Title Screen ────────────────────────── */
#startScreen {
  background: radial-gradient(ellipse at 30% 20%, #1a0a3e 0%, #0a0a1a 50%, #001a33 100%);
  background-image: linear-gradient(rgba(10, 10, 26, 0.7), rgba(10, 10, 26, 0.9)), url("../assets/images/thumbnail.png");
  background-size: cover;
  background-position: center;
}

.thumbnail-bg {
  display: none;
}

.city-silhouette {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 45%;
  background: 
    linear-gradient(to top, #0a0a1a 0%, transparent 100%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1400 300'%3E%3Crect x='0' y='80' width='60' height='220' fill='%230d1a3a'/%3E%3Crect x='20' y='40' width='20' height='40' fill='%230d1a3a'/%3E%3Crect x='70' y='120' width='80' height='180' fill='%23111f44'/%3E%3Crect x='160' y='60' width='50' height='240' fill='%230d1a3a'/%3E%3Crect x='170' y='20' width='30' height='40' fill='%230d1a3a'/%3E%3Crect x='220' y='100' width='70' height='200' fill='%23111f44'/%3E%3Crect x='300' y='140' width='90' height='160' fill='%230d1a3a'/%3E%3Crect x='400' y='50' width='60' height='250' fill='%23111f44'/%3E%3Crect x='420' y='10' width='20' height='40' fill='%23111f44'/%3E%3Crect x='470' y='110' width='80' height='190' fill='%230d1a3a'/%3E%3Crect x='560' y='70' width='55' height='230' fill='%23111f44'/%3E%3Crect x='625' y='130' width='75' height='170' fill='%230d1a3a'/%3E%3Crect x='710' y='45' width='65' height='255' fill='%23111f44'/%3E%3Crect x='720' y='5' width='25' height='40' fill='%23111f44'/%3E%3Crect x='785' y='90' width='85' height='210' fill='%230d1a3a'/%3E%3Crect x='880' y='120' width='60' height='180' fill='%23111f44'/%3E%3Crect x='950' y='55' width='70' height='245' fill='%230d1a3a'/%3E%3Crect x='960' y='15' width='30' height='40' fill='%230d1a3a'/%3E%3Crect x='1030' y='95' width='80' height='205' fill='%23111f44'/%3E%3Crect x='1120' y='65' width='55' height='235' fill='%230d1a3a'/%3E%3Crect x='1185' y='135' width='70' height='165' fill='%23111f44'/%3E%3Crect x='1265' y='50' width='60' height='250' fill='%230d1a3a'/%3E%3Crect x='1335' y='110' width='65' height='190' fill='%23111f44'/%3E%3C/svg%3E") bottom center / cover no-repeat;
}

.start-content {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  max-width: 520px;
  padding: 40px 20px;
  text-align: center;
}

.game-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  animation: float 3s ease-in-out infinite;
}

.logo-icon {
  width: 120px;
  height: 120px;
  background: url("../assets/icons/icon.png") center/cover;
  border-radius: 20%;
  border: 4px solid var(--primary);
  box-shadow: 0 0 30px var(--primary);
  filter: drop-shadow(0 0 20px #00d4ff);
  animation: pulse-glow 2s ease-in-out infinite;
}

.logo-title {
  font-family: var(--font-game);
  font-size: clamp(28px, 6vw, 52px);
  font-weight: 900;
  letter-spacing: 3px;
  background: linear-gradient(135deg, #00d4ff 0%, #a855f7 50%, #ff6b35 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: none;
  filter: drop-shadow(0 0 20px rgba(0,212,255,0.5));
}

.logo-subtitle {
  font-family: var(--font-game);
  font-size: clamp(10px, 2vw, 13px);
  letter-spacing: 6px;
  color: rgba(0,212,255,0.7);
  text-transform: uppercase;
}

.start-stats {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  justify-content: center;
}

.stat-badge {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 10px 18px;
  backdrop-filter: blur(10px);
  font-size: 12px;
  color: rgba(255,255,255,0.7);
  display: flex;
  align-items: center;
  gap: 6px;
}

.stat-badge .icon { font-size: 16px; }
.stat-badge .value { font-family: var(--font-game); color: var(--primary); font-weight: 700; }

.btn-primary {
  font-family: var(--font-game);
  font-size: clamp(14px, 3vw, 18px);
  font-weight: 700;
  letter-spacing: 3px;
  color: #000;
  background: linear-gradient(135deg, #00d4ff, #0099cc);
  border: none;
  border-radius: 50px;
  padding: 18px 52px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  box-shadow: 0 0 30px rgba(0,212,255,0.5), 0 8px 32px rgba(0,0,0,0.4);
  transition: transform 0.2s, box-shadow 0.2s;
  min-width: 220px;
  text-transform: uppercase;
}

.btn-primary::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(45deg, transparent, rgba(255,255,255,0.3), transparent);
  transform: rotate(45deg) translateX(-100%);
  transition: transform 0.6s;
}

.btn-primary:hover::before { transform: rotate(45deg) translateX(100%); }
.btn-primary:hover { transform: translateY(-3px) scale(1.02); box-shadow: 0 0 50px rgba(0,212,255,0.7), 0 12px 40px rgba(0,0,0,0.5); }
.btn-primary:active { transform: translateY(0) scale(0.98); }

.btn-secondary {
  font-family: var(--font-game);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 2px;
  color: rgba(255,255,255,0.6);
  background: transparent;
  border: 1px solid var(--glass-border);
  border-radius: 50px;
  padding: 12px 32px;
  cursor: pointer;
  transition: all 0.2s;
  text-transform: uppercase;
}

.btn-secondary:hover { color: #fff; border-color: rgba(0,212,255,0.4); background: var(--glass); }

/* ─── Tutorial Screen ─────────────────────────────── */
#tutorialScreen {
  background: radial-gradient(ellipse at center, #0d1233 0%, #0a0a1a 100%);
}

.tutorial-card {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  padding: 40px 36px;
  max-width: 480px;
  width: 90%;
  backdrop-filter: blur(20px);
  box-shadow: 0 0 60px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,255,255,0.1);
}

.tutorial-title {
  font-family: var(--font-game);
  font-size: clamp(18px, 4vw, 24px);
  font-weight: 900;
  color: var(--primary);
  text-align: center;
  margin-bottom: 28px;
  letter-spacing: 2px;
}

.tutorial-steps {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 28px;
}

.tutorial-step {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 14px 16px;
  background: rgba(255,255,255,0.04);
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.06);
  animation: slideInLeft 0.4s ease both;
}

.step-icon {
  font-size: 28px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,212,255,0.1);
  border-radius: 12px;
  flex-shrink: 0;
}

.step-text h4 { font-size: 14px; font-weight: 700; color: #fff; margin-bottom: 4px; }
.step-text p { font-size: 12px; color: rgba(255,255,255,0.55); line-height: 1.5; }

.tutorial-step:nth-child(1) { animation-delay: 0.1s; }
.tutorial-step:nth-child(2) { animation-delay: 0.2s; }
.tutorial-step:nth-child(3) { animation-delay: 0.3s; }
.tutorial-step:nth-child(4) { animation-delay: 0.4s; }

/* ─── Level Select ────────────────────────────────── */
#levelScreen {
  background: radial-gradient(ellipse at center, #0d1233 0%, #0a0a1a 100%);
  overflow-y: auto;
}

.level-screen-inner {
  width: 100%;
  max-width: 680px;
  padding: 30px 16px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

.screen-title {
  font-family: var(--font-game);
  font-size: clamp(20px, 5vw, 32px);
  font-weight: 900;
  color: var(--primary);
  letter-spacing: 3px;
  text-align: center;
}

.level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 12px;
  width: 100%;
}

.level-btn {
  aspect-ratio: 1;
  border-radius: 16px;
  border: 1px solid var(--glass-border);
  background: var(--glass);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  backdrop-filter: blur(10px);
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}

.level-btn.locked { opacity: 0.4; cursor: not-allowed; }
.level-btn.completed { border-color: rgba(0,255,136,0.4); }
.level-btn.current { border-color: rgba(0,212,255,0.6); box-shadow: 0 0 20px rgba(0,212,255,0.3); }

.level-btn:not(.locked):hover {
  transform: translateY(-3px);
  border-color: rgba(0,212,255,0.5);
  box-shadow: 0 8px 24px rgba(0,212,255,0.2);
}

.level-num {
  font-family: var(--font-game);
  font-size: 20px;
  font-weight: 900;
  color: #fff;
}

.level-stars { display: flex; gap: 2px; font-size: 10px; }
.level-stars .star { color: rgba(255,255,255,0.2); }
.level-stars .star.lit { color: var(--gold); filter: drop-shadow(0 0 4px #ffd700); }

.level-lock { font-size: 22px; color: rgba(255,255,255,0.3); }

/* ─── HUD ─────────────────────────────────────────── */
#hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--ui-h);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: linear-gradient(to bottom, rgba(5,5,20,0.95) 0%, transparent 100%);
  pointer-events: none;
}

#hud.hidden { display: none; }

.hud-left, .hud-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

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

.hud-panel {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  padding: 8px 14px;
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
  will-change: transform;
  transition: transform 0.2s;
}

.hud-panel .label {
  font-size: 9px;
  font-family: var(--font-game);
  letter-spacing: 1px;
  color: rgba(255,255,255,0.4);
  text-transform: uppercase;
}

.hud-panel .value {
  font-family: var(--font-game);
  font-size: 16px;
  font-weight: 700;
  color: #fff;
}

.hud-panel .value.score { color: var(--gold); }
.hud-panel .value.combo { color: var(--secondary); }
.hud-panel .value.speed { color: var(--primary); }

.level-indicator {
  font-family: var(--font-game);
  font-size: clamp(10px, 2vw, 13px);
  font-weight: 700;
  color: rgba(255,255,255,0.5);
  letter-spacing: 2px;
}

.progress-bar-wrap {
  width: 160px;
  height: 6px;
  background: rgba(255,255,255,0.1);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 3px;
  transition: width 0.3s ease;
}

.hud-btn {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid var(--glass-border);
  background: var(--glass);
  color: rgba(255,255,255,0.7);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  backdrop-filter: blur(10px);
  transition: all 0.2s;
  pointer-events: auto;
}

.hud-btn:hover { background: rgba(255,255,255,0.12); color: #fff; }

/* ─── Combo Banner ────────────────────────────────── */
#comboBanner {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  font-family: var(--font-game);
  font-size: clamp(22px, 5vw, 38px);
  font-weight: 900;
  letter-spacing: 4px;
  text-align: center;
  background: linear-gradient(135deg, #ff6b35, #ffd700);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 0 20px rgba(255,107,53,0.8));
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
}

#comboBanner.show { opacity: 1; animation: comboAnim 0.5s ease; }

/* ─── Pause Screen ────────────────────────────────── */
#pauseScreen {
  background: rgba(5, 5, 20, 0.88);
  backdrop-filter: blur(20px);
}

.pause-card {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 28px;
  padding: 48px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  min-width: 300px;
  box-shadow: 0 0 80px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,255,255,0.1);
}

.pause-title {
  font-family: var(--font-game);
  font-size: 28px;
  font-weight: 900;
  color: var(--primary);
  letter-spacing: 4px;
}

.pause-menu { display: flex; flex-direction: column; gap: 14px; width: 100%; }

.pause-btn {
  font-family: var(--font-game);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 2px;
  padding: 15px 30px;
  border-radius: 14px;
  border: 1px solid var(--glass-border);
  background: var(--glass);
  color: rgba(255,255,255,0.85);
  cursor: pointer;
  transition: all 0.2s;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.pause-btn:hover { background: rgba(0,212,255,0.1); border-color: rgba(0,212,255,0.4); color: #fff; transform: translateX(4px); }
.pause-btn.resume { background: rgba(0,212,255,0.15); border-color: rgba(0,212,255,0.5); color: var(--primary); }
.pause-btn.resume:hover { background: rgba(0,212,255,0.25); }

/* ─── Level Complete ──────────────────────────────── */
#levelCompleteScreen {
  background: rgba(5, 5, 20, 0.9);
  backdrop-filter: blur(20px);
}

.level-complete-card {
  background: var(--glass);
  border: 1px solid rgba(0,255,136,0.3);
  border-radius: 28px;
  padding: 48px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  min-width: 320px;
  box-shadow: 0 0 80px rgba(0,255,136,0.15), inset 0 1px 0 rgba(255,255,255,0.1);
}

.complete-badge { font-size: 64px; animation: popIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1); }
.complete-title {
  font-family: var(--font-game);
  font-size: clamp(18px, 4vw, 28px);
  font-weight: 900;
  color: var(--success);
  letter-spacing: 3px;
}

.results-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  width: 100%;
}

.result-item {
  background: rgba(255,255,255,0.04);
  border-radius: 14px;
  padding: 14px;
  text-align: center;
}

.result-item .r-label { font-size: 10px; color: rgba(255,255,255,0.4); font-family: var(--font-game); letter-spacing: 1px; margin-bottom: 6px; }
.result-item .r-value { font-family: var(--font-game); font-size: 20px; font-weight: 700; color: #fff; }
.result-item.gold .r-value { color: var(--gold); }
.result-item.cyan .r-value { color: var(--primary); }

.stars-row { display: flex; gap: 12px; justify-content: center; }
.star-big { font-size: 42px; opacity: 0.2; transition: all 0.3s; }
.star-big.lit {
  opacity: 1;
  color: var(--gold);
  filter: drop-shadow(0 0 10px #ffd700);
  animation: starPop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.star-big:nth-child(1) { animation-delay: 0.3s; }
.star-big:nth-child(2) { animation-delay: 0.5s; }
.star-big:nth-child(3) { animation-delay: 0.7s; }

/* ─── Game Over Screen ────────────────────────────── */
#gameOverScreen { background: rgba(5,5,20,0.92); backdrop-filter: blur(20px); }

.game-over-card {
  background: var(--glass);
  border: 1px solid rgba(255,59,59,0.3);
  border-radius: 28px;
  padding: 48px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  min-width: 300px;
  box-shadow: 0 0 80px rgba(255,59,59,0.15);
}

.go-title {
  font-family: var(--font-game);
  font-size: clamp(20px, 5vw, 32px);
  font-weight: 900;
  color: var(--danger);
  letter-spacing: 4px;
}

/* ─── Mobile Controls ─────────────────────────────── */
#mobileControls {
  position: fixed;
  bottom: 20px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 20px;
  pointer-events: none;
  z-index: 50;
}

#mobileControls.hidden { display: none; }

.swing-btn {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  border: 2px solid rgba(0,212,255,0.5);
  background: rgba(0,212,255,0.08);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  cursor: pointer;
  pointer-events: auto;
  transition: all 0.15s;
  box-shadow: 0 0 20px rgba(0,212,255,0.2);
  -webkit-tap-highlight-color: transparent;
}

.swing-btn:active {
  background: rgba(0,212,255,0.25);
  border-color: rgba(0,212,255,0.9);
  box-shadow: 0 0 40px rgba(0,212,255,0.5);
  transform: scale(0.95);
}

.swing-hint {
  font-family: var(--font-game);
  font-size: 10px;
  color: rgba(255,255,255,0.3);
  letter-spacing: 1px;
  text-align: center;
}

/* ─── Speed Lines Overlay ─────────────────────────── */
#speedLines {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  opacity: 0;
  transition: opacity 0.3s;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(0,212,255,0.06) 100%);
}

/* ─── Animations ─────────────────────────────────── */
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-12px); }
}

@keyframes pulse-glow {
  0%, 100% { filter: drop-shadow(0 0 20px #00d4ff); }
  50% { filter: drop-shadow(0 0 40px #00d4ff) drop-shadow(0 0 60px #a855f7); }
}

@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-20px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes popIn {
  from { transform: scale(0) rotate(-20deg); opacity: 0; }
  to { transform: scale(1) rotate(0deg); opacity: 1; }
}

@keyframes comboAnim {
  0% { transform: translateX(-50%) scale(0.5); }
  50% { transform: translateX(-50%) scale(1.1); }
  100% { transform: translateX(-50%) scale(1); }
}

@keyframes starPop {
  from { transform: scale(0); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* ─── Scrollbar ───────────────────────────────────── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,212,255,0.3); border-radius: 2px; }

/* ─── Responsive ──────────────────────────────────── */
@media (max-width: 640px) {
  :root { --ui-h: 52px; }
  .hud-panel { padding: 6px 10px; gap: 8px; }
  .hud-panel .label { font-size: 8px; }
  .hud-panel .value { font-size: 14px; }
  .level-grid { grid-template-columns: repeat(4, 1fr); padding: 10px; gap: 10px; }
  .level-btn { width: 55px; height: 55px; border-radius: 12px; }
  .logo-title { font-size: 38px; }
  .logo-icon { width: 90px; height: 90px; }
}

@media (max-width: 400px) {
  .level-grid { grid-template-columns: repeat(3, 1fr); }
  .hud-center { display: none; } /* Hide progress bar on super narrow if needed, but we'll try to keep it */
}

@media (min-width: 1024px) {
  #mobileControls { display: none !important; }
}

/* ─── Toast / Notification ────────────────────────── */
#toast {
  position: fixed;
  bottom: 120px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  background: rgba(0,0,0,0.8);
  border: 1px solid var(--glass-border);
  border-radius: 50px;
  padding: 12px 28px;
  font-family: var(--font-game);
  font-size: 13px;
  color: #fff;
  letter-spacing: 1px;
  backdrop-filter: blur(12px);
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
  white-space: nowrap;
}

#toast.show { opacity: 1; }
