/* ==========================================================================
   Cute & Friendly Pomodoro Timer - Ppotto Stylesheet
   ========================================================================== */

/* --- Theme Variables --- */
:root {
  /* Default: Tomato Theme */
  --bg-gradient: linear-gradient(135deg, #fff0f0 0%, #ffe3e3 50%, #ffd8d8 100%);
  --card-bg: rgba(255, 255, 255, 0.88);
  --card-border: rgba(255, 255, 255, 0.9);
  --card-shadow: 0 12px 36px rgba(255, 107, 107, 0.12), 0 4px 12px rgba(0, 0, 0, 0.04);
  
  --primary: #ff6b6b;
  --primary-hover: #fa5252;
  --primary-light: #ffe3e3;
  --primary-shadow: rgba(255, 107, 107, 0.35);
  
  --secondary: #f1f3f5;
  --secondary-hover: #e9ecef;
  
  --mascot-main: #ff6b6b;
  --mascot-light: #ffa8a8;
  --mascot-dark: #e03131;
  
  --text-main: #2b2d42;
  --text-muted: #868e96;
  --text-light: #adb5bd;
  
  --ring-bg: #ffe3e3;
  --ring-color: #ff6b6b;
  --ring-break: #51cf66;
  --ring-longbreak: #339af0;
  
  --accent-green: #51cf66;
  --accent-blue: #339af0;
  
  --font-family: 'Fredoka', 'Nunito', 'Gaegu', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-sm: 12px;
  --radius-pill: 9999px;
  
  --transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* --- Theme Variants --- */
body[data-theme="matcha"] {
  --bg-gradient: linear-gradient(135deg, #f4fce3 0%, #ebfbee 50%, #d3f9d8 100%);
  --card-shadow: 0 12px 36px rgba(81, 207, 102, 0.15), 0 4px 12px rgba(0, 0, 0, 0.04);
  --primary: #40c057;
  --primary-hover: #2f9e44;
  --primary-light: #ebfbee;
  --primary-shadow: rgba(64, 192, 87, 0.35);
  --mascot-main: #51cf66;
  --mascot-light: #8ce99a;
  --mascot-dark: #2f9e44;
  --ring-bg: #ebfbee;
  --ring-color: #40c057;
}

body[data-theme="berry"] {
  --bg-gradient: linear-gradient(135deg, #f8f0fc 0%, #f3d9fa 50%, #eebefa 100%);
  --card-shadow: 0 12px 36px rgba(204, 93, 232, 0.15), 0 4px 12px rgba(0, 0, 0, 0.04);
  --primary: #cc5de8;
  --primary-hover: #ae3ec9;
  --primary-light: #f8f0fc;
  --primary-shadow: rgba(204, 93, 232, 0.35);
  --mascot-main: #cc5de8;
  --mascot-light: #e599f7;
  --mascot-dark: #9c36b5;
  --ring-bg: #f8f0fc;
  --ring-color: #cc5de8;
}

body[data-theme="peach"] {
  --bg-gradient: linear-gradient(135deg, #fff9db 0%, #ffe8cc 50%, #ffd8a8 100%);
  --card-shadow: 0 12px 36px rgba(255, 146, 43, 0.15), 0 4px 12px rgba(0, 0, 0, 0.04);
  --primary: #ff922b;
  --primary-hover: #f76707;
  --primary-light: #fff4e6;
  --primary-shadow: rgba(255, 146, 43, 0.35);
  --mascot-main: #ffa94d;
  --mascot-light: #ffc078;
  --mascot-dark: #e8590c;
  --ring-bg: #fff4e6;
  --ring-color: #ff922b;
}

body[data-theme="dark"] {
  --bg-gradient: linear-gradient(135deg, #1a1b1e 0%, #25262b 50%, #2c2e33 100%);
  --card-bg: rgba(37, 38, 43, 0.85);
  --card-border: rgba(255, 255, 255, 0.08);
  --card-shadow: 0 12px 36px rgba(0, 0, 0, 0.4);
  --primary: #ff6b6b;
  --primary-hover: #fa5252;
  --primary-light: rgba(255, 107, 107, 0.15);
  --secondary: #2c2e33;
  --secondary-hover: #373a40;
  --text-main: #f1f3f5;
  --text-muted: #a6a7ab;
  --text-light: #5c5f66;
  --ring-bg: #2c2e33;
  --ring-color: #ff6b6b;
}

/* --- Base Reset & Setup --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font-family);
  background: var(--bg-gradient);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 24px 16px;
  position: relative;
  overflow-x: hidden;
  transition: background 0.4s ease;
}

/* --- Confetti Canvas --- */
#confettiCanvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 999;
}

/* --- App Layout --- */
.app-wrapper {
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  z-index: 1;
}

/* --- Header --- */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
}

.logo-icon {
  font-size: 1.8rem;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
  animation: cuteFloat 3s ease-in-out infinite alternate;
}

.logo-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.5px;
}

.logo-badge {
  font-size: 0.75rem;
  font-weight: 800;
  background: var(--primary);
  color: white;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  margin-left: 4px;
  vertical-align: middle;
  letter-spacing: 0.5px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-pill);
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  transition: var(--transition);
}

.icon-btn:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.icon-btn:active {
  transform: translateY(0) scale(0.96);
}

.btn-icon {
  font-size: 1.1rem;
}

.ambient-tag {
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--primary);
  background: var(--primary-light);
  padding: 2px 6px;
  border-radius: 6px;
}

/* --- Mode Tabs --- */
.mode-tabs {
  display: flex;
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-pill);
  padding: 6px;
  gap: 4px;
  box-shadow: var(--card-shadow);
}

