/* ════════════════════════════════════════════════════════
   MATCH 3 DELUXE  –  Premium Stylesheet
   ════════════════════════════════════════════════════════ */

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

:root {
  --bg-deep:    #0a0615;
  --bg-cave:    #0f0a22;
  --gold:       #f0c040;
  --gold-light: #ffe080;
  --purple:     #7b3fa0;
  --accent:     #c060ff;
  --text:       #e8d8ff;
  --text-dim:   #a080c0;
  --modal-bg:   rgba(8,4,20,0.96);
  --modal-border: rgba(180,100,255,0.4);
  --btn-grad:   linear-gradient(135deg,#8020d0,#c060ff);
  --btn-sec:    linear-gradient(135deg,#2a1a40,#4a2a70);
  --shadow-gem: 0 0 24px rgba(180,100,255,0.6);
  --hud-h:      64px;
  --prog-h:     8px;
}

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg-deep);
  color: var(--text);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* ── OVERLAYS ─────────────────────────────────────────── */
.overlay {
  position: fixed; inset: 0;
  display: none;
  z-index: 10;
}
.overlay.active { display: flex; }

/* ── START SCREEN ─────────────────────────────────────── */
#start-screen {
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 50% 40%, #1a0840 0%, #08031a 70%);
  flex-direction: column;
}

#rain-canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
}

.start-content {
  position: relative; z-index: 2;
  display: flex; flex-direction: column;
  align-items: center; gap: 18px;
  padding: 32px 24px;
  text-align: center;
}

.game-title {
  line-height: 1;
  text-shadow: 0 0 40px rgba(180,80,255,0.8);
  letter-spacing: 2px;
}
.title-match {
  display: block;
  font-size: clamp(2.8rem, 8vw, 5.2rem);
  font-weight: 900;
  color: var(--gold-light);
  text-shadow: 0 0 20px rgba(240,192,64,0.9), 0 0 60px rgba(240,150,20,0.5);
  letter-spacing: 8px;
}
.title-3 {
  display: inline-block;
  font-size: clamp(5rem, 15vw, 10rem);
  font-weight: 900;
  background: linear-gradient(160deg, #fff 0%, #c080ff 40%, #7020d0 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 0.9;
  filter: drop-shadow(0 0 20px rgba(160,60,255,0.9));
}
.title-deluxe {
  display: block;
  font-size: clamp(1rem, 3vw, 1.8rem);
  letter-spacing: 12px;
  color: var(--accent);
  font-weight: 300;
  text-transform: uppercase;
  margin-top: -4px;
}

.subtitle {
  font-size: clamp(0.85rem, 2vw, 1.1rem);
  color: var(--text-dim);
  letter-spacing: 3px;
  text-transform: uppercase;
}

.gem-legend {
  margin-top: 8px;
  opacity: 0.85;
}

/* ── BUTTONS ──────────────────────────────────────────── */
.btn-primary {
  padding: 14px 48px;
  font-size: clamp(0.95rem, 2.5vw, 1.1rem);
  font-weight: 700;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: #fff;
  background: var(--btn-grad);
  border: none;
  border-radius: 40px;
  cursor: pointer;
  box-shadow: 0 0 24px rgba(160,60,255,0.6), 0 4px 16px rgba(0,0,0,0.5);
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
  position: relative; overflow: hidden;
}
.btn-primary::after {
  content: '';
  position: absolute; top: 0; left: -100%;
  width: 60%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.25), transparent);
  transform: skewX(-20deg);
  animation: btn-shine 3s infinite;
}
@keyframes btn-shine {
  0%   { left: -100%; }
  40%  { left: 160%; }
  100% { left: 160%; }
}
.btn-primary:hover  { transform: translateY(-2px); box-shadow: 0 0 36px rgba(180,80,255,0.8), 0 8px 24px rgba(0,0,0,0.5); filter: brightness(1.1); }
.btn-primary:active { transform: translateY(1px); filter: brightness(0.9); }

.btn-secondary {
  padding: 12px 36px;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text);
  background: var(--btn-sec);
  border: 1px solid rgba(180,100,255,0.3);
  border-radius: 40px;
  cursor: pointer;
  box-shadow: 0 2px 12px rgba(0,0,0,0.4);
  transition: transform 0.12s, filter 0.12s;
}
.btn-secondary:hover  { filter: brightness(1.15); transform: translateY(-1px); }
.btn-secondary:active { transform: translateY(1px); }

