/* ===== VARIABLES ===== */
:root {
  --bg:        #0d0500;
  --panel:     #160900;
  --card:      #2a1100;
  --border:    #3d1a00;
  --gold:      #f0a500;
  --gold-lite: #ffd166;
  --text:      #fff8e7;
  --muted:     #8a6a40;
  --green:     #4caf50;
  --red:       #f44336;
  --blue:      #42a5f5;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ===== HEADER ===== */
header {
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-shrink: 0;
  z-index: 50;
  height: 62px;
}

.header-left { flex: 1; min-width: 0; }

#cookie-count {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--gold);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#total-count {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 1px;
}

#cps-display {
  font-size: 0.95rem;
  color: var(--muted);
  white-space: nowrap;
}

/* ===== SYNC STATUS BADGE ===== */
.sync-status {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid;
  white-space: nowrap;
  transition: color 0.3s, border-color 0.3s;
}

.sync-status.synced  { color: var(--green); border-color: var(--green); }
.sync-status.syncing { color: var(--blue);  border-color: var(--blue);
                        animation: badge-pulse 1s ease-in-out infinite; }
.sync-status.pending { color: var(--gold);  border-color: var(--gold); }
.sync-status.offline { color: var(--red);   border-color: var(--red); }
.sync-status.error   { color: var(--red);   border-color: var(--red); }

@keyframes badge-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.35; }
}

/* ===== MAIN LAYOUT ===== */
main {
  display: grid;
  grid-template-columns: 1fr 360px;
  flex: 1;
  min-height: 0;
  height: calc(100vh - 62px);
}

/* ===== CLICK AREA ===== */
#click-area {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  background: radial-gradient(ellipse at center, #1e0900 0%, var(--bg) 72%);
  user-select: none;
}

#cookie-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

#cookie {
  font-size: 140px;
  line-height: 1;
  cursor: pointer;
  display: block;
  filter: drop-shadow(0 0 24px rgba(240,165,0,0.45));
  transition: filter 0.15s;
  will-change: transform;
}

#cookie:hover {
  filter: drop-shadow(0 0 36px rgba(240,165,0,0.75));
}

#cookie.clicked {
  animation: cookie-pop 0.12s ease;
}

@keyframes cookie-pop {
  0%   { transform: scale(1); }
  40%  { transform: scale(0.88); }
  100% { transform: scale(1); }
}

#click-hint {
  font-size: 0.8rem;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0;
  transition: opacity 0.5s;
  pointer-events: none;
}

body.no-cookies #click-hint { opacity: 1; }

/* ===== FLOATING TEXT ===== */
.float-text {
  position: absolute;
  pointer-events: none;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--gold-lite);
  text-shadow: 0 0 8px rgba(255,209,102,0.6);
  animation: float-up 0.9s ease-out forwards;
  white-space: nowrap;
  z-index: 10;
}

@keyframes float-up {
  0%   { transform: translateY(0) scale(1);    opacity: 1; }
  20%  { transform: translateY(-20px) scale(1.1); }
  100% { transform: translateY(-90px) scale(0.9); opacity: 0; }
}

/* ===== SHOP ===== */
#shop {
  background: var(--panel);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

#shop::-webkit-scrollbar       { width: 5px; }
#shop::-webkit-scrollbar-track { background: transparent; }
#shop::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

#shop h2 {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  padding: 10px 14px 8px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--panel);
  z-index: 5;
}

.empty-msg {
  padding: 10px 14px;
  font-size: 0.8rem;
  color: var(--muted);
  font-style: italic;
}

/* ===== SHOP ITEMS ===== */
.shop-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  opacity: 0.42;
  transition: background 0.12s, opacity 0.15s;
}

.shop-item.affordable { opacity: 1; }

.shop-item:hover {
  background: var(--card);
  opacity: 1;
}

.shop-item:active { background: #331500; }

.item-emoji {
  font-size: 1.7rem;
  flex-shrink: 0;
  width: 36px;
  text-align: center;
}

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

.item-name {
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-desc {
  font-size: 0.7rem;
  color: var(--muted);
  margin-top: 1px;
}

.item-production {
  font-size: 0.68rem;
  color: var(--gold);
  margin-top: 2px;
}

.item-right {
  text-align: right;
  flex-shrink: 0;
  min-width: 56px;
}

.item-cost {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--gold-lite);
}

.item-cost-label {
  font-size: 0.6rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.item-owned {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--gold);
  margin-top: 3px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 680px) {
  body { overflow: auto; }

  main {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    height: auto;
  }

  #click-area {
    min-height: 260px;
    padding: 20px;
  }

  #cookie { font-size: 110px; }

  #shop {
    border-left: none;
    border-top: 1px solid var(--border);
    max-height: 55vh;
  }
}