.mode-tab {
  flex: 1;
  border: none;
  background: transparent;
  padding: 10px 14px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-muted);
  border-radius: var(--radius-pill);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: var(--transition);
}

.mode-tab .tab-emoji {
  font-size: 1rem;
  transition: transform 0.2s ease;
}

.mode-tab:hover {
  color: var(--text-main);
  background: rgba(0, 0, 0, 0.03);
}

.mode-tab.active {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 4px 12px var(--primary-shadow);
}

.mode-tab.active .tab-emoji {
  transform: scale(1.2) rotate(-5deg);
}

/* --- Timer Card --- */
.timer-card {
  background: var(--card-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 24px 20px;
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  text-align: center;
  overflow: hidden;
}

/* --- Cute Mascot "뽀또" --- */
.mascot-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  cursor: pointer;
  margin-bottom: 8px;
  user-select: none;
}

.mascot-speech-bubble {
  background: #ffffff;
  border: 2px solid var(--primary-light);
  color: var(--text-main);
  padding: 6px 14px;
  border-radius: 16px;
  font-size: 0.85rem;
  font-weight: 700;
  box-shadow: 0 4px 14px rgba(0,0,0,0.06);
  margin-bottom: 6px;
  position: relative;
  max-width: 240px;
  animation: bubblePop 0.3s ease-out;
  transition: var(--transition);
}

body[data-theme="dark"] .mascot-speech-bubble {
  background: #2c2e33;
  border-color: rgba(255,255,255,0.1);
  color: #f1f3f5;
}

.mascot-speech-bubble::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 6px solid #ffffff;
}

body[data-theme="dark"] .mascot-speech-bubble::after {
  border-top-color: #2c2e33;
}