.icon-btn {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  font-size: 1.2rem;
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--text);
  transition: background 0.15s, transform 0.1s;
}
.icon-btn:hover  { background: rgba(255,255,255,0.16); }
.icon-btn:active { transform: scale(0.9); }

/* ── GAME SCREEN ──────────────────────────────────────── */
#game-screen {
  flex-direction: column;
  align-items: center;
  background: radial-gradient(ellipse at 50% 20%, #12062e 0%, #06020f 80%);
}

/* ── HUD ──────────────────────────────────────────────── */
#hud {
  width: 100%;
  max-width: 520px;
  height: var(--hud-h);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 12px;
  background: linear-gradient(180deg, rgba(20,8,50,0.95) 0%, rgba(12,4,30,0.9) 100%);
  border-bottom: 1px solid rgba(160,80,255,0.25);
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  flex-shrink: 0;
}

.hud-block {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
}

.hud-label {
  font-size: 0.55rem;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--text-dim);
  text-transform: uppercase;
}

.hud-value {
  font-size: clamp(1rem, 3vw, 1.35rem);
  font-weight: 900;
  color: var(--gold-light);
  text-shadow: 0 0 8px rgba(240,192,64,0.7);
  font-variant-numeric: tabular-nums;
  transition: transform 0.1s;
}
.hud-value.pop {
  animation: hud-pop 0.25s ease;
}
@keyframes hud-pop {
  0%   { transform: scale(1.4); color: #fff; }
  100% { transform: scale(1); }
}

.hud-controls {
  display: flex;
  gap: 6px;
  align-items: center;
  padding-left: 4px;
}

/* ── PROGRESS BAR ─────────────────────────────────────── */
#progress-wrap {
  width: 100%;
  max-width: 520px;
  height: var(--prog-h);
  flex-shrink: 0;
}
#progress-bar {
  width: 100%; height: 100%;
  background: rgba(255,255,255,0.07);
}
#progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #8020d0, #e060ff, #ffcc44);
  box-shadow: 0 0 8px rgba(220,100,255,0.8);
  transition: width 0.4s cubic-bezier(0.4,0,0.2,1);
}

/* ── CANVAS WRAP ──────────────────────────────────────── */
#canvas-wrap {
  flex: 1;
  width: 100%;
  max-width: 520px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 8px;
}

#game-canvas {
  display: block;
  border-radius: 12px;
  box-shadow: 0 0 60px rgba(120,40,200,0.5), 0 0 120px rgba(60,0,120,0.3);
  cursor: pointer;
  touch-action: none;
}

/* ── MODAL OVERLAYS ───────────────────────────────────── */
.modal-overlay {
  align-items: center;
  justify-content: center;
  background: rgba(4,0,12,0.75);
  backdrop-filter: blur(6px);
  z-index: 50;
}

.modal-box {
  background: var(--modal-bg);
  border: 1px solid var(--modal-border);
  border-radius: 20px;
  padding: 40px 48px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  box-shadow: 0 0 60px rgba(140,60,255,0.35), 0 20px 60px rgba(0,0,0,0.7);
  max-width: min(440px, 90vw);
  width: 100%;
  animation: modal-in 0.3s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes modal-in {
  from { transform: scale(0.8) translateY(20px); opacity: 0; }
  to   { transform: scale(1) translateY(0); opacity: 1; }
}

.modal-box h2 {
  font-size: clamp(1.5rem, 5vw, 2.2rem);
  font-weight: 900;
  letter-spacing: 4px;
  text-transform: uppercase;
}

.complete-title { color: var(--gold-light); text-shadow: 0 0 20px rgba(240,192,64,0.7); }
.over-title     { color: #ff6080; text-shadow: 0 0 20px rgba(255,80,100,0.6); }

.tally {
  width: 100%;
  display: flex; flex-direction: column; gap: 10px;
  border-top: 1px solid rgba(255,255,255,0.1);
  padding-top: 16px;
}
.tally-row {
  display: flex; justify-content: space-between;
  font-size: 1rem; color: var(--text-dim);
}
.tally-total {
  font-size: 1.15rem; font-weight: 700;
  color: var(--gold-light);
  border-top: 1px solid rgba(255,255,255,0.1);
  padding-top: 10px;
  margin-top: 4px;
}

/* ── RESPONSIVE ───────────────────────────────────────── */
@media (max-height: 640px) {
  :root { --hud-h: 52px; }
  .modal-box { padding: 28px 32px; gap: 14px; }
}
@media (max-width: 360px) {
  .hud-label { font-size: 0.48rem; }
  .hud-controls .icon-btn { width: 32px; height: 32px; font-size: 1rem; }
}
