/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

/* Safari-specific styles for better viewport handling */
html {
    /* Prevent zoom on double tap */
    touch-action: manipulation;
    /* Better font rendering on Safari */
    -webkit-text-size-adjust: 100%;
    /* Support for viewport-fit */
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #0f0f23 0%, #1a1a2e 50%, #16213e 100%);
    min-height: 100vh;
    /* Use 100svh for better Safari mobile viewport handling */
    min-height: 100svh;
    overflow-x: hidden;
    overflow-y: auto;
    position: relative;
    /* Better handling of overscroll behavior on Safari */
    overscroll-behavior: none;
    /* Prevent rubber band scrolling */
    -webkit-overflow-scrolling: touch;
}

/* Animated Background */
.bg-animation {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    background: linear-gradient(135deg, #0f0f23 0%, #1a1a2e 30%, #16213e 70%, #0e1538 100%);
    background-size: 400% 400%;
    animation: gradient 15s ease infinite;
}

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

/* Layout */
.container {
    max-width: 390px;
    margin: 0 auto;
    padding: 15px;
    height: 100vh;
    /* Use dynamic viewport units for better Safari support */
    height: 100dvh;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    overflow-y: auto;
    box-sizing: border-box;
    /* Hide scrollbar for webkit browsers */
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* Internet Explorer 10+ */
    /* Respect safe areas on devices with notches */
    padding-top: max(15px, env(safe-area-inset-top));
    padding-bottom: 0; /* Footer handles bottom spacing */
    padding-left: max(15px, env(safe-area-inset-left));
    padding-right: max(15px, env(safe-area-inset-right));
}

.container::-webkit-scrollbar {
    width: 0;
    height: 0;
    display: none;
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 25px;
    animation: fadeInUp 1s ease-out;
    flex-shrink: 0;
}

.header h1 {
    font-size: 2.5rem;
    font-weight: 900;
    background: linear-gradient(45deg, #e2e8f0, #cbd5e1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 10px;
    text-shadow: 0 2px 20px rgba(226,232,240,0.3);
}

.header p {
    color: rgba(255,255,255,0.8);
    font-size: 1.1rem;
    font-weight: 300;
}

/* Steps */
.step {
    background: rgba(255,255,255,0.03);
    backdrop-filter: blur(20px);
    border-radius: 25px;
    padding: 25px;
    margin-bottom: 20px;
    border: 1px solid rgba(255,255,255,0.08);
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
    transition: all 0.3s ease;
    animation: fadeInUp 1s ease-out;
    animation-fill-mode: both;
    flex-shrink: 0;
}

.step.hidden {
    display: none !important;
}

.step-title {
    font-size: 1.3rem;
    font-weight: 700;
    color: white;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Apparatus Grid */
.apparatus-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-top: 20px;
}

.apparatus-grid.single-apparatus {
    grid-template-columns: 1fr;
    justify-items: center;
    max-width: 300px;
    margin: 20px auto 0;
}

.apparatus-item {
    background: rgba(255,255,255,0.02);
    border: 2px solid rgba(255,255,255,0.08);
    border-radius: 20px;
    padding: 20px;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
    user-select: none;
    position: relative;
    overflow: hidden;
    min-height: 80px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.apparatus-item:active {
    transform: scale(0.95);
}

.apparatus-item.selected {
    background: rgba(59,130,246,0.15);
    border-color: #3b82f6;
    box-shadow: 0 0 25px rgba(59,130,246,0.4);
    transform: scale(1.05);
}

.apparatus-item::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, transparent, rgba(255,255,255,0.1), transparent);
    transform: rotate(45deg);
    transition: all 0.6s ease;
    opacity: 0;
}

.apparatus-item:hover::before {
    animation: shine 0.6s ease-in-out;
}

@keyframes shine {
    0% { transform: translateX(-100%) translateY(-100%) rotate(45deg); opacity: 0; }
    50% { opacity: 1; }
    100% { transform: translateX(100%) translateY(100%) rotate(45deg); opacity: 0; }
}

.apparatus-name {
    font-weight: 600;
    color: white;
    font-size: 0.95rem;
    margin-bottom: 5px;
}

.apparatus-count {
    color: rgba(255,255,255,0.7);
    font-size: 0.8rem;
}

/* Count Selector */
.count-selector {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 20px;
}

.count-label {
    color: rgba(255,255,255,0.9);
    font-weight: 500;
}

.count-controls {
    display: flex;
    align-items: center;
    gap: 20px;
}

.count-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.3);
    background: rgba(255,255,255,0.1);
    color: white;
    font-size: 1.5rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.count-btn:active {
    transform: scale(0.9);
    background: rgba(255,255,255,0.2);
}

