.modal-content {
  overflow-y: auto;
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE 10+ */
}
.modal-content::-webkit-scrollbar {
  display: none; /* Chrome, Safari, Opera */
}
/* ==========================================================================
   1. CSS Setup & Global Variables
   ========================================================================== */

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

/* Prevent scrolling on mobile */
html,
body {
  min-height: 100vh;
  min-height: 100dvh; /* Dynamic viewport height for mobile */
  overflow: hidden;
  touch-action: manipulation;
  -webkit-font-smoothing: antialiased;
  -webkit-touch-callout: none;
  /* Support for safe areas on notched devices */
  padding-top: env(safe-area-inset-top);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}

/* Allow modal content to scroll if needed */
.modal-content {
  overflow-y: auto;
}

:root {
  --pomodoro: #5cb85c;
  --shortBreak: #4db8a5;
  --longBreak: #5a9fd4;
  --color-text-light: rgba(255, 255, 255, 0.9);
  --color-text-medium: rgba(255, 255, 255, 0.6);
  --color-bg-light: #fff;
  --color-progress-bar: rgba(0, 0, 0, 0.1);
  --burger-icon-color: #fff;

  /* Neumorphic Variables */
  --neu-bg: #5cb85c;
  --neu-shadow-light: rgba(255, 255, 255, 0.25);
  --neu-shadow-dark: rgba(0, 0, 0, 0.2);
  --neu-inset-light: rgba(255, 255, 255, 0.1);
  --neu-inset-dark: rgba(0, 0, 0, 0.15);
}

/* Digital/Pixel Font Import */
@import url("https://fonts.googleapis.com/css2?family=Jersey+25&family=Orbitron:wght@400;700;900&display=swap");

/* ==========================================================================
   NEUMORPHIC DESIGN SYSTEM
   ========================================================================== */

/* Neumorphic raised element (buttons, cards) */
.neu-raised {
  background: var(--neu-bg);
  box-shadow:
    8px 8px 16px var(--neu-shadow-dark),
    -8px -8px 16px var(--neu-shadow-light);
  border-radius: 20px;
}

/* Neumorphic pressed/inset element */
.neu-inset {
  background: var(--neu-bg);
  box-shadow:
    inset 4px 4px 8px var(--neu-inset-dark),
    inset -4px -4px 8px var(--neu-inset-light);
  border-radius: 20px;
}

/* Neumorphic button with 3D pop effect */
.neu-button {
  background: linear-gradient(145deg, #62c962, #52a852);
  box-shadow:
    6px 6px 12px rgba(0, 0, 0, 0.2),
    -6px -6px 12px rgba(255, 255, 255, 0.15);
  border-radius: 20px;
  transition: all 0.2s ease;
}

.neu-button:active {
  box-shadow:
    inset 3px 3px 6px rgba(0, 0, 0, 0.2),
    inset -3px -3px 6px rgba(255, 255, 255, 0.1);
}

/* Neumorphic pill container */
.neu-pill {
  background: rgba(0, 0, 0, 0.15);
  box-shadow:
    inset 3px 3px 6px rgba(0, 0, 0, 0.15),
    inset -3px -3px 6px rgba(255, 255, 255, 0.08);
  border-radius: 50px;
}

/* Sliding indicator for mode switcher */
.mode-slider {
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}

/* Watermark Logo with Sparkle Effect */
.watermark-logo {
  position: fixed;
  top: 14px;
  left: 16px;
  z-index: 50;
  font-size: 1.25rem;
  font-weight: 900;
  letter-spacing: 0.15em;
  color: rgba(255, 255, 255, 0.35);
  text-shadow: 
    0 0 10px rgba(255, 255, 255, 0.2),
    0 0 15px rgba(255, 255, 255, 0.1);
  pointer-events: none;
  animation: sparkle-glow 4s ease-in-out infinite;
  white-space: nowrap;
  padding: 8px 12px;
  border-radius: 8px;
}

/* Tablet Screens */
@media (min-width: 640px) {
  .watermark-logo {
    font-size: 1.5rem;
    left: 20px;
    top: 18px;
    padding: 10px 14px;
  }
}

/* Desktop Screens */
@media (min-width: 1024px) {
  .watermark-logo {
    font-size: 1.75rem;
    left: 24px;
    top: 20px;
    padding: 12px 16px;
  }
}

@keyframes sparkle-glow {
  0% {
    opacity: 0.3;
    text-shadow: 
      0 0 10px rgba(255, 255, 255, 0.2),
      0 0 20px rgba(255, 255, 255, 0.1),
      0 0 30px rgba(255, 255, 255, 0.05);
  }
  25% {
    opacity: 0.5;
    text-shadow: 
      0 0 15px rgba(255, 255, 255, 0.4),
      0 0 25px rgba(255, 255, 255, 0.25),
      0 0 40px rgba(255, 255, 255, 0.15);
  }
  50% {
    opacity: 0.35;
    text-shadow: 
      0 0 12px rgba(255, 255, 255, 0.3),
      0 0 22px rgba(255, 255, 255, 0.15),
      0 0 35px rgba(255, 255, 255, 0.08);
  }
  75% {
    opacity: 0.45;
    text-shadow: 
      0 0 18px rgba(255, 255, 255, 0.35),
      0 0 28px rgba(255, 255, 255, 0.2),
      0 0 45px rgba(255, 255, 255, 0.12);
  }
  100% {
    opacity: 0.3;
    text-shadow: 
      0 0 10px rgba(255, 255, 255, 0.2),
      0 0 20px rgba(255, 255, 255, 0.1),
      0 0 30px rgba(255, 255, 255, 0.05);
  }
}

/* Mode button hover effect */
.mode-btn:hover:not(.active) {
  color: rgba(255, 255, 255, 0.85);
}

/* Neumorphic icon button */
.neu-icon-btn {
  background: linear-gradient(
    145deg,
    rgba(255, 255, 255, 0.15),
    rgba(255, 255, 255, 0.05)
  );
  box-shadow:
    4px 4px 8px rgba(0, 0, 0, 0.15),
    -4px -4px 8px rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  transition: all 0.2s ease;
}

.neu-icon-btn:active {
  box-shadow:
    inset 2px 2px 4px rgba(0, 0, 0, 0.15),
    inset -2px -2px 4px rgba(255, 255, 255, 0.08);
}

/* Digital timer font */
.digital-timer {
  font-family: "Jersey 25", "Orbitron", "Courier New", monospace;
  font-weight: 400;
  letter-spacing: 0.05em;
  text-shadow:
    0 0 20px rgba(255, 255, 255, 0.5),
    0 4px 8px rgba(0, 0, 0, 0.2);
}

/* Custom Scrollbar for aesthetic feel */
.custom-scrollbar::-webkit-scrollbar {
  width: 6px;
}
.custom-scrollbar::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.05);
}
.custom-scrollbar::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 10px;
}
.custom-scrollbar::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.3);
}

