/* ============================================================
   SmashIt! — Styles
   ============================================================ */

/* Reset & Base */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  touch-action: none;
  font-family: 'Comic Sans MS', 'Chalkboard SE', 'Marker Felt', 'Trebuchet MS', sans-serif;
}

/* ============================================================
   Themes (CSS Custom Properties)
   ============================================================ */

body.theme-rainbow {
  --bg-gradient: linear-gradient(135deg, #ff6b6b 0%, #feca57 20%, #48dbfb 40%, #ff9ff3 60%, #54a0ff 80%, #ff6b6b 100%);
  --panel-bg: rgba(255, 255, 255, 0.95);
  --panel-text: #2d3436;
  --counter-color: rgba(255, 255, 255, 0.85);
  --idle-color: rgba(255, 255, 255, 0.95);
  --button-bg: #ffffff;
  --button-text: #2d3436;
  --setting-bg: rgba(0, 0, 0, 0.06);
}

body.theme-space {
  --bg-gradient: radial-gradient(ellipse at bottom, #1b2735 0%, #090a0f 100%);
  --panel-bg: rgba(20, 20, 45, 0.96);
  --panel-text: #dfe6e9;
  --counter-color: rgba(165, 200, 255, 0.7);
  --idle-color: rgba(165, 200, 255, 0.85);
  --button-bg: #2d3436;
  --button-text: #dfe6e9;
  --setting-bg: rgba(255, 255, 255, 0.08);
}

body.theme-underwater {
  --bg-gradient: linear-gradient(180deg, #00a8cc 0%, #0077b6 40%, #023e8a 100%);
  --panel-bg: rgba(0, 25, 55, 0.96);
  --panel-text: #caf0f8;
  --counter-color: rgba(150, 230, 255, 0.75);
  --idle-color: rgba(150, 230, 255, 0.9);
  --button-bg: #0077b6;
  --button-text: #ffffff;
  --setting-bg: rgba(255, 255, 255, 0.08);
}

/* Animated background */
body {
  background: var(--bg-gradient);
  background-size: 400% 400%;
  animation: gradient-shift 18s ease infinite;
}

body.reduce-motion {
  animation: none;
}

body.reduce-motion .welcome-screen {
  animation: none;
}

@keyframes gradient-shift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* ============================================================
   Utility
   ============================================================ */

.hidden {
  display: none !important;
}

/* ============================================================
   App Stage
   ============================================================ */

.app {
  position: fixed;
  inset: 0;
  overflow: hidden;
  touch-action: none;
}

/* ============================================================
   Welcome Screen
   ============================================================ */

.welcome-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-gradient);
  background-size: 400% 400%;
  animation: gradient-shift 18s ease infinite;
}

.welcome-content {
  position: relative;
  z-index: 2;
  text-align: center;
  color: #fff;
  padding: 2rem;
}

.welcome-content h1 {
  font-size: clamp(3.5rem, 12vw, 7rem);
  margin-bottom: 0.5rem;
  text-shadow: 4px 4px 0 rgba(0, 0, 0, 0.15);
  animation: welcome-bounce 2.2s ease-in-out infinite;
  letter-spacing: -2px;
}

.welcome-content p {
  font-size: clamp(1.2rem, 3vw, 1.8rem);
  margin-bottom: 2.5rem;
  opacity: 0.95;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.2);
}

.parent-hint {
  margin-top: 1.5rem;
  font-size: clamp(0.9rem, 2vw, 1.1rem);
  opacity: 0.75;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.2);
}

#start-btn {
  font-size: clamp(1.3rem, 3vw, 2rem);
  padding: 1.1rem 3rem;
  border: none;
  border-radius: 60px;
  background: #fff;
  color: #2d3436;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 12px 35px rgba(0,0,0,0.25);
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s;
  font-family: inherit;
}

#start-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 18px 50px rgba(0,0,0,0.35);
}

#start-btn:active {
  transform: scale(0.94);
}

/* Browser support warning */
.browser-warning {
  margin-top: 1.5rem;
  padding: 0.7rem 1.2rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: #2d3436;
  background: rgba(255, 255, 255, 0.85);
  border-radius: 12px;
  max-width: 320px;
  line-height: 1.4;
}

/* Floating decorations */
.welcome-decoration {
  position: absolute;
  border-radius: 50%;
  opacity: 0.25;
  pointer-events: none;
}

.d1 {
  width: 120px;
  height: 120px;
  background: #ff6b6b;
  top: 12%;
  left: 12%;
  animation: float 7s ease-in-out infinite;
}

.d2 {
  width: 180px;
  height: 180px;
  background: #48dbfb;
  bottom: 12%;
  right: 10%;
  animation: float 8s ease-in-out infinite -2s;
}

