/* ============================================================
   DINGUS CLICKER — 4 Panel + Big Dingus Layout
   ============================================================ */

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

:root {
  --bg:            #1a1c2c;
  --surface:       #252838;
  --surface-raised:#30334a;
  --text:          #e8e0d0;
  --text-dim:      #8a8578;
  --accent:        #e05555;
  --accent2:       #6cc070;
  --gold:          #dba840;
  --souls:         #b880ff;
  --divider:       rgba(138,133,120,0.25);
  --font:          'Pixelify Sans', cursive;
}

html, body {
  width: 100%; height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  image-rendering: pixelated;
  -webkit-user-select: none;
  user-select: none;
}

/* ----- SCANLINES & VIGNETTE ------------------------------ */
.scanlines {
  position: fixed; inset: 0; z-index: 999; pointer-events: none;
  background: repeating-linear-gradient(0deg, transparent, transparent 3px, rgba(0,0,0,0.05) 3px, rgba(0,0,0,0.05) 6px);
}
.vignette {
  position: fixed; inset: 0; z-index: 998; pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 60%, rgba(0,0,0,0.55) 100%);
}

/* ----- PARTICLE CANVAS ----------------------------------- */
#particle-canvas { position: fixed; inset: 0; z-index: 500; pointer-events: none; }

/* ===== TOP BAR ========================================== */
.top-bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 150;
  padding: 12px 20px 10px;
  display: flex; align-items: baseline; gap: 30px;
  background: linear-gradient(180deg, rgba(26,28,44,1) 0%, rgba(26,28,44,0.95) 70%, transparent 100%);
}
.title {
  font-size: 1.8rem; font-weight: 700; letter-spacing: 2px; color: var(--accent);
  text-shadow: 3px 3px 0 rgba(0,0,0,0.35); white-space: nowrap;
  animation: titlePulse 3s ease-in-out infinite;
}
.cursor-blink { animation: blink 0.8s steps(1) infinite; color: var(--accent2); }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0} }
@keyframes titlePulse { 0%,100%{transform:scale(1)} 50%{transform:scale(1.01)} }

.top-stats { display: flex; gap: 24px; flex-wrap: wrap; }
.top-stat { display: flex; flex-direction: column; gap: 1px; }
.ts-label { font-size: 0.55rem; letter-spacing: 2px; color: var(--text-dim); }
.ts-value { font-size: 1.3rem; font-weight: 700; color: var(--text); text-shadow: 1px 1px 0 rgba(0,0,0,0.4); }
.ts-value.dps { color: var(--accent2); }
.ts-value.souls { color: var(--souls); }

/* ===== PANELS =========================================== */
.panel {
  position: fixed; top: 100px; bottom: 20px;
  width: 210px;
  z-index: 100;
  display: flex; flex-direction: column; gap: 10px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--surface-raised) transparent;
}
.panel::-webkit-scrollbar { width: 4px; }
.panel::-webkit-scrollbar-track { background: transparent; }
.panel::-webkit-scrollbar-thumb { background: var(--surface-raised); border-radius: 2px; }

.p1 { left: 16px; }
.p2 { left: 236px; }
.p3 { left: 456px; }
.p4 { left: 676px; }

/* ===== SECTIONS ========================================= */
.section {
  background: var(--surface);
  padding: 10px 12px;
  border: 2px solid var(--divider);
}
.section-title {
  font-size: 0.62rem; font-weight: 700; letter-spacing: 4px; color: var(--accent2);
  margin-bottom: 8px;
}

/* Stat rows */
.stat-row {
  display: flex; justify-content: space-between; padding: 3px 0;
  font-size: 0.68rem; color: var(--text-dim);
  border-bottom: 1px dotted var(--divider);
}
.stat-row:last-child { border-bottom: none; }
.stat-row span:last-child { color: var(--text); font-weight: 600; }

/* Combo */
.combo-meter { width: 100%; height: 10px; background: #0f1018; overflow: hidden; }
.combo-fill {
  height: 100%;
  background: repeating-linear-gradient(90deg, var(--accent2) 0px, var(--accent2) 8px, var(--gold) 8px, var(--gold) 16px);
  width: 0%; transition: width 0.15s ease;
}
.combo-text {
  font-size: 0.68rem; font-weight: 700; color: var(--gold); min-height: 18px; margin-top: 4px; letter-spacing: 1px;
}
.combo-text.max { color: var(--accent); animation: shake 0.2s ease infinite; }
@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-3px)} 75%{transform:translateX(3px)} }

