/* ============================================================
   JELLY MERGE — Style Sheet
   ============================================================ */

:root {
  --bg-top:    #fde8f0;
  --bg-bot:    #ffd6a5;
  --accent:    #ff6b9d;
  --accent2:   #ffaa5c;
  --text:      #4a2040;
  --modal-bg:  rgba(255,240,250,0.97);
  --shadow:    0 8px 40px rgba(120,40,80,0.18);
  --radius:    20px;
  --font:      'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
}

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

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: linear-gradient(160deg, var(--bg-top) 0%, var(--bg-bot) 100%);
  font-family: var(--font);
  color: var(--text);
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

/* ---- Screens ---- */
.screen {
  position: fixed; inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}
.screen.active { display: flex; }
.screen.overlay {
  background: rgba(80,20,50,0.55);
  backdrop-filter: blur(6px);
  z-index: 100;
}

/* ---- Start Screen ---- */
#start-screen {
  position: relative;
  overflow: hidden;
}
#start-canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
}
.start-content {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 24px 20px;
}
.game-logo {
  display: flex;
  align-items: center;
  gap: 16px;
}
.logo-jelly {
  font-size: 52px;
  animation: logoJiggle 1.6s ease-in-out infinite alternate;
  display: inline-block;
}
.logo-jelly:last-child { animation-delay: 0.8s; }
@keyframes logoJiggle {
  0%   { transform: rotate(-8deg) scale(1); }
  100% { transform: rotate(8deg) scale(1.12); }
}
.logo-title {
  font-size: clamp(40px, 8vw, 72px);
  font-weight: 900;
  line-height: 1;
  text-align: center;
  color: var(--accent);
  text-shadow:
    0 2px 0 #c0305a,
    0 4px 12px rgba(200,50,100,0.3);
  letter-spacing: -1px;
}
.tagline {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent2);
  text-shadow: 0 1px 4px rgba(0,0,0,0.1);
  letter-spacing: 2px;
  text-transform: uppercase;
}
.jelly-preview-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 360px;
}
.jelly-preview-row canvas {
  border-radius: 50%;
}
.start-hiscores {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  background: rgba(255,255,255,0.6);
  padding: 8px 20px;
  border-radius: 50px;
}
.start-hiscores strong { color: var(--accent); }
.how-to {
  font-size: 13px;
  color: #8a5070;
  text-align: center;
  max-width: 300px;
  line-height: 1.6;
  background: rgba(255,255,255,0.45);
  padding: 10px 16px;
  border-radius: 14px;
}

/* ---- Game Screen ---- */
#game-screen {
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0;
}
#game-screen.active { display: flex; }
#game-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  width: 100%;
  max-width: 520px;
  padding: 8px 8px 4px;
  gap: 6px;
}

/* ---- HUD ---- */
#hud {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  background: rgba(255,255,255,0.55);
  border-radius: 16px;
  backdrop-filter: blur(8px);
  box-shadow: 0 2px 12px rgba(180,60,100,0.1);
  flex-shrink: 0;
}
.hud-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 80px;
}
.hud-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 2px;
  color: #b06090;
  text-transform: uppercase;
}
.hud-value {
  font-size: 26px;
  font-weight: 900;
  color: var(--accent);
  line-height: 1;
  text-shadow: 0 2px 0 rgba(200,50,100,0.2);
  transition: transform 0.1s;
}
.hud-value.pop {
  animation: hudPop 0.3s ease-out;
}
@keyframes hudPop {
  0%   { transform: scale(1.4); color: #ff2060; }
  100% { transform: scale(1); }
}
.hud-controls {
  display: flex;
  gap: 8px;
}

/* ---- Canvas Area ---- */
#canvas-area {
  position: relative;
  flex: 1;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
#game-canvas {
  display: block;
  border-radius: 20px;
  cursor: none;
  touch-action: none;
}
#next-panel {
  position: absolute;
  top: 8px;
  right: -6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: rgba(255,255,255,0.65);
  padding: 8px;
  border-radius: 16px;
  backdrop-filter: blur(6px);
  box-shadow: 0 2px 12px rgba(180,60,100,0.12);
}
.next-label {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 2px;
  color: #b06090;
}
#next-canvas {
  border-radius: 50%;
}