/* Hide scrollbar but allow scrolling */
.hide-scrollbar {
  -ms-overflow-style: none; /* IE and Edge */
  scrollbar-width: none; /* Firefox */
}
.hide-scrollbar::-webkit-scrollbar {
  display: none;
}

/* Onboarding toggle switch */
.onboarding-toggle {
  position: relative;
  width: 46px;
  height: 26px;
  display: inline-block;
  flex-shrink: 0;
}

.onboarding-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.onboarding-toggle-track {
  position: absolute;
  inset: 0;
  background: #e5e7eb;
  border-radius: 999px;
  transition: background 0.2s ease;
  box-shadow:
    inset 2px 2px 4px rgba(0, 0, 0, 0.08),
    inset -2px -2px 4px rgba(255, 255, 255, 0.6);
}

.onboarding-toggle-track::after {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 999px;
  transition: transform 0.2s ease;
  box-shadow:
    0 2px 6px rgba(0, 0, 0, 0.15),
    0 1px 2px rgba(0, 0, 0, 0.1);
}

.onboarding-toggle input:checked + .onboarding-toggle-track {
  background: #111827;
}

.onboarding-toggle input:checked + .onboarding-toggle-track::after {
  transform: translateX(20px);
}

.onboarding-toggle input:focus-visible + .onboarding-toggle-track {
  outline: 2px solid rgba(17, 24, 39, 0.35);
  outline-offset: 3px;
}

/* ========================================================================== */
/* MOBILE-FIRST UTILITIES                                                     */
/* ========================================================================== */

/* Tap targets - minimum 44px for touch */
button,
input[type="button"],
input[type="submit"],
a {
  min-height: 44px;
  min-width: 44px;
}

/* Prevent horizontal scrolling on mobile */
body,
html {
  overflow-x: hidden;
}

/* Modal styling - mobile first */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.25);
  z-index: 40;
}

#js-chat-modal,
#js-chat-modal.open {
  background: transparent !important;
}

#js-chat-modal .modal-content {
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
}

.modal-content {
  background: white;
  border-radius: 20px;
  max-width: 95vw;
  max-height: 90vh;
  max-height: 90dvh; /* Dynamic viewport height */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 475px) {
  .modal-content {
    border-radius: 20px 20px 0 0;
    max-width: 100vw;
    max-height: calc(85dvh - env(safe-area-inset-bottom, 0px));
    padding: 20px 16px;
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    margin-bottom: 0;
  }
}

.task-item {
  background-color: #f9f9f9;
  padding: 18px;
  border-radius: 16px;
  border-left: 4px solid #555;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  color: #333;
}

.task-item .task-info {
  flex: 1;
  min-width: 0;
}

.task-item .task-name {
  font-weight: 600;
  font-size: 16px;
  word-break: break-word;
  margin-bottom: 6px;
}

.task-item .task-pomos {
  font-size: 14px;
  color: #666;
}

.task-item.selected {
  background-color: #e3f2fd;
  border-left-color: #2196f3;
}

.task-item.completed {
  opacity: 0.6;
}

.task-item.completed .task-name {
  text-decoration: line-through;
}

.task-controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  width: 100%;
}