/* Shop */
.shop-section { flex: 1; min-height: 0; display: flex; flex-direction: column; }
#shop-items { flex: 1; display: flex; flex-direction: column; gap: 4px; overflow-y: auto; min-height: 0; }
.shop-item {
  background: var(--surface-raised); padding: 6px 8px; cursor: pointer;
  transition: all 0.1s ease; border: 2px solid transparent;
}
.shop-item:hover { border-color: var(--accent2); background: #363a52; transform: translateX(2px); }
.shop-item.unaffordable { opacity: 0.35; cursor: not-allowed; }
.shop-item.unaffordable:hover { border-color: transparent; transform: none; background: var(--surface-raised); }
.shop-item.owned { border-color: rgba(108,192,112,0.2); }
.shop-item-name { font-size: 0.62rem; font-weight: 700; color: var(--text); }
.shop-item-desc { font-size: 0.54rem; color: var(--text-dim); margin: 1px 0; }
.shop-item-bottom { display: flex; justify-content: space-between; align-items: center; margin-top: 2px; }
.shop-item-cost { font-size: 0.58rem; font-weight: 700; color: var(--gold); }
.shop-item-owned-count { font-size: 0.52rem; color: var(--accent2); }
.shop-item-effect { font-size: 0.52rem; color: var(--accent2); margin-top: 1px; }

/* Achievements */
.achievements-list { display: flex; flex-wrap: wrap; gap: 3px; min-height: 20px; align-items: center; }
.no-achievements { font-size: 0.58rem; color: var(--text-dim); font-style: italic; }
.achievement-badge {
  font-size: 0.54rem; padding: 2px 6px; background: var(--surface-raised);
  color: var(--gold);
  animation: badgePop 0.35s cubic-bezier(0.68,-0.55,0.27,1.55); letter-spacing: 1px;
}
@keyframes badgePop { 0%{transform:scale(0);opacity:0} 60%{transform:scale(1.15)} 100%{transform:scale(1);opacity:1} }

/* ===== PRESTIGE ========================================= */
.prestige-info { font-size: 0.58rem; color: var(--text-dim); line-height: 1.5; }
.prestige-info p { margin-bottom: 3px; }
.hl { color: var(--souls); font-weight: 700; }
.prestige-gain span { color: var(--souls); font-weight: 700; }
.prestige-req span { color: var(--accent); font-weight: 700; }

#prestige-btn {
  margin-top: 6px;
  width: 100%; padding: 6px;
  font-family: var(--font); font-size: 0.7rem; font-weight: 700; letter-spacing: 2px;
  background: var(--souls); color: #fff; border: none; cursor: pointer;
  transition: all 0.15s; text-shadow: 1px 1px 0 rgba(0,0,0,0.4);
}
#prestige-btn:hover:not(:disabled) { background: #c99dff; transform: scale(1.03); }
#prestige-btn:disabled { opacity: 0.3; cursor: not-allowed; background: #444; }

/* Soul shop */
#soul-shop-items { display: flex; flex-direction: column; gap: 4px; }
.soul-item {
  background: var(--surface-raised); padding: 6px 8px; cursor: pointer;
  transition: all 0.1s ease; border: 2px solid transparent;
}
.soul-item:hover { border-color: var(--souls); background: #36304a; transform: translateX(2px); }
.soul-item.unaffordable { opacity: 0.35; cursor: not-allowed; }
.soul-item.unaffordable:hover { border-color: transparent; transform: none; background: var(--surface-raised); }
.soul-item.bought { opacity: 0.5; border-color: rgba(184,128,255,0.3); cursor: default; }
.soul-item.bought:hover { transform: none; background: var(--surface-raised); }
.soul-item-name { font-size: 0.62rem; font-weight: 700; color: var(--souls); }
.soul-item-desc { font-size: 0.54rem; color: var(--text-dim); margin: 1px 0; }
.soul-item-cost { font-size: 0.58rem; font-weight: 700; color: var(--souls); }

/* ===== MISSIONS ========================================= */
#missions-list { display: flex; flex-direction: column; gap: 6px; }
.mission-card {
  background: var(--surface-raised); padding: 8px 10px;
  border: 2px solid var(--divider);
  transition: all 0.15s;
}
.mission-card.claimable { border-color: var(--accent2); cursor: pointer; }
.mission-card.claimable:hover { background: #364038; transform: translateX(2px); }
.mission-card.completed { opacity: 0.4; border-color: rgba(108,192,112,0.15); cursor: default; }
.mission-card-name { font-size: 0.6rem; font-weight: 700; color: var(--text); }
.mission-card-desc { font-size: 0.54rem; color: var(--text-dim); margin: 2px 0; }
.mission-card-progress {
  width: 100%; height: 6px; background: #0f1018; margin-top: 4px; overflow: hidden;
}
.mission-card-fill {
  height: 100%; background: var(--accent2);
  transition: width 0.3s ease;
}
.mission-card-reward { font-size: 0.54rem; color: var(--gold); margin-top: 3px; }
.mission-timer { font-size: 0.54rem; color: var(--text-dim); margin-top: 8px; text-align: center; }

/* ===== DINGUS — Always flush bottom-right ============== */
.dingus-zone { position: fixed; right: 0; bottom: 0; z-index: 200; padding: 0; }
.dingus-wrapper { position: relative; cursor: pointer; display: block; line-height: 0; }
#dingus {
  display: block;
  width: calc(100vw - 1100px);
  min-width: 200px;
  height: auto;
  image-rendering: pixelated;
  transition: transform 0.05s ease, filter 0.07s ease;
  filter: drop-shadow(-6px -6px 0 rgba(0,0,0,0.4));
}
.dingus-wrapper:hover #dingus { filter: drop-shadow(-6px -6px 0 rgba(0,0,0,0.5)) brightness(1.06); transform: scale(1.07); }
.dingus-wrapper.crit #dingus {
  transform: scale(0.85) rotate(-7deg);
  filter: brightness(1.4) saturate(2.5) hue-rotate(20deg) drop-shadow(-6px -6px 0 rgba(0,0,0,0.5));
}
.dingus-wrapper.lucky #dingus { animation: dingusWiggle 0.3s ease; }
@keyframes dingusWiggle {
  0%{transform:scale(0.9) rotate(0)} 25%{transform:scale(0.86) rotate(-4deg)}
  50%{transform:scale(0.93) rotate(4deg)} 75%{transform:scale(0.88) rotate(-3deg)}
  100%{transform:scale(0.9) rotate(0)}
}

