/* Cross-browser fixes */
* {
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
}

/* Firefox button fixes */
button::-moz-focus-inner {
    border: 0;
    padding: 0;
}

/* Safari input fixes */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type="number"] {
    -moz-appearance: textfield;
}

/* Better touch targets for all platforms */
@media (pointer: coarse) {
    .btn, .key-btn, .btn-icon {
        min-height: 48px !important;
        min-width: 48px !important;
    }
}

/* Windows high contrast mode support */
@media (prefers-contrast: high) {
    .card {
        border: 2px solid;
    }
    
    .btn {
        border: 2px solid;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Better focus indicators for keyboard users */
.btn:focus-visible,
.key-btn:focus-visible,
input:focus-visible {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* iOS-specific fixes */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

/* Prevent double-tap zoom and touch behaviors on keypad */
.keypad {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    touch-action: manipulation; /* Prevents double-tap zoom */
}

.key-btn {
    /* Prevent double-tap zoom with CSS only */
    touch-action: manipulation;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    
    /* Immediate visual feedback */
    transition: transform 0.05s ease, background-color 0.05s ease;
}

.key-btn:active {
    transform: scale(0.95);
    opacity: 0.8;
}

/* Additional prevention for all interactive elements */
button, input, select {
    touch-action: manipulation;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

button, input, select {
    -webkit-appearance: none;
    -webkit-tap-highlight-color: transparent;
}

/* Override for checkboxes to make them visible */
input[type="checkbox"] {
    -webkit-appearance: checkbox;
    appearance: checkbox;
}

/* Add these new CSS rules to your styles.css file for remainder functionality */

/* Remainder variant styling */
/* Add these CSS rules for remainder functionality */

.player-action-area.remainder {
    background: rgba(167, 139, 250, 0.1);
    border-color: rgba(167, 139, 250, 0.3);
}

.dark .player-action-area.remainder {
    background: rgba(167, 139, 250, 0.15);
    border-color: rgba(167, 139, 250, 0.4);
}

.dark .player-action-area.remainder .action-title {
    color: #a78bfa;
}

.dark .player-action-area.remainder .switch-message {
    color: #a78bfa;
}

/* Error state for invalid remainder */
.player-action-area.remainder-error {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
}

.dark .player-action-area.remainder-error {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.4);
}

.player-action-area.remainder-error .action-title {
    color: #ef4444;
}

.player-action-area.remainder-error .switch-message {
    color: #ef4444;
}

.dark .player-action-area.remainder-error .action-title {
    color: #f87171;
}

.dark .player-action-area.remainder-error .switch-message {
    color: #f87171;
}

/* Cursor states for remainder cards */
.player-card[style*="cursor: not-allowed"] {
    opacity: 0.7;
}

.player-card[style*="cursor: not-allowed"]:hover {
    /* transform: scale(1.01) !important; */
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.15) !important;
}

body {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    overscroll-behavior: none;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #1a202c;
    transition: all 0.3s ease;
    min-height: 100vh;
}

body.dark {
    background: linear-gradient(135deg, #1a202c 0%, #2d3748 100%);
    color: #f7fafc;
}

.container {
    max-width: 1150px;
    margin: 0 auto;
    padding: 16px;
    min-height: 100vh;
    position: relative;
    z-index: 2;
}

.card {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 24px;
    box-shadow: 0 32px 64px rgba(0, 0, 0, 0.15);
    padding: 16px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.dark .card {
    background: rgba(26, 32, 44, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 32px;
    flex-wrap: wrap;
    gap: 24px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.title {
    font-size: 32px;
    font-weight: 800;
    background: linear-gradient(135deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.dark .title {
    background: linear-gradient(135deg, #81e6d9, #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

.btn:disabled:hover {
    transform: none !important;
    box-shadow: none !important;
    background: inherit !important;
}

/* Enhanced remainder button states */
#remainder-btn:not(:disabled) {
    background: linear-gradient(135deg, #a78bfa, #7c3aed);
    box-shadow: 0 4px 16px rgba(167, 139, 250, 0.4);
}

#remainder-btn:not(:disabled):hover {
    background: linear-gradient(135deg, #9333ea, #6b21a8);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(167, 139, 250, 0.5);
}

#remainder-btn:disabled {
    background: #9ca3af;
    color: #6b7280;
    box-shadow: none;
}

.switch-player-btn {
    /* Prevent any layout interference */
    position: relative;
    z-index: 1;
    border: none !important;
    background: rgba(102, 126, 234, 0.1) !important;
    color: #667eea !important;
    font-family: inherit;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.switch-player-btn:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* Ensure keypad buttons are not affected */
.keypad {
    position: relative;
    z-index: 2; /* Higher than switch buttons */
    isolation: isolate; /* Create new stacking context */
}

.key-btn {
    position: relative;
    z-index: 3; /* Highest priority for keypad buttons */
    pointer-events: auto; /* Ensure clickability */
}

/* Prevent any interference between player cards and keypad */
.player-cards-container {
    position: relative;
    z-index: 1;
    margin-bottom: 24px; /* Ensure proper spacing */
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
}

.btn-primary { 
    background: linear-gradient(135deg, #667eea, #764ba2); 
    color: white;
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.4);
}

.btn-success { 
    background: linear-gradient(135deg, #4ecdc4, #44a08d); 
    color: white;
    box-shadow: 0 4px 16px rgba(78, 205, 196, 0.4);
}

.btn-danger { 
    background: linear-gradient(135deg, #ff6b6b, #ee5a24); 
    color: white;
    box-shadow: 0 4px 16px rgba(255, 107, 107, 0.4);
}

.btn-warning { 
    background: linear-gradient(135deg, #feca57, #ff9ff3); 
    color: white;
    box-shadow: 0 4px 16px rgba(254, 202, 87, 0.4);
}

.btn-purple { 
    background: linear-gradient(135deg, #a78bfa, #7c3aed); 
    color: white;
    box-shadow: 0 4px 16px rgba(167, 139, 250, 0.4);
}

.btn-icon {
    padding: 12px;
    min-width: 48px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    color: inherit;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.input {
    padding: 20px 24px;
    border: 3px solid rgba(102, 126, 234, 0.3);
    border-radius: 16px;
    font-size: 20px;
    font-weight: 600;
    width: 100%;
    background: rgba(255, 255, 255, 0.9);
    color: #1a202c;
    transition: all 0.3s ease;
    -webkit-appearance: none;
    -webkit-tap-highlight-color: transparent;
    min-height: 60px;
}

.input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.2);
    background: rgba(255, 255, 255, 1);
    transform: translateY(-1px);
}

.game-setup-label {
    display: block;
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 12px;
    color: #374151;
}

.dark .game-setup-label {
    color: #f7fafc;
}

.dark .input {
    background: rgba(45, 55, 72, 0.95);
    border-color: rgba(167, 139, 250, 0.4);
    color: #f7fafc;
}

.dark .input:focus {
    border-color: #a78bfa;
    box-shadow: 0 0 0 4px rgba(167, 139, 250, 0.2);
    background: rgba(45, 55, 72, 1);
}

/* Shared action area */
/* Updated player-action-area CSS to prevent keypad shifting */
.player-action-area {
    height: 60px; /* Fixed height - never changes */
    margin: 12px 0;
    border-radius: 8px;
    padding: 12px;
    display: flex; /* Always flex, never display: none */
    flex-direction: column;
    justify-content: center;
    overflow: hidden;
    transition: opacity 0.3s ease, transform 0.3s ease; /* Only transition opacity and transform */
    border: 1px solid transparent;
    pointer-events: none;
    
    /* Force consistent width and maintain layout space */
    width: 100%;
    box-sizing: border-box;
    flex-shrink: 0; /* Prevent shrinking */
}

/* Visible state - full opacity and normal scale */
.player-action-area.visible {
    opacity: 1;
    transform: scale(1);
}

/* Hidden state - invisible but still takes up space */
.player-action-area.not-visible {
    opacity: 0;
    transform: scale(0.98);
    /* DO NOT use display: none - this would cause layout shift */
}

/* Override the global .hidden class for action areas specifically */
.player-action-area.hidden {
    opacity: 0 !important;
    transform: scale(0.98) !important;
    display: flex !important; /* Force flex even with .hidden class */
    visibility: hidden; /* Use visibility instead of display for accessibility */
}

/* Checkout variant styling */
.player-action-area.checkout {
    background: #fef3c7;
    border-color: #f59e0b;
}

.player-action-area.checkout.visible {
    background: #fef3c7;
    border-color: #f59e0b;
}

.player-action-area.checkout.not-visible,
.player-action-area.checkout.hidden {
    background: transparent; /* Remove background when hidden */
    border-color: transparent;
}

/* Switch variant styling */
.player-action-area.switch {
    background: rgba(59, 130, 246, 0.1);
    border-color: rgba(59, 130, 246, 0.3);
}

.player-action-area.switch.visible {
    background: rgba(59, 130, 246, 0.1);
    border-color: rgba(59, 130, 246, 0.3);
}

.player-action-area.switch.not-visible,
.player-action-area.switch.hidden {
    background: transparent; /* Remove background when hidden */
    border-color: transparent;
}

/* Dark mode support */
.dark .player-action-area.checkout.visible {
    background: rgba(245, 158, 11, 0.2);
    border-color: #f59e0b;
}

.dark .player-action-area.switch.visible {
    background: rgba(59, 130, 246, 0.15);
    border-color: rgba(59, 130, 246, 0.4);
}

/* Dark mode support */
.dark .player-action-area.checkout {
    background: rgba(245, 158, 11, 0.2);
    border-color: #f59e0b;
}

.dark .player-action-area.checkout .action-title {
    color: #fbbf24;
}

.dark .player-action-area.checkout .checkout-routine {
    color: #fcd34d;
}

.dark .player-action-area.switch {
    background: rgba(59, 130, 246, 0.15);
    border-color: rgba(59, 130, 246, 0.4);
}

.dark .player-action-area.switch .action-title {
    color: #60a5fa;
}

.dark .player-action-area.switch .switch-message {
    color: #60a5fa;
}

/* Preview box styling */
.preview-box {
    background: #ecfdf5;
    border: 1px solid #10b981;
    border-radius: 8px;
    padding: 8px;
    margin: 8px 0;
    text-align: center;
    pointer-events: none; /* Don't interfere with card clicks */
}

/* Subtle pulse animation for clickable cards */
@keyframes subtle-pulse {
    0%, 100% { 
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.4);
    }
    50% { 
        box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
    }
}

.player-card[style*="cursor: pointer"]:not(.active) {
    animation: subtle-pulse 3s infinite;
}

.player-card[style*="cursor: pointer"]:not(.active):hover {
    animation: none; /* Stop pulse on hover */
}

.player-cards-container {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    overflow: hidden !important; /* Hide all scrollbars */
    width: 100%;
}

.player-card {
    border: 4px solid #e5e7eb;
    border-radius: 12px;
    padding: 8px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    min-height: 350px;
    
    /* FIXED WIDTH - NO MORE CHANGING! */
    flex: 1 1 0; /* Equal flex basis */
    width: 0; /* Force equal distribution */
    min-width: 0; /* Allow content to be constrained */
    max-width: none; /* No maximum restriction */
    
    /* Ensure content doesn't affect width */
    overflow: hidden;
    box-sizing: border-box;
}

.player-card * {
    max-width: 100%;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.player-card.active {
    border-color: #3b82f6;
    background: #eff6ff;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

.dark .player-card[style*="cursor: pointer"]:hover {
    background: rgba(59, 130, 246, 0.05);
    border-color: #60a5fa;
}

.dark .player-card.active {
    border-color: #3b82f6;
    background: rgba(59, 130, 246, 0.1);
}

.player-name {
    font-size: 20px;
    font-weight: bold;
    margin-bottom: 8px;
}

.player-legs {
    font-size: 20px;
    font-weight: bold;
}

.player-wins {
    font-size: 28px;
    font-weight: bold;
    color: #6b7280;
    margin-bottom: 16px;
}

.player-score {
    font-size: 140px;
    font-weight: bold;
    text-align: center;
    margin: 0;
    color: #374151;
    line-height: 1;
}

.player-card.active .player-score {
    color: #3b82f6;
}

.dark .player-score {
    color: #d1d5db;
}

.checkout-box {
    background: #fef3c7;
    border: 1px solid #f59e0b;
    border-radius: 8px;
    padding: 12px;
    margin: 0 0;
    /* FIXED HEIGHT TO PREVENT SHIFTING */
    height: 60px; /* Fixed height instead of auto */
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow: hidden;
    transition: opacity 0.3s ease; /* Only opacity transitions */
}

.dark .checkout-box {
    background: rgba(245, 158, 11, 0.2);
    border-color: #f59e0b;
}

.checkout-title {
    font-weight: bold;
    font-size: 14px;
    color: #92400e;
    margin-bottom: 4px;
}

.dark .checkout-title {
    color: #fbbf24;
}

.checkout-routine {
    font-family: 'Courier New', monospace;
    font-weight: bold;
    font-size: 16px;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    width: 100% !important;
    max-width: 100% !important;
}

/* Desktop and tablet - fixed equal widths */
@media (min-width: 768px) {
    .player-cards-container {
        flex-wrap: nowrap;
        display: flex;
    }
    
    .player-card {
        /* Explicit equal width calculation */
        flex: 1 1 0%;
        width: calc((100% - (12px * (var(--player-count, 2) - 1))) / var(--player-count, 2));
        min-width: 0;
        max-width: none;
    }
}

/* Mobile - allow stacking but maintain consistency */
@media (max-width: 767px) {
    .player-cards-container {
        flex-direction: column;
        gap: 16px;
    }
    
    .player-card {
        width: 100%;
        flex: none;
        min-height: 300px;
    }
}

.dark .checkout-routine {
    color: #fcd34d;
}

.checkout-placeholder {
    height: 60px;
    margin: 12px 0;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.checkout-placeholder.visible {
    opacity: 1;
    visibility: visible;
}

.player-stats {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 14px;
    color: #6b7280;
}

.stat-row {
    display: flex;
    justify-content: space-between;
}

.keypad {
    background: #f3f4f6;
    border-radius: 4px;
	/* width: 90%; */
}

.dark .keypad {
    background: #374151;
}

.key-btn {
    flex: 1;
    height: 64px;
    border: none;
    border-radius: 6px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 30px;
    padding: 8px;
}

.key-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.key-hotkey {
    background: #6366f1;
    color: white;
}

.key-hotkey:hover:not(:disabled) {
    background: #4f46e5;
}

.key-number {
    background: white;
    border: 2px solid #d1d5db;
    color: #111827;
}

.key-number:hover:not(:disabled) {
    background: #f9fafb;
}

.dark .key-number {
    background: #4b5563;
    border-color: #6b7280;
    color: white;
}

.key-clear {
    background: #ef4444;
    color: white;
}

.key-clear:hover {
    background: #dc2626;
}

.key-back {
    background: #f59e0b;
    color: white;
}

.key-checkout {
    background: #f97316 !important;
    border-color: #ea580c !important;
    color: white !important;
    animation: pulse 2s infinite;
}

.key-checkout.active {
    animation: pulse-fast 0.5s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}

@keyframes pulse-fast {
    0%, 100% { transform: scale(1); background: #f97316; }
    50% { transform: scale(1.05); background: #ea580c; }
}

.progress-bar {
    background: #f3f4f6;
    border-radius: 8px;
    padding: 8px;
    margin-bottom: 8px;
}

.dark .progress-bar {
    background: #374151;
}

.current-player {
    font-weight: bold;
    color: #3b82f6;
    font-size: 16px;
}

.hidden { display: none !important; }

.settings-input {
    background: rgba(255, 255, 255, 0.9);
    color: #1a202c;
}

.dark .settings-input {
    background: rgba(45, 55, 72, 0.95);
    border-color: rgba(167, 139, 250, 0.4);
    color: #f7fafc;
}

.dark .settings-input:focus {
    border-color: #a78bfa;
    box-shadow: 0 0 0 4px rgba(167, 139, 250, 0.2);
}

.checkout-info {
    height: 48px; /* Fixed height instead of min-height */
    background: #fef3c7;
    border: 1px solid #f59e0b;
    border-radius: 8px;
    padding: 12px;
    margin-top: 12px;
    margin-bottom: 16px; /* Keep consistent bottom margin */
    opacity: 1;
    transition: opacity 0.3s ease; /* Smooth opacity transitions only */
    display: flex;
    align-items: center;
    font-size: 14px;
    overflow: hidden;
    line-height: 1.2;
    white-space: nowrap;
    text-overflow: ellipsis;
    box-sizing: border-box; /* Include padding in height calculation */
}

.dark .checkout-info {
    background: rgba(245, 158, 11, 0.2);
    border-color: #f59e0b;
    color: #fcd34d;
}

.modal-inner-box {
    background: #f3f4f6;
    border-radius: 8px;
    padding: 16px;
    margin: 16px 0;
}

.dark .modal-inner-box {
    background: #374151;
}

.stats-section {
    background: #eff6ff;
    border: 1px solid #3b82f6;
    border-radius: 8px;
    padding: 16px;
    margin: 16px 0;
}

.dark .stats-section {
    background: rgba(59, 130, 246, 0.1);
    border-color: #3b82f6;
}

.stats-title {
    font-size: 18px;
    font-weight: bold;
    color: #1e40af;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.dark .stats-title {
    color: #60a5fa;
}

.stats-player {
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    padding: 12px;
    margin: 12px 0;
}

.stats-player.winner {
    border-color: #fbbf24;
    background: #fffbeb;
}

.dark .stats-player {
    background: #1f2937;
    border-color: #4b5563;
}

.dark .stats-player.winner {
    background: rgba(251, 191, 36, 0.1);
    border-color: #fbbf24;
}

.stats-player-name {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.stats-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    font-size: 14px;
}

.stats-grid > div {
    flex: 1;
    min-width: 120px;
}

.leg-details {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #e5e7eb;
}

.dark .leg-details {
    border-color: #4b5563;
}

.leg-details-title {
    font-size: 12px;
    font-weight: 500;
    margin-bottom: 8px;
}

.leg-detail {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    margin: 4px 0;
}

.match-summary-box {
    background: #f3f4f6;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 16px;
}

.dark .match-summary-box {
    background: #374151;
}

.leg-breakdown-box {
    background: #f9fafb;
    padding: 12px;
    border-radius: 8px;
    margin-top: 16px;
}

.dark .leg-breakdown-box {
    background: #1f2937;
}

.highlight-popup {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 60;
    pointer-events: none;
}

.highlight-popup-content {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    color: #111827;
    padding: 32px 48px;
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    text-align: center;
    animation: highlight-appear 0.4s ease-out;
    border: 3px solid #fff;
}

/* Add these styles to the existing styles.css file */

/* Update Check Section Styles */
.settings-section {
    margin: 20px 0;
    padding: 16px;
    border-radius: 12px;
    transition: all 0.3s ease;
}

#update-check-section {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.3);
    position: relative;
    overflow: hidden;
}

#update-check-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6);
    border-radius: 12px 12px 0 0;
}

.dark #update-check-section {
    background: rgba(59, 130, 246, 0.15);
    border-color: rgba(59, 130, 246, 0.4);
}

/* Update Status Styles */
#update-status {
    animation: slideDown 0.3s ease-out;
    border-radius: 8px;
    font-weight: 500;
    line-height: 1.4;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
        max-height: 0;
    }
    to {
        opacity: 1;
        transform: translateY(0);
        max-height: 200px;
    }
}

/* Update status variants */
.update-status-info {
    background: #eff6ff;
    border: 1px solid #3b82f6;
    color: #1d4ed8;
}

.update-status-success {
    background: #ecfdf5;
    border: 1px solid #10b981;
    color: #059669;
}

.update-status-warning {
    background: #fffbeb;
    border: 1px solid #f59e0b;
    color: #d97706;
}

.update-status-error {
    background: #fef2f2;
    border: 1px solid #ef4444;
    color: #dc2626;
}

/* Dark mode variants */
.dark .update-status-info {
    background: rgba(59, 130, 246, 0.15);
    border-color: #60a5fa;
    color: #93c5fd;
}

.dark .update-status-success {
    background: rgba(16, 185, 129, 0.15);
    border-color: #34d399;
    color: #6ee7b7;
}

.dark .update-status-warning {
    background: rgba(245, 158, 11, 0.15);
    border-color: #fbbf24;
    color: #fcd34d;
}

.dark .update-status-error {
    background: rgba(239, 68, 68, 0.15);
    border-color: #f87171;
    color: #fca5a5;
}

/* Check Updates Button */
#check-updates-btn {
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

#check-updates-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #3b82f6, #6366f1);
    transform: translateY(-1px);
    box-shadow: 0 8px 16px rgba(59, 130, 246, 0.3);
}

#check-updates-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

/* Loading animation for check button */
#check-updates-btn:disabled::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Apply Update Button */
#apply-update-btn {
    background: linear-gradient(135deg, #10b981, #059669);
    border: none;
    color: white;
    font-weight: 600;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#apply-update-btn:hover {
    background: linear-gradient(135deg, #059669, #047857);
    transform: translateY(-1px);
    box-shadow: 0 6px 12px rgba(16, 185, 129, 0.3);
}

/* Version Info */
#current-version {
    font-weight: 600;
    color: #3b82f6;
    background: rgba(59, 130, 246, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
}

.dark #current-version {
    color: #60a5fa;
    background: rgba(96, 165, 250, 0.15);
}

/* Settings section title styling */
#update-check-section h3 {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-size: 16px;
    font-weight: bold;
    color: #3b82f6;
}

.dark #update-check-section h3 {
    color: #60a5fa;
}

/* Description text */
#update-check-section p {
    margin: 4px 0 0 0;
    font-size: 14px;
    color: #6b7280;
    line-height: 1.4;
}

.dark #update-check-section p {
    color: #9ca3af;
}

/* Update available indicator */
.update-available-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #10b981;
    border-radius: 50%;
    animation: pulse 2s infinite;
    margin-left: 8px;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.5;
        transform: scale(1.1);
    }
}

/* Toast notification for updates (optional) */
.update-toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #10b981;
    color: white;
    padding: 16px 20px;
    border-radius: 8px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    animation: toastSlideIn 0.3s ease-out;
    max-width: 300px;
}

@keyframes toastSlideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.update-toast-close {
    background: none;
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    float: right;
    line-height: 1;
    margin-left: 10px;
}

/* Add these styles to your styles.css for better hotkey button feedback */

/* Hotkey Button Enhancements */
.key-hotkey {
    position: relative;
    transition: all 0.3s ease;
    background: #6366f1;
    color: white;
    border: 2px solid #6366f1;
}

.key-hotkey:hover:not(:disabled) {
    background: #4f46e5;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.key-hotkey:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background: #9ca3af;
    border-color: #9ca3af;
    transform: none;
}

/* Disabled hotkey button (set to 0) */
.key-hotkey[data-disabled="true"] {
    opacity: 0.3;
    background: #6b7280;
    border-color: #6b7280;
    cursor: not-allowed;
    position: relative;
}

.key-hotkey[data-disabled="true"]::after {
    content: '✕';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 20px;
    color: #ef4444;
    font-weight: bold;
}

/* Active hotkey button feedback */
.key-hotkey:active {
    transform: scale(0.95);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Hotkey button number display */
.key-hotkey .hotkey-number {
    font-size: 18px;
    font-weight: bold;
    display: block;
}

/* Updated hotkey button animation */
.key-hotkey.updated {
    animation: hotkeyUpdate 0.6s ease-out;
}

@keyframes hotkeyUpdate {
    0% {
        background: #10b981;
        transform: scale(1.05);
        box-shadow: 0 0 20px rgba(16, 185, 129, 0.5);
    }
    50% {
        background: #059669;
        transform: scale(1.1);
    }
    100% {
        background: #6366f1;
        transform: scale(1);
        box-shadow: none;
    }
}

/* Settings modal input focus enhancement */
.settings-section input[type="number"]:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
    transform: translateY(-1px);
}

/* Invalid hotkey input styling */
.settings-section input[type="number"]:invalid {
    border-color: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

/* Hotkey grid enhancement */
.settings-section .hotkey-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 12px;
}

/* Individual hotkey input styling */
.hotkey-input {
    padding: 12px 8px;
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    background: white;
    transition: all 0.3s ease;
    min-height: 44px;
}

.hotkey-input:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
    outline: none;
}

.hotkey-input:valid {
    border-color: #10b981;
}

.hotkey-input:invalid {
    border-color: #ef4444;
}

/* Dark mode hotkey enhancements */
.dark .key-hotkey {
    background: #7c3aed;
    border-color: #7c3aed;
}

.dark .key-hotkey:hover:not(:disabled) {
    background: #6d28d9;
}

.dark .key-hotkey:disabled {
    background: #4b5563;
    border-color: #4b5563;
}

.dark .hotkey-input {
    background: #374151;
    border-color: #4b5563;
    color: #f9fafb;
}

.dark .hotkey-input:focus {
    border-color: #8b5cf6;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

/* Success feedback for hotkey updates */
.hotkey-success-message {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    margin-top: 8px;
    animation: slideInUp 0.3s ease-out;
}

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

/* Responsive hotkey grid */
@media (max-width: 480px) {
    .settings-section .hotkey-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
    }
    
    .hotkey-input {
        padding: 10px 6px;
        font-size: 13px;
        min-height: 40px;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .key-hotkey {
        border-width: 3px;
    }
    
    .key-hotkey:disabled {
        border-style: dashed;
    }
    
    .hotkey-input {
        border-width: 3px;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .key-hotkey,
    .hotkey-input,
    .hotkey-success-message {
        animation: none !important;
        transition: none !important;
    }
    
    .key-hotkey:hover:not(:disabled) {
        transform: none !important;
    }
}

/* Responsive adjustments */
@media (max-width: 767px) {
    #update-check-section {
        margin: 16px 0;
        padding: 12px;
    }
    
    #update-check-section > div:first-child {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    
    #check-updates-btn {
        width: 100%;
        padding: 14px 20px;
    }
    
    #apply-update-btn {
        width: 100%;
        padding: 12px 16px;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    #update-check-section {
        border: 2px solid;
    }
    
    #update-status {
        border: 2px solid;
    }
    
    #check-updates-btn,
    #apply-update-btn {
        border: 2px solid;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    #update-status,
    #check-updates-btn,
    #apply-update-btn,
    .update-available-indicator,
    .update-toast {
        animation: none !important;
        transition: none !important;
    }
    
    #check-updates-btn:hover:not(:disabled),
    #apply-update-btn:hover {
        transform: none !important;
    }
}

