:root {
    --primary: #4F46E5;
    --primary-dark: #4338CA;
    --secondary: #EC4899;
    --secondary-dark: #DB2777;
    --background: #F9FAFB;
    --surface: #FFFFFF;
    --text: #111827;
    --text-secondary: #6B7280;
    --shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.1);
    --border: #E5E7EB;
}

:root[data-theme="dark"] {
    --primary: #818CF8;
    --primary-dark: #6366F1;
    --secondary: #F472B6;
    --secondary-dark: #EC4899;
    --background: #111827;
    --surface: #1F2937;
    --text: #F9FAFB;
    --text-secondary: #D1D5DB;
    --shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.3);
    --border: #374151;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    height: 100vh;
    margin: 0;
    padding: 0;
    background-color: var(--background);
    color: var(--text);
    transition: background-color 0.3s ease;
    box-sizing: border-box;
    overflow: hidden;
}

.container {
    position: relative;
    text-align: center;
    background-color: var(--surface);
    padding: 2.5rem;
    border-radius: 24px;
    box-shadow: var(--shadow);
    max-width: 420px;
    width: 100%;
    margin: 1rem auto;
    border: 1px solid var(--border);
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
}

h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 2rem;
    color: var(--text);
}

.timer {
    font-size: 6rem;
    font-weight: 800;
    margin: 2rem 0;
    color: var(--primary);
    font-feature-settings: "tnum";
    font-variant-numeric: tabular-nums;
    letter-spacing: -2px;
    line-height: 1;
}

.streak-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 2rem;
    padding: 0.75rem 1.5rem;
    background: var(--background);
    border-radius: 12px;
    border: 1px solid var(--border);
}

.streak-count {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

#streak-number {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

.streak-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.streak-flame {
    font-size: 1.5rem;
    animation: flame-pulse 2s ease-in-out infinite;
}

@keyframes flame-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.controls {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 2rem;
}

.secondary-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.controls button {
    font-size: 1rem;
    padding: 1rem 1.5rem;
    cursor: pointer;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    transition: all 0.2s ease;
    backdrop-filter: blur(5px);
}

#timer-toggle {
    background-color: var(--primary);
    color: white;
    font-size: 1.1rem;
    padding: 1.25rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#timer-toggle:hover {
    background-color: var(--primary-dark);
    transform: translateY(-1px);
}

#reset {
    background-color: var(--surface);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    font-size: 0.95rem;
}

#reset:hover {
    background-color: var(--background);
    color: var(--text);
}

#mode-toggle {
    background-color: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
}

#mode-toggle:hover {
    background-color: var(--background);
}

.status {
    margin: 1.5rem 0;
    padding: 0.75rem;
    border-radius: 12px;
    background-color: var(--background);
}

#status-text {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin: 0;
    font-weight: 500;
}

