:root {
  --blue-900: #06213f;
  --blue-800: #0a2f5c;
  --blue-700: #0f3e78;
  --brand-blue: #0d6efd;
  --brand-blue-light: #4f9dff;
  --accent: #22d3a5;
  --accent-dark: #14a883;
  --gold: #ffc94d;
  --card-bg: rgba(255, 255, 255, 0.06);
  --card-bg-hover: rgba(255, 255, 255, 0.1);
  --card-border: rgba(255, 255, 255, 0.12);
  --text-main: #eef4ff;
  --text-dim: #9fb3d1;
  --danger: #ff6b6b;
  --radius: 14px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: var(--font);
  background: radial-gradient(ellipse at top, var(--blue-700) 0%, var(--blue-900) 60%, #030f1f 100%);
  color: var(--text-main);
  overflow-x: hidden;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.bg-decor {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    radial-gradient(circle at 15% 20%, rgba(79, 157, 255, 0.12) 0%, transparent 35%),
    radial-gradient(circle at 85% 75%, rgba(34, 211, 165, 0.10) 0%, transparent 40%);
}

/* ---------- Topbar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 14px 24px;
  background: rgba(6, 20, 40, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--card-border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.3rem;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--brand-blue), var(--brand-blue-light));
  font-size: 1.1rem;
  box-shadow: 0 4px 14px rgba(13, 110, 253, 0.45);
}

.brand-mark .plus { color: var(--accent); }

.plus-text { color: var(--accent); }

.stats {
  display: flex;
  gap: 22px;
  flex-wrap: wrap;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  min-width: 90px;
}

.stat-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}

.stat-value {
  font-size: 1.15rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

#score { color: var(--gold); }
#perSecond { color: var(--accent); }

/* ---------- Layout ---------- */

.game {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(320px, 480px);
  gap: 24px;
  max-width: 1180px;
  margin: 0 auto;
  padding: 32px 24px 60px;
}

@media (max-width: 860px) {
  .game { grid-template-columns: 1fr; }
}

/* ---------- Clicker zone ---------- */

.clicker-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding-top: 20px;
  position: relative;
}

.level-progress-wrap {
  width: 100%;
  max-width: 340px;
  margin-bottom: 28px;
}

.level-progress-bar {
  width: 100%;
  height: 10px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  border: 1px solid var(--card-border);
}

.level-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--brand-blue), var(--accent));
  transition: width 0.25s ease;
}

.level-progress-text {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 6px;
}

.house-btn {
  position: relative;
  width: 260px;
  height: 260px;
  border-radius: 50%;
  border: none;
  touch-action: manipulation;
  background: radial-gradient(circle at 35% 30%, #143f77, #0a2242 75%);
  box-shadow:
    0 0 0 8px rgba(13, 110, 253, 0.12),
    0 20px 50px rgba(0, 0, 0, 0.45),
    inset 0 0 40px rgba(79, 157, 255, 0.15);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.06s ease;
}

.house-btn:active { transform: scale(0.94); }

.house-emoji {
  font-size: 7.5rem;
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.5));
  transition: transform 0.08s ease;
}

.house-btn:active .house-emoji { transform: scale(0.92) rotate(-2deg); }

.click-value {
  position: absolute;
  bottom: 14px;
  background: rgba(6, 20, 40, 0.85);
  border: 1px solid var(--card-border);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--gold);
}

.tagline {
  margin-top: 26px;
  font-size: 0.95rem;
  color: var(--text-dim);
  font-style: italic;
  text-align: center;
  min-height: 1.3em;
}

.hint {
  margin-top: 4px;
  font-size: 0.78rem;
  color: var(--text-dim);
  opacity: 0.7;
}

/* ---------- Floating +$ numbers ---------- */

.float-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
}

.float-num {
  position: absolute;
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--gold);
  text-shadow: 0 2px 6px rgba(0,0,0,0.5);
  animation: floatUp 0.9s ease-out forwards;
}

@keyframes floatUp {
  0% { transform: translate(-50%, 0) scale(0.8); opacity: 1; }
  100% { transform: translate(-50%, -70px) scale(1.15); opacity: 0; }
}

