* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0f0f1a;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  color: #ffffff;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

/* ===== Loading Screen ===== */
.loading-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #0f0f1a;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left);
  z-index: 9999;
  transition: opacity 0.4s ease;
}

.loading-screen.fade-out {
  opacity: 0;
  pointer-events: none;
}

.loading-content {
  text-align: center;
}

.loading-title {
  font-size: 2.5rem;
  font-weight: 900;
  letter-spacing: 2px;
  margin-bottom: 30px;
}

.loading-bar-track {
  width: 200px;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  margin: 0 auto 12px;
  overflow: hidden;
}

.loading-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #e94560, #4ECDC4);
  border-radius: 3px;
  transition: width 0.3s ease;
}

.loading-text {
  font-size: 0.85rem;
  color: #8888aa;
}

#app {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-top: calc(var(--safe-top) + 10px);
  padding-right: var(--safe-right);
  padding-bottom: var(--safe-bottom);
  padding-left: var(--safe-left);
  position: relative;
}

#game-canvas {
  display: block;
  cursor: default;
}

/* ===== Hidden utility ===== */
.hidden { display: none !important; }

/* ===== Game Toolbar ===== */
.game-toolbar {
  position: fixed;
  top: var(--safe-top);
  left: var(--safe-left);
  right: var(--safe-right);
  height: 44px;
  box-sizing: border-box;
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  z-index: 90;
  pointer-events: none;
  gap: 6px;
}

.toolbar-left,
.toolbar-right {
  display: flex;
  align-items: center;
  gap: 4px;
  pointer-events: auto;
  flex-shrink: 0;
}

.toolbar-center {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
}

/* ===== Icon Button (Settings) ===== */
.icon-btn {
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  font-size: 1.2rem;
  cursor: pointer;
  z-index: 50;
  transition: transform 0.15s, background 0.15s;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: rotate(30deg);
}

.icon-btn:active {
  transform: scale(0.9) rotate(30deg);
}

/* Undo Button */
.undo-btn {
  z-index: 90;
  background: rgba(255, 193, 7, 0.1);
  border: 2px solid rgba(255, 193, 7, 0.3);
  border-radius: 8px;
  padding: 5px 8px;
  font-size: 12px;
  color: #ffc107;
  cursor: pointer;
  transition: all 0.2s ease;
  display: none;
  white-space: nowrap;
}

.undo-btn:hover {
  background: rgba(255, 193, 7, 0.25);
  border-color: #ffc107;
}

.powerup-btn {
  z-index: 90;
  background: rgba(78, 205, 196, 0.12);
  border: 2px solid rgba(78, 205, 196, 0.35);
  border-radius: 8px;
  padding: 5px 8px;
  font-size: 12px;
  color: #4ECDC4;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.powerup-btn:hover {
  background: rgba(78, 205, 196, 0.22);
  border-color: #4ECDC4;
}

.powerup-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.undo-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Rewarded Undo Button */
.rewarded-undo-btn {
  z-index: 90;
  background: rgba(255, 193, 7, 0.12);
  border: 2px solid rgba(255, 193, 7, 0.35);
  border-radius: 8px;
  padding: 5px 8px;
  font-size: 13px;
  color: #ffc107;
  cursor: pointer;
  transition: all 0.2s ease;
  display: none;
}

.rewarded-undo-btn:hover {
  background: rgba(255, 193, 7, 0.25);
  border-color: #ffc107;
}

.rewarded-undo-btn.hidden {
  display: none !important;
}

/* Rewarded Options on Game Over */
.rewarded-options {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}

.rewarded-options.hidden {
  display: none;
}

/* Restart Button */
.restart-btn {
  z-index: 90;
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  padding: 5px 8px;
  font-size: 14px;
  color: #fff;
  cursor: pointer;
  transition: all 0.2s ease;
  display: none;
}

.restart-btn:hover {
  background: rgba(233, 69, 96, 0.2);
  border-color: #e94560;
}

.restart-btn:active {
  transform: scale(0.9);
}