.mascot-body-wrapper {
  position: relative;
  display: inline-block;
  transform-origin: bottom center;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.mascot-body-wrapper:hover {
  transform: scale(1.06);
}

.mascot-body-wrapper:active {
  transform: scale(0.92) translateY(4px);
}

/* Mascot Idle & State Animations */
.mascot-svg {
  filter: drop-shadow(0 8px 16px rgba(0,0,0,0.08));
  animation: mascotBreathe 3.5s ease-in-out infinite;
}

.mascot-svg.running {
  animation: mascotBreatheRunning 1.8s ease-in-out infinite;
}

.mascot-svg.celebrating {
  animation: mascotCelebrate 0.8s ease-in-out infinite alternate;
}

.cheek {
  animation: cheekGlow 2.5s ease-in-out infinite alternate;
}

.leaf-1, .leaf-2 {
  transform-origin: 100px 35px;
  animation: leafSway 4s ease-in-out infinite alternate;
}

.leaf-2 {
  animation-delay: -2s;
}

/* Heart & Star Particles on Click */
.particle-emitter {
  position: absolute;
  top: 50%;
  left: 50%;
  pointer-events: none;
  width: 10px;
  height: 10px;
}

.particle {
  position: absolute;
  font-size: 1.3rem;
  pointer-events: none;
  animation: particleFloat 0.9s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

/* --- Progress Ring & Timer Display --- */
.timer-display-wrap {
  position: relative;
  width: 280px;
  height: 280px;
  margin: 12px 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.progress-ring {
  position: absolute;
  top: 0;
  left: 0;
  transform: rotate(-90deg);
  width: 100%;
  height: 100%;
}

.progress-ring-bg {
  fill: transparent;
  stroke: var(--ring-bg);
  stroke-width: 14;
}

.progress-ring-circle {
  fill: transparent;
  stroke: var(--ring-color);
  stroke-width: 14;
  stroke-linecap: round;
  stroke-dasharray: 779.11; /* 2 * PI * 124 */
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.8s linear, stroke 0.4s ease;
  filter: drop-shadow(0 2px 6px var(--primary-shadow));
}

.timer-text-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 2;
  gap: 12px;
}

/* --- Draggable Timer Digits & Controls --- */
.timer-digits-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  user-select: none;
  margin: 2px 0 4px 0;
  touch-action: none;
}

.draggable-digit-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 4px 10px 6px 10px;
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.025);
  border: 2px dashed transparent;
  cursor: ns-resize;
  transition: var(--transition);
  min-width: 86px;
  outline: none;
}

body[data-theme="dark"] .draggable-digit-box {
  background: rgba(255, 255, 255, 0.04);
}

.draggable-digit-box:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  transform: translateY(-2px);
}

.draggable-digit-box:focus-visible {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-shadow);
}

.draggable-digit-box.is-dragging {
  background: var(--primary-light);
  border-color: var(--primary);
  border-style: solid;
  box-shadow: 0 8px 24px var(--primary-shadow);
  transform: scale(1.1) translateY(-4px);
  cursor: grabbing;
  z-index: 10;
}

.digit-step-btn {
  background: transparent;
  border: none;
  font-size: 0.72rem;
  font-weight: 900;
  color: var(--text-light);
  cursor: pointer;
  padding: 2px 10px;
  border-radius: 6px;
  transition: var(--transition);
  opacity: 0.35;
  line-height: 1;
  user-select: none;
}

.draggable-digit-box:hover .digit-step-btn {
  opacity: 0.85;
  color: var(--primary);
}

.digit-step-btn:hover {
  background: var(--primary);
  color: #ffffff !important;
  opacity: 1 !important;
  transform: scale(1.25);
}

.digit-val-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 48px;
}

.digit-num {
  font-size: 3.4rem;
  font-weight: 800;
  font-family: 'Fredoka', var(--font-family);
  color: var(--text-main);
  letter-spacing: -1.5px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  user-select: none;
  transition: transform 0.15s ease;
}

.draggable-digit-box.is-dragging .digit-num {
  color: var(--primary);
  transform: scale(1.05);
}

.digit-colon {
  font-size: 3rem;
  font-weight: 800;
  font-family: 'Fredoka', var(--font-family);
  color: var(--text-main);
  line-height: 1;
  margin: -14px 2px 0 2px;
  user-select: none;
  opacity: 0.8;
}

