/* =========================================================
   GOLD DIGGER — style.css
   Modern, colorful, cartoon arcade UI.
   ========================================================= */

:root {
  --gold: #ffd700;
  --gold-dark: #b8860b;
  --gold-light: #fff2a8;
  --bg-dark: #1a1030;
  --bg-mid: #2a1a3e;
  --bg-brown: #3d2a1a;
  --accent: #ff4d6d;
  --accent2: #29b6f6;
  --green: #3ddc84;
  --panel: rgba(30, 20, 50, 0.92);
  --panel-border: rgba(255, 215, 0, 0.35);
  --text: #fff8e7;
  --text-dim: #c9b8a0;
  --radius: 16px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg-dark);
  color: var(--text);
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

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

/* ---------- Screens ---------- */
.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  overflow: hidden;
}
.screen.active { display: flex; }
.screen.overlay {
  background: rgba(10, 5, 20, 0.75);
  backdrop-filter: blur(6px);
  align-items: center;
  justify-content: center;
  z-index: 50;
}

/* ---------- Main Menu ---------- */
#screen-menu { align-items: center; justify-content: center; }

.menu-bg {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, #1a1030 0%, #2a1a3e 45%, #3d2a1a 100%);
  overflow: hidden;
}
.mine-layer {
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 20% 80%, rgba(255,215,0,0.08) 0, transparent 30%),
    radial-gradient(circle at 80% 70%, rgba(255,215,0,0.06) 0, transparent 25%),
    radial-gradient(circle at 50% 95%, rgba(255,215,0,0.1) 0, transparent 40%);
  animation: minePulse 6s ease-in-out infinite;
}
@keyframes minePulse {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}
.floating-coins { position: absolute; inset: 0; pointer-events: none; }
.floating-coins span {
  position: absolute;
  font-size: 28px;
  opacity: 0.5;
  animation: floatUp 9s linear infinite;
}
.floating-coins span:nth-child(1) { left: 10%; animation-delay: 0s; }
.floating-coins span:nth-child(2) { left: 30%; animation-delay: 2s; }
.floating-coins span:nth-child(3) { left: 55%; animation-delay: 4s; }
.floating-coins span:nth-child(4) { left: 75%; animation-delay: 1s; }
.floating-coins span:nth-child(5) { left: 90%; animation-delay: 3s; }
@keyframes floatUp {
  0% { transform: translateY(110vh) rotate(0deg); opacity: 0; }
  10% { opacity: 0.6; }
  90% { opacity: 0.6; }
  100% { transform: translateY(-10vh) rotate(360deg); opacity: 0; }
}

.menu-content {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  padding: 24px;
  width: 100%;
  max-width: 460px;
}

.game-title {
  text-align: center;
  line-height: 0.95;
  font-size: clamp(42px, 12vw, 72px);
  font-weight: 900;
  letter-spacing: 2px;
  filter: drop-shadow(0 6px 0 rgba(0,0,0,0.4));
}
.title-gold {
  display: block;
  background: linear-gradient(180deg, #fff2a8, #ffd700 45%, #b8860b);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: shine 3s ease-in-out infinite;
}
.title-digger {
  display: block;
  color: #fff;
  text-shadow: 0 3px 0 #7a4a00, 0 6px 12px rgba(0,0,0,0.5);
}
@keyframes shine {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.25); }
}
.tagline {
  color: var(--text-dim);
  font-size: 15px;
  letter-spacing: 3px;
  text-transform: uppercase;
  margin-bottom: 6px;
}

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