.count-btn:hover {
    background: rgba(255,255,255,0.15);
    border-color: rgba(255,255,255,0.5);
}

.count-display {
    font-size: 2rem;
    font-weight: bold;
    color: white;
    min-width: 40px;
    text-align: center;
}

/* Buttons */
.generate-btn {
    width: 100%;
    height: 60px;
    border-radius: 30px;
    border: none;
    background: linear-gradient(45deg, #3b82f6, #6366f1);
    color: white;
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 8px 25px rgba(59,130,246,0.3);
    position: relative;
    overflow: hidden;
}

.generate-btn:active {
    transform: translateY(2px);
    box-shadow: 0 4px 15px rgba(59,130,246,0.4);
}

.generate-btn:hover {
    box-shadow: 0 12px 35px rgba(59,130,246,0.4);
    transform: translateY(-2px);
}

.generate-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.regenerate-btn {
    width: 100%;
    height: 50px;
    border-radius: 25px;
    border: 2px solid rgba(255,255,255,0.3);
    background: rgba(255,255,255,0.1);
    color: white;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 20px;
    margin-bottom: 20px; /* Extra bottom margin for Safari */
}

.regenerate-btn:active {
    transform: scale(0.98);
    background: rgba(255,255,255,0.2);
}

.regenerate-btn:hover {
    background: rgba(255,255,255,0.15);
    border-color: rgba(255,255,255,0.5);
}

/* New UI Components */
.next-btn {
    width: 100%;
    height: 60px;
    border-radius: 30px;
    border: none;
    background: linear-gradient(45deg, #1e40af, #1d4ed8);
    color: white;
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 8px 25px rgba(30,64,175,0.3);
    position: relative;
    overflow: hidden;
}

.next-btn:hover {
    box-shadow: 0 12px 35px rgba(16,185,129,0.4);
    transform: translateY(-2px);
}

.next-btn:active {
    transform: translateY(2px);
    box-shadow: 0 4px 15px rgba(16,185,129,0.4);
}

.next-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    background: linear-gradient(45deg, #666, #888);
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}

.back-btn, .clear-moves-btn {
    background: rgba(255,255,255,0.2);
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 15px;
    padding: 12px 20px;
    color: white;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.back-btn:hover, .clear-moves-btn:hover:not(:disabled) {
    background: rgba(255,255,255,0.3);
    transform: translateY(-1px);
}

.back-btn:disabled, .clear-moves-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.step-actions {
    display: flex;
    gap: 15px;
    margin-top: 25px;
    margin-bottom: 25px; /* Minimal bottom margin */
    position: relative;
    z-index: 10; /* Ensure buttons are always above other content */
}

.step-actions .back-btn {
    flex: 0 0 auto;
}

.step-actions .generate-btn {
    flex: 1;
}

/* Safari-specific button improvements */
.generate-btn, .next-btn, .regenerate-btn, .back-btn, .clear-moves-btn, .preset-btn {
    -webkit-appearance: none;
    appearance: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    /* Better font rendering on Safari */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* Prevent zoom on focus for inputs */
    font-size: max(16px, 1rem);
}

/* Fix for Safari double-tap zoom issue */
.generate-btn, .next-btn {
    font-size: max(16px, 1.2rem);
}

.back-btn, .clear-moves-btn, .preset-btn {
    font-size: max(16px, 0.9rem);
}

.move-selection-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 15px;
    background: rgba(255,255,255,0.1);
    border-radius: 15px;
    backdrop-filter: blur(10px);
    gap: 15px;
}

.move-selection-info span {
    color: rgba(255,255,255,0.9);
    font-weight: 600;
    flex: 1;
}

.select-all-btn {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 12px;
    color: white;
    padding: 8px 16px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.select-all-btn:hover {
    background: rgba(255,255,255,0.15);
    border-color: rgba(255,255,255,0.3);
    transform: translateY(-1px);
}

.select-all-btn.active {
    background: rgba(59,130,246,0.2);
    border-color: rgba(59,130,246,0.4);
}

.moves-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.move-item {
    background: rgba(255,255,255,0.02);
    border: 2px solid rgba(255,255,255,0.08);
    border-radius: 15px;
    padding: 15px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    position: relative;
    min-height: 90px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.move-item:hover {
    background: rgba(255,255,255,0.05);
    border-color: rgba(255,255,255,0.2);
    transform: translateY(-2px);
}

.move-item.selected {
    background: linear-gradient(45deg, rgba(59,130,246,0.2), rgba(99,102,241,0.2));
    border-color: rgba(59,130,246,0.8);
    box-shadow: 0 0 20px rgba(59,130,246,0.3);
}

.move-name {
    color: white;
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 5px;
}

.move-variation {
    margin-top: 6px;
    color: rgba(255,255,255,0.85);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.3px;
    display: none;
}

.move-variation.visible {
    display: block;
}

/* Dimming removed intentionally */

.move-variation-selector {
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    padding: 8px 6px;
    z-index: 10000; /* above overlay */
    display: flex;
    flex-direction: row;
    gap: 4px;
    justify-content: center;
    align-items: center;
    pointer-events: auto;
}

/* Per-item dimming removed intentionally */

.move-variation-option {
    background: rgba(30,30,40,0.95);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 12px;
    color: rgba(255,255,255,0.9);
    padding: 6px 10px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    flex: 1;
    white-space: nowrap;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    max-width: 70px;
    overflow: hidden;
    text-overflow: ellipsis;
    position: relative;
    z-index: 10000;
    backdrop-filter: blur(8px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.move-variation-option:hover {
    background: rgba(255,255,255,0.2);
    border-color: rgba(255,255,255,0.4);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.move-variation-option[aria-checked="true"] {
    background: rgba(59,130,246,0.3);
    border-color: rgba(59,130,246,0.9);
    color: white;
    box-shadow: 0 0 15px rgba(59,130,246,0.3);
    transform: translateY(-1px);
}

.move-variation-option:hover {
    background: rgba(255,255,255,0.05);
    border-color: rgba(255,255,255,0.3);
    transform: translateY(-1px);
}

.move-variation-option[aria-checked="true"]:hover {
    background: rgba(59,130,246,0.2);
    border-color: rgba(59,130,246,0.9);
}





/* Difficulty Preset Selector */
.difficulty-preset-selector {
    margin-bottom: 25px;
    padding: 20px;
    background: rgba(255,255,255,0.1);
    border-radius: 15px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.2);
}

.preset-title {
    color: rgba(255,255,255,0.9);
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 15px;
    text-align: center;
}

.preset-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

.preset-btn {
    background: rgba(255,255,255,0.02);
    border: 2px solid rgba(255,255,255,0.08);
    border-radius: 12px;
    padding: 10px 16px;
    color: white;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    min-width: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.preset-btn:hover {
    background: rgba(255,255,255,0.05);
    border-color: rgba(255,255,255,0.2);
    transform: translateY(-2px);
}

.preset-btn:active {
    transform: translateY(0);
}

.preset-btn.beginner {
    border-color: rgba(74, 222, 128, 0.5);
}

.preset-btn.beginner:hover {
    border-color: rgba(74, 222, 128, 0.8);
    background: rgba(74, 222, 128, 0.2);
}

.preset-btn.intermediate {
    border-color: rgba(251, 191, 36, 0.5);
}

.preset-btn.intermediate:hover {
    border-color: rgba(251, 191, 36, 0.8);
    background: rgba(251, 191, 36, 0.2);
}

.preset-btn.advanced {
    border-color: rgba(249, 115, 22, 0.5);
}

.preset-btn.advanced:hover {
    border-color: rgba(249, 115, 22, 0.8);
    background: rgba(249, 115, 22, 0.2);
}

.preset-btn.expert {
    border-color: rgba(239, 68, 68, 0.5);
}

.preset-btn.expert:hover {
    border-color: rgba(239, 68, 68, 0.8);
    background: rgba(239, 68, 68, 0.2);
}

.preset-btn.all {
    border-color: rgba(0, 245, 255, 0.5);
}

.preset-btn.all:hover {
    border-color: rgba(0, 245, 255, 0.8);
    background: rgba(0, 245, 255, 0.2);
}

.preset-btn.selected {
    background: linear-gradient(45deg, rgba(0,245,255,0.3), rgba(255,0,110,0.3));
    border-color: rgba(0,245,255,0.8);
    box-shadow: 0 0 15px rgba(0,245,255,0.3);
}

@media (max-width: 768px) {
    .preset-buttons {
        flex-direction: column;
        align-items: stretch;
    }
    
    .preset-btn {
        min-width: auto;
        width: 100%;
    }
}

.move-limits {
    background: rgba(255,255,255,0.05);
    border-radius: 15px;
    padding: 15px;
    margin: 20px 0;
}

/* Show/hide controls based on move type */
.reps-control, .hold-control {
    display: none;
}

/* Show both controls for static moves */
[data-move-type="static"] .reps-control,
[data-move-type="static"] .hold-control {
    display: block;
}

/* Show only reps control for reps mode */
[data-move-type="reps"] .reps-control {
    display: block;
}

/* Dynamic moves don't show any controls */
[data-move-type="dynamic"] .reps-control,
[data-move-type="dynamic"] .hold-control {
    display: none;
}

.limit-section {
    padding: 15px;
    background: rgba(255,255,255,0.05);
    border-radius: 15px;
    border: 1px solid rgba(255,255,255,0.1);
}

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

.limit-label {
    color: rgba(255,255,255,0.9);
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.limit-values {
    display: flex;
    align-items: center;
    gap: 8px;
}

.limit-separator {
    color: rgba(255,255,255,0.5);
    font-weight: 500;
}

.limit-value {
    color: white;
    font-size: 0.9rem;
    font-weight: 600;
    min-width: 25px;
    text-align: center;
}

.limit-control {
    padding: 0 5px;
}

.double-slider-container {
    position: relative;
    flex: 1;
    height: 30px;
    margin: 0 10px;
}

.limit-slider {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
    height: 2px;
    background: transparent;
    outline: none;
    pointer-events: none;
}

.limit-slider.min {
    z-index: 2;
}

.limit-slider.max {
    z-index: 3;
}

.slider-track {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    height: 2px;
    width: 100%;
    --start: 0%;
    --end: 100%;
    background: linear-gradient(90deg, 
        rgba(255,255,255,0.2) var(--start),
        #3b82f6 var(--start),
        #3b82f6 var(--end),
        rgba(255,255,255,0.2) var(--end)
    );
}

.limit-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #3b82f6;
    border: 2px solid rgba(255,255,255,0.9);
    cursor: pointer;
    transition: all 0.2s;
    pointer-events: auto;
}

.limit-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #3b82f6;
    border: 2px solid rgba(255,255,255,0.9);
    cursor: pointer;
    transition: all 0.2s;
    pointer-events: auto;
}

.limit-slider:hover::-webkit-slider-thumb {
    transform: scale(1.2);
    box-shadow: 0 0 15px rgba(59,130,246,0.4);
}

.limit-slider:hover::-moz-range-thumb {
    transform: scale(1.2);
    box-shadow: 0 0 15px rgba(59,130,246,0.4);
}

.limit-slider.min::-webkit-slider-thumb {
    background: linear-gradient(135deg, #3b82f6, #6366f1);
}

.limit-slider.max::-webkit-slider-thumb {
    background: linear-gradient(135deg, #6366f1, #3b82f6);
}

.limit-slider.min::-moz-range-thumb {
    background: linear-gradient(135deg, #3b82f6, #6366f1);
}

.limit-slider.max::-moz-range-thumb {
    background: linear-gradient(135deg, #6366f1, #3b82f6);
}

.limit-value {
    color: white;
    font-size: 0.9rem;
    font-weight: 600;
    min-width: 35px;
    text-align: right;
}

.move-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.selection-summary {
    display: flex;
    align-items: center;
    gap: 15px;
}

.selection-summary span {
    color: rgba(255,255,255,0.9);
    font-weight: 600;
}

.combo-settings {
    margin-bottom: 25px;
}

.generation-summary {
    margin-top: 15px;
    padding: 15px;
    background: rgba(255,255,255,0.1);
    border-radius: 15px;
    backdrop-filter: blur(10px);
}

.generation-summary span {
    color: rgba(255,255,255,0.9);
    font-size: 0.9rem;
    line-height: 1.4;
}

/* Combo Results */
.combo-result {
    background: linear-gradient(135deg, rgba(0,245,255,0.2), rgba(255,0,110,0.2));
    backdrop-filter: blur(20px);
    border-radius: 25px;
    padding: 30px;
    border: 1px solid rgba(255,255,255,0.3);
    animation: slideInUp 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    margin-top: 25px;
    margin-bottom: 40px; /* Extra bottom margin for Safari scrolling */
}

.combo-title {
    text-align: center;
    font-size: 1.5rem;
    font-weight: bold;
    color: white;
    margin-bottom: 25px;
}

.combo-apparatus {
    text-align: center;
    margin-bottom: 20px;
    padding: 15px;
    background: rgba(255,255,255,0.1);
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.2);
}

.apparatus-label {
    color: rgba(255,255,255,0.8);
    font-size: 0.9rem;
    font-weight: 500;
    display: block;
    margin-bottom: 5px;
}

.apparatus-list {
    color: #00f5ff;
    font-size: 1.1rem;
    font-weight: 600;
    text-shadow: 0 0 10px rgba(0,245,255,0.3);
}

.combo-list {
    list-style: none;
}

.combo-item {
    background: rgba(255,255,255,0.15);
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 15px;
    animation: slideInRight 0.6s ease-out;
    animation-fill-mode: both;
    transition: all 0.3s ease;
}

.combo-item:hover {
    background: rgba(255,255,255,0.2);
    transform: translateX(5px);
}

.combo-item:nth-child(1) { animation-delay: 0.1s; }
.combo-item:nth-child(2) { animation-delay: 0.2s; }
.combo-item:nth-child(3) { animation-delay: 0.3s; }
.combo-item:nth-child(4) { animation-delay: 0.4s; }
.combo-item:nth-child(5) { animation-delay: 0.5s; }

.combo-number {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    background: linear-gradient(45deg, #00f5ff, #ff006e);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    flex-shrink: 0;
}

.combo-move {
    color: white;
    font-size: 1.1rem;
    font-weight: 500;
    flex: 1;
}

.combo-value {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 4px;
    min-width: 140px;
}

.combo-value-display {
    color: rgba(255,255,255,0.9);
    font-size: 0.9rem;
    font-weight: 600;
    min-width: 60px;
    text-align: right;
}

.combo-value-slider {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 2px;
    background: rgba(255,255,255,0.2);
    outline: none;
    opacity: 0.9;
    transition: all 0.2s;
}

.combo-value-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #3b82f6;
    border: 2px solid rgba(255,255,255,0.9);
    cursor: pointer;
    transition: all 0.2s;
}

.combo-value-slider::-moz-range-thumb {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #3b82f6;
    border: 2px solid rgba(255,255,255,0.9);
    cursor: pointer;
    transition: all 0.2s;
}

.combo-value-slider:hover {
    opacity: 1;
}

.combo-value-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 0 10px rgba(59,130,246,0.4);
}

.combo-value-slider::-moz-range-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 0 10px rgba(59,130,246,0.4);
}

/* Loading State */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Utility Classes */
.hidden {
    display: none;
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Responsive Design */
@media (max-width: 480px) {
    .container {
        padding: 12px;
        /* Better safe area handling for Safari on smaller screens */
        padding-top: max(12px, env(safe-area-inset-top));
        padding-bottom: max(12px, env(safe-area-inset-bottom)); /* Minimal for small screens */
        padding-left: max(12px, env(safe-area-inset-left));
        padding-right: max(12px, env(safe-area-inset-right));
    }
    
    .header {
        margin-bottom: 20px;
    }
    
    .header h1 {
        font-size: 2rem;
        margin-bottom: 8px;
    }
    
    .header p {
        font-size: 1rem;
    }
    
    .step {
        padding: 20px;
        margin-bottom: 15px;
        border-radius: 20px;
    }
    
    .apparatus-item {
        padding: 15px;
        min-height: 70px;
    }
    
    .count-controls {
        gap: 15px;
    }
    
    .count-btn {
        width: 45px;
        height: 45px;
        font-size: 1.3rem;
    }
    
    .combo-item {
        padding: 15px;
    }
    
    .combo-result {
        padding: 20px;
        margin-top: 15px;
    }
}

@media (max-width: 360px) {
    .container {
        padding: 10px;
        /* Even more bottom margin for very small screens */
        padding-bottom: max(10px, env(safe-area-inset-bottom)); /* Minimal for very small screens */
    }
    
    .header {
        margin-bottom: 15px;
    }
    
    .header h1 {
        font-size: 1.8rem;
    }
    
    .step {
        padding: 15px;
        margin-bottom: 12px;
    }
    
    .apparatus-grid {
        gap: 10px;
    }
    
    .apparatus-grid.single-apparatus {
        max-width: 280px;
    }
    
    .apparatus-item {
        padding: 12px;
        min-height: 65px;
    }
    
    .apparatus-name {
        font-size: 0.85rem;
    }
    
    .apparatus-count {
        font-size: 0.75rem;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .step {
        background: rgba(255,255,255,0.12);
    }
    
    .apparatus-item {
        background: rgba(255,255,255,0.08);
    }
    
    .combo-item {
        background: rgba(255,255,255,0.12);
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .step {
        border: 2px solid rgba(255,255,255,0.5);
    }
    
    .apparatus-item {
        border: 2px solid rgba(255,255,255,0.4);
    }
    
    .apparatus-item.selected {
        border-color: #ffffff;
        background: rgba(255,255,255,0.3);
    }
}

/* Safari-specific bottom margin improvements - minimal spacing */
@supports (-webkit-appearance: none) {
    .container {
        padding-bottom: max(15px, env(safe-area-inset-bottom)) !important;
    }
    
    .step-actions {
        margin-bottom: 25px !important;
    }
    
    .combo-result {
        margin-bottom: 25px !important;
    }
    
    .regenerate-btn {
        margin-bottom: 20px !important;
    }
}

/* iOS Safari specific fixes - minimal spacing */
@supports (-webkit-touch-callout: none) {
    .container {
        padding-bottom: max(15px, env(safe-area-inset-bottom)) !important;
    }
    
    .step-actions {
        margin-bottom: 25px !important;
    }
    
    .combo-result {
        margin-bottom: 25px !important;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .bg-animation {
        animation: none;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    }
}

/* Login Section Styles */
.login-section {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(20px);
    border-radius: 20px;
    padding: 30px;
    margin: 40px 20px 30px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.login-section.hidden {
    display: none;
}

.login-content {
    text-align: center;
}

.login-header h2 {
    color: #ffffff;
    font-size: 2.2rem;
    font-weight: 700;
    margin-bottom: 10px;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.login-header p {
    color: rgba(255, 255, 255, 0.9);
    font-size: 1.1rem;
    margin-bottom: 30px;
    line-height: 1.5;
}

.login-benefits {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 35px;
}

.benefit-item {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 15px 20px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: all 0.3s ease;
}

.benefit-item:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.benefit-icon {
    font-size: 1.5rem;
    margin-right: 15px;
    flex-shrink: 0;
}

.benefit-text {
    color: rgba(255, 255, 255, 0.9);
    font-weight: 500;
    font-size: 0.95rem;
}

.login-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.google-signin-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: #ffffff;
    color: #333333;
    border: none;
    border-radius: 50px;
    padding: 15px 30px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    min-width: 200px;
    position: relative;
    overflow: hidden;
}

.google-signin-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
    background: #f8f9fa;
}

.google-signin-btn:active {
    transform: translateY(0);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.google-signin-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.google-icon {
    flex-shrink: 0;
}

.login-privacy {
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.85rem;
    max-width: 300px;
    line-height: 1.4;
    margin: 0;
}

/* Loading state for Google sign-in */
.google-signin-btn.loading {
    opacity: 0.8;
    cursor: not-allowed;
}

.google-signin-btn.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
    animation: loading-shimmer 1.5s infinite;
}

@keyframes loading-shimmer {
    0% { left: -100%; }
    100% { left: 100%; }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* User Profile Section Styles */
.user-profile-section {
    background: rgba(76, 175, 80, 0.15);
    backdrop-filter: blur(20px);
    border-radius: 20px;
    padding: 25px 30px;
    margin: 40px 20px 30px;
    border: 1px solid rgba(76, 175, 80, 0.3);
    box-shadow: 0 8px 32px rgba(76, 175, 80, 0.1);
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.user-profile-section.hidden {
    display: none;
}

.user-profile-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
    flex: 1;
    min-width: 200px;
}

.user-avatar {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    overflow: hidden;
    background: linear-gradient(135deg, #4CAF50, #81C784);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px solid rgba(255, 255, 255, 0.3);
    cursor: pointer;
    transition: all 0.3s ease;
}

.user-avatar:hover .avatar-upload-overlay {
    opacity: 1;
}

.avatar-upload-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.avatar-upload-overlay span {
    color: white;
    font-size: 20px;
}

.user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-avatar span {
    color: white;
    font-weight: bold;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-details {
    flex: 1;
    text-align: left;
}

.user-name-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-details h3 {
    color: white;
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 4px;
    cursor: pointer;
}

.user-details h3:hover {
    text-decoration: underline;
    text-decoration-style: dotted;
}

.edit-name-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    padding: 4px;
    font-size: 14px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.edit-name-btn:hover {
    color: white;
    background: rgba(255, 255, 255, 0.1);
}

.name-edit-container {
    margin: 8px 0;
}

.name-edit-container.hidden {
    display: none;
}

.name-input {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    color: white;
    padding: 8px 12px;
    font-size: 16px;
    width: 100%;
    margin-bottom: 8px;
}

.name-input:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.4);
    background: rgba(255, 255, 255, 0.15);
}

.name-edit-actions {
    display: flex;
    gap: 8px;
}

.save-name-btn, .cancel-name-btn {
    padding: 6px 12px;
    border-radius: 6px;
    border: none;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.save-name-btn {
    background: #4CAF50;
    color: white;
}

.save-name-btn:hover {
    background: #43A047;
}

.cancel-name-btn {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.cancel-name-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.user-details p {
    color: rgba(255, 255, 255, 0.8);
    font-size: 14px;
    margin-bottom: 6px;
}

.user-status {
    background: rgba(76, 175, 80, 0.2);
    color: #4CAF50;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    border: 1px solid rgba(76, 175, 80, 0.3);
}

.user-actions {
    display: flex;
    gap: 10px;
}

.sign-out-btn {
    background: rgba(244, 67, 54, 0.15);
    color: #f44336;
    border: 1px solid rgba(244, 67, 54, 0.3);
    padding: 10px 20px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    backdrop-filter: blur(10px);
}

.sign-out-btn:hover {
    background: rgba(244, 67, 54, 0.25);
    border-color: rgba(244, 67, 54, 0.5);
    transform: translateY(-2px);
}

.sign-out-btn:active {
    transform: translateY(0);
}

/* Authentication Callback Handler Styles */
.callback-processing {
    text-align: center;
    color: white;
    padding: 40px;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

.callback-processing p {
    font-size: 16px;
    color: rgba(255, 255, 255, 0.9);
}

/* Responsive adjustments for login section */
@media (max-width: 768px) {
    .login-section {
        margin: 30px 15px 25px;
        padding: 25px 20px;
    }
    
    .user-profile-section {
        margin: 30px 15px 25px;
        padding: 20px;
    }
    
    .user-profile-content {
        flex-direction: column;
        text-align: center;
        gap: 15px;
    }
    
    .user-info {
        flex-direction: column;
        text-align: center;
        min-width: auto;
    }
    
    .user-details {
        text-align: center;
    }
    
    .user-actions {
        justify-content: center;
    }
    
    .login-header h2 {
        font-size: 1.8rem;
    }
    
    .login-header p {
        font-size: 1rem;
    }
    
    .login-benefits {
        grid-template-columns: 1fr;
        gap: 15px;
        margin-bottom: 30px;
    }
    
    .benefit-item {
        padding: 12px 15px;
    }
    
    .benefit-text {
        font-size: 0.9rem;
    }
    
    .google-signin-btn {
        padding: 12px 25px;
        font-size: 0.95rem;
        min-width: 180px;
    }
}

@media (max-width: 480px) {
    .login-section {
        margin: 25px 10px 20px;
        padding: 20px 15px;
    }
    
    .user-profile-section {
        margin: 25px 10px 20px;
        padding: 15px;
    }
    
    .user-avatar {
        width: 50px;
        height: 50px;
    }
    
    .user-avatar span {
        font-size: 18px;
    }
    
    .user-details h3 {
        font-size: 16px;
    }
    
    .user-details p {
        font-size: 13px;
    }
    
    .sign-out-btn {
        padding: 8px 16px;
        font-size: 13px;
    }
    
    .login-header h2 {
        font-size: 1.6rem;
    }
    
    .benefit-item {
        flex-direction: column;
        text-align: center;
        gap: 8px;
        padding: 15px;
    }
    
    .benefit-icon {
        margin-right: 0;
        margin-bottom: 5px;
    }
}

/* Tab Content Styles */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Navigation Section Styles */
.navigation-section {
    margin-top: 30px;
    margin-bottom: 30px;
    padding: 0 15px;
}

.nav-content {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 20px;
    padding: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
}

.nav-buttons {
    display: flex;
    justify-content: center;
    gap: 30px;
    align-items: center;
}

.nav-button {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.9);
    cursor: pointer;
    padding: 15px 25px;
    border-radius: 15px;
    transition: all 0.3s ease;
    min-width: 120px;
}

.nav-button:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.nav-button:active {
    transform: translateY(0);
}

.nav-icon {
    font-size: 1.8rem;
    line-height: 1;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.nav-label {
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 0.5px;
}

/* Responsive adjustments */
@media (max-width: 480px) {
    .navigation-section {
        margin-top: 20px;
        margin-bottom: 20px;
        padding: 0 10px;
    }

    .nav-content {
        padding: 15px;
    }

    .nav-buttons {
        gap: 15px;
    }

    .nav-button {
        padding: 12px 20px;
        min-width: 100px;
    }

    .nav-icon {
        font-size: 1.5rem;
    }

    .nav-label {
        font-size: 0.8rem;
    }
}