/* Blur overlay */
.blur-overlay { animation: blurIn 0.4s ease-out forwards; }
@keyframes blurIn {
  0%{ filter: blur(0px) brightness(1); }
  40%{ filter: blur(3px) brightness(1.5); }
  100%{ filter: blur(0px) brightness(1); }
}

/* ===== FLOATING NUMBERS ================================= */
#floating-numbers { position: fixed; inset: 0; pointer-events: none; z-index: 600; }
.float-number {
  position: absolute; font-family: var(--font); font-weight: 700; font-size: 2.4rem;
  color: var(--text); text-shadow: 2px 2px 0 rgba(0,0,0,0.5);
  pointer-events: none; animation: floatUp 0.9s ease-out forwards;
}
.float-number.crit { font-size: 3.6rem; color: var(--accent); text-shadow: 2px 2px 0 rgba(0,0,0,0.5); animation: floatUpCrit 0.85s ease-out forwards; }
.float-number.lucky-pop { font-size: 2.8rem; color: var(--accent2); text-shadow: 2px 2px 0 rgba(0,0,0,0.5); }
.float-number.combo-fire { font-size: 3rem; color: var(--gold); text-shadow: 2px 2px 0 rgba(0,0,0,0.5); animation: floatUpCombo 0.85s ease-out forwards; }
@keyframes floatUp {
  0% { opacity:1; transform:translateY(0) scale(0.2); }
  10% { opacity:1; transform:translateY(-10px) scale(1.35); }
  100% { opacity:0; transform:translateY(-160px) scale(0.85); }
}
@keyframes floatUpCrit {
  0% { opacity:1; transform:translateY(0) scale(0.15) rotate(-5deg); }
  10% { opacity:1; transform:translateY(-8px) scale(1.5) rotate(3deg); }
  100% { opacity:0; transform:translateY(-180px) scale(0.8) rotate(0deg); }
}
@keyframes floatUpCombo {
  0% { opacity:1; transform:translateY(0) scale(0.3) rotate(0); }
  10% { opacity:1; transform:translateY(-12px) scale(1.4) rotate(-4deg); }
  100% { opacity:0; transform:translateY(-170px) scale(0.9) rotate(2deg); }
}

/* ===== SCREEN SHAKE ===================================== */
body.shake-active { animation: screenShake 0.25s ease-out; }
body.shake-heavy { animation: screenShakeHeavy 0.35s ease-out; }
@keyframes screenShake {
   0%{transform:translate(0)} 10%{transform:translate(-5px,3px)} 20%{transform:translate(5px,-4px)}
  30%{transform:translate(-3px,0)} 40%{transform:translate(4px,2px)} 50%{transform:translate(-2px,-2px)}
  60%{transform:translate(3px,0)} 70%{transform:translate(-2px,2px)} 80%{transform:translate(2px,-1px)}
  90%{transform:translate(-1px,1px)} 100%{transform:translate(0)}
}
@keyframes screenShakeHeavy {
   0%{transform:translate(0)} 10%{transform:translate(-8px,5px)} 20%{transform:translate(8px,-6px)}
  30%{transform:translate(-5px,2px)} 40%{transform:translate(6px,4px)} 50%{transform:translate(-4px,-4px)}
  60%{transform:translate(5px,1px)} 70%{transform:translate(-3px,3px)} 80%{transform:translate(4px,-2px)}
  90%{transform:translate(-2px,2px)} 100%{transform:translate(0)}
}

