:root {
  --main-font: 'Merriweather', serif;
  --bg-color: #1a120b;
  --panel-bg: rgba(20, 15, 10, 0.85);
  --border-color: #5c3d2e;
  --text-main: #f5ebe0;
  --text-accent: #e3b04b;
  --text-muted: #a39171;
  --lane-bg: rgba(255, 255, 255, 0.03);
}

/* ANTI-HANDY-BUG: Verhindert Markieren und Zoomen */
* { 
  box-sizing: border-box; margin: 0; padding: 0; 
  user-select: none; 
  -webkit-user-select: none; 
  -webkit-touch-callout: none; 
}

body { font-family: var(--main-font); background: url('bakery.jpg') center/cover no-repeat fixed var(--bg-color); color: var(--text-main); height: 100vh; overflow: hidden; }

/* Keks & Effekte */
#falling-items-container, #floating-text-container { position: fixed; inset: 0; pointer-events: none; z-index: 9999; overflow: hidden; }
.falling-item { position: absolute; width: 30px; height: 30px; border-radius: 50%; background-image: url('cookie.jpg'); background-size: cover; animation: fallAnimation 2s linear forwards; }
@keyframes fallAnimation { 0% { transform: translateY(-50px) rotate(0deg); opacity: 1; } 100% { transform: translateY(110vh) rotate(360deg); opacity: 0; } }

.floating-number { position: absolute; font-size: 1.5rem; font-weight: 900; color: #fff; text-shadow: 0 2px 4px rgba(0,0,0,0.8); animation: floatUp 1s ease-out forwards; pointer-events: none; }
@keyframes floatUp { 0% { transform: translateY(0) scale(1); opacity: 1; } 100% { transform: translateY(-50px) scale(1.5); opacity: 0; } }

#golden-cookie { position: fixed; width: 80px; height: 80px; border-radius: 50%; background: radial-gradient(circle, #ffeb3b, #f57f17); box-shadow: 0 0 20px #ffeb3b, inset 0 0 10px #fff; cursor: pointer; z-index: 10000; display: none; animation: pulseGolden 2s infinite alternate; }
@keyframes pulseGolden { 0% { transform: scale(0.9) rotate(-5deg); box-shadow: 0 0 10px #ffeb3b; } 100% { transform: scale(1.1) rotate(5deg); box-shadow: 0 0 40px #fff; } }

/* NEU: Das Tooltip (Hover-Info) */
.game-tooltip { position: fixed; background: #2b1d16; border: 2px solid #a37254; color: white; padding: 12px; border-radius: 4px; pointer-events: none; z-index: 100000; box-shadow: 4px 4px 15px rgba(0,0,0,0.8); width: 280px; }
.game-tooltip.hidden { display: none; }
.tooltip-header { display: flex; justify-content: space-between; font-weight: bold; font-size: 1.1rem; margin-bottom: 8px; border-bottom: 1px solid rgba(255,255,255,0.1); padding-bottom: 4px; }
.tt-cost { color: #ff8a8a; } /* Rote Kosten wie im Screenshot */
.tt-desc { font-size: 0.9rem; color: #ccc; white-space: pre-line; } /* pre-line: für CPS-Aufschlüsselung mit Zeilenumbrüchen */

.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.8); display: flex; justify-content: center; align-items: center; z-index: 20000; }
.modal.hidden { display: none; }
.modal-content { background: var(--panel-bg); border: 4px solid var(--text-accent); padding: 30px; border-radius: 15px; text-align: center; max-width: 400px; }
.offline-amount { font-size: 2rem; color: var(--text-accent); margin: 20px 0; font-weight: 900; }
.modal-btn { background: var(--text-accent); color: #000; border: none; font-weight: bold; padding: 10px 20px; font-size: 1.2rem; cursor: pointer; border-radius: 5px; }

.news-ticker { background: rgba(0,0,0,0.9); border-bottom: 2px solid var(--border-color); padding: 8px; text-align: center; font-style: italic; color: #ddd; height: 35px; overflow: hidden; }

.home-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 15000;
  color: var(--text-main);
  background: rgba(0,0,0,0.72);
  border: 1px solid var(--border-color);
  border-radius: 999px;
  padding: 8px 12px;
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 700;
  box-shadow: 0 4px 14px rgba(0,0,0,0.35);
}

.home-link:hover,
.home-link:focus-visible {
  color: #000;
  background: var(--text-accent);
  outline: none;
}

.game-wrapper { display: grid; grid-template-columns: 320px 1fr 340px; height: calc(100vh - 35px); }
.panel { display: flex; flex-direction: column; background: var(--panel-bg); backdrop-filter: blur(5px); }

/* Links */
.left-panel { border-right: 4px solid var(--border-color); align-items: center; padding-top: 20px; }
.bakery-name { font-size: 1.5rem; font-weight: 900; background: rgba(0,0,0,0.5); padding: 10px 20px; border-radius: 20px; margin-bottom: 20px; }
.score-board { text-align: center; margin-bottom: 40px; }
.big-score { font-size: 3rem; font-weight: 900; color: var(--text-accent); text-shadow: 0 4px 10px rgba(0,0,0,0.5); transition: color 0.3s; }
.score-label { font-size: 1.2rem; margin-bottom: 5px; }
.cps-text { font-size: 0.9rem; color: var(--text-muted); }

/* WICHTIG: Keks-Button Bugfix */
.main-cookie-btn { background: none; border: none; cursor: pointer; transition: transform 0.1s; outline: none; touch-action: manipulation; }
.main-cookie-btn:active { transform: scale(0.92); }
.main-cookie-btn.wobble { animation: cookieWobble 0.25s ease; }
@keyframes cookieWobble {
  0% { transform: scale(1); }
  30% { transform: scale(0.93) rotate(-2deg); }
  60% { transform: scale(1.04) rotate(1.5deg); }
  100% { transform: scale(1) rotate(0deg); }
}
body.frenzy .cps-text { color: #ffeb3b; font-weight: bold; }
#main-cookie-img { width: 260px; filter: drop-shadow(0 15px 25px rgba(0,0,0,0.5)); border-radius: 50%; pointer-events: none; } /* Bild nicht auswählbar machen! */

/* Mitte (Lanes mit CSS/Emoji Icons) */
.middle-panel { overflow-y: auto; background: rgba(0,0,0,0.4); }
.lane { min-height: 120px; border-bottom: 2px solid var(--border-color); background: var(--lane-bg); position: relative; display: flex; flex-wrap: wrap; align-content: flex-start; gap: 8px; padding: 30px 15px 15px 15px; }
.lane-title { position: absolute; top: 5px; left: 10px; font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; font-weight: bold; }
.lane-icon { font-size: 30px; line-height: 1; filter: drop-shadow(2px 2px 2px rgba(0,0,0,0.8)); animation: idleBob 3s infinite ease-in-out; }
.lane-icon:nth-child(even) { animation-delay: 1.5s; }
@keyframes idleBob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }

/* Rechts */
.right-panel { border-left: 4px solid var(--border-color); overflow-y: auto; padding-bottom: 30px; }
.shop-title { text-align: center; font-size: 1.5rem; padding: 15px; background: rgba(0,0,0,0.6); font-weight: 900; border-bottom: 2px solid var(--border-color); }
.upgrades-container { display: flex; flex-wrap: wrap; gap: 10px; padding: 15px; background: rgba(0,0,0,0.4); border-bottom: 2px solid var(--border-color); }
.upgrade-item { width: 50px; height: 50px; background: #443; border: 2px solid var(--border-color); border-radius: 5px; cursor: pointer; font-size: 28px; text-align: center; line-height: 46px; transition: 0.2s; }
.upgrade-item:hover { transform: translateY(-2px); border-color: var(--text-accent); }
.upgrade-item.disabled { opacity: 0.3; cursor: not-allowed; }

.buy-amount-container { display: flex; justify-content: space-evenly; align-items: center; padding: 10px; background: rgba(0,0,0,0.3); border-bottom: 1px solid var(--border-color); }
.amount-btn { background: transparent; border: 1px solid var(--text-muted); color: var(--text-muted); padding: 5px 15px; border-radius: 4px; cursor: pointer; font-weight: bold; }
.amount-btn.active { background: var(--text-accent); color: #000; border-color: var(--text-accent); }

.shop-item { display: grid; grid-template-columns: 50px 1fr auto; gap: 15px; align-items: center; padding: 15px; border-bottom: 1px solid rgba(255,255,255,0.05); cursor: pointer; }
.shop-item:hover { background: rgba(255,255,255,0.08); }
.shop-item.disabled { opacity: 0.4; filter: grayscale(100%); cursor: not-allowed; }
.shop-item-icon { font-size: 35px; width: 50px; height: 50px; text-align: center; background: rgba(0,0,0,0.3); border-radius: 8px; line-height: 50px; }
.item-details { display: flex; flex-direction: column; }
.item-name { font-size: 1.2rem; font-weight: bold; }
.item-price { color: #81c784; font-weight: bold; }
.item-owned { font-size: 2rem; font-weight: 900; color: rgba(255,255,255,0.15); }
.reset-btn { margin: 20px; padding: 10px; background: #8b0000; color: white; border: none; cursor: pointer; border-radius: 5px; font-weight: bold; }

/* Tablet & Handy: Panels untereinander, Shop direkt nach dem Keks */
@media (max-width: 900px) {
  body { overflow-x: hidden; overflow-y: auto; height: auto; min-height: 100vh; }
  .game-wrapper { display: flex; flex-direction: column; height: auto; }
  .left-panel { border-right: none; border-bottom: 4px solid var(--border-color); padding: 15px 10px 25px; }
  .score-board { margin-bottom: 20px; }
  .big-score { font-size: 2.2rem; }
  #main-cookie-img { width: 200px; }
  /* Shop vor die Welt-Ansicht ziehen, damit er ohne langes Scrollen erreichbar ist */
  .right-panel { order: 2; border-left: none; border-bottom: 4px solid var(--border-color); overflow-y: visible; padding-bottom: 10px; }
  .middle-panel { order: 3; min-height: 200px; overflow-y: visible; }
  .lane { min-height: 90px; padding: 28px 10px 12px 10px; }
}

/* Schmale Handys */
@media (max-width: 480px) {
  .bakery-name { font-size: 1.1rem; padding: 8px 14px; margin-bottom: 12px; }
  #main-cookie-img { width: 150px; }
  .shop-title { font-size: 1.2rem; padding: 10px; }
  .shop-item { grid-template-columns: 40px 1fr auto; gap: 10px; padding: 10px 12px; }
  .shop-item-icon { font-size: 26px; width: 40px; height: 40px; line-height: 40px; }
  .item-name { font-size: 1rem; }
  .item-price { font-size: 0.85rem; }
  .item-owned { font-size: 1.4rem; }
  .upgrade-item { width: 44px; height: 44px; font-size: 24px; line-height: 40px; }
  .upgrades-container { gap: 8px; padding: 10px; }
  .amount-btn { padding: 5px 10px; }
  .lane-icon { font-size: 24px; }
  .game-tooltip { width: min(280px, calc(100vw - 20px)); }
  .modal-content { max-width: calc(100vw - 30px); padding: 20px; }
}