/* ---------- Buttons ---------- */
.btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 1px;
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.12s ease, box-shadow 0.12s;
  color: #fff;
  text-transform: uppercase;
}
.btn:active { transform: scale(0.96); }
.btn-icon { font-size: 20px; }
.btn-label { flex: 1; text-align: left; }
.btn-sub {
  font-size: 12px;
  font-weight: 600;
  opacity: 0.85;
  background: rgba(0,0,0,0.25);
  padding: 3px 8px;
  border-radius: 8px;
}
.btn-primary {
  background: linear-gradient(180deg, #ffd700, #f0a500);
  color: #3a2500;
  box-shadow: 0 5px 0 #a06e00, 0 8px 20px rgba(255,215,0,0.35);
}
.btn-primary:active { box-shadow: 0 2px 0 #a06e00; }
.btn-secondary {
  background: linear-gradient(180deg, #4a3a6a, #33254d);
  box-shadow: 0 4px 0 #1e1430, 0 6px 16px rgba(0,0,0,0.4);
  border: 1px solid rgba(255,255,255,0.08);
}
.btn-secondary:active { box-shadow: 0 1px 0 #1e1430; }
.btn-danger {
  background: linear-gradient(180deg, #ff5c7a, #d32f4a);
  box-shadow: 0 4px 0 #8e1f33;
}
.btn-lg { padding: 18px 22px; font-size: 20px; }
.btn-block { width: 100%; margin-top: 10px; }
.btn-icon-only {
  width: 52px; height: 52px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(180deg, #4a3a6a, #33254d);
  color: #fff;
  font-size: 22px;
  cursor: pointer;
  box-shadow: 0 4px 0 #1e1430;
}
.btn-icon-only:active { transform: scale(0.94); }
.btn-back {
  width: 42px; height: 42px;
  border-radius: 12px;
  border: none;
  background: rgba(255,255,255,0.1);
  color: #fff;
  font-size: 22px;
  cursor: pointer;
}
.btn-back:active { transform: scale(0.94); }

.badge {
  position: absolute;
  top: -6px; right: -6px;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  width: 22px; height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: pulse 1.2s infinite;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

.coin-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0,0,0,0.35);
  padding: 8px 16px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 18px;
  border: 1px solid var(--panel-border);
}
.coin-bar.small { font-size: 15px; padding: 6px 12px; }
.coin-icon { font-size: 20px; }
.coin-value { color: var(--gold); }

/* ---------- Game screen ---------- */
#screen-game { background: #0d0818; }
.game-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}
#game-canvas {
  display: block;
  width: 100%;
  flex: 1;
  touch-action: none;
}

.hud {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  z-index: 10;
  pointer-events: none;
}
.hud-left, .hud-right { display: flex; flex-direction: column; gap: 2px; }
.hud-right { align-items: flex-end; }
.hud-chip {
  background: rgba(0,0,0,0.5);
  border: 1px solid var(--panel-border);
  padding: 6px 14px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 15px;
  color: var(--gold);
}
.hud-timer {
  font-size: 30px;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 2px 8px rgba(0,0,0,0.6);
  background: rgba(0,0,0,0.45);
  padding: 4px 20px;
  border-radius: 999px;
  border: 2px solid var(--panel-border);
  transition: color 0.2s;
}
.hud-timer.low { color: #ff5252; animation: pulse 0.6s infinite; }
.hud-money {
  font-size: 22px;
  font-weight: 900;
  color: var(--gold);
  text-shadow: 0 2px 6px rgba(0,0,0,0.6);
}
.hud-target { font-size: 12px; color: var(--text-dim); font-weight: 700; }

.hud-progress {
  position: absolute;
  top: 62px; left: 14px; right: 14px;
  height: 8px;
  background: rgba(0,0,0,0.5);
  border-radius: 999px;
  overflow: hidden;
  z-index: 10;
}
.hud-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #ffd700, #ff8f00);
  border-radius: 999px;
  transition: width 0.25s ease;
  box-shadow: 0 0 10px rgba(255,215,0,0.6);
}

.game-controls {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  z-index: 10;
  gap: 10px;
}
.powerup-bar { display: flex; gap: 8px; flex-wrap: wrap; }
.pu-btn {
  position: relative;
  width: 50px; height: 50px;
  border-radius: 14px;
  border: 2px solid rgba(255,255,255,0.15);
  background: linear-gradient(180deg, #4a3a6a, #2a1a3e);
  font-size: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s, box-shadow 0.15s;
}
.pu-btn:active { transform: scale(0.92); }
.pu-btn.empty { opacity: 0.45; }
.pu-btn.active {
  border-color: var(--gold);
  box-shadow: 0 0 16px rgba(255,215,0,0.7);
  animation: pulse 0.8s infinite;
}
.pu-count {
  position: absolute;
  bottom: -4px; right: -4px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  min-width: 18px; height: 18px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

/* ---------- Panels (levels/shop/daily/lb/settings) ---------- */
.panel {
  width: 100%;
  height: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 16px;
  overflow-y: auto;
  background: linear-gradient(180deg, #1a1030, #241636);
}
.panel-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  position: sticky;
  top: 0;
  background: linear-gradient(180deg, #1a1030, rgba(26,16,48,0.9));
  padding: 6px 0;
  z-index: 5;
}
.panel-header h2 { flex: 1; font-size: 22px; }
.panel-sub { color: var(--text-dim); margin-bottom: 14px; font-size: 14px; }
.section-title {
  font-size: 15px;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin: 18px 0 10px;
}

/* Levels grid */
.levels-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 12px;
}
.level-card {
  aspect-ratio: 1;
  border-radius: var(--radius);
  border: 2px solid var(--panel-border);
  background: linear-gradient(180deg, #3a2a5a, #241636);
  color: #fff;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: transform 0.12s, box-shadow 0.15s;
}
.level-card:active { transform: scale(0.95); }
.level-card:not(.locked):hover { box-shadow: 0 0 18px rgba(255,215,0,0.4); }
.level-card.locked { opacity: 0.5; cursor: not-allowed; }
.level-num { font-size: 26px; font-weight: 900; color: var(--gold); }
.level-stars { font-size: 12px; letter-spacing: 1px; }

/* Shop */
.shop-list { display: flex; flex-direction: column; gap: 10px; }
.shop-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius);
  padding: 12px;
}
.shop-icon {
  font-size: 28px;
  width: 48px; height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.3);
  border-radius: 12px;
  flex-shrink: 0;
}
.shop-info { flex: 1; min-width: 0; }
.shop-name { font-weight: 800; font-size: 15px; display: flex; gap: 8px; align-items: center; }
.shop-lvl { font-size: 12px; color: var(--gold); font-weight: 700; }
.shop-desc { font-size: 12px; color: var(--text-dim); margin: 2px 0 6px; }
.shop-bar { height: 6px; background: rgba(0,0,0,0.4); border-radius: 999px; overflow: hidden; }
.shop-bar-fill { height: 100%; background: linear-gradient(90deg, #ffd700, #ff8f00); }
.shop-buy {
  border: none;
  border-radius: 12px;
  padding: 10px 14px;
  font-weight: 800;
  font-size: 14px;
  background: linear-gradient(180deg, #ffd700, #f0a500);
  color: #3a2500;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 3px 0 #a06e00;
}
.shop-buy:active { transform: scale(0.95); }
.shop-buy.maxed { background: #555; color: #aaa; box-shadow: none; }
#shop-coins.flash { animation: flashRed 0.4s; }
@keyframes flashRed {
  0%, 100% { color: var(--gold); }
  50% { color: #ff5252; }
}

/* Daily */
.daily-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
.daily-cell {
  position: relative;
  background: rgba(255,255,255,0.05);
  border: 2px solid rgba(255,255,255,0.1);
  border-radius: 14px;
  padding: 10px 6px;
  text-align: center;
}
.daily-cell.claimed { border-color: var(--green); background: rgba(61,220,132,0.12); }
.daily-cell.next { border-color: var(--gold); box-shadow: 0 0 16px rgba(255,215,0,0.5); animation: pulse 1.2s infinite; }
.daily-day { font-size: 11px; color: var(--text-dim); font-weight: 700; }
.daily-coin { font-size: 22px; margin: 4px 0; }
.daily-amt { font-weight: 800; color: var(--gold); font-size: 14px; }
.daily-check {
  position: absolute; top: 4px; right: 6px;
  color: var(--green); font-weight: 900;
}

/* Leaderboard */
.lb-head, .lb-row {
  display: grid;
  grid-template-columns: 44px 1fr 70px 90px;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
}
.lb-head { color: var(--text-dim); font-size: 12px; text-transform: uppercase; letter-spacing: 1px; }
.lb-row {
  background: rgba(255,255,255,0.05);
  border-radius: 12px;
  margin-bottom: 8px;
  font-weight: 700;
}
.lb-row.top1 { background: linear-gradient(90deg, rgba(255,215,0,0.25), rgba(255,215,0,0.05)); }
.lb-row.top2 { background: linear-gradient(90deg, rgba(192,192,192,0.2), rgba(192,192,192,0.03)); }
.lb-row.top3 { background: linear-gradient(90deg, rgba(205,127,50,0.2), rgba(205,127,50,0.03)); }
.lb-rank { font-size: 18px; text-align: center; }
.lb-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-level { color: var(--text-dim); font-size: 13px; }
.lb-score { color: var(--gold); text-align: right; }

/* Settings */
.settings-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255,255,255,0.05);
  border-radius: 14px;
  padding: 14px 16px;
  font-weight: 700;
  cursor: pointer;
}
.toggle {
  appearance: none;
  width: 52px; height: 30px;
  background: #444;
  border-radius: 999px;
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
}
.toggle::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 24px; height: 24px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}
.toggle:checked { background: var(--green); }
.toggle:checked::after { transform: translateX(22px); }
.select {
  background: #33254d;
  color: #fff;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 10px;
  padding: 8px 12px;
  font-weight: 700;
  font-size: 14px;
}
.version { text-align: center; color: var(--text-dim); font-size: 12px; margin-top: 16px; }

/* ---------- Modals ---------- */
.modal {
  width: 90%;
  max-width: 400px;
  background: var(--panel);
  border: 2px solid var(--panel-border);
  border-radius: 22px;
  padding: 24px;
  box-shadow: var(--shadow);
  text-align: center;
  animation: modalIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes modalIn {
  from { transform: scale(0.8); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.modal h2 { font-size: 26px; margin-bottom: 16px; }
.modal-sub { color: var(--text-dim); font-size: 14px; font-weight: 700; margin-top: -10px; margin-bottom: 12px; }
.win-title { color: var(--gold); text-shadow: 0 0 20px rgba(255,215,0,0.6); }
.lose-title { color: #ff5252; }
.lose-sub { color: var(--text-dim); margin-bottom: 16px; font-size: 14px; }

.stars-row {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 18px;
}
.star {
  font-size: 40px;
  opacity: 0.25;
  filter: grayscale(1);
}
.star.earned {
  opacity: 1;
  filter: none;
  animation: starPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
@keyframes starPop {
  0% { transform: scale(0) rotate(-180deg); }
  70% { transform: scale(1.3) rotate(10deg); }
  100% { transform: scale(1) rotate(0); }
}

.result-rows { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }
.result-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 14px;
  background: rgba(255,255,255,0.05);
  border-radius: 10px;
  font-size: 15px;
}
.result-row b { color: var(--gold); }
.result-row.highlight { background: rgba(255,215,0,0.15); border: 1px solid var(--panel-border); }
.result-row.highlight b { font-size: 18px; }
.result-row.coins b { color: var(--gold); }

/* ---------- Toast ---------- */
#toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(0,0,0,0.85);
  color: #fff;
  padding: 12px 22px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 15px;
  border: 1px solid var(--panel-border);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, transform 0.3s;
  z-index: 200;
  white-space: nowrap;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Ad slots (placeholders) ---------- */
.ad-slot { display: none; }
.ad-banner {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 50px;
  background: rgba(0,0,0,0.4);
  border-top: 1px dashed rgba(255,255,255,0.15);
  z-index: 5;
}