/* ---------- Panel / shop ---------- */

.panel {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  min-height: 400px;
  max-height: 640px;
}

.panel-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}

.tab-btn {
  flex: 1;
  padding: 9px 6px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-dim);
  font-weight: 600;
  font-size: 0.82rem;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.tab-btn:hover { background: rgba(255,255,255,0.06); }

.tab-btn.active {
  background: rgba(13, 110, 253, 0.18);
  border-color: rgba(79, 157, 255, 0.4);
  color: var(--text-main);
}

.tab-content {
  display: none;
  overflow-y: auto;
  flex: 1;
  padding-right: 4px;
}

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

.shop-list, .achv-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ---------- Shop item ---------- */

.shop-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--card-border);
  background: rgba(255,255,255,0.03);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
  text-align: left;
}

.shop-item:hover:not(.disabled) {
  background: var(--card-bg-hover);
  border-color: rgba(79, 157, 255, 0.35);
}

.shop-item:active:not(.disabled) { transform: scale(0.985); }

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

.shop-item.affordable {
  border-color: rgba(34, 211, 165, 0.45);
  box-shadow: 0 0 0 1px rgba(34, 211, 165, 0.15) inset;
}

.shop-icon {
  font-size: 1.8rem;
  width: 42px;
  text-align: center;
  flex-shrink: 0;
}

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

.shop-name {
  font-weight: 700;
  font-size: 0.92rem;
  display: flex;
  align-items: center;
  gap: 6px;
}

.shop-count {
  font-size: 0.72rem;
  background: rgba(255,255,255,0.1);
  padding: 1px 7px;
  border-radius: 10px;
  color: var(--text-dim);
  font-weight: 600;
}

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

.shop-sub {
  font-size: 0.72rem;
  color: var(--accent);
  margin-top: 2px;
}

.shop-cost {
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--gold);
  white-space: nowrap;
  flex-shrink: 0;
}

/* ---------- Achievements ---------- */

.achv-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--card-border);
  background: rgba(255,255,255,0.03);
}

.achv-item.unlocked {
  border-color: rgba(255, 201, 77, 0.5);
  background: rgba(255, 201, 77, 0.06);
}

.achv-icon {
  font-size: 1.6rem;
  width: 36px;
  text-align: center;
  filter: grayscale(1) opacity(0.4);
}

.achv-item.unlocked .achv-icon {
  filter: none;
}

.achv-name {
  font-weight: 700;
  font-size: 0.85rem;
}

.achv-desc {
  font-size: 0.72rem;
  color: var(--text-dim);
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(10, 30, 55, 0.95);
  border: 1px solid rgba(255, 201, 77, 0.5);
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 100;
  max-width: 90vw;
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---------- Footer ---------- */

.footer {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 18px 24px 30px;
  text-align: center;
  font-size: 0.7rem;
  color: var(--text-dim);
  opacity: 0.7;
}

.contact-link {
  color: var(--brand-blue-light);
  text-decoration: none;
  opacity: 1;
}

.contact-link:hover {
  text-decoration: underline;
}

.reset-btn {
  background: transparent;
  border: 1px solid var(--card-border);
  color: var(--danger);
  padding: 5px 12px;
  border-radius: 8px;
  font-size: 0.7rem;
  cursor: pointer;
  opacity: 1;
}

.reset-btn:hover {
  background: rgba(255, 107, 107, 0.1);
  border-color: rgba(255, 107, 107, 0.4);
}

/* scrollbar */
.tab-content::-webkit-scrollbar { width: 6px; }
.tab-content::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 4px; }

/* ---------- Mobile ---------- */

@media (max-width: 480px) {
  .topbar { padding: 10px 16px; gap: 8px 16px; }
  .stats { gap: 10px 18px; }
  .stat { align-items: flex-start; }
  .game { padding: 16px 16px 40px; }
  .clicker-zone { padding-top: 4px; }
  .house-btn { width: 190px; height: 190px; }
  .house-emoji { font-size: 5.4rem; }
  .level-progress-wrap { margin-bottom: 18px; }
}