.digit-label {
  font-size: 0.68rem;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-top: 2px;
  transition: color 0.2s ease;
}

.draggable-digit-box:hover .digit-label,
.draggable-digit-box.is-dragging .digit-label {
  color: var(--primary);
}

.quick-adjust-btns {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.quick-adjust-btn {
  background: var(--secondary);
  border: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: var(--transition);
}

.quick-adjust-btn:hover {
  background: var(--primary-light);
  color: var(--primary);
  transform: translateY(-1px);
}

.quick-adjust-btn:active {
  transform: scale(0.92);
}

/* --- Main Controls --- */
.timer-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  width: 100%;
  margin-top: 8px;
}

.control-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  font-weight: 800;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  user-select: none;
}

.control-btn.primary {
  background: var(--primary);
  color: #ffffff;
  font-size: 1.25rem;
  padding: 16px 36px;
  border-radius: var(--radius-pill);
  box-shadow: 0 8px 24px var(--primary-shadow);
  min-width: 160px;
}

.control-btn.primary:hover {
  background: var(--primary-hover);
  transform: translateY(-3px) scale(1.03);
  box-shadow: 0 12px 28px var(--primary-shadow);
}

.control-btn.primary:active {
  transform: translateY(1px) scale(0.96);
  box-shadow: 0 4px 12px var(--primary-shadow);
}

.control-btn.secondary {
  background: var(--secondary);
  color: var(--text-muted);
  font-size: 0.95rem;
  padding: 12px 18px;
  border-radius: var(--radius-pill);
}

.control-btn.secondary:hover {
  background: var(--secondary-hover);
  color: var(--text-main);
  transform: translateY(-2px);
}

.control-btn.secondary:active {
  transform: scale(0.94);
}

/* --- Current Active Task Banner --- */
.current-task-banner {
  margin-top: 18px;
  background: var(--primary-light);
  color: var(--primary);
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  font-size: 0.85rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 90%;
  animation: fadeIn 0.3s ease;
}

.current-task-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

.clear-current-task-btn {
  background: transparent;
  border: none;
  color: var(--primary);
  font-size: 0.9rem;
  cursor: pointer;
  padding: 0 4px;
}

/* --- Cycles & Progress Indicator --- */
.pomodoro-cycles-wrapper {
  margin-top: 20px;
  width: 100%;
  padding-top: 16px;
  border-top: 1px dashed rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

body[data-theme="dark"] .pomodoro-cycles-wrapper {
  border-top-color: rgba(255, 255, 255, 0.08);
}

.cycle-title {
  display: flex;
  justify-content: space-between;
  width: 100%;
  max-width: 240px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
}

.cycle-dots {
  display: flex;
  gap: 12px;
  align-items: center;
}

.cycle-tomato {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  opacity: 0.35;
  transition: var(--transition);
  filter: grayscale(1);
}

.cycle-tomato.filled {
  opacity: 1;
  filter: grayscale(0);
  background: var(--primary-light);
  transform: scale(1.15);
  animation: tomatoBounce 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* --- Task Card (To-Do List) --- */
.tasks-card {
  background: var(--card-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 22px 20px;
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text-main);
}

.task-counter {
  font-size: 0.75rem;
  font-weight: 800;
  background: var(--secondary);
  color: var(--text-muted);
  padding: 3px 8px;
  border-radius: var(--radius-pill);
}

.text-link-btn {
  background: transparent;
  border: none;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.2s ease;
}

.text-link-btn:hover {
  color: var(--primary);
  text-decoration: underline;
}

.add-task-form {
  display: flex;
  gap: 8px;
}

.task-input {
  flex: 1;
  background: var(--secondary);
  border: 2px solid transparent;
  border-radius: var(--radius-pill);
  padding: 12px 18px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-main);
  outline: none;
  transition: var(--transition);
}

.task-input:focus {
  border-color: var(--primary);
  background: #ffffff;
  box-shadow: 0 0 0 4px var(--primary-light);
}

body[data-theme="dark"] .task-input:focus {
  background: #1a1b1e;
}

.task-add-btn {
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-pill);
  padding: 0 20px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 12px var(--primary-shadow);
  transition: var(--transition);
}

