/* ============================================
   Aurum Tycoon — Style System
   Dark luxury theme, gold accents, glassmorphism
   ============================================ */

/* ==================== DESIGN TOKENS ==================== */

:root {
  --bg-primary: oklch(12% 0.02 270);
  --bg-surface: oklch(18% 0.02 270);
  --bg-elevated: oklch(22% 0.02 270);
  --gold: oklch(72% 0.15 85);
  --gold-light: oklch(82% 0.10 85);
  --gold-dark: oklch(55% 0.18 85);
  --text: oklch(95% 0.01 270);
  --text-muted: oklch(60% 0.02 270);
  --danger: oklch(55% 0.22 25);
  --success: oklch(60% 0.18 145);
  --card: oklch(20% 0.02 270 / 0.7);
  --card-border: oklch(40% 0.03 270 / 0.3);
  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --shadow-gold: 0 0 20px oklch(72% 0.15 85 / 0.3);
  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.4);
  --transition: 0.2s ease;
  --font-heading: 'Poppins', sans-serif;
  --font-body: 'Inter', sans-serif;
}

/* ==================== RESET ==================== */

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-body);
  background: var(--bg-primary);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

/* ==================== APP LAYOUT ==================== */

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
  overflow: hidden;
}

/* ==================== GOLD COUNTER (TOP BAR) ==================== */

#gold-counter {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 16px 8px;
  background: linear-gradient(180deg, var(--bg-primary), transparent);
  z-index: 10;
  position: relative;
}

#gold-display {
  font-family: var(--font-heading);
  font-size: 36px;
  font-weight: 700;
  color: var(--gold);
  text-shadow: 0 0 20px oklch(72% 0.15 85 / 0.4);
  transition: transform var(--transition);
  line-height: 1.1;
}

#gold-counter.pulse #gold-display {
  animation: goldPulse 0.2s ease;
}

@keyframes goldPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

#gold-per-sec {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

#settings-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 40px;
  height: 40px;
  border: none;
  background: var(--card);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  backdrop-filter: blur(10px);
}

#settings-btn:hover {
  color: var(--gold);
  background: oklch(25% 0.02 270);
}

/* ==================== MAIN CONTENT ==================== */

#main-content {
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* ==================== TABS ==================== */

.tab-content {
  display: none;
  height: 100%;
  overflow-y: auto;
  padding: 0 16px 16px;
}

.tab-content.active {
  display: block;
}

.tab-content::-webkit-scrollbar {
  width: 4px;
}

.tab-content::-webkit-scrollbar-track {
  background: transparent;
}

.tab-content::-webkit-scrollbar-thumb {
  background: var(--card-border);
  border-radius: 4px;
}

/* ==================== MINE TAB ==================== */

#tab-mine {
  padding: 0;
  display: none;
  flex-direction: column;
}

#tab-mine.active {
  display: flex;
}

#canvas-container {
  flex: 1;
  position: relative;
  min-height: 0;
}

#mine-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

#mining-area {
  position: absolute;
  inset: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

#mine-btn {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  border: 3px solid var(--gold);
  background: radial-gradient(circle, oklch(35% 0.08 85 / 0.6), oklch(15% 0.03 270 / 0.8));
  color: var(--gold);
  font-size: 36px;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: var(--shadow-gold), inset 0 0 20px oklch(72% 0.15 85 / 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

#mine-btn:active {
  transform: scale(0.92);
  box-shadow: 0 0 30px oklch(72% 0.15 85 / 0.5);
}

.mine-info-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  background: var(--bg-primary);
  border-top: 1px solid var(--card-border);
}

.combo-display {
  font-family: var(--font-heading);
  font-size: 14px;
  color: var(--gold);
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.3s;
}

.combo-display.visible {
  opacity: 1;
}

/* Prestige Button */

#prestige-btn {
  margin: 8px 16px 12px;
  padding: 12px;
  border: 2px solid var(--gold);
  border-radius: var(--radius);
  background: linear-gradient(135deg, oklch(25% 0.08 85 / 0.3), oklch(15% 0.03 270 / 0.5));
  color: var(--gold);
  font-family: var(--font-heading);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  text-align: center;
  backdrop-filter: blur(10px);
  /* Hexagonal feel via clip-path */
  clip-path: polygon(5% 0%, 95% 0%, 100% 50%, 95% 100%, 5% 100%, 0% 50%);
  padding-left: 20px;
  padding-right: 20px;
}