.d3 {
  width: 90px;
  height: 90px;
  background: #feca57;
  top: 55%;
  left: 75%;
  animation: float 6s ease-in-out infinite -4s;
}

@keyframes welcome-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-18px); }
}

@keyframes float {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-35px) rotate(12deg); }
}

/* ============================================================
   Corner Hold Zone
   ============================================================ */

.corner-zone {
  position: fixed;
  top: 0;
  left: 0;
  width: 80px;
  height: 80px;
  z-index: 50;
  cursor: pointer;
}

.corner-progress-svg {
  width: 40px;
  height: 40px;
  margin: 20px;
  opacity: 0.5;
  pointer-events: none;
}

.corner-progress-bg {
  fill: none;
  stroke: rgba(255,255,255,0.12);
  stroke-width: 4;
}

.corner-progress-fill {
  fill: none;
  stroke: rgba(255,255,255,0.65);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-dasharray: 113.1;
  stroke-dashoffset: 113.1;
  transform: rotate(-90deg);
  transform-origin: center;
  transition: stroke-dashoffset 0.05s linear;
}

/* ============================================================
   Counter
   ============================================================ */

.counter {
  position: fixed;
  top: 20px;
  right: 24px;
  font-size: 1.05rem;
  color: var(--counter-color);
  z-index: 40;
  font-weight: 700;
  pointer-events: none;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.15);
}

/* ============================================================
   Idle Prompt
   ============================================================ */

.idle-prompt {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: clamp(1.6rem, 4.5vw, 2.8rem);
  color: var(--idle-color);
  z-index: 30;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.6s ease;
  font-weight: 800;
  text-align: center;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
}

.idle-prompt.visible {
  opacity: 1;
  animation: idle-bounce 2.5s ease-in-out infinite;
}

@keyframes idle-bounce {
  0%, 100% { transform: translate(-50%, -50%) translateY(0); }
  50% { transform: translate(-50%, -50%) translateY(-22px); }
}

/* ============================================================
   Effects Container
   ============================================================ */

.effects-container {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 20;
  overflow: hidden;
}

/* ============================================================
   Letter / Emoji Effects
   ============================================================ */

.effect-letter,
.effect-emoji {
  position: absolute;
  font-weight: 900;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0);
  opacity: 0;
  will-change: transform, opacity;
  text-shadow: 3px 3px 6px rgba(0,0,0,0.25);
}

.effect-letter.active,
.effect-emoji.active {
  animation: letter-pop 1.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.reduce-motion .effect-letter.active,
.reduce-motion .effect-emoji.active {
  animation: simple-fade 1s ease-out forwards;
}

@keyframes letter-pop {
  0% {
    transform: translate(-50%, -50%) scale(0) rotate(-18deg);
    opacity: 0;
  }
  25% {
    transform: translate(-50%, -50%) scale(1.45) rotate(10deg);
    opacity: 1;
  }
  50% {
    transform: translate(-50%, -50%) scale(0.92) rotate(-4deg);
    opacity: 1;
  }
  80% {
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -50%) scale(1) rotate(0deg);
    opacity: 0;
  }
}

/* Space theme glow */
.theme-space .effect-letter,
.theme-space .effect-emoji {
  text-shadow:
    0 0 10px currentColor,
    0 0 30px currentColor,
    0 0 60px currentColor;
}

/* Underwater theme bubble-like */
.theme-underwater .effect-letter,
.theme-underwater .effect-emoji {
  text-shadow:
    2px 2px 0 rgba(0,0,0,0.15),
    0 0 20px rgba(255,255,255,0.3);
}

/* ============================================================
   Confetti Effect
   ============================================================ */

.confetti-piece {
  position: absolute;
  pointer-events: none;
  opacity: 0;
  border-radius: 2px;
  will-change: transform, opacity;
}

