:root {
  --red: #e74c3c;
  --red-dark: #c0392b;
  --green: #2ecc71;
  --green-dark: #27ae60;
  --gold: #f1c40f;
  --bg: #1b1e2b;
  --bg-card: #262a3d;
  --bg-card-hover: #2f3450;
  --text: #eef0f6;
  --text-dim: #9aa0b5;
  --border: #3a3f5c;
  --rarity-common: #b0bec5;
  --rarity-uncommon: #4caf50;
  --rarity-rare: #2196f3;
  --rarity-epic: #9c27b0;
  --rarity-legendary: #ff9800;
  --rarity-mythic: #f44336;
}

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

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: linear-gradient(160deg, #141722 0%, #1b1e2b 50%, #20302a 100%);
  color: var(--text);
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: rgba(0, 0, 0, 0.35);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.logo {
  font-size: 1.4rem;
  letter-spacing: 1px;
  background: linear-gradient(90deg, var(--red), var(--gold));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: none;
}

.stats {
  display: flex;
  gap: 18px;
}

.stat {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-card);
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.stat-value {
  font-weight: 700;
  font-size: 1.05rem;
}

.game {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 24px 60px;
}

.click-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
}

.apple-button {
  position: relative;
  width: 260px;
  height: 260px;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 50%;
  transition: transform 0.08s ease;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

.apple-button:active {
  transform: scale(0.93);
}

.apple-emoji {
  font-size: 13rem;
  line-height: 1;
  filter: drop-shadow(0 14px 18px rgba(0, 0, 0, 0.45));
  transition: transform 0.08s ease;
  display: block;
  user-select: none;
}

.apple-button:hover .apple-emoji {
  transform: scale(1.04);
}

.apple-shadow {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  width: 150px;
  height: 26px;
  background: radial-gradient(ellipse, rgba(0, 0, 0, 0.45), transparent 70%);
  border-radius: 50%;
  z-index: -1;
}

.hint {
  margin-top: 22px;
  color: var(--text-dim);
  font-size: 0.95rem;
}

.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 65vh;
}

.tabs {
  display: flex;
  background: rgba(0, 0, 0, 0.25);
  border-bottom: 1px solid var(--border);
}

.tab {
  flex: 1;
  padding: 12px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}

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

.tab.active {
  color: var(--text);
  background: var(--bg-card);
  border-bottom: 2px solid var(--red);
}

.tab-panel {
  display: none;
  padding: 18px;
  overflow-y: auto;
  flex: 1;
}

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

.tab-panel h2 {
  font-size: 1.1rem;
  margin-bottom: 14px;
}

.panel-hint {
  color: var(--text-dim);
  font-size: 0.85rem;
  margin-bottom: 14px;
}

.upgrade-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.upgrade {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s;
}

.upgrade:hover {
  border-color: var(--green);
  transform: translateX(3px);
}

.upgrade.disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.upgrade.disabled:hover {
  border-color: var(--border);
  transform: none;
}

.upgrade-icon {
  font-size: 1.8rem;
}

.upgrade-info {
  flex: 1;
}

.upgrade-name {
  font-weight: 700;
}

.upgrade-desc {
  font-size: 0.82rem;
  color: var(--text-dim);
  margin-top: 2px;
}

.upgrade-cost {
  font-weight: 700;
  color: var(--gold);
  white-space: nowrap;
}

.upgrade-level {
  font-size: 0.78rem;
  color: var(--text-dim);
  text-align: right;
  white-space: nowrap;
}

.collection-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
}

.collection-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  text-align: center;
  transition: transform 0.1s;
}

.collection-card.found {
  border-color: var(--rarity-color, var(--rarity-common));
  box-shadow: 0 0 12px rgba(0, 0, 0, 0.4);
}

.collection-card.locked {
  opacity: 0.35;
}

.collection-icon {
  font-size: 2.2rem;
  display: block;
  margin-bottom: 6px;
}

.collection-name {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--rarity-color, var(--rarity-common));
}

.collection-count {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 3px;
}

.stat-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.stat-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
}

.stat-label {
  color: var(--text-dim);
  font-size: 0.9rem;
}

.save-controls {
  margin-top: 18px;
  text-align: center;
}

.btn {
  padding: 10px 18px;
  border: none;
  border-radius: 10px;
  font-weight: 700;
  cursor: pointer;
  font-size: 0.9rem;
  transition: filter 0.15s;
}

.btn:hover {
  filter: brightness(1.15);
}

.btn-danger {
  background: var(--red-dark);
  color: #fff;
}

.toast {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--gold);
  color: #1b1e2b;
  font-weight: 700;
  padding: 12px 22px;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  z-index: 100;
  transition: opacity 0.25s, transform 0.25s;
}

.toast.hidden {
  opacity: 0;
  transform: translateX(-50%) translateY(-12px);
  pointer-events: none;
}

.float-text {
  position: fixed;
  pointer-events: none;
  font-weight: 800;
  font-size: 1.3rem;
  color: var(--green);
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
  z-index: 50;
  animation: floatUp 1s ease-out forwards;
}

.float-text.rare {
  color: var(--gold);
  font-size: 1.6rem;
}

@keyframes floatUp {
  0% {
    opacity: 1;
    transform: translateY(0);
  }
  100% {
    opacity: 0;
    transform: translateY(-70px);
  }
}

@media (max-width: 760px) {
  .game {
    grid-template-columns: 1fr;
    padding: 18px 14px 40px;
  }

  .click-area {
    min-height: auto;
    padding: 20px 0;
  }

  .apple-button {
    width: 200px;
    height: 200px;
  }

  .apple-emoji {
    font-size: 10rem;
  }

  .panel {
    max-height: none;
  }

  .stats {
    gap: 8px;
  }

  .stat {
    padding: 6px 10px;
  }

  .logo {
    font-size: 1rem;
  }
}