/* ---- Buttons ---- */
.btn {
  padding: 14px 36px;
  border: none;
  border-radius: 50px;
  font-size: 18px;
  font-weight: 800;
  cursor: pointer;
  letter-spacing: 0.5px;
  transition: transform 0.12s, box-shadow 0.12s;
}
.btn:active { transform: scale(0.96); }
.btn-primary {
  background: linear-gradient(135deg, #ff6b9d, #ff3d7a);
  color: #fff;
  box-shadow: 0 4px 18px rgba(255,60,120,0.4), 0 2px 0 #c01050;
}
.btn-primary:hover { box-shadow: 0 6px 24px rgba(255,60,120,0.55), 0 2px 0 #c01050; transform: translateY(-2px); }
.btn-secondary {
  background: rgba(255,255,255,0.75);
  color: var(--text);
  box-shadow: 0 2px 10px rgba(100,30,60,0.12);
}
.btn-secondary:hover { background: rgba(255,255,255,0.92); transform: translateY(-1px); }

.icon-btn {
  width: 38px; height: 38px;
  border: none;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  background: rgba(255,255,255,0.7);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(100,30,60,0.1);
  transition: transform 0.1s, background 0.1s;
}
.icon-btn:hover { background: rgba(255,255,255,0.95); transform: scale(1.1); }
.icon-btn:active { transform: scale(0.92); }

/* ---- Modal ---- */
.modal {
  background: var(--modal-bg);
  border-radius: 28px;
  padding: 36px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow), 0 0 0 2px rgba(255,120,160,0.15);
  max-width: 340px;
  width: 90%;
}
.modal h2 {
  font-size: 32px;
  font-weight: 900;
  color: var(--accent);
  text-shadow: 0 2px 0 rgba(200,50,100,0.2);
}
.gameover-emoji {
  font-size: 56px;
  animation: bounceIn 0.5s cubic-bezier(0.36,0.07,0.19,0.97);
}
@keyframes bounceIn {
  0%   { transform: scale(0) rotate(-20deg); opacity: 0; }
  60%  { transform: scale(1.2) rotate(5deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg); }
}
.gameover-msg {
  font-size: 16px;
  color: #8a5070;
  font-weight: 600;
  text-align: center;
}
.gameover-scores {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: rgba(255,180,210,0.15);
  border-radius: 16px;
  padding: 14px 20px;
}
.score-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.score-row.best { color: var(--accent); }
.score-label {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  opacity: 0.7;
}
.score-num {
  font-size: 28px;
  font-weight: 900;
}

/* ---- Score Popups (DOM layer) ---- */
.score-popup {
  position: fixed;
  pointer-events: none;
  font-size: 20px;
  font-weight: 900;
  color: #ff3d7a;
  text-shadow: 0 2px 6px rgba(0,0,0,0.18);
  animation: scoreFloat 1.2s ease-out forwards;
  z-index: 50;
}
@keyframes scoreFloat {
  0%   { transform: translateY(0) scale(1); opacity: 1; }
  100% { transform: translateY(-70px) scale(0.7); opacity: 0; }
}

/* ---- Flash Overlay ---- */
#flash-overlay {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 200;
  opacity: 0;
  background: radial-gradient(circle, rgba(255,255,180,0.9) 0%, rgba(255,200,100,0.5) 60%, transparent 100%);
  transition: opacity 0.08s;
}
#flash-overlay.flash {
  animation: flashAnim 0.55s ease-out forwards;
}
@keyframes flashAnim {
  0%   { opacity: 0.85; }
  100% { opacity: 0; }
}

/* ---- Responsive ---- */
@media (max-width: 480px) {
  #next-panel { right: 2px; }
  .modal { padding: 28px 24px; }
  .logo-title { font-size: 44px; }
}
@media (max-height: 640px) {
  .start-content { gap: 8px; }
  .how-to { display: none; }
}