.confetti-piece.active {
  animation: confetti-fall 2.2s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

.reduce-motion .confetti-piece.active {
  animation: simple-fade 1s ease-out forwards;
}

@keyframes confetti-fall {
  0% {
    transform: translateY(0) translateX(0) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(110vh) translateX(var(--drift, 0px)) rotate(720deg);
    opacity: 0;
  }
}

/* ============================================================
   Bubble Effect
   ============================================================ */

.bubble-piece {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
  will-change: transform, opacity;
  box-shadow:
    inset -6px -6px 12px rgba(0,0,0,0.12),
    inset 6px 6px 12px rgba(255,255,255,0.35),
    0 4px 15px rgba(0,0,0,0.1);
}

.theme-space .bubble-piece {
  box-shadow:
    inset -4px -4px 10px rgba(0,0,0,0.3),
    inset 4px 4px 10px rgba(255,255,255,0.1),
    0 0 25px currentColor;
}

.bubble-piece.active {
  animation: bubble-rise 3.2s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

.reduce-motion .bubble-piece.active {
  animation: simple-fade 1.5s ease-out forwards;
}

@keyframes bubble-rise {
  0% {
    transform: translate(-50%, 0) scale(0);
    opacity: 0;
  }
  12% {
    transform: translate(-50%, -20px) scale(1);
    opacity: 0.55;
  }
  100% {
    transform: translate(-50%, -110vh) scale(1.25);
    opacity: 0;
  }
}

/* ============================================================
   Reduced Motion Fallback
   ============================================================ */

@keyframes simple-fade {
  0% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(0.9); }
}

/* ============================================================
   Resume Overlay
   ============================================================ */

.resume-overlay {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-gradient);
  background-size: 400% 400%;
  animation: gradient-shift 18s ease infinite;
  cursor: pointer;
}

.resume-content {
  text-align: center;
  color: #fff;
  padding: 2rem;
}

.resume-content h2 {
  font-size: clamp(2rem, 6vw, 3.5rem);
  margin-bottom: 0.5rem;
  text-shadow: 3px 3px 0 rgba(0, 0, 0, 0.15);
  animation: welcome-bounce 2.2s ease-in-out infinite;
}

.resume-content p {
  font-size: clamp(1.1rem, 2.5vw, 1.5rem);
  margin-bottom: 2rem;
  opacity: 0.95;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.2);
}

#resume-btn {
  font-size: clamp(1.3rem, 3vw, 2rem);
  padding: 1.1rem 3rem;
  border: none;
  border-radius: 60px;
  background: #fff;
  color: #2d3436;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 12px 35px rgba(0,0,0,0.25);
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s;
  font-family: inherit;
}

#resume-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 18px 50px rgba(0,0,0,0.35);
}

#resume-btn:active {
  transform: scale(0.94);
}

body.reduce-motion .resume-overlay {
  animation: none;
}

body.reduce-motion .resume-content h2 {
  animation: none;
}

/* ============================================================
   Parent Panel
   ============================================================ */

.parent-panel {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: panel-fade-in 0.25s ease-out;
}

@keyframes panel-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.parent-content {
  background: var(--panel-bg);
  color: var(--panel-text);
  padding: 2rem;
  border-radius: 24px;
  width: 92%;
  max-width: 420px;
  box-shadow: 0 25px 70px rgba(0,0,0,0.35);
  animation: panel-slide-up 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes panel-slide-up {
  from { transform: translateY(30px) scale(0.96); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

.parent-content h2 {
  font-size: 1.7rem;
  margin-bottom: 1.5rem;
  text-align: center;
  font-weight: 800;
}

/* Settings rows */
.setting {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.9rem;
  padding: 0.85rem 1rem;
  background: var(--setting-bg);
  border-radius: 14px;
}

.setting label {
  font-weight: 700;
  font-size: 1rem;
}

.setting button,
.setting select {
  font-size: 0.95rem;
  padding: 0.45rem 1rem;
  border-radius: 10px;
  border: 2px solid rgba(0,0,0,0.08);
  background: var(--button-bg);
  color: var(--button-text);
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
  min-width: 90px;
  text-align: center;
  transition: transform 0.15s, box-shadow 0.15s;
}

.setting button:hover,
.setting select:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}

.setting button:active {
  transform: scale(0.96);
}

/* Parent action buttons */
.parent-buttons {
  display: flex;
  gap: 0.8rem;
  margin-top: 1.8rem;
}

.parent-buttons button {
  flex: 1;
  font-size: 1rem;
  padding: 0.9rem;
  border-radius: 14px;
  border: none;
  font-weight: 800;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.15s, box-shadow 0.15s;
}

.parent-buttons button:hover {
  transform: scale(1.03);
}

.parent-buttons button:active {
  transform: scale(0.97);
}

#close-panel {
  background: #dfe6e9;
  color: #2d3436;
}

#exit-fullscreen {
  background: #ff6b6b;
  color: #fff;
  box-shadow: 0 4px 15px rgba(255, 107, 107, 0.35);
}

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 768px) {
  .welcome-content {
    padding: 1.5rem;
  }

  .parent-content {
    padding: 1.5rem;
    border-radius: 20px;
  }

  .corner-zone {
    width: 100px;
    height: 100px;
  }

  .corner-progress-svg {
    width: 50px;
    height: 50px;
    margin: 25px;
  }

  .counter {
    font-size: 0.9rem;
    top: 16px;
    right: 16px;
  }
}