#prestige-btn:hover:not(.disabled) {
  background: linear-gradient(135deg, oklch(35% 0.12 85 / 0.4), oklch(20% 0.05 270 / 0.5));
  box-shadow: var(--shadow-gold);
}

#prestige-btn.disabled {
  opacity: 0.4;
  cursor: not-allowed;
  border-color: var(--text-muted);
  color: var(--text-muted);
}

/* ==================== UPGRADE TAB ==================== */

#upgrades-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  padding-top: 8px;
}

.upgrade-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  backdrop-filter: blur(10px);
  transition: all var(--transition);
}

.upgrade-card.affordable {
  border-color: oklch(72% 0.15 85 / 0.3);
}

.upgrade-card.maxed {
  border-color: oklch(60% 0.18 145 / 0.3);
  opacity: 0.8;
}

.upgrade-icon {
  font-size: 28px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: oklch(15% 0.02 270);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.upgrade-info {
  flex: 1;
  min-width: 0;
}

.upgrade-name {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
}

.upgrade-effect {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.upgrade-level {
  font-size: 11px;
  color: var(--gold);
  margin-top: 2px;
}

.upgrade-progress-bar {
  height: 4px;
  background: oklch(15% 0.02 270);
  border-radius: 2px;
  margin-top: 6px;
  overflow: hidden;
}

.upgrade-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold-dark), var(--gold));
  border-radius: 2px;
  transition: width 0.3s ease;
}

.upgrade-buy-btn {
  padding: 8px 14px;
  border: 1px solid var(--gold);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--gold);
  font-family: var(--font-heading);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  min-width: 70px;
  text-align: center;
}

.upgrade-buy-btn:hover:not(.disabled):not(.maxed) {
  background: var(--gold);
  color: var(--bg-primary);
}

.upgrade-buy-btn.disabled {
  opacity: 0.3;
  cursor: not-allowed;
  border-color: var(--text-muted);
  color: var(--text-muted);
}

.upgrade-buy-btn.maxed {
  background: oklch(60% 0.18 145 / 0.2);
  border-color: var(--success);
  color: var(--success);
  cursor: default;
}

/* ==================== MINES TAB ==================== */

#mines-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 8px;
}

.mine-card {
  padding: 16px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  backdrop-filter: blur(10px);
  transition: all var(--transition);
}

.mine-card.active {
  border-color: var(--gold);
  box-shadow: var(--shadow-gold);
}

.mine-card.locked {
  opacity: 0.6;
}

.mine-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.mine-icon {
  font-size: 32px;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mine-name {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 16px;
}

.mine-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.mine-details {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.mine-mult {
  font-family: var(--font-heading);
  font-weight: 600;
  color: var(--gold);
  font-size: 14px;
}

.mine-cost {
  font-size: 13px;
  color: var(--text-muted);
}

.mine-active-badge {
  font-size: 11px;
  font-weight: 700;
  color: var(--success);
  background: oklch(60% 0.18 145 / 0.15);
  padding: 2px 8px;
  border-radius: 20px;
  letter-spacing: 1px;
}

.mine-color-bar {
  height: 4px;
  border-radius: 2px;
  margin-bottom: 10px;
  opacity: 0.6;
}

.mine-unlock-btn, .mine-select-btn {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--gold);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--gold);
  font-family: var(--font-heading);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

.mine-unlock-btn:hover:not(.disabled),
.mine-select-btn:hover {
  background: var(--gold);
  color: var(--bg-primary);
}

.mine-unlock-btn.disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* ==================== STATS TAB ==================== */

.stats-section {
  margin-bottom: 20px;
}

.stats-title {
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 600;
  color: var(--gold);
  margin-bottom: 10px;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.stat-card {
  padding: 14px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  backdrop-filter: blur(10px);
  text-align: center;
}

.stat-value {
  font-family: var(--font-heading);
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}

.stat-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Achievements in stats */

.achievements-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.achievement-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  backdrop-filter: blur(10px);
}

.achievement-item.unlocked {
  border-color: oklch(72% 0.15 85 / 0.2);
}

.achievement-item.locked {
  opacity: 0.5;
}

.achievement-icon {
  font-size: 22px;
  width: 36px;
  text-align: center;
}

.achievement-name {
  font-family: var(--font-heading);
  font-size: 13px;
  font-weight: 600;
}

.achievement-desc {
  font-size: 11px;
  color: var(--text-muted);
}

/* ==================== BOTTOM NAVIGATION ==================== */

#bottom-nav {
  display: flex;
  background: var(--bg-surface);
  border-top: 1px solid var(--card-border);
  padding: 6px 0;
  padding-bottom: max(6px, env(safe-area-inset-bottom));
  z-index: 10;
}

.tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 4px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-heading);
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  -webkit-tap-highlight-color: transparent;
}

.tab-btn .tab-icon {
  font-size: 20px;
  line-height: 1;
}

.tab-btn.active {
  color: var(--gold);
}

.tab-btn.active .tab-icon {
  filter: drop-shadow(0 0 6px oklch(72% 0.15 85 / 0.5));
}

/* ==================== MODALS ==================== */

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 100;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  padding: 20px;
}

.modal-overlay.active {
  display: flex;
}

.modal-content {
  background: var(--bg-surface);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 360px;
  max-height: 80vh;
  overflow-y: auto;
  backdrop-filter: blur(20px);
}

.modal-title {
  font-family: var(--font-heading);
  font-size: 20px;
  font-weight: 700;
  color: var(--gold);
  text-align: center;
  margin-bottom: 16px;
}

.modal-btn {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--text);
  font-family: var(--font-heading);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  margin-bottom: 8px;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-btn:hover {
  background: var(--bg-elevated);
  border-color: var(--gold);
}

.modal-btn.danger {
  border-color: var(--danger);
  color: var(--danger);
}

.modal-btn.danger:hover {
  background: oklch(55% 0.22 25 / 0.15);
}

.modal-close {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-heading);
  font-size: 14px;
  cursor: pointer;
  transition: all var(--transition);
  margin-top: 8px;
}

.modal-close:hover {
  color: var(--text);
}

/* Prestige Modal */

.prestige-preview {
  text-align: center;
  margin: 16px 0;
}

.prestige-preview .gain-number {
  font-family: var(--font-heading);
  font-size: 48px;
  font-weight: 700;
  color: var(--gold);
  text-shadow: var(--shadow-gold);
}

.prestige-preview .gain-label {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 4px;
}

.prestige-bonus-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--card-border);
  font-size: 13px;
}

.prestige-bonus-row .label {
  color: var(--text-muted);
}

.prestige-bonus-row .value {
  color: var(--gold);
  font-weight: 600;
}

.prestige-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.prestige-actions button {
  flex: 1;
  padding: 12px;
  border-radius: var(--radius-sm);
  font-family: var(--font-heading);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

#prestige-confirm {
  background: var(--gold);
  color: var(--bg-primary);
  border: none;
}

#prestige-confirm:hover {
  box-shadow: var(--shadow-gold);
}

#prestige-cancel {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--card-border);
}

/* Reset Confirm Modal */

.reset-warning {
  text-align: center;
  color: var(--danger);
  font-size: 14px;
  margin-bottom: 16px;
}

.reset-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.reset-actions button {
  flex: 1;
  padding: 12px;
  border-radius: var(--radius-sm);
  font-family: var(--font-heading);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

#reset-confirm {
  background: var(--danger);
  color: white;
  border: none;
}

#reset-cancel {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--card-border);
}

/* ==================== NOTIFICATIONS ==================== */

#notification-container {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 90%;
  max-width: 400px;
  pointer-events: none;
}

.notification {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  border: 1px solid var(--card-border);
  color: var(--text);
  font-size: 13px;
  backdrop-filter: blur(20px);
  transform: translateY(-20px);
  opacity: 0;
  transition: all 0.3s ease;
  pointer-events: auto;
}

.notification.show {
  transform: translateY(0);
  opacity: 1;
}

.notification.success {
  border-color: var(--success);
}

.notification.error {
  border-color: var(--danger);
}

.notification.achievement {
  border-color: var(--gold);
  box-shadow: var(--shadow-gold);
}

.notification.prestige {
  border-color: var(--gold);
  box-shadow: var(--shadow-gold);
  background: linear-gradient(135deg, oklch(20% 0.05 85 / 0.9), var(--bg-surface));
}

/* ==================== RESPONSIVE ==================== */

@media (min-width: 481px) {
  #app {
    border-left: 1px solid var(--card-border);
    border-right: 1px solid var(--card-border);
  }
}

@media (max-height: 600px) {
  #gold-display {
    font-size: 28px;
  }
  #mine-btn {
    width: 80px;
    height: 80px;
    font-size: 28px;
  }
  .upgrade-card {
    padding: 10px;
  }
}

/* ==================== ANIMATIONS ==================== */

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes shimmer {
  0% { background-position: -200px 0; }
  100% { background-position: 200px 0; }
}

.upgrade-card {
  animation: fadeIn 0.3s ease forwards;
}

.mine-card {
  animation: fadeIn 0.3s ease forwards;
}