/* ===== GOLDEN FLASH ===================================== */
.golden-flash { animation: goldenPulse 0.5s ease-out; }
@keyframes goldenPulse {
  0% { box-shadow: 0 0 40px rgba(219,168,64,0.6), 0 0 80px rgba(219,168,64,0.25); }
  100% { box-shadow: 0 0 0 rgba(219,168,64,0); }
}

/* ===== RESET BUTTON ===================================== */
#reset-btn {
  position: fixed; top: 8px; right: 8px; z-index: 700;
  background: var(--surface); border: 2px solid var(--divider);
  color: var(--text-dim); font-family: var(--font); font-size: 0.9rem;
  width: 28px; height: 28px; cursor: pointer; transition: all 0.15s;
}
#reset-btn:hover { color: var(--accent); border-color: var(--accent); }

/* ===== RAINBOW MODE ===================================== */
body.rainbow-bg { animation: rainbowBg 5s linear infinite; }
@keyframes rainbowBg {
   0%{background-color:#1a1c2c} 16%{background-color:#221a2a} 33%{background-color:#1a1c2c}
  50%{background-color:#1a242a} 66%{background-color:#1a2a24} 83%{background-color:#2a1a1c}
 100%{background-color:#1a1c2c}
}

/* ===== RESPONSIVE ======================================= */
@media (max-width: 1050px) {
  .panel { width: 170px; }
  .p1 { left: 10px; } .p2 { left: 190px; } .p3 { left: 370px; } .p4 { left: 550px; }
  #dingus { width: calc(100vw - 740px); min-width: 150px; }
  .title { font-size: 1.4rem; }
}
@media (max-width: 800px) {
  .panel { width: 150px; }
  .p1 { left: 6px; } .p2 { left: 162px; } .p3 { left: 318px; } .p4 { left: 474px; }
  #dingus { width: calc(100vw - 640px); min-width: 120px; }
  .title { font-size: 1.2rem; }
  .top-bar { padding: 8px 10px; gap: 16px; }
}

/* ===== MOBILE LAYOUT (JS adds .mobile class to body) ==== */
body.mobile {
  overflow-y: auto;
  overflow-x: hidden;
}
body.mobile .top-bar {
  position: relative; top: auto; left: auto; right: auto;
  padding: 10px 12px 8px; gap: 20px;
  flex-wrap: wrap; background: var(--bg);
}
body.mobile .title { font-size: 1.4rem; }
body.mobile .top-stats { gap: 14px; }
body.mobile .ts-value { font-size: 1rem; }

/* Tab bar */
.mobile-tabs {
  display: none;
  position: sticky; top: 0; z-index: 300;
  background: var(--surface);
  border-bottom: 2px solid var(--divider);
}
body.mobile .mobile-tabs { display: flex; }
.mobile-tab {
  flex: 1; padding: 10px 4px; text-align: center;
  font-family: var(--font); font-size: 0.55rem; font-weight: 700;
  letter-spacing: 1px; color: var(--text-dim);
  background: transparent; border: none; border-bottom: 3px solid transparent;
  cursor: pointer; transition: all 0.15s;
}
.mobile-tab.active { color: var(--accent2); border-bottom-color: var(--accent2); background: rgba(108,192,112,0.05); }

/* Panels on mobile */
body.mobile .panel {
  position: relative; top: auto; left: auto; right: auto; bottom: auto;
  width: 100% !important;
  padding: 10px 12px; gap: 10px;
  display: none;
}
body.mobile .panel.active { display: flex; }
body.mobile .section { max-height: none; }
body.mobile #shop-items { max-height: 50vh; }

/* Dingus on mobile */
body.mobile .dingus-zone {
  position: relative; right: auto; bottom: auto;
  width: 100%; text-align: center; padding: 16px 0 0;
}
body.mobile #dingus {
  width: 70vw; max-width: 320px; min-width: 200px;
  margin: 0 auto;
}

/* Floating numbers stay fixed */
body.mobile #floating-numbers { position: fixed; }
body.mobile #reset-btn { position: fixed; top: 8px; right: 8px; }

/* Hide normal panel positioning on mobile */
body.mobile .p1, body.mobile .p2, body.mobile .p3, body.mobile .p4 {
  left: auto !important;
}

/* Scrollable body on mobile */
body.mobile { padding-bottom: 20px; }