.task-add-btn:hover {
  background: var(--primary-hover);
  transform: translateY(-2px);
}

.task-add-btn:active {
  transform: scale(0.95);
}

.task-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 280px;
  overflow-y: auto;
  padding-right: 4px;
}

.task-list::-webkit-scrollbar {
  width: 5px;
}
.task-list::-webkit-scrollbar-thumb {
  background: var(--text-light);
  border-radius: 10px;
}

.task-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--secondary);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  transition: var(--transition);
  gap: 8px;
}

.task-item:hover {
  background: rgba(0, 0, 0, 0.04);
  transform: translateX(3px);
}

body[data-theme="dark"] .task-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.task-item.active-focus {
  border-color: var(--primary);
  background: var(--primary-light);
}

.task-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.task-checkbox {
  appearance: none;
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border: 2px solid var(--text-light);
  border-radius: 8px;
  cursor: pointer;
  display: grid;
  place-content: center;
  transition: var(--transition);
  flex-shrink: 0;
}

.task-checkbox::before {
  content: "✔";
  font-size: 13px;
  font-weight: 800;
  color: white;
  transform: scale(0);
  transition: 0.2s transform ease-in-out;
}

.task-checkbox:checked {
  background: var(--accent-green);
  border-color: var(--accent-green);
}

.task-checkbox:checked::before {
  transform: scale(1);
}

.task-text {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  transition: 0.2s ease;
}

.task-item.completed .task-text {
  text-decoration: line-through;
  color: var(--text-muted);
  opacity: 0.7;
}

.task-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.task-action-btn {
  background: transparent;
  border: none;
  font-size: 0.9rem;
  cursor: pointer;
  opacity: 0.6;
  padding: 4px;
  border-radius: 6px;
  transition: var(--transition);
}

.task-action-btn:hover {
  opacity: 1;
  transform: scale(1.2);
}

.task-action-btn.delete-btn:hover {
  color: #fa5252;
}

.empty-task-placeholder {
  text-align: center;
  padding: 24px 10px;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 600;
}

.empty-task-placeholder .empty-emoji {
  font-size: 2rem;
  display: block;
  margin-bottom: 6px;
}

/* --- Footer --- */
.app-footer {
  text-align: center;
  padding: 10px;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.footer-quote {
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--text-main);
}

/* --- Modals & Popovers --- */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: #ffffff;
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.2);
  transform: translateY(20px) scale(0.95);
  transition: var(--transition);
  max-height: 90vh;
  overflow-y: auto;
}

body[data-theme="dark"] .modal-card {
  background: #25262b;
  color: #f1f3f5;
}

.modal-backdrop.open .modal-card {
  transform: translateY(0) scale(1);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

.modal-title {
  font-size: 1.2rem;
  font-weight: 800;
}

.modal-close-btn {
  background: var(--secondary);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  color: var(--text-muted);
  transition: var(--transition);
}

.modal-close-btn:hover {
  background: var(--primary-light);
  color: var(--primary);
  transform: rotate(90deg);
}

/* Ambient Sound Grid */
.ambient-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}

.ambient-item {
  background: var(--secondary);
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-family: inherit;
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--text-main);
  transition: var(--transition);
}

.ambient-item:hover {
  background: var(--primary-light);
}

.ambient-item.active {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
}

.ambient-item .ambient-icon {
  font-size: 1.3rem;
}

.ambient-volume-wrap, .volume-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
}

/* Stats Modal Grid */
.stats-summary-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.stat-box {
  background: var(--secondary);
  padding: 16px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: 12px;
}

.stat-icon {
  font-size: 2rem;
}

.stat-info {
  display: flex;
  flex-direction: column;
}

.stat-number {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--primary);
  font-family: 'Fredoka', sans-serif;
}

.stat-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
}

.stats-cheer-message {
  background: var(--primary-light);
  color: var(--primary);
  padding: 12px;
  border-radius: var(--radius-md);
  text-align: center;
  font-size: 0.85rem;
  font-weight: 700;
}

/* Settings Sections */
.settings-content {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.settings-sec-title {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 12px;
}

.time-inputs-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.input-group label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
}

.num-input {
  background: var(--secondary);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
  outline: none;
  transition: var(--transition);
}

.num-input:focus {
  border-color: var(--primary);
  background: #ffffff;
}

body[data-theme="dark"] .num-input:focus {
  background: #1a1b1e;
}

.toggle-option {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  font-size: 0.9rem;
  font-weight: 700;
}

/* Custom Switch Toggle */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: var(--secondary-hover);
  transition: .3s;
  border-radius: 24px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

input:checked + .slider {
  background-color: var(--primary);
}

input:checked + .slider:before {
  transform: translateX(20px);
}

/* Custom Sliders */
.custom-slider {
  -webkit-appearance: none;
  width: 100%;
  height: 8px;
  border-radius: 5px;
  background: var(--secondary-hover);
  outline: none;
}

.custom-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  box-shadow: 0 2px 6px var(--primary-shadow);
  transition: transform 0.15s ease;
}

.custom-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

/* Theme Selection */
.theme-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.theme-btn {
  background: var(--secondary);
  border: 2px solid transparent;
  border-radius: var(--radius-pill);
  padding: 8px 14px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-main);
  transition: var(--transition);
}

.theme-btn .color-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
}

.theme-btn:hover {
  transform: translateY(-2px);
}

.theme-btn.active {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
}

.modal-footer {
  margin-top: 24px;
}

.modal-action-btn {
  width: 100%;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-pill);
  padding: 14px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 6px 18px var(--primary-shadow);
  transition: var(--transition);
}

.modal-action-btn:hover {
  background: var(--primary-hover);
  transform: translateY(-2px);
}

/* ==========================================================================
   Animations Keyframes
   ========================================================================== */
@keyframes cuteFloat {
  0% { transform: translateY(0) rotate(0deg); }
  100% { transform: translateY(-4px) rotate(4deg); }
}

@keyframes mascotBreathe {
  0%, 100% { transform: scale(1) translateY(0); }
  50% { transform: scale(1.02, 0.98) translateY(2px); }
}

@keyframes mascotBreatheRunning {
  0%, 100% { transform: scale(1) translateY(0); }
  50% { transform: scale(1.04, 0.96) translateY(4px); }
}

@keyframes mascotCelebrate {
  0% { transform: scale(1) translateY(0) rotate(-4deg); }
  100% { transform: scale(1.08) translateY(-12px) rotate(4deg); }
}

@keyframes cheekGlow {
  0% { opacity: 0.6; transform: scale(0.95); }
  100% { opacity: 0.95; transform: scale(1.1); }
}

@keyframes leafSway {
  0% { transform: rotate(-3deg); }
  100% { transform: rotate(4deg); }
}

@keyframes bubblePop {
  0% { opacity: 0; transform: translateY(6px) scale(0.85); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes tomatoBounce {
  0% { transform: scale(0.6); }
  60% { transform: scale(1.28); }
  100% { transform: scale(1.15); }
}

@keyframes particleFloat {
  0% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(0.5);
  }
  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1.4);
  }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   Responsive Adjustments
   ========================================================================== */
@media (max-width: 480px) {
  body {
    padding: 12px 8px;
  }
  .timer-card {
    padding: 18px 14px;
  }
  .timer-display-wrap {
    width: 250px;
    height: 250px;
  }
  .progress-ring {
    width: 250px;
    height: 250px;
  }
  .timer-digits {
    font-size: 3.1rem;
  }
  .control-btn.primary {
    padding: 14px 28px;
    font-size: 1.1rem;
    min-width: 140px;
  }
}