.task-btn {
  min-height: 44px;
  flex: 1;
  min-width: 70px;
  font-size: 13px;
  padding: 10px 14px;
  border-radius: 10px;
  border: none;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.task-btn.edit {
  background: #e0e0e0;
}

.task-item.completed .task-btn.edit {
  background: #cccccc;
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.task-btn.save {
  background: #4caf50;
  color: white;
}

.task-btn.done {
  background: #2196f3;
  color: white;
}

.task-btn.cancel {
  background: #f44336;
  color: white;
}

.task-btn.delete {
  background: #f44336;
  color: white;
}

/* Edit inputs */
.task-edit-name,
.task-edit-pomos {
  width: 100%;
  padding: 6px;
  margin-bottom: 4px;
  font-size: 13px;
  border-radius: 6px;
  border: 1px solid #ccc;
  color: #333;
}

.color-picker-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.color-picker-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  color: #555;
  font-size: 20px;
}

/* Custom Color Input Styling to look like Squares */
.color-picker-item input[type="color"] {
  -webkit-appearance: none;
  appearance: none;
  border: none;
  width: 44px;
  height: 44px;
  cursor: pointer;
  background: white;
  padding: 4px;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.color-picker-item input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
  border-radius: 4px;
}

.color-picker-item input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 4px;
}

/* Firefox support */
.color-picker-item input[type="color"]::-moz-color-swatch {
  border: none;
  border-radius: 4px;
}

/* ==========================================================================
   6. Utility & Animations
   ========================================================================== */

.hidden {
  display: none !important;
}

/* Skip button hidden state */
.skip-btn-hidden {
  display: none !important;
}

/* PiP button - hide on mobile, show on desktop */
.pip-btn-desktop {
  display: flex;
}

@media screen and (max-width: 640px) {
  .pip-btn-desktop {
    display: none !important;
  }
}

/* ==========================================================================
   7. Responsive Design
   ========================================================================== */

@media screen and (max-width: 480px) {
  /* Hide video background and info buttons when any modal is open on mobile */
  body:has(.modal.open) .video-bg-btn,
  body:has(.modal.open) .about-btn,
  body:has(.modal.open) .info-btn,
  body:has(.modal.open) .music-btn,
  body.modal-open .video-bg-btn,
  body.modal-open .about-btn,
  body.modal-open .info-btn,
  body.modal-open .music-btn {
    display: none !important;
  }
}

/* ==========================================================================
   8. Video Background Feature
   ========================================================================== */

/* ==========================================================================
   NEUMORPHIC FOOTER BUTTONS
   ========================================================================== */

.footer-buttons-container {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 24px;
  padding: 20px 24px calc(24px + env(safe-area-inset-bottom, 8px)) 24px;
  padding-left: max(24px, env(safe-area-inset-left));
  padding-right: max(24px, env(safe-area-inset-right));
  z-index: 50;
  transition:
    opacity 0.3s ease,
    visibility 0.3s ease;
}

/* Hide footer buttons when any modal is open */
body:has(.modal.open) .footer-buttons-container,
body.modal-open .footer-buttons-container {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* Hide chat button when chat modal is open */
body:has(#js-chat-modal.open) #js-floating-chat-btn {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* Chat modal animations */
@keyframes chatModalSlideIn {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(20px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes chatModalSlideOut {
  from {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
  to {
    opacity: 0;
    transform: scale(0.95) translateY(20px);
  }
}

/* Chat modal base (mobile-first) */
#js-chat-modal {
  display: none;
  justify-content: flex-end;
  align-items: center;
}

#js-chat-modal.open {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-top: 6vh;
  background: rgba(0, 0, 0, 0.35);
}

#js-chat-modal .modal-content {
  width: min(92vw, 560px);
  max-height: min(84vh, 680px);
  min-height: 50vh;
  border-radius: 20px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.35);
  overflow: hidden;
  background: linear-gradient(to bottom, #ffffff, #f8fafc);
  display: flex;
  flex-direction: column;
  animation: chatModalSlideOut 0.3s ease-out forwards;
}

#js-chat-modal.open .modal-content {
  animation: chatModalSlideIn 0.3s ease-out forwards;
}

#js-chat-modal .modal-content #js-chat-modes-container {
  flex: 1; 
  min-height: 0;
  overflow: hidden;
}

#js-chat-modal .modal-content #js-messages-container {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}


/* Fix chat modal positioning on desktop */
@media (min-width: 768px) {
  #js-chat-modal .modal-content {
    position: relative !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    bottom: auto !important;
  }
}

.video-bg-btn,
.music-btn,
.about-btn,
.info-btn,
.chat-btn {
  width: 60px;
  height: 60px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(
    145deg,
    rgba(255, 255, 255, 0.18),
    rgba(255, 255, 255, 0.08)
  );
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 20px;
  color: white;
  font-size: 24px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow:
    6px 6px 12px rgba(0, 0, 0, 0.15),
    -6px -6px 12px rgba(255, 255, 255, 0.1);
  font-family: inherit;
  position: relative;
}

.video-bg-btn:hover,
.music-btn:hover,
.about-btn:hover,
.info-btn:hover,
.chat-btn:hover {
  background: linear-gradient(
    145deg,
    rgba(255, 255, 255, 0.25),
    rgba(255, 255, 255, 0.12)
  );
  transform: translateY(-2px);
  box-shadow:
    8px 8px 16px rgba(0, 0, 0, 0.18),
    -8px -8px 16px rgba(255, 255, 255, 0.12);
}

.video-bg-btn:active,
.music-btn:active,
.about-btn:active,
.info-btn:active,
.chat-btn:active {
  transform: translateY(0);
  box-shadow:
    inset 3px 3px 6px rgba(0, 0, 0, 0.15),
    inset -3px -3px 6px rgba(255, 255, 255, 0.08);
}

/* Remove old positioning - handled by container now */
.video-bg-btn {
  position: relative;
  bottom: auto;
  left: auto;
}

.music-btn {
  position: relative;
  bottom: auto;
  left: auto;
}

.about-btn {
  position: relative;
  bottom: auto;
  right: auto;
}

.info-btn {
  position: relative;
  bottom: auto;
  right: auto;
}

/* Mobile responsive footer buttons */
@media (max-width: 480px) {
  .footer-buttons-container {
    gap: 16px;
    padding: 16px 20px 28px 20px;
  }

  .video-bg-btn,
  .music-btn,
  .about-btn,
  .info-btn {
    width: 56px;
    height: 56px;
    font-size: 22px;
    border-radius: 18px;
  }
}

@media (max-width: 360px) {
  .footer-buttons-container {
    gap: 12px;
    padding: 14px 16px 24px 16px;
  }

  .video-bg-btn,
  .music-btn,
  .about-btn,
  .info-btn {
    width: 50px;
    height: 50px;
    font-size: 20px;
    border-radius: 16px;
  }
}

/* Video Modal Grid - Hide scrollbar on all resolutions */
#js-video-modal .grid {
  -ms-overflow-style: none; /* IE and Edge */
  scrollbar-width: none; /* Firefox */
}

#js-video-modal .grid::-webkit-scrollbar {
  display: none; /* Chrome, Safari and Opera */
}

#bg-video {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: -1;
  display: none;
  filter: brightness(0.6); /* Darken video to ensure text readability */
}

/* Override body background when video is active */
body.video-active {
  background-color: transparent !important;
}

/* ==========================================================================
   12. Leaderboard Styles
   ========================================================================== */

.leaderboard-header {
  display: grid;
  grid-template-columns: 50px 50px 1fr 80px;
  gap: 10px;
  padding: 12px 15px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  font-weight: 700;
  font-size: 14px;
  color: white;
  text-transform: uppercase;
  border-bottom: 2px solid #ccc;
  position: sticky;
  top: 0;
  z-index: 10;
}

.leaderboard-row {
  display: grid;
  grid-template-columns: 50px 50px 1fr 80px;
  gap: 10px;
  padding: 12px 15px;
  align-items: center;
  border-bottom: 1px solid #e0e0e0;
  transition: all 0.2s ease;
}

.leaderboard-row:hover {
  background-color: #f8f9ff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.leaderboard-row:last-child {
  border-bottom: none;
}

.leaderboard-rank {
  font-size: 18px;
  font-weight: 700;
  text-align: center;
  color: var(--pomodoro);
}

.leaderboard-photo {
  display: flex;
  justify-content: center;
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #ddd;
  transition: transform 0.2s ease;
}

.leaderboard-row:hover .user-avatar {
  transform: scale(1.1);
}

.leaderboard-name {
  font-size: 16px;
  color: #333;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.leaderboard-pomodoros {
  text-align: center;
  font-size: 20px;
  font-weight: 700;
  color: var(--pomodoro);
}

.leaderboard-empty,
.leaderboard-error {
  padding: 24px 15px;
  text-align: center;
  color: #999;
  font-size: 14px;
}

/* ========================================================================== */
/* LEADERBOARD REDESIGN - MODERN & USER-FRIENDLY                            */
/* ========================================================================== */

/* ========================================================================== */
/* STATS TABS - Pomofocus Style                                               */
/* ========================================================================== */

.stats-tabs {
  display: flex;
  background: #fff;
  border-bottom: 1px solid #e5e5e5;
}

.stats-tab {
  flex: 1;
  padding: 14px 16px;
  font-size: 13px;
  font-weight: 500;
  color: #9ca3af;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.stats-tab:hover {
  color: #6b7280;
  background: #f9fafb;
}

.stats-tab.active {
  color: #1f2937;
  border-bottom-color: #f59e0b;
}

.stats-tab.active span {
  opacity: 1;
}

.stats-tab span {
  opacity: 0.7;
}

.stats-tab-content {
  animation: fadeIn 0.2s ease;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

#js-tab-ranking {
  height: 100%;
}

.stats-tab-content.hidden {
  display: none;
}

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

/* ========================================================================== */
/* LEADERBOARD - POMOFOCUS STYLE (Mobile-First, Text-Priority)               */
/* ========================================================================== */

.leaderboard-container {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: #fff;
}

.leaderboard-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: #f8f8f8;
  border-bottom: 1px solid #e5e5e5;
  color: #9ca3af;
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 20;
}

.leaderboard-header-rank {
  width: 28px;
  flex-shrink: 0;
}

.leaderboard-header-user {
  flex: 1;
  min-width: 0;
}

.leaderboard-header-total {
  width: 72px;
  text-align: right;
  flex-shrink: 0;
}

.leaderboard-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
}

.leaderboard-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid #f0f0f0;
  transition: background 0.15s ease;
  background: #fff;
}

.leaderboard-row:hover {
  background: #fafafa;
}

.leaderboard-row:last-child {
  border-bottom: none;
}

.leaderboard-rank-cell {
  width: 28px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.rank-number {
  font-size: 15px;
  font-weight: 500;
  color: #6b7280;
}

.leaderboard-user-cell {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.leaderboard-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: #e5e7eb;
}

.user-name {
  font-size: 15px;
  font-weight: 500;
  color: #1f2937;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.leaderboard-total-cell {
  width: 72px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.total-count {
  font-size: 15px;
  font-weight: 700;
  color: #1f2937;
}

/* Mobile responsiveness */
@media (max-width: 640px) {
  #js-onboarding-modal {
    align-items: stretch;
    padding: 0;
  }

  #js-onboarding-modal .modal-content {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0 !important;
    box-shadow: none;
  }

  #js-onboarding-modal .onboarding-modal-content {
    opacity: 0;
    transform: translateY(16px) scale(0.98) !important;
    transition: opacity 0.3s ease, transform 0.45s ease;
  }

  #js-onboarding-modal.open .onboarding-modal-content {
    opacity: 1;
    transform: translateY(0) scale(1) !important;
  }

  #js-stats-modal .modal-content {
    padding: 18px 14px;
  }

  #js-stats-content h2 {
    font-size: 22px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid rgba(0, 0, 0, 0.08);
  }

  .stats-grid {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 12px;
  }

  .stats-grid div {
    padding: 18px 14px;
    background: linear-gradient(
      135deg,
      rgba(255, 255, 255, 0.8) 0%,
      rgba(255, 255, 255, 0.6) 100%
    );
    border-radius: 16px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    flex: 0 1 calc(50% - 8px);
    min-width: 110px;
    text-align: center;
  }

  .stats-grid div:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
  }

  #js-stat-sessions,
  #js-stat-today,
  #js-stat-week {
    font-size: 36px;
    font-weight: 800;
    margin-bottom: 6px;
    color: var(--pomodoro);
  }

  .stats-grid p {
    font-size: 12px;
    letter-spacing: 1px;
    font-weight: 600;
    text-transform: uppercase;
    color: #666;
  }

  .leaderboard-container {
    max-height: calc(60svh - env(safe-area-inset-bottom, 0px));
  }

  .leaderboard-header {
    gap: 10px;
    padding: 10px 14px;
    font-size: 10px;
  }

  .leaderboard-header-rank {
    width: 24px;
  }

  .leaderboard-header-total {
    width: 64px;
  }

  .leaderboard-row {
    gap: 10px;
    padding: 10px 14px;
  }

  .leaderboard-rank-cell {
    width: 24px;
  }

  .rank-number {
    font-size: 14px;
  }

  .leaderboard-user-cell {
    gap: 10px;
  }

  .leaderboard-avatar {
    width: 32px;
    height: 32px;
  }

  .user-name {
    font-size: 14px;
  }

  .leaderboard-total-cell {
    width: 64px;
  }

  .total-count {
    font-size: 14px;
  }
}

/* Extra small phones (< 480px) */
@media (max-width: 480px) {
  #js-stats-modal .modal-content {
    padding: 16px 12px;
    max-height: 85dvh;
  }

  #js-stats-content h2 {
    font-size: 20px;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 2px solid rgba(0, 0, 0, 0.08);
  }

  .stats-grid {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: space-around;
    margin-top: 10px;
  }

  .stats-grid div {
    padding: 14px 10px;
    background: linear-gradient(
      135deg,
      rgba(255, 255, 255, 0.8) 0%,
      rgba(255, 255, 255, 0.6) 100%
    );
    border-radius: 14px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    flex: 1;
    min-width: 95px;
  }

  #js-stat-sessions,
  #js-stat-today,
  #js-stat-week {
    font-size: 28px;
    font-weight: 800;
    margin-bottom: 4px;
    color: var(--pomodoro);
  }

  .stats-grid p {
    font-size: 10px;
    letter-spacing: 0.8px;
    font-weight: 600;
    text-transform: uppercase;
    color: #666;
  }

  .leaderboard-container {
    max-height: calc(56svh - env(safe-area-inset-bottom, 0px));
  }

  .leaderboard-header {
    gap: 8px;
    padding: 8px 12px;
    font-size: 10px;
  }

  .leaderboard-header-rank {
    width: 22px;
  }

  .leaderboard-header-total {
    width: 58px;
  }

  .leaderboard-row {
    gap: 8px;
    padding: 10px 12px;
  }

  .leaderboard-rank-cell {
    width: 22px;
  }

  .rank-number {
    font-size: 13px;
  }

  .leaderboard-user-cell {
    gap: 10px;
  }

  .leaderboard-avatar {
    width: 32px;
    height: 32px;
  }

  .user-name {
    font-size: 14px;
  }

  .leaderboard-total-cell {
    width: 58px;
  }

  .total-count {
    font-size: 14px;
  }

  .leaderboard-empty,
  .leaderboard-error {
    padding: 15px 10px;
    font-size: 12px;
  }
}

/* iPhone SE / Small phones (< 390px) */
@media (max-width: 389px) {
  #js-stats-modal .modal-content {
    padding: 14px 10px;
  }

  #js-stats-content h2 {
    font-size: 18px;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid rgba(0, 0, 0, 0.08);
  }

  .stats-grid {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: space-around;
    margin-top: 8px;
  }

  .stats-grid div {
    padding: 12px 8px;
    background: linear-gradient(
      135deg,
      rgba(255, 255, 255, 0.8) 0%,
      rgba(255, 255, 255, 0.6) 100%
    );
    border-radius: 12px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
    flex: 1;
    min-width: 88px;
  }

  #js-stat-sessions,
  #js-stat-today,
  #js-stat-week {
    font-size: 26px;
    font-weight: 800;
    margin-bottom: 3px;
    color: var(--pomodoro);
  }

  .stats-grid p {
    font-size: 9px;
    letter-spacing: 0.6px;
    font-weight: 600;
    text-transform: uppercase;
    color: #666;
  }

  .leaderboard-container {
    max-height: calc(52svh - env(safe-area-inset-bottom, 0px));
  }

  .leaderboard-header {
    gap: 8px;
    padding: 8px 10px;
    font-size: 9px;
  }

  .leaderboard-header-rank {
    width: 20px;
  }

  .leaderboard-header-total {
    width: 54px;
  }

  .leaderboard-row {
    gap: 8px;
    padding: 10px 10px;
  }

  .leaderboard-rank-cell {
    width: 20px;
  }

  .rank-number {
    font-size: 13px;
  }

  .leaderboard-user-cell {
    gap: 8px;
  }

  .leaderboard-avatar {
    width: 30px;
    height: 30px;
  }

  .user-name {
    font-size: 13px;
  }

  .leaderboard-total-cell {
    width: 54px;
  }

  .total-count {
    font-size: 13px;
  }

  .leaderboard-empty,
  .leaderboard-error {
    padding: 16px 10px;
    font-size: 13px;
  }
}

/* Very small phones (< 360px) */
@media (max-width: 359px) {
  #js-stats-modal .modal-content {
    padding: 12px 8px;
  }

  #js-stats-content h2 {
    font-size: 16px;
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 2px solid rgba(0, 0, 0, 0.08);
  }

  .stats-grid {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    justify-content: space-around;
    margin-top: 6px;
  }

  .stats-grid div {
    padding: 10px 6px;
    background: linear-gradient(
      135deg,
      rgba(255, 255, 255, 0.8) 0%,
      rgba(255, 255, 255, 0.6) 100%
    );
    border-radius: 10px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
    flex: 1;
    min-width: 80px;
  }

  #js-stat-sessions,
  #js-stat-today,
  #js-stat-week {
    font-size: 22px;
    font-weight: 800;
    margin-bottom: 2px;
    color: var(--pomodoro);
  }

  .stats-grid p {
    font-size: 8px;
    letter-spacing: 0.4px;
    font-weight: 600;
    text-transform: uppercase;
    color: #666;
  }

  .leaderboard-container {
    max-height: calc(48svh - env(safe-area-inset-bottom, 0px));
  }

  .leaderboard-header {
    gap: 6px;
    padding: 8px 8px;
    font-size: 9px;
  }

  .leaderboard-header-rank {
    width: 18px;
  }

  .leaderboard-header-total {
    width: 50px;
  }

  .leaderboard-row {
    gap: 6px;
    padding: 9px 8px;
  }

  .leaderboard-rank-cell {
    width: 18px;
  }

  .rank-number {
    font-size: 12px;
  }

  .leaderboard-user-cell {
    gap: 6px;
  }

  .leaderboard-avatar {
    width: 28px;
    height: 28px;
  }

  .user-name {
    font-size: 12px;
  }

  .leaderboard-total-cell {
    width: 50px;
  }

  .total-count {
    font-size: 12px;
  }
}

/* ==========================================================================
   Timer Simple Aesthetic Animation
   ========================================================================== */

@keyframes simpleAestheticTick {
  0% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.8;
    transform: scale(1.05);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes softGlowPulse {
  0%,
  100% {
    text-shadow: 0 0 0px rgba(255, 255, 255, 0);
  }
  50% {
    text-shadow: 0 0 12px rgba(255, 255, 255, 0.5);
  }
}

#js-clock {
  perspective: 1000px;
}

#js-minutes.tick,
#js-seconds.tick {
  display: inline-block;
  animation: simpleAestheticTick 0.4s ease-in-out forwards;
}

#js-clock.tick-glow {
  animation: softGlowPulse 0.4s ease-in-out forwards;
}

/* ==========================================================================
   Large Mobile Screens (iPhone X, 11, 12, 13, 14, 15, 16, 17 Pro)
   ========================================================================== */

@media (min-width: 390px) and (max-width: 768px) {
  /* Stats Modal */
  #js-stats-modal .modal-content {
    max-width: 600px;
    padding: 8px;
  }

  #js-stats-modal h2 {
    font-size: 28px;
    margin-bottom: 20px;
  }

  #js-stat-sessions,
  #js-stat-today,
  #js-stat-week {
    font-size: 42px;
    margin-bottom: 8px;
  }

  .stats-grid div {
    padding: 16px;
    min-width: 120px;
  }

  .stats-grid p {
    font-size: 14px;
  }

  .leaderboard-container {
    max-height: 500px;
  }

  .leaderboard-header {
    gap: 14px;
    padding: 12px 20px;
    font-size: 11px;
  }

  .leaderboard-header-rank {
    width: 32px;
  }

  .leaderboard-header-total {
    width: 80px;
  }

  .leaderboard-row {
    gap: 14px;
    padding: 14px 20px;
  }

  .leaderboard-rank-cell {
    width: 32px;
  }

  .rank-number {
    font-size: 16px;
  }

  .leaderboard-user-cell {
    gap: 14px;
  }

  .leaderboard-avatar {
    width: 42px;
    height: 42px;
  }

  .user-name {
    font-size: 16px;
  }

  .leaderboard-total-cell {
    width: 80px;
  }

  .total-count {
    font-size: 16px;
  }
}

/* ==========================================================================
   Extra Small Phones (iPhone SE and smaller)
   ========================================================================== */

@media (max-width: 375px) {
  #js-stats-modal .modal-content {
    padding: 16px 12px;
    max-height: 85dvh;
    gap: 1;
    border-radius: 20px;
  }

  #js-stats-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
  }

  #js-stats-content h2 {
    font-size: 22px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid rgba(0, 0, 0, 0.08);
    flex-shrink: 0;
    font-weight: 700;
  }

  .stats-grid {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
    justify-content: space-around;
    padding-bottom: 12px;
    flex-shrink: 0;
  }

  .stats-grid div {
    padding: 16px 12px;
    background: linear-gradient(
      135deg,
      rgba(255, 255, 255, 0.8) 0%,
      rgba(255, 255, 255, 0.6) 100%
    );
    border-radius: 16px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    flex: 1;
    min-width: 100px;
    transition:
      transform 0.2s,
      box-shadow 0.2s;
  }

  .stats-grid div:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
  }

  #js-stat-sessions,
  #js-stat-today,
  #js-stat-week {
    font-size: 32px;
    font-weight: 800;
    margin-bottom: 6px;
    color: var(--pomodoro);
  }

  .stats-grid p {
    font-size: 11px;
    letter-spacing: 1px;
    font-weight: 600;
    text-transform: uppercase;
    color: #666;
    margin: 0;
  }

  .overflow-y-auto {
    overflow-x: hidden !important;
    flex: 1;
    min-height: 0;
  }

  /* Leaderboard Container */
  .leaderboard-container {
    max-height: 300px;
  }

  .leaderboard-header {
    gap: 8px;
    padding: 8px 12px;
    font-size: 10px;
  }

  .leaderboard-header-rank {
    width: 22px;
  }

  .leaderboard-header-total {
    width: 56px;
  }

  .leaderboard-row {
    gap: 8px;
    padding: 10px 12px;
  }

  .leaderboard-rank-cell {
    width: 22px;
  }

  .rank-number {
    font-size: 13px;
  }

  .leaderboard-user-cell {
    gap: 10px;
  }

  .leaderboard-avatar {
    width: 32px;
    height: 32px;
  }

  .user-name {
    font-size: 13px;
  }

  .leaderboard-total-cell {
    width: 56px;
  }

  .total-count {
    font-size: 13px;
  }
}

/* ========================================================================== */
/* COMPREHENSIVE MOBILE-FIRST RESPONSIVE DESIGN                              */
/* ========================================================================== */

/* Base mobile styles (default) */
@media (max-width: 640px) {
  /* Typography scaling */
  h1,
  h2,
  h3 {
    letter-spacing: normal;
  }

  /* Improved button sizes for touch */
  button {
    min-height: 44px;
    transition: all 0.2s ease;
  }

  button:active {
    transform: scale(0.98);
  }

  /* Modal adjustments for mobile */
  .modal {
    padding: 0;
  }

  .modal-content {
    margin: 20px;
    max-width: calc(100vw - 40px);
  }

  /* Input field sizing */
  input[type="text"],
  input[type="number"],
  input[type="password"],
  input[type="email"],
  select,
  textarea {
    min-height: 44px;
    padding: 12px;
    font-size: 16px; /* Prevents iOS zoom on focus */
  }

  /* Task list optimization */
  .task-item {
    padding: 14px;
    gap: 12px;
  }

  /* Prevent overflow on mobile */
  * {
    max-width: 100%;
  }
}