.theme-toggle {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 50%;
    cursor: pointer;
    color: var(--text);
    padding: 0.75rem;
    font-size: 1.25rem;
    transition: all 0.2s ease;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-toggle:hover {
    transform: scale(1.1) rotate(8deg);
    background-color: var(--background);
}

@media (max-width: 480px) {
    .container {
        padding: 2rem;
        border-radius: 20px;
    }
    
    .timer {
        font-size: 4rem;
    }
}

/* Mobile Optimizations */
@media (max-width: 428px) { /* iPhone 15 width */
  .container {
    padding: 2rem;
    border-radius: 16px;
    width: min(85%, calc(100% - 3rem));
    margin: 1rem auto;
    height: auto;
    min-height: unset;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 1.5rem;
    position: relative;
    top: unset;
    left: unset;
    transform: none;
    max-width: 380px;
  }

  body {
    padding: env(safe-area-inset-top) max(1rem, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(1rem, env(safe-area-inset-left));
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .timer {
    font-size: 3.5rem;
    margin: 0.5rem 0;
  }

  h1 {
    font-size: 1.5rem;
    margin-bottom: 0.75rem;
  }

  .status {
    margin: 0.5rem 0;
    padding: 0.5rem;
  }

  #status-text {
    font-size: 0.9rem;
  }

  .controls {
    gap: 0.5rem;
    margin-top: 0;
    padding-top: 0;
  }

  .secondary-controls {
    gap: 0.5rem;
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .controls button {
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
  }

  #timer-toggle {
    padding: 0.875rem;
    font-size: 1rem;
  }

  .theme-toggle {
    position: absolute;
    top: max(0.75rem, env(safe-area-inset-top));
    right: max(0.75rem, env(safe-area-inset-right));
    width: 32px;
    height: 32px;
    padding: 0.4rem;
    font-size: 1rem;
    z-index: 10;
  }
}

/* Safe area insets for notched iPhones */
@supports (padding: max(0px)) {
  .container {
    padding-left: max(1.5rem, env(safe-area-inset-left));
    padding-right: max(1.5rem, env(safe-area-inset-right));
    padding-top: max(1.5rem, env(safe-area-inset-top));
    padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
  }
}

/* Prevent text size adjustment on orientation change */
html {
  -webkit-text-size-adjust: 100%;
}

/* Disable double-tap to zoom */
* {
  touch-action: manipulation;
}

.add-time-button {
    background-color: var(--surface);
    color: var(--primary);
    border: 1px solid var(--border);
    grid-column: span 2;
    font-size: 0.95rem;
    display: none; /* Hide by default */
}

.add-time-button:hover {
    background-color: var(--background);
    color: var(--primary-dark);
}

/* Update the secondary-controls grid for the new button */
.secondary-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.focus-modal {
    position: relative;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 2rem;
    background: var(--surface);
    color: var(--text);
    max-width: 400px;
    width: 90%;
    overflow: visible;
}

.focus-modal::backdrop {
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(3px);
}

.focus-modal h2 {
    margin-top: 0;
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    text-align: center;
}

.focus-modal input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--background);
    color: var(--text);
    font-size: 1rem;
    margin-bottom: 1.5rem;
    box-sizing: border-box;
}

.sound-prompt {
    background: none;
    border: none;
    color: var(--text);
    font-size: 0.9rem;
    padding: 0.75rem 0;
    margin: 0;
    cursor: pointer;
    width: 100%;
    text-align: left;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: color 0.2s ease;
}

.sound-prompt:hover {
    color: var(--primary);
}

.sound-prompt::after {
    content: '';
    width: 6px;
    height: 6px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg);
    transition: transform 0.2s ease;
    margin-right: 6px;
}

.sound-prompt.active::after {
    transform: rotate(-135deg);
    margin-top: 4px;
}

.sound-selection {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: all 0.3s ease-out;
}

.sound-selection.active {
    max-height: 500px;
    opacity: 1;
    margin: 1rem 0;
}

.sound-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin: 1.5rem 0;
}

.sound-option {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--surface);
    z-index: 1;
}

.sound-option:hover {
    border-color: var(--primary);
    transform: translateY(-1px);
    z-index: 2;
}

.sound-option .tooltip {
    position: absolute;
    top: auto;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 0.75rem;
    border-radius: 8px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    width: max-content;
    max-width: 200px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    pointer-events: none;
    margin-bottom: 10px;
}

.sound-option:hover .tooltip {
    opacity: 1;
    visibility: visible;
}

.sound-option input[type="radio"] {
    display: none;
}