@keyframes highlight-appear {
    from {
        opacity: 0;
        transform: scale(0.7) translateY(-50px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@media (max-width: 767px) {
    .header { 
        flex-direction: column; 
        align-items: stretch; 
    }
    
    .title { 
        font-size: 24px; 
    }
    
    .container {
        max-width: 1150px;
        margin: 0 auto;
        padding: 16px;
        min-height: 100vh;
        position: relative;
        z-index: 2;
        overflow-x: hidden; /* Prevent horizontal scrolling */
    }
    
    .card {
        background: rgba(255, 255, 255, 0.95);
        border-radius: 24px;
        box-shadow: 0 32px 64px rgba(0, 0, 0, 0.15);
        padding: 16px;
        border: 1px solid rgba(255, 255, 255, 0.2);
        overflow: hidden; /* Prevent content from causing scrollbars */
    }
    
    .player-cards-container {
        flex-direction: column;
        gap: 16px;
    }
    
    .player-card {
        min-height: 300px;
    }
}

/* iPad Pro and large tablet optimizations */
@media (min-width: 1024px) and (max-width: 1366px) {
    .container {
        max-width: 1200px;
    }
    
    .player-score {
        font-size: 160px;
    }
}

/* Landscape phone optimizations */
@media (max-height: 500px) and (orientation: landscape) {
    .player-score {
        font-size: 80px;
    }
    
    .player-card {
        min-height: 200px;
    }
    
    .header {
        margin-bottom: 16px;
    }
}

/* Full screen and safe area support */
@supports (display-mode: fullscreen) {
    body {
        padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    }
}

/* iPad specific gap fixes */
@media (min-width: 768px) and (max-width: 1024px) {
    .keypad {
        padding: 16px !important;
    }
    
    /* Main keypad container */
    .keypad > div {
        gap: 16px !important;
    }
    
    /* Left side container - gaps between rows */
    .keypad > div > div:first-child {
        gap: 16px !important;
    }
    
    /* Each row - gaps between buttons */
    .keypad > div > div:first-child > div {
        gap: 8px !important;
    }
    
    /* Right side container - gap between 180 and ENTER */
    .keypad > div > div:last-child {
        gap: 8px !important;
    }
    
    /* Ensure all buttons have proper spacing */
    .key-btn {
        margin: 2px !important; /* Reset any conflicting margins */
    }
}