/* =========================================================
   Merge Duck — Stylesheet
   Modernes, buntes Idle-/Mobile-Game Design
   ========================================================= */

:root {
  --bg-1: #2b1055;
  --bg-2: #7597de;
  --panel-bg: rgba(255, 255, 255, 0.10);
  --panel-border: rgba(255, 255, 255, 0.25);
  --pond-1: #4fd1ff;
  --pond-2: #1a7fc7;
  --gold: #ffd24d;
  --accent: #ff6fb0;
  --text-light: #fff8f0;
  --radius-lg: 22px;
  --radius-md: 14px;
  --shadow-soft: 0 8px 24px rgba(0, 0, 0, 0.35);
  font-family: 'Segoe UI', 'Trebuchet MS', system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  color: var(--text-light);
  overflow-x: hidden;
  /* kein globales touch-action:none mehr - das blockierte auf dem Handy
     jegliches Scrollen der Seite. Nur .duck-token unterdrueckt es lokal,
     damit man Enten weiterhin sauber ziehen kann. */
}

body {
  background:
    radial-gradient(circle at 15% 10%, rgba(255, 255, 255, 0.12), transparent 40%),
    radial-gradient(circle at 85% 0%, rgba(255, 210, 77, 0.18), transparent 45%),
    linear-gradient(160deg, var(--bg-1) 0%, #4b2a8f 40%, var(--bg-2) 100%);
  background-attachment: fixed;
  min-height: 100vh;
  padding-bottom: 40px;
  user-select: none;
  -webkit-user-select: none;
}

/* ---------------------------------------------------------
   Top bar
--------------------------------------------------------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(6px);
  box-shadow: var(--shadow-soft);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 1.3rem;
  letter-spacing: 0.5px;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}
.brand-icon { font-size: 1.6rem; }

.stat-pill {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, #ffe27a, var(--gold));
  color: #4a3200;
  font-weight: 800;
  padding: 8px 16px;
  border-radius: 999px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.6);
  font-size: 1.05rem;
}
.stat-icon { font-size: 1.1rem; }

.icon-btn {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid var(--panel-border);
  color: var(--text-light);
  font-size: 1.1rem;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.3); transform: scale(1.08); }
.icon-btn:active { transform: scale(0.94); }

/* ---------------------------------------------------------
   Stage progress bar
--------------------------------------------------------- */
.stage-bar {
  max-width: 1000px;
  margin: 16px auto 0;
  padding: 12px 20px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  backdrop-filter: blur(4px);
}

.stage-info {
  display: flex;
  flex-direction: column;
  min-width: 160px;
  font-weight: 700;
}
#stageLabel { font-size: 1.1rem; color: var(--gold); }
#stageGoal { font-size: 0.8rem; opacity: 0.85; font-weight: 500; }

.progress-track {
  position: relative;
  flex: 1;
  min-width: 160px;
  height: 22px;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.2);
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #35e08a, #22c1c3);
  transition: width 0.4s ease;
  border-radius: 999px;
}
.progress-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

.advance-btn {
  background: linear-gradient(135deg, #ff9966, #ff5e62);
  border: none;
  color: white;
  font-weight: 800;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(255, 94, 98, 0.5);
  transition: transform 0.15s ease, opacity 0.15s ease;
}
.advance-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  box-shadow: none;
}
.advance-btn:not(:disabled):hover { transform: translateY(-2px) scale(1.03); }
.advance-btn:not(:disabled) {
  animation: pulseGlow 1.4s ease-in-out infinite;
}

@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 4px 12px rgba(255, 94, 98, 0.5); }
  50% { box-shadow: 0 4px 24px rgba(255, 94, 98, 0.9); }
}

/* ---------------------------------------------------------
   Main game world / panels
--------------------------------------------------------- */
.game-world {
  max-width: 1000px;
  margin: 18px auto;
  padding: 0 16px;
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 18px;
}

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

.panel {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  padding: 16px;
  backdrop-filter: blur(4px);
  box-shadow: var(--shadow-soft);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}
.panel-header h2 {
  margin: 0;
  font-size: 1.15rem;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}

/* Grid (merge field) — sits on a "pond" background */
.grid-panel .grid {
  background:
    radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.15), transparent 60%),
    linear-gradient(160deg, var(--pond-1), var(--pond-2));
  border-radius: var(--radius-md);
  padding: 10px;
}

.grid-3x3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  aspect-ratio: 1 / 1;
}

/* ---------------------------------------------------------
   Enten-Haus: echtes Haus mit 3 Etagen + Garten mit Trampolin
--------------------------------------------------------- */
.house-layout {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: flex-start;
}

.house-illustration {
  flex: 2;
  min-width: 190px;
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}

.roof {
  height: 40px;
  background: linear-gradient(135deg, #a15a2e, #6b3a1a);
  clip-path: polygon(50% 0%, 100% 100%, 0% 100%);
}

.floor {
  position: relative;
  min-height: 92px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.floor.zone-attic {
  background: repeating-linear-gradient(45deg, #e0b979, #e0b979 9px, #cc9c56 9px, #cc9c56 18px);
}

.floor.zone-swim {
  background: linear-gradient(180deg, #6fd8ff, #0f7fc4);
}

.floor.zone-ground {
  background: repeating-linear-gradient(90deg, #cf9a63, #cf9a63 22px, #b57f4a 22px, #b57f4a 44px);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
}

/* animierte Wellenlinien auf der Schwimmetage */
.wave-lines {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.5;
}
.wave-lines span {
  position: absolute;
  left: -20%;
  width: 140%;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.55);
  animation: waveDrift 3s ease-in-out infinite;
}
.wave-lines span:nth-child(1) { top: 18%; animation-delay: 0s; }
.wave-lines span:nth-child(2) { top: 52%; animation-delay: 0.6s; }
.wave-lines span:nth-child(3) { top: 80%; animation-delay: 1.2s; }
@keyframes waveDrift {
  0%, 100% { transform: translateX(-6%); opacity: 0.35; }
  50% { transform: translateX(6%); opacity: 0.7; }
}

.zone-label {
  align-self: flex-start;
  font-size: 0.72rem;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
  margin-bottom: 4px;
  z-index: 2;
}
.zone-sub {
  display: block;
  font-size: 0.62rem;
  font-weight: 500;
  opacity: 0.85;
}

.zone-income {
  position: absolute;
  bottom: 4px;
  right: 8px;
  font-size: 0.68rem;
  font-weight: 800;
  color: var(--gold);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
  z-index: 2;
}

.cat-display {
  position: absolute;
  bottom: 4px;
  left: 8px;
  font-size: 0.85rem;
  z-index: 2;
}

.zone-tier-badge {
  position: absolute;
  top: 4px;
  right: 8px;
  font-size: 0.62rem;
  font-weight: 800;
  color: var(--gold);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
  z-index: 2;
  transition: filter 0.3s ease;
}

/* Garten mit Trampolin — auesserhalb des Hauses */
.garden-panel {
  flex: 1;
  min-width: 130px;
  background: radial-gradient(circle at 50% 0%, #8fd858, transparent 70%), linear-gradient(180deg, #6bbf3f, #3d8a22);
  border-radius: var(--radius-md);
  padding: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  min-height: 176px;
}

.trampoline {
  width: 70%;
  aspect-ratio: 2 / 1;
  margin-top: auto;
  border-radius: 50%;
  background: radial-gradient(circle, #2b6cb0 55%, #1a4971 100%);
  border: 5px solid #ffd24d;
  box-shadow: inset 0 4px 10px rgba(0, 0, 0, 0.4);
}

.house-illustration .cell,
.garden-panel .cell {
  width: 62px;
  height: 62px;
  aspect-ratio: unset;
  margin: 0 auto;
  z-index: 2;
}
.garden-panel .cell {
  position: absolute;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
}

.cell {
  position: relative;
  background: rgba(255, 255, 255, 0.12);
  border: 2px dashed rgba(255, 255, 255, 0.25);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1 / 1;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.cell.drag-over {
  background: rgba(255, 255, 255, 0.28);
  border-color: var(--gold);
}

.cell.cell-selected {
  background: rgba(255, 210, 77, 0.22);
  border-color: var(--gold);
  border-style: solid;
  box-shadow: 0 0 0 3px rgba(255, 210, 77, 0.55);
  animation: selectedPulse 1s ease-in-out infinite;
}
@keyframes selectedPulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(255, 210, 77, 0.55); }
  50% { box-shadow: 0 0 0 6px rgba(255, 210, 77, 0.25); }
}

/* Duck token sitting in a cell */
.duck-token {
  position: relative;
  width: 86%;
  height: 86%;
  cursor: grab;
  touch-action: none;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.35));
  transition: transform 0.12s ease;
}

.duck-svg {
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}

.level-badge {
  position: absolute;
  bottom: -2px;
  right: -4px;
  background: rgba(0, 0, 0, 0.6);
  color: #fff8f0;
  font-size: 0.62rem;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 8px;
  pointer-events: none;
  white-space: nowrap;
}
.duck-token:active { cursor: grabbing; }
.duck-token:hover { transform: scale(1.05); }

.duck-token .level-badge {
  pointer-events: none;
}

.duck-token.merging {
  animation: mergeBounce 0.45s ease;
}
@keyframes mergeBounce {
  0%   { transform: scale(0.6) rotate(-8deg); }
  40%  { transform: scale(1.25) rotate(6deg); }
  65%  { transform: scale(0.92) rotate(-3deg); }
  100% { transform: scale(1) rotate(0deg); }
}

.duck-token.spawn-in {
  animation: spawnIn 0.3s ease;
}
@keyframes spawnIn {
  from { transform: scale(0); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

.duck-token.dragging-source {
  opacity: 0.25;
}

.duck-token.shake {
  animation: shakeNo 0.3s ease;
}
@keyframes shakeNo {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

/* ---------------------------------------------------------
   Zonen-Animationen: jede Haus-Aktivitaet bewegt die Ente anders
--------------------------------------------------------- */
.duck-token.anim-attic { animation: grazeMotion 1.8s ease-in-out infinite; }
@keyframes grazeMotion {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  35% { transform: translateY(7px) rotate(-6deg); }
  65% { transform: translateY(3px) rotate(4deg); }
}

.duck-token.anim-swim { animation: swimMotion 4s ease-in-out infinite; }
@keyframes swimMotion {
  0%   { transform: translateX(-22px) translateY(0) rotate(-4deg); }
  25%  { transform: translateX(0)     translateY(-3px) rotate(0deg); }
  50%  { transform: translateX(22px)  translateY(0) rotate(4deg); }
  75%  { transform: translateX(0)     translateY(-3px) rotate(0deg); }
  100% { transform: translateX(-22px) translateY(0) rotate(-4deg); }
}

.duck-token.anim-ground { animation: walkMotion 3.2s linear infinite; }
@keyframes walkMotion {
  0%   { transform: translateX(-24px) scaleX(1); }
  48%  { transform: translateX(24px) scaleX(1); }
  50%  { transform: translateX(24px) scaleX(-1); }
  98%  { transform: translateX(-24px) scaleX(-1); }
  100% { transform: translateX(-24px) scaleX(1); }
}

.duck-token.anim-garden { animation: trampolineMotion 1.2s ease-in-out infinite; }
@keyframes trampolineMotion {
  0%, 100% { transform: translateY(0) scale(1, 1); }
  8%  { transform: translateY(4px) scale(1.1, 0.85); }
  45% { transform: translateY(-42px) scale(0.94, 1.08); }
  55% { transform: translateY(-42px) scale(0.94, 1.08); }
  92% { transform: translateY(4px) scale(1.1, 0.85); }
}

/* Drag ghost — follows the pointer */
.drag-ghost {
  position: fixed;
  top: 0;
  left: 0;
  width: 80px;
  height: 80px;
  pointer-events: none;
  z-index: 999;
  display: none;
  filter: drop-shadow(0 8px 10px rgba(0, 0, 0, 0.5));
  transform: translate(-50%, -50%) scale(1.15);
}

/* ---------------------------------------------------------
   Buy / upgrade buttons
--------------------------------------------------------- */
.buy-row { display: flex; }

.buy-btn, .upgrade-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  background: linear-gradient(135deg, #35e08a, #1fb6c1);
  border: none;
  color: #06382a;
  font-weight: 800;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
  transition: transform 0.12s ease, filter 0.12s ease;
}
.buy-btn:hover, .upgrade-btn:hover { transform: translateY(-2px); }
.buy-btn:active, .upgrade-btn:active { transform: translateY(0); }

.buy-btn:disabled, .upgrade-btn:disabled {
  filter: grayscale(0.6) brightness(0.75);
  cursor: not-allowed;
  transform: none;
}

.buy-cost, .upg-cost { font-size: 0.8rem; opacity: 0.85; }
.buy-label, .upg-title { font-size: 0.95rem; }

.upgrades {
  display: flex;
  gap: 10px;
  margin-top: 14px;
  flex-wrap: wrap;
}
.upgrade-btn {
  flex: 1;
  min-width: 140px;
  background: linear-gradient(135deg, #ffb86c, #ff6fb0);
  color: #3a0620;
}
.upgrade-btn small {
  font-weight: 600;
  opacity: 0.85;
}

.house-shop {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
}
.house-shop .upgrade-btn { min-width: 0; }

.house-income {
  font-weight: 800;
  color: var(--gold);
  background: rgba(0, 0, 0, 0.25);
  padding: 6px 12px;
  border-radius: 999px;
}

/* ---------------------------------------------------------
   Floating "+coin" popups
--------------------------------------------------------- */
#floatLayer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 500;
}
.float-popup {
  position: absolute;
  font-weight: 800;
  color: var(--gold);
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
  animation: floatUp 1.1s ease-out forwards;
  white-space: nowrap;
}
@keyframes floatUp {
  0%   { transform: translate(-50%, 0); opacity: 1; }
  100% { transform: translate(-50%, -60px); opacity: 0; }
}

/* ---------------------------------------------------------
   Help modal
--------------------------------------------------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}
.modal-overlay.hidden { display: none; }

.modal {
  background: linear-gradient(160deg, #3a1c6b, #1f0f42);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  max-width: 480px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
}
.modal h2 { margin-top: 0; }
.modal ul { padding-left: 20px; line-height: 1.6; }
.modal .buy-btn { margin-top: 10px; width: 100%; align-items: center; }

/* scrollbar niceties */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.3); border-radius: 4px; }