/* Small phones (375px - 475px) */
@media (min-width: 375px) and (max-width: 475px) {
  main {
    padding: 12px;
  }

  .stats-grid div {
    min-width: 100px;
  }
}

/* Standard mobile (476px - 640px) */
@media (min-width: 476px) and (max-width: 640px) {
  main {
    padding: 16px;
  }

  .modal-content {
    margin: 20px auto;
  }
}

/* Tablet & larger (641px+) */
@media (min-width: 641px) {
  main {
    padding: 24px;
  }

  .modal-content {
    margin: 0 auto;
  }

  /* Larger spacing on bigger screens */
  button,
  input {
    min-height: 48px;
  }
}

/* Fix modal overlay on all devices */
.modal-overlay,
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
}

/* Ensure no horizontal scroll */
body,
html {
  overflow-x: hidden;
}

/* Touch-friendly spacing */
@media (max-width: 640px) {
  .modal-content {
    border-radius: 28px 28px 0 0;
  }

  .close {
    width: 40px !important;
    height: 40px !important;
    min-width: 40px;
    min-height: 40px;
  }
}

/* Improve text readability on mobile */
@media (max-width: 640px) {
  body {
    -webkit-text-size-adjust: 100%;
    -moz-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    text-size-adjust: 100%;
  }

  p,
  span,
  label,
  div {
    word-break: break-word;
    overflow-wrap: break-word;
  }
}

/* ==========================================================================
   MOBILE BROWSER SAFE AREA & VIEWPORT FIX
   ========================================================================== */

/* Safe area insets for notched phones and browser chrome */
@supports (padding: max(0px)) {
  body {
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
  }

  /* Fixed header accounts for browser top UI */
  header {
    padding-top: max(1rem, env(safe-area-inset-top)) !important;
  }

  /* Footer buttons stay above bottom browser UI */
  .footer-buttons-container {
    padding-bottom: max(
      24px,
      calc(16px + env(safe-area-inset-bottom))
    ) !important;
  }
}

/* Modal positioning for mobile browsers */
@media (max-width: 640px) {
  .modal {
    /* Account for browser UI on mobile */
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  #js-stats-modal {
    align-items: stretch;
  }

  #js-stats-modal .modal-content {
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100svh;
    max-height: 100svh !important;
    margin: 0 !important;
    border-radius: 0 !important;
    box-shadow: none;
  }

  .modal-content {
    /* Reduce max height to account for browser chrome */
    max-height: calc(
      85dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)
    ) !important;
    margin-bottom: env(safe-area-inset-bottom, 0px);
  }

  /* Ensure scrollable content doesn't get cut off */
  .modal-content .overflow-y-auto {
    padding-bottom: calc(1.5rem + env(safe-area-inset-bottom, 0px));
  }
}

/* Login modal background image */
#js-login-modal {
  background-image: linear-gradient(
      rgba(0, 0, 0, 0.25),
      rgba(0, 0, 0, 0.45)
    ),
    url("/Picture/loginpixel.jpg");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

#js-login-modal .modal-content {
  position: relative;
  z-index: 1;
}

/* Fix for iOS Safari dynamic toolbar */
@supports (-webkit-touch-callout: none) {
  body {
    min-height: -webkit-fill-available;
  }

  .modal {
    min-height: -webkit-fill-available;
  }
}

/* iOS/Chrome: use small viewport height to avoid toolbar overlap */
@supports (height: 100svh) {
  html,
  body {
    height: 100svh;
    min-height: 100svh;
  }

  .modal,
  .modal-overlay {
    height: 100svh;
  }

  @media (max-width: 640px) {
    .modal-content {
      max-height: calc(
        85svh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)
      ) !important;
    }

    #js-onboarding-modal .modal-content {
      height: 100svh !important;
      max-height: 100svh !important;
    }
  }
}

/* Chrome/Android browser fix */
@supports (height: 100dvh) {
  body {
    height: 100dvh;
  }

  .modal {
    height: 100dvh;
  }
}

/* Onboarding shortcut button colors */
#js-onboarding-open-tasks {
  background: linear-gradient(to right, #1976d2, #1565c0);
}

#js-onboarding-open-tasks:hover {
  background: linear-gradient(to right, #1565c0, #0d47a1);
}

#js-onboarding-open-settings {
  background: linear-gradient(to right, #757575, #616161);
}

#js-onboarding-open-settings:hover {
  background: linear-gradient(to right, #616161, #424242);
}

#js-onboarding-open-music {
  background: linear-gradient(to right, #9c27b0, #7b1fa2);
}

#js-onboarding-open-music:hover {
  background: linear-gradient(to right, #7b1fa2, #4a148c);
}

#js-onboarding-open-video {
  background: linear-gradient(to right, #f44336, #d32f2f);
}

#js-onboarding-open-video:hover {
  background: linear-gradient(to right, #d32f2f, #b71c1c);
}