/* ===== Overlays ===== */
.overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  /* Near-opaque + blur: the board (or a menu underneath, e.g. Skins over Settings)
     must not ghost through the text */
  background: rgba(13, 13, 24, 0.985);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  z-index: 100;
  transition: opacity 0.3s ease;
  animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.overlay.hidden {
  display: none;
}

.overlay-content {
  text-align: center;
  padding: 40px 30px;
  max-width: 400px;
  width: 90%;
}

.title {
  font-size: 3rem;
  font-weight: 900;
  letter-spacing: 4px;
  margin-bottom: 8px;
}

.title-sm {
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: 3px;
  margin-bottom: 20px;
  color: #e94560;
}

.accent {
  color: #e94560;
}

.subtitle {
  color: #8888aa;
  font-size: 1rem;
  margin-bottom: 30px;
}

.continue-gate-panel {
  width: 100%;
  max-width: 280px;
  margin: 0 auto 18px;
  padding: 14px 14px 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
}

.continue-gate-panel.hidden {
  display: none !important;
}

.continue-gate-title {
  color: #FFD93D;
  font-size: 0.95rem;
  font-weight: 700;
}

.continue-gate-message {
  margin-top: 8px;
  color: #a0a0cc;
  font-size: 0.82rem;
  line-height: 1.4;
}

#continue-gate-btn {
  width: 100%;
  margin-top: 10px;
  margin-bottom: 0;
}

/* ===== Buttons ===== */
.btn {
  display: block;
  width: 220px;
  margin: 12px auto;
  padding: 14px 0;
  border: none;
  border-radius: 10px;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 2px;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.btn:active {
  transform: scale(0.95);
}

.btn:disabled,
.mode-btn:disabled,
#daily-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-primary {
  background: linear-gradient(135deg, #e94560 0%, #c73e54 100%);
  color: #fff;
  box-shadow: 0 4px 18px rgba(233, 69, 96, 0.4);
}

.btn-primary:hover {
  box-shadow: 0 6px 24px rgba(233, 69, 96, 0.55);
}

.btn-secondary {
  background: transparent;
  color: #8888aa;
  border: 2px solid #2a2a4a;
}

.btn-secondary:hover {
  border-color: #4a4a6a;
  color: #ffffff;
}

.btn-danger {
  background: rgba(233, 69, 96, 0.15);
  color: #e94560;
  border: 2px solid rgba(233, 69, 96, 0.4);
}

.btn-danger:hover {
  background: rgba(233, 69, 96, 0.3);
  border-color: #e94560;
  color: #fff;
}

.text-btn {
  background: none;
  border: none;
  color: #6688aa;
  font-size: 0.9rem;
  cursor: pointer;
  padding: 5px 10px;
  transition: color 0.15s;
}

.text-btn:hover {
  color: #ffffff;
}

/* ===== Score Displays ===== */
.score-display {
  margin: 12px 0;
}

.score-label {
  font-size: 0.85rem;
  color: #8888aa;
  text-transform: uppercase;
  letter-spacing: 2px;
}

.score-value {
  font-size: 2.5rem;
  font-weight: 900;
}

.best-display {
  margin-top: 24px;
  color: #8888aa;
  font-size: 0.9rem;
}

.wallet-strip {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin: 14px auto 10px;
}

.wallet-chip {
  min-width: 88px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 700;
}

.undo-shop-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 14px auto 0;
  max-width: 320px;
}

.undo-pack-btn {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.12s ease;
}

.undo-pack-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 217, 61, 0.45);
}

.undo-pack-btn:active {
  transform: scale(0.96);
}

.undo-pack-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.powerup-shop-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 10px auto 0;
  max-width: 320px;
}

.powerup-pack-btn {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid rgba(78, 205, 196, 0.25);
  background: rgba(78, 205, 196, 0.08);
  color: #dffefd;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.12s ease;
}

.powerup-pack-btn:hover {
  background: rgba(78, 205, 196, 0.16);
  border-color: rgba(78, 205, 196, 0.48);
}

.powerup-pack-btn:active {
  transform: scale(0.96);
}

.powerup-pack-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.daily-objectives-panel {
  margin: 10px auto 0;
  max-width: 320px;
}