.sound-option span {
    color: var(--text);
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sound-option:has(input[type="radio"]:checked) {
    background: var(--background);
    border-color: var(--primary);
    box-shadow: 0 0 0 1px var(--primary);
}

.sound-option input[type="radio"]:checked + span {
    color: var(--primary);
    font-weight: 500;
}

.focus-modal form {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.focus-modal form button {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
}

.focus-modal form button:hover {
    background: var(--primary-dark);
}

.current-focus {
    font-size: 1.1rem;
    color: var(--primary);
    font-weight: 500;
    margin-top: 0.5rem;
}

.focus-modal .modal-buttons {
    display: flex;
    gap: 1rem;
}

.focus-modal .modal-buttons button {
    flex: 1;
}

.focus-modal .cancel-button {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
}

.focus-modal .cancel-button:hover {
    background: var(--background);
}

.close-modal {
    position: absolute;
    top: -10px;
    right: -10px;
    background: #ff4444;
    color: white;
    border: none;
    width: 26px;
    height: 26px;
    min-width: 26px;
    max-width: 26px;
    font-size: 18px;
    font-weight: 300;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    z-index: 2;
    transition: all 0.2s ease;
    font-family: 'Inter', sans-serif;
    line-height: 0;
    transform: rotate(45deg);
}

.close-modal::before {
    content: '+';
    position: relative;
    top: -1px;
}

.close-modal:hover {
    background: #ff2222;
    transform: rotate(45deg) scale(1.1);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.2);
}

/* Mobile Optimizations for Modal */
@media (max-width: 428px) {
    .focus-modal {
        width: calc(100% - 2rem);
        max-width: none;
        margin: 0;
        padding: 1.5rem;
        border-radius: 16px;
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        box-sizing: border-box;
    }

    .focus-modal h2 {
        font-size: 1.25rem;
        margin-bottom: 1rem;
    }

    .focus-modal input {
        width: 100%;
        box-sizing: border-box;
        padding: 0.875rem;
        font-size: 1rem;
        margin-bottom: 1rem;
    }

    .focus-modal form button {
        padding: 0.875rem;
        font-size: 1rem;
        width: 100%;
        box-sizing: border-box;
    }

    .sound-options {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
    
    .sound-option {
        padding: 0.625rem;
    }
    
    .sound-prompt {
        font-size: 0.9rem;
        margin-bottom: 0.75rem;
    }
}

/* Ensure these styles are maintained on mobile */
@media (max-width: 428px) {
    .close-modal {
        width: 26px !important;
        height: 26px !important;
        min-width: 26px !important;
        max-width: 26px !important;
        padding: 0 !important;
        border-radius: 50% !important;
        top: -10px !important;
        right: -10px !important;
    }
}

.sound-control-toggle {
    display: none;  /* Hidden by default */
    position: absolute;
    top: 1.5rem;
    right: 4.75rem;  /* Adjusted from 5.5rem to 4.75rem for better spacing */
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 50%;
    cursor: pointer;
    color: var(--text);
    padding: 0.75rem;
    font-size: 1.25rem;
    transition: all 0.2s ease;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
}

.sound-control-toggle:hover {
    transform: scale(1.1);
    background-color: var(--background);
}

.sound-control-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    z-index: 1000;
    width: min(90%, 320px);
    box-shadow: var(--shadow);
    margin: 0;
    box-sizing: border-box;
    overflow: hidden;
}

.sound-control-panel::backdrop {
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(3px);
}

.sound-control-content {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    width: 100%;
}

.sound-control-content h3 {
    margin: 0;
    text-align: center;
    font-size: 1.25rem;
    color: var(--text);
}

.volume-control {
    margin-bottom: 1rem;
}

.volume-control label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.volume-control input[type="range"] {
    width: 100%;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    appearance: none;
    outline: none;
}

.volume-control input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 16px;
    height: 16px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
}

.volume-control input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

.sound-control-panel .sound-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-top: 1rem;
    width: 100%;
}

.sound-control-panel .sound-option {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--surface);
}

.sound-control-panel .sound-option:hover {
    border-color: var(--primary);
    transform: translateY(-1px);
}

.sound-control-panel .sound-option .tooltip {
    position: absolute;
    bottom: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 0.75rem;
    border-radius: 8px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    width: max-content;
    max-width: 200px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 100;
    text-align: center;
    line-height: 1.4;
}

.sound-control-panel .sound-option:hover .tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(-5px);
}

/* Mobile adjustments */
@media (max-width: 428px) {
    .sound-control-panel {
        width: min(calc(100% - 2rem), 320px);
        padding: 1.25rem;
        margin: 0;
    }
    
    .sound-control-panel .sound-options {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
}

/* Convert the panel to use dialog element */
dialog.sound-control-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    z-index: 1000;
    width: 90%;
    max-width: 320px;
    box-shadow: var(--shadow);
    margin: 0;
}

dialog.sound-control-panel::backdrop {
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(3px);
}