.progression-content {
  max-width: 420px;
  max-height: 82vh;
  overflow-y: auto;
}

.progression-wallet {
  flex-wrap: wrap;
  margin-top: 18px;
  margin-bottom: 18px;
}

.progression-overview {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.progression-card {
  padding: 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  text-align: left;
}

.progression-card-wide {
  grid-column: 1 / -1;
}

.progression-card-label {
  color: #8ea8c9;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
}

.progression-card-value {
  margin-top: 6px;
  color: #ffffff;
  font-size: 1.2rem;
  font-weight: 800;
}

.progression-card-meta {
  margin-top: 4px;
  color: #7f94af;
  font-size: 0.78rem;
}

.progression-inline-btn {
  margin-top: 12px;
}

.progression-section {
  margin: 14px 0;
  padding: 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.progression-section-title {
  color: #ffffff;
  font-size: 0.84rem;
  font-weight: 800;
  letter-spacing: 1.2px;
  text-transform: uppercase;
}

.progression-daily-panel {
  margin-top: 12px;
  max-width: none;
}

.progression-section .undo-shop-row,
.progression-section .powerup-shop-row {
  max-width: none;
}

.daily-objectives-list {
  display: grid;
  gap: 8px;
}

.daily-objective {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.daily-objective.completed {
  border-color: rgba(255, 217, 61, 0.45);
  background: rgba(255, 217, 61, 0.08);
}

.daily-objective-main {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.daily-objective-icon {
  font-size: 1rem;
}

.daily-objective-label {
  color: #f4f4fb;
  font-size: 0.84rem;
  font-weight: 700;
}

.daily-objective-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.daily-objective-progress {
  color: #9cb4cf;
  font-size: 0.75rem;
  font-weight: 700;
}

.daily-objective-reward {
  color: #FFD93D;
  font-size: 0.76rem;
  font-weight: 700;
}

.new-best {
  color: #FFD93D;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 3px;
  margin-bottom: 10px;
  animation: pulse 0.6s ease-in-out infinite alternate;
}

@keyframes pulse {
  from { opacity: 0.7; transform: scale(1); }
  to { opacity: 1; transform: scale(1.08); }
}

/* ===== Menu Links ===== */
.menu-links {
  margin-top: 30px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 2px 5px;
}

.divider {
  color: #4a4a6a;
}

/* ===== Tutorial ===== */
.tutorial-content {
  max-width: 350px;
}

.tutorial-steps {
  margin: 25px 0;
  text-align: left;
}

.tutorial-step {
  display: flex;
  align-items: center;
  margin: 18px 0;
  padding: 12px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
}

.step-icon {
  font-size: 1.8rem;
  margin-right: 15px;
  min-width: 40px;
  text-align: center;
}

.step-visual {
  margin-right: 15px;
  min-width: 120px;
  flex-shrink: 0;
}

.tutorial-canvas {
  border-radius: 6px;
  background: #1a1a2e;
}

.step-text {
  font-size: 0.95rem;
  color: #ccccdd;
  line-height: 1.4;
}

/* ===== Settings ===== */
.settings-content {
  max-width: 320px;
}

.settings-list {
  margin: 25px 0;
}

.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid #2a2a4a;
}

.setting-row:last-child {
  border-bottom: none;
}

.setting-label {
  font-size: 1rem;
  color: #ccccdd;
}

.toggle-btn {
  width: 60px;
  padding: 8px 0;
  border: none;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.toggle-btn.on {
  background: #4ECDC4;
  color: #0f0f1a;
}

.toggle-btn.off {
  background: #3a3a5a;
  color: #8888aa;
}

.setting-divider {
  border: none;
  border-top: 1px solid #2a2a4a;
  margin: 20px 0;
}

.settings-info {
  margin: 15px 0;
  font-size: 0.85rem;
  color: #6688aa;
}

.text-dim {
  color: #4a4a6a;
  font-size: 0.8rem;
  margin-top: 5px;
}

.legal-links {
  margin-top: 10px;
  font-size: 0.75rem;
}

.legal-links a {
  color: #4ECDC4;
  text-decoration: none;
}

.legal-links a:hover {
  text-decoration: underline;
}

/* ===== Daily Challenge ===== */
.daily-date {
  font-size: 1.1rem;
  color: #8888aa;
  margin-bottom: 20px;
}

.daily-streak {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 20px 0;
  font-size: 1.2rem;
  color: #FFD93D;
}

.streak-flame {
  font-size: 1.5rem;
  animation: flicker 0.5s ease-in-out infinite alternate;
}

@keyframes flicker {
  from { transform: scale(1) rotate(-5deg); }
  to { transform: scale(1.1) rotate(5deg); }
}

/* ===== Ad Slot ===== */
.ad-slot {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: #1a1a2e;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.ad-slot.hidden {
  display: none;
}

/* ===== Confirm Dialog ===== */
.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.confirm-box {
  background: #1a1a2e;
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-radius: 16px;
  padding: 24px 28px;
  text-align: center;
  max-width: 280px;
  width: 90%;
}

.confirm-message {
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 18px 0;
  line-height: 1.4;
}

.confirm-buttons {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.confirm-buttons .btn {
  min-width: 80px;
}

/* ===== Rewarded Ad Overlay ===== */
.rewarded-ad-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}

.rewarded-ad-content {
  text-align: center;
  color: #fff;
  padding: 32px;
  background: #1a1a2e;
  border-radius: 16px;
  border: 2px solid rgba(233, 69, 96, 0.4);
  max-width: 320px;
}

.rewarded-ad-content p { margin: 8px 0; }
.rewarded-ad-desc { color: #8888aa; font-size: 0.85rem; }
.rewarded-ad-close { margin-top: 16px; }

/* ===== Rewarded Ad Buttons ===== */
.rewarded-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  background: rgba(255, 193, 7, 0.15);
  border: 2px solid rgba(255, 193, 7, 0.4);
  border-radius: 12px;
  color: #ffc107;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  margin-top: 8px;
}

.rewarded-btn:hover {
  background: rgba(255, 193, 7, 0.25);
  border-color: #ffc107;
}

/* ===== Responsive ===== */
@media (max-height: 600px) {
  .overlay-content { padding: 20px 20px; }
  .title { font-size: 2.2rem; }
  .score-value { font-size: 2rem; }
  .tutorial-step { margin: 10px 0; padding: 8px; }
}

@media (max-width: 360px) {
  .title { font-size: 2.4rem; letter-spacing: 2px; }
  .btn { width: 190px; font-size: 1rem; }
}

/* ===== Leaderboard ===== */
.leaderboard-content {
  max-width: 380px;
}

.leaderboard-tabs {
  display: flex;
  margin-bottom: 20px;
  border-radius: 8px;
  overflow: hidden;
  background: #1a1a2e;
}

.tab-btn {
  flex: 1;
  padding: 12px 0;
  border: none;
  background: transparent;
  color: #6688aa;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 1px;
  cursor: pointer;
  transition: all 0.2s;
}

.tab-btn.active {
  background: #e94560;
  color: #fff;
}

.tab-btn:not(.active):hover {
  background: rgba(233, 69, 96, 0.2);
}

.leaderboard-list {
  max-height: 300px;
  overflow-y: auto;
  margin-bottom: 20px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 10px;
  padding: 5px 0;
}

.leaderboard-loading,
.leaderboard-empty {
  padding: 40px 20px;
  color: #6688aa;
  font-size: 0.95rem;
}

.leaderboard-row {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.leaderboard-row:last-child {
  border-bottom: none;
}

.leaderboard-row.highlight {
  background: rgba(233, 69, 96, 0.15);
}

.lb-rank {
  width: 36px;
  font-weight: 700;
  color: #8888aa;
  font-size: 0.9rem;
}

.lb-rank.gold { color: #FFD700; }
.lb-rank.silver { color: #C0C0C0; }
.lb-rank.bronze { color: #CD7F32; }

.lb-name {
  flex: 1;
  text-align: left;
  font-size: 1rem;
  color: #fff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lb-score {
  font-weight: 700;
  font-size: 1rem;
  color: #4ECDC4;
}

/* ===== Name Input Row ===== */
.name-input-row {
  display: flex;
  gap: 10px;
  margin: 15px 0;
  max-width: 280px;
  margin-left: auto;
  margin-right: auto;
}

.name-input {
  flex: 1;
  padding: 12px 15px;
  border: 2px solid #3a3a5a;
  border-radius: 8px;
  background: #1a1a2e;
  color: #fff;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}

.name-input:focus {
  border-color: #e94560;
}

.name-input::placeholder {
  color: #5a5a7a;
}

.btn-sm {
  padding: 12px 18px;
  width: auto;
  font-size: 0.85rem;
}

.btn-accent {
  background: #4ECDC4;
  color: #0f0f1a;
  border: none;
}

.btn-accent:hover {
  background: #5dd9d0;
}

.btn-accent:disabled {
  background: #3a5a5a;
  color: #6a8a8a;
  cursor: not-allowed;
}

.submit-status {
  font-size: 0.9rem;
  margin: 10px 0 15px;
  padding: 8px 12px;
  border-radius: 6px;
}

.submit-status.success {
  background: rgba(78, 205, 196, 0.2);
  color: #4ECDC4;
}

.submit-status.error {
  background: rgba(233, 69, 96, 0.2);
  color: #e94560;
}

.submit-status.hidden {
  display: none;
}

/* ===== Button Row ===== */
.btn-row {
  display: flex;
  gap: 10px;
  max-width: 280px;
  margin: 10px auto;
}

.btn-half {
  flex: 1;
  width: auto;
  margin: 0;
  padding: 12px 0;
  font-size: 0.9rem;
}

/* ===== Rank Display ===== */
.rank-display {
  font-size: 1rem;
  color: #FFD93D;
  margin: 10px 0;
}

.rank-display.hidden {
  display: none;
}

/* ===== Stats Screen ===== */
.stats-content {
  max-width: 380px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 25px;
  padding: 15px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 12px;
}

.stat-item {
  text-align: center;
  padding: 10px 5px;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 900;
  color: #4ECDC4;
  margin-bottom: 4px;
}

.stat-label {
  font-size: 0.7rem;
  color: #6688aa;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* ===== Streak Section ===== */
.streak-section {
  margin: 25px 0;
  padding: 20px;
  background: rgba(255, 215, 61, 0.05);
  border-radius: 12px;
  border: 1px solid rgba(255, 215, 61, 0.15);
}

.streak-title {
  font-size: 1.1rem;
  color: #FFD93D;
  margin-bottom: 15px;
}

.streak-info {
  display: flex;
  justify-content: center;
  align-items: baseline;
  gap: 20px;
  margin-bottom: 20px;
}

.streak-current,
.streak-best {
  font-size: 2rem;
  font-weight: 900;
  color: #fff;
}

.streak-current {
  color: #FFD93D;
}

.streak-label {
  font-size: 0.75rem;
  color: #6688aa;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-right: 10px;
}

/* Streak Calendar */
.streak-calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-top: 15px;
}

.streak-day {
  aspect-ratio: 1;
  border-radius: 4px;
  background: #1a1a2e;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  color: #4a4a6a;
  transition: transform 0.1s;
}

.streak-day.completed {
  background: linear-gradient(135deg, #FFD93D 0%, #FFA500 100%);
  color: #0f0f1a;
  font-weight: 700;
}

.streak-day.today {
  border: 2px solid #e94560;
}

.streak-day.future {
  background: transparent;
  border: 1px dashed #2a2a4a;
}

.calendar-header {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 6px;
}

.calendar-header span {
  font-size: 0.6rem;
  color: #4a4a6a;
  text-align: center;
  text-transform: uppercase;
}

/* ===== Game Mode Selector ===== */
.mode-selector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 20px 0;
  max-width: 300px;
  margin-left: auto;
  margin-right: auto;
}

.mode-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 10px;
  width: auto;
  margin: 0;
  border-radius: 12px;
  transition: all 0.2s ease;
}

.mode-btn .mode-icon {
  font-size: 1.6rem;
  margin-bottom: 6px;
}

.mode-btn .mode-name {
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 1px;
}

.mode-btn .mode-desc {
  font-size: 0.65rem;
  opacity: 0.7;
  margin-top: 4px;
  letter-spacing: 0;
  font-weight: 400;
}

.mode-btn.btn-secondary:hover {
  background: rgba(233, 69, 96, 0.15);
  border-color: #e94560;
}

.btn-full {
  width: 100%;
  max-width: 300px;
}

/* ===== Achievements ===== */
.achievements-content {
  max-width: 400px;
  max-height: 80vh;
  overflow-y: auto;
}

.achievements-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.achievements-header h3 {
  font-size: 1.3rem;
  color: #e94560;
}

.achievements-progress {
  font-size: 0.9rem;
  color: #4ECDC4;
  font-weight: 700;
}

.achievements-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.achievement-card {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 16px 12px;
  text-align: center;
  transition: transform 0.15s, background 0.15s;
}

.achievement-card:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.08);
}

.achievement-card.locked {
  opacity: 0.5;
}

.achievement-card-icon {
  font-size: 2rem;
  margin-bottom: 8px;
}

.achievement-card-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 4px;
}

.achievement-card-desc {
  font-size: 0.7rem;
  color: #6688aa;
  line-height: 1.3;
}

/* ===== Achievement Popup ===== */
.achievement-popup {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(-100px);
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(135deg, #1a1a2e 0%, #2a2a4a 100%);
  border: 2px solid #FFD93D;
  border-radius: 12px;
  padding: 14px 20px;
  z-index: 200;
  box-shadow: 0 8px 32px rgba(255, 215, 61, 0.3);
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.achievement-popup.show {
  transform: translateX(-50%) translateY(0);
}

.achievement-icon {
  font-size: 2rem;
}

.achievement-text {
  text-align: left;
}

.achievement-label {
  font-size: 0.7rem;
  color: #FFD93D;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 2px;
}

.achievement-name {
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
}

.achievement-reward {
  margin-top: 4px;
  font-size: 0.8rem;
  font-weight: 700;
  color: #FFD93D;
}

/* ===== Daily Challenge Hint ===== */
#daily-btn {
  flex-direction: column;
  padding: 16px 24px;
}

#daily-btn .daily-hint {
  display: block;
  font-size: 0.7rem;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.6);
  margin-top: 4px;
  letter-spacing: 0.5px;
}

/* ===== Grid Size Selector ===== */
.grid-size-selector {
  display: flex;
  gap: 8px;
}

.grid-size-selector.menu-grid-size {
  justify-content: center;
  margin-bottom: 12px;
}

.grid-size-btn {
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid transparent;
  border-radius: 8px;
  color: #888;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.grid-size-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.grid-size-btn.active {
  background: rgba(233, 69, 96, 0.2);
  border-color: #e94560;
  color: #e94560;
}

/* Leaderboard size sub-tabs */
.leaderboard-size-tabs {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-bottom: 12px;
}

.size-tab-btn {
  padding: 4px 12px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  color: #888;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.size-tab-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.15);
}

.size-tab-btn.active {
  background: rgba(78, 205, 196, 0.2);
  border-color: #4ECDC4;
  color: #4ECDC4;
}

/* ===== Language Selector ===== */
.language-select {
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  color: #fff;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  transition: all 0.2s;
}

.language-select:hover,
.language-select:focus {
  background: rgba(255, 255, 255, 0.15);
  border-color: #e94560;
}

.language-select option {
  background: #1a1a2e;
  color: #fff;
}

/* ===== Level Display ===== */
.level-display {
  background: rgba(15, 15, 26, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 2px 10px;
  z-index: 40;
  min-width: 80px;
  max-width: 180px;
  margin: 0 auto;
}

.level-display.hidden {
  display: none;
}

.level-info {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
}

.level-num {
  font-size: 0.75rem;
  font-weight: 700;
  color: #FFD93D;
}

.level-num span {
  font-size: 0.85rem;
}

.level-name {
  font-size: 0.6rem;
  color: #8888aa;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.level-progress-bar {
  width: 100%;
  height: 3px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 1px;
}

.level-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #e94560, #FFD93D);
  border-radius: 2px;
  transition: width 0.3s ease;
  width: 0%;
}

.level-target {
  display: none;
}

/* ===== Level Up Animation ===== */
.level-up-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(15, 15, 26, 0.8);
  z-index: 200;
  pointer-events: none;
}

.level-up-overlay.hidden {
  display: none;
}

.level-up-content {
  text-align: center;
  animation: levelUpPop 1.5s ease forwards;
}

@keyframes levelUpPop {
  0% { 
    transform: scale(0.5); 
    opacity: 0; 
  }
  20% { 
    transform: scale(1.2); 
    opacity: 1; 
  }
  40% { 
    transform: scale(1); 
  }
  80% { 
    transform: scale(1); 
    opacity: 1; 
  }
  100% { 
    transform: scale(1.5); 
    opacity: 0; 
  }
}

.level-up-text {
  font-size: 1.5rem;
  font-weight: 900;
  color: #FFD93D;
  letter-spacing: 4px;
  text-shadow: 0 0 20px rgba(255, 217, 61, 0.5);
  margin-bottom: 8px;
}

.level-up-num {
  font-size: 5rem;
  font-weight: 900;
  color: #fff;
  text-shadow: 
    0 0 30px rgba(233, 69, 96, 0.8),
    0 0 60px rgba(233, 69, 96, 0.4);
  line-height: 1;
}

.level-up-name {
  font-size: 1.2rem;
  font-weight: 600;
  color: #e94560;
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-top: 8px;
}

/* ===== Celebration Overlay ===== */
.celebration-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(15, 15, 26, 0.7);
  z-index: 200;
  pointer-events: none;
}

.celebration-overlay.hidden {
  display: none;
}

.celebration-content {
  text-align: center;
  animation: celebrationPop 2s ease forwards;
}

@keyframes celebrationPop {
  0% { transform: scale(0.3) rotate(-10deg); opacity: 0; }
  15% { transform: scale(1.15) rotate(2deg); opacity: 1; }
  30% { transform: scale(1) rotate(0); }
  75% { transform: scale(1); opacity: 1; }
  100% { transform: scale(1.3); opacity: 0; }
}

.celebration-emoji {
  font-size: 4rem;
  color: #FFD93D; /* level ratings (★★☆) render as text */
  letter-spacing: 4px;
  margin-bottom: 10px;
  animation: celebrationBounce 0.6s ease infinite alternate;
}

@keyframes celebrationBounce {
  from { transform: translateY(0); }
  to { transform: translateY(-10px); }
}

.celebration-title {
  font-size: 1.8rem;
  font-weight: 900;
  color: #FFD93D;
  letter-spacing: 3px;
  text-shadow: 0 0 20px rgba(255, 217, 61, 0.6);
  margin-bottom: 6px;
}

.celebration-desc {
  font-size: 1rem;
  font-weight: 600;
  color: #a0a0cc;
  letter-spacing: 1px;
}

/* ===== Themes / Skins Screen ===== */
.themes-content {
  max-width: 380px;
}

.themes-wallet {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  margin-top: -8px;
  margin-bottom: 10px;
  color: #FFD93D;
  font-size: 0.95rem;
  font-weight: 700;
}

.themes-ad-stars {
  width: auto;
  margin: 0;
  padding: 6px 12px;
  font-size: 0.8rem;
}

.themes-ad-stars small {
  opacity: 0.7;
  margin-left: 4px;
}

.themes-list {
  margin: 15px 0;
  max-height: 55vh;
  overflow-y: auto;
}

.theme-section + .theme-section {
  margin-top: 16px;
}

.theme-section-title {
  margin: 0 0 8px;
  color: #9cb4cf;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 1.4px;
  text-transform: uppercase;
}

.theme-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  text-align: left;
  padding: 10px 12px;
  margin: 6px 0;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.theme-card:hover {
  background: rgba(255, 255, 255, 0.08);
}

.theme-card.active {
  border-color: #e94560;
}

/* Locked: dim only the preview and add a lock — names, descriptions and prices stay readable */
.theme-card.locked .theme-preview {
  opacity: 0.5;
  position: relative;
}

.theme-card.locked .theme-name::after {
  content: ' 🔒';
  font-size: 0.75rem;
}

.theme-preview {
  display: grid;
  grid-template-columns: repeat(3, 14px);
  gap: 3px;
}

.theme-preview-block {
  width: 14px;
  height: 14px;
  border-radius: 3px;
}

.theme-preview-bg {
  width: 14px;
}

.theme-info {
  flex: 1;
  min-width: 0;
}

.theme-name {
  font-weight: 700;
  font-size: 0.9rem;
  color: #fff;
}

.theme-desc {
  font-size: 0.75rem;
  color: #a4a4c4;
  line-height: 1.3;
}

.theme-unlock-info {
  font-size: 0.7rem;
  color: #FFD93D;
  margin-top: 2px;
}

.theme-action {
  justify-self: end;
}

.theme-action-stack {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}

.theme-active-mark {
  color: #e94560;
  font-weight: 700;
  font-size: 0.8rem;
}

.theme-action .btn-sm {
  width: auto;
  margin: 0;
  font-size: 0.8rem;
  padding: 7px 10px;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.theme-action-stack .btn-sm {
  width: 100%;
}

.theme-card button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.achievement-card-reward {
  margin-top: 6px;
  font-size: 0.78rem;
  font-weight: 700;
  color: #FFD93D;
}

/* ===== Mode Complete Screen ===== */
.mode-stats {
  display: flex;
  justify-content: center;
  gap: 30px;
  margin: 15px 0;
  padding: 15px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 10px;
}

.mode-stat {
  font-size: 0.95rem;
  color: #8888aa;
}

.daily-reward-earned {
  margin: 12px auto 0;
  padding: 8px 12px;
  border-radius: 999px;
  width: fit-content;
  background: rgba(255, 217, 61, 0.14);
  color: #FFD93D;
  font-size: 0.9rem;
  font-weight: 700;
}

.daily-format-summary {
  margin: 10px auto 0;
  color: #9cb4cf;
  font-size: 0.82rem;
  font-weight: 700;
}

.daily-objectives-result {
  margin-top: 14px;
}

.mode-stat span:last-child {
  color: #4ECDC4;
  font-weight: 700;
}

/* ===== Timer Display (for Timed mode) ===== */
.timer-display {
  background: rgba(15, 15, 26, 0.9);
  padding: 4px 12px;
  border-radius: 8px;
  border: 2px solid #e94560;
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  z-index: 50;
  font-variant-numeric: tabular-nums;
  text-align: center;
  max-width: 120px;
  margin: 0 auto;
}

.timer-display.warning {
  border-color: #FFD93D;
  color: #FFD93D;
  animation: timerPulse 0.5s ease-in-out infinite alternate;
}

.timer-display.danger {
  border-color: #ff4444;
  color: #ff4444;
  animation: timerPulse 0.3s ease-in-out infinite alternate;
}

@keyframes timerPulse {
  from { transform: scale(1); }
  to { transform: scale(1.05); }
}

/* ===== Progress Bar (for Sprint mode) ===== */
.progress-display {
  position: relative;
  height: 22px;
  background: rgba(15, 15, 26, 0.9);
  border-radius: 10px;
  overflow: hidden;
  z-index: 50;
  border: 2px solid #2a2a4a;
  max-width: 160px;
  margin: 0 auto;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #4ECDC4 0%, #45B7B8 100%);
  transition: width 0.3s ease;
  border-radius: 10px;
}

.progress-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* ===== Screen Transitions ===== */
.overlay {
  animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.overlay.fade-out {
  animation: fadeOut 0.2s ease-in forwards;
}

@keyframes fadeOut {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(-20px);
  }
}

/* ===== Zen Mode Indicator ===== */
.zen-indicator {
  background: rgba(78, 205, 196, 0.15);
  padding: 3px 12px;
  border-radius: 20px;
  border: 1px solid #4ECDC4;
  font-size: 0.75rem;
  color: #4ECDC4;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 0 auto;
  max-width: 140px;
  width: fit-content;
}

.zen-indicator span {
  animation: breathe 3s ease-in-out infinite;
}

@keyframes breathe {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}