.sound-selection {
    margin-top: 1rem;
    margin-bottom: 1.5rem;
}

.background-sounds-toggle {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.9rem;
    padding: 0;
    margin: 1rem 0;
    cursor: pointer;
    width: 100%;
    text-align: left;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: color 0.2s ease;
}

.background-sounds-toggle:hover {
    color: var(--text);
}

.background-sounds-toggle::after {
    content: '';
    width: 8px;
    height: 8px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg);
    transition: transform 0.2s ease;
    margin-left: 8px;
}

.background-sounds-toggle.active::after {
    transform: rotate(-135deg);
}

.sound-selection {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: all 0.3s ease-out;
}

.sound-selection.active {
    max-height: 500px;
    opacity: 1;
    margin: 1rem 0;
}

.sound-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.sound-option {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--surface);
}

.sound-option:hover {
    border-color: var(--primary);
    transform: translateY(-1px);
}

.sound-option .tooltip {
    position: absolute;
    bottom: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 0.75rem;
    border-radius: 8px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    width: max-content;
    max-width: 200px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 100;
    text-align: center;
    line-height: 1.4;
}

.sound-option .tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-width: 6px;
    border-style: solid;
    border-color: var(--surface) transparent transparent transparent;
}

.sound-option:hover .tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(-5px);
}

.sound-option input[type="radio"] {
    display: none;
}

.sound-option span {
    color: var(--text);
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sound-option:has(input[type="radio"]:checked) {
    background: var(--background);
    border-color: var(--primary);
    box-shadow: 0 0 0 1px var(--primary);
}

.sound-option input[type="radio"]:checked + span {
    color: var(--primary);
    font-weight: 500;
}

.focus-modal form {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.focus-modal form button {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
}

.focus-modal form button:hover {
    background: var(--primary-dark);
}

.current-focus {
    font-size: 1.1rem;
    color: var(--primary);
    font-weight: 500;
    margin-top: 0.5rem;
}

.focus-modal .modal-buttons {
    display: flex;
    gap: 1rem;
}

.focus-modal .modal-buttons button {
    flex: 1;
}

.focus-modal .cancel-button {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
}

.focus-modal .cancel-button:hover {
    background: var(--background);
}

.close-modal {
    position: absolute;
    top: -10px;
    right: -10px;
    background: #ff4444;
    color: white;
    border: none;
    width: 26px;
    height: 26px;
    min-width: 26px;
    max-width: 26px;
    font-size: 18px;
    font-weight: 300;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    z-index: 2;
    transition: all 0.2s ease;
    font-family: 'Inter', sans-serif;
    line-height: 0;
    transform: rotate(45deg);
}

.close-modal::before {
    content: '+';
    position: relative;
    top: -1px;
}

.close-modal:hover {
    background: #ff2222;
    transform: rotate(45deg) scale(1.1);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.2);
}

/* Mobile Optimizations for Modal */
@media (max-width: 428px) {
    .focus-modal {
        width: calc(100% - 2rem);
        max-width: none;
        margin: 0;
        padding: 1.5rem;
        border-radius: 16px;
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        box-sizing: border-box;
    }

    .focus-modal h2 {
        font-size: 1.25rem;
        margin-bottom: 1rem;
    }

    .focus-modal input {
        width: 100%;
        box-sizing: border-box;
        padding: 0.875rem;
        font-size: 1rem;
        margin-bottom: 1rem;
    }

    .focus-modal form button {
        padding: 0.875rem;
        font-size: 1rem;
        width: 100%;
        box-sizing: border-box;
    }

    .sound-options {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
    
    .sound-option {
        padding: 0.625rem;
    }
    
    .sound-prompt {
        font-size: 0.9rem;
        margin-bottom: 0.75rem;
    }
}

/* Ensure these styles are maintained on mobile */
@media (max-width: 428px) {
    .close-modal {
        width: 26px !important;
        height: 26px !important;
        min-width: 26px !important;
        max-width: 26px !important;
        padding: 0 !important;
        border-radius: 50% !important;
        top: -10px !important;
        right: -10px !important;
    }
} 