/* ===== BRIDGE MODES CALCULATOR - COMPLETE UPDATED STYLES ===== */
/* Enhanced version with improved suit buttons and better typography */

/* Global Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

/* Root Variables - Enhanced Color Palette */
:root {
    --primary-bg: #2c3e50;
    --secondary-bg: #34495e;
    --accent-blue: #3498db;
    --success-green: #27ae60;
    --warning-orange: #f39c12;
    --danger-red: #e74c3c;
    --text-light: #ecf0f1;
    --text-muted: #bdc3c7;
    --text-dark: #7f8c8d;
    --border-color: #4a6741;
    
    /* New enhanced colors */
    --button-shadow: rgba(0, 0, 0, 0.15);
    --button-hover-shadow: rgba(0, 0, 0, 0.25);
    --active-glow: rgba(40, 167, 69, 0.4);
    --card-bg: #ffffff;
    --card-shadow: rgba(0, 0, 0, 0.08);
}

/* HTML & Body - Viewport Fix */
html {
    height: 100vh;
    height: 100svh;
    width: 100vw;
    max-width: 100vw;
    max-height: 100vh;
    overflow: hidden;
    touch-action: manipulation;
    -webkit-text-size-adjust: 100%;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #212529;
    height: 100vh;
    height: 100svh;
    width: 100vw;
    overflow: hidden;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    touch-action: manipulation;
    transform: translateZ(0);
}

/* Loading Screen */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.loading-content {
    text-align: center;
    color: var(--text-light);
}

.loading-spinner {
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top: 3px solid var(--accent-blue);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Main App Container */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100svh;
    width: 100vw;
    max-width: 100vw;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    position: relative;
    justify-content: center;
    align-items: center;
    padding: 12px;
}

/* Calculator Container - More Modern Design */
.calculator {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 420px;
    height: auto;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 24px;
    padding: 16px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15), 
                0 0 0 1px rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

/* Display Panel - Enhanced with Better Definition */
.display-panel {
    background: #ffffff;
    color: #2c3e50;
    border-radius: 16px;
    margin-bottom: 12px;
    padding: 18px;
    min-height: 130px;
    
    /* Enhanced shadow for better definition */
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15), 
                0 4px 12px rgba(0, 0, 0, 0.08),
                0 1px 4px rgba(0, 0, 0, 0.04);
    
    /* Subtle border for crisp edges */
    border: 1px solid rgba(0, 0, 0, 0.08);
    
    position: relative;
    z-index: 1;
}

.title-score-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.mode-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--accent-blue);
    letter-spacing: -0.2px;
}

.score-display {
    text-align: right;
    font-size: 14px;
    line-height: 1.3;
    color: #2c3e50;
    background: #f8f9fa;
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid #e9ecef;
    font-weight: 600;
    min-width: 70px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

.game-content {
    margin: 10px 0;
    text-align: center;
}

/* License Code Display - Enhanced */
.code-display {
    font-family: 'SF Mono', 'Monaco', 'Menlo', 'Courier New', monospace;
    font-size: 22px;
    font-weight: 700;
    color: var(--accent-blue);
    margin: 16px 0;
    letter-spacing: 6px;
    text-align: center;
    background: rgba(52, 152, 219, 0.05);
    padding: 14px;
    border-radius: 12px;
    border: 1px solid rgba(52, 152, 219, 0.15);
    box-shadow: inset 0 1px 3px rgba(52, 152, 219, 0.1);
}

.status-message {
    color: #495057;
    font-size: 14px;
    margin: 12px 0;
    text-align: center;
    font-weight: 500;
    background: rgba(73, 80, 87, 0.03);
    padding: 8px 12px;
    border-radius: 8px;
}

/* Licensed Mode Content */
.mode-selection {
    text-align: center;
}

.mode-grid {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 10px 0;
}

.mode-row {
    display: flex;
    justify-content: space-around;
    font-size: 13px;
    line-height: 1.4;
    min-height: 18px;
    font-weight: 500;
}

.mode-row span {
    color: #495057;
    white-space: nowrap;
    flex: 1;
    text-align: center;
}

.mode-row:has(span:only-child) {
    justify-content: center;
}

.license-status {
    position: absolute;
    bottom: 6px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 11px;
    color: var(--accent-blue);
    text-align: center;
    width: 100%;
    font-weight: 600;
}

.current-state {
    font-size: 12px;
    color: #6c757d;
    text-align: center;
    margin-top: 8px;
    padding: 8px 12px;
    background: rgba(108, 117, 125, 0.06);
    border-radius: 8px;
    font-weight: 500;
    border: 1px solid rgba(108, 117, 125, 0.1);
}

/* Control Bar - Refined Design */
.control-bar {
    display: flex;
    justify-content: space-around;
    align-items: center;
    height: 38px;
    background: rgba(0, 0, 0, 0.06);
    border-radius: 12px;
    margin-bottom: 8px;
    padding: 0 10px;
    gap: 6px;
}

.control-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 10px;
    font-size: 12px;
    color: #495057;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 8px;
    height: 30px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    touch-action: manipulation;
    min-width: 50px;
    justify-content: center;
    font-weight: 600;
    backdrop-filter: blur(5px);
}

.control-item:hover {
    background: rgba(255, 255, 255, 0.9);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.control-item:active {
    transform: translateY(0);
    background: rgba(255, 255, 255, 1);
}

/* Wake Toggle Switch - Modern Design */
.toggle-switch {
    width: 28px;
    height: 16px;
    background: #ddd;
    border-radius: 8px;
    position: relative;
    transition: background 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}

.toggle-knob {
    width: 12px;
    height: 12px;
    background: white;
    border-radius: 50%;
    position: absolute;
    top: 2px;
    left: 2px;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.toggle-switch.active {
    background: var(--success-green);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2);
}

.toggle-switch.active .toggle-knob {
    transform: translateX(12px);
}

/* Copyright - Subtle */
.copyright {
    text-align: center;
    font-size: 10px;
    color: rgba(0, 0, 0, 0.4);
    margin-bottom: 8px;
    padding: 2px;
    font-weight: 500;
}

/* Button Grid - Optimized Layout */
.button-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    padding: 12px;
    flex: 1;
    min-height: 280px;
}

/* Enhanced Button Styles - Base */
.btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 12px;
    color: white;
    font-size: 15px;
    font-weight: 700;
    min-height: 42px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
    box-shadow: 0 2px 8px var(--button-shadow);
    position: relative;
    overflow: hidden;
    letter-spacing: -0.2px;
}

/* Button Hover Effect */
.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px var(--button-hover-shadow);
}

.btn:active,
.btn.pressed {
    transform: translateY(0) scale(0.98);
    box-shadow: 0 2px 6px var(--button-shadow);
}

/* Active/Enabled Button Glow */
.btn:not(.disabled) {
    box-shadow: 0 2px 8px var(--button-shadow), 
                0 0 0 2px var(--active-glow);
    animation: subtle-pulse 2s ease-in-out infinite;
}

@keyframes subtle-pulse {
    0%, 100% { box-shadow: 0 2px 8px var(--button-shadow), 0 0 0 2px var(--active-glow); }
    50% { box-shadow: 0 2px 8px var(--button-shadow), 0 0 0 2px rgba(40, 167, 69, 0.6); }
}

.btn:not(.disabled):hover {
    box-shadow: 0 6px 16px var(--button-hover-shadow), 
                0 0 0 2px rgba(255, 255, 255, 0.8);
    animation: none;
}

/* Disabled Button Style - Enhanced Dark Grey */
.btn.disabled {
    background: linear-gradient(135deg, #374151 0%, #1f2937 100%);
    color: rgba(255, 255, 255, 0.85);
    cursor: not-allowed;
    transform: none;
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.08);
    animation: none;
}

.btn.disabled:hover,
.btn.disabled:active {
    transform: none;
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.25);
    background: linear-gradient(135deg, #374151 0%, #1f2937 100%);
}

/* Enhanced Button Variants */
.btn-number {
    background: linear-gradient(135deg, #2ecc71 0%, #27ae60 100%);
    font-size: 16px;
    font-weight: 800;
}

.btn-declarer {
    background: linear-gradient(135deg, #9b59b6 0%, #8e44ad 100%);
    color: white;
    font-weight: 800;
}

.btn-double {
    background: linear-gradient(135deg, #17a2b8 0%, #138496 100%);
    color: white;
    font-weight: 800;
}

.btn-result {
    background: linear-gradient(135deg, #20c997 0%, #17a085 100%);
    color: white;
    font-weight: 700;
}

.btn-action {
    background: linear-gradient(135deg, #fd7e14 0%, #e55100 100%);
    color: white;
    font-weight: 700;
}

/* ===== ENHANCED SUIT BUTTON DESIGN ===== */
/* All suit buttons get blue background with traditional suit colors */

/* Base suit button styling - unified blue background */
.btn-clubs,
.btn-diamonds, 
.btn-hearts,
.btn-spades,
.btn-notrump {
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%) !important;
    border: 2px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 3px 12px rgba(52, 152, 219, 0.3);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Active/enabled suit buttons */
.btn-clubs:not(.disabled),
.btn-diamonds:not(.disabled),
.btn-hearts:not(.disabled), 
.btn-spades:not(.disabled),
.btn-notrump:not(.disabled) {
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%) !important;
    border: 2px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 3px 12px rgba(52, 152, 219, 0.4), 
                0 0 0 2px rgba(52, 152, 219, 0.5);
    animation: subtle-blue-pulse 2s ease-in-out infinite;
}

@keyframes subtle-blue-pulse {
    0%, 100% { 
        box-shadow: 0 3px 12px rgba(52, 152, 219, 0.4), 
                    0 0 0 2px rgba(52, 152, 219, 0.5); 
    }
    50% { 
        box-shadow: 0 3px 12px rgba(52, 152, 219, 0.5), 
                    0 0 0 2px rgba(52, 152, 219, 0.7); 
    }
}

/* Hover effects */
.btn-clubs:not(.disabled):hover,
.btn-diamonds:not(.disabled):hover,
.btn-hearts:not(.disabled):hover,
.btn-spades:not(.disabled):hover,
.btn-notrump:not(.disabled):hover {
    background: linear-gradient(135deg, #2980b9 0%, #1f639a 100%) !important;
    box-shadow: 0 6px 16px rgba(52, 152, 219, 0.5), 
                0 0 0 2px rgba(255, 255, 255, 0.8);
    transform: translateY(-2px);
    animation: none;
}

/* Disabled suit buttons - same dark grey as others */
.btn-clubs.disabled,
.btn-diamonds.disabled,
.btn-hearts.disabled,
.btn-spades.disabled,
.btn-notrump.disabled {
    background: linear-gradient(135deg, #374151 0%, #1f2937 100%) !important;
    color: rgba(255, 255, 255, 0.7) !important;
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.25) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    animation: none !important;
}

/* Suit symbols - larger and properly colored */
.suit-symbol {
    font-size: 26px !important;
    font-weight: 900;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    display: block;
    line-height: 1;
}

/* Clubs - Black */
.btn-clubs .suit-symbol {
    color: #000000 !important;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4),
                 0 0 1px rgba(255, 255, 255, 0.8);
}

/* Diamonds - Red */
.btn-diamonds .suit-symbol {
    color: #dc3545 !important;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4),
                 0 0 1px rgba(255, 255, 255, 0.8);
}

/* Hearts - Red */
.btn-hearts .suit-symbol {
    color: #dc3545 !important;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4),
                 0 0 1px rgba(255, 255, 255, 0.8);
}

/* Spades - Black */
.btn-spades .suit-symbol {
    color: #000000 !important;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4),
                 0 0 1px rgba(255, 255, 255, 0.8);
}

/* No Trump - White with larger text */
.btn-notrump .suit-symbol {
    color: #ffffff !important;
    font-size: 18px !important;
    font-weight: 800;
    letter-spacing: 1px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

/* Disabled suit symbol colors */
.btn-clubs.disabled .suit-symbol,
.btn-spades.disabled .suit-symbol,
.btn-diamonds.disabled .suit-symbol,
.btn-hearts.disabled .suit-symbol,
.btn-notrump.disabled .suit-symbol {
    color: rgba(255, 255, 255, 0.6) !important;
    text-shadow: none !important;
}

/* Enhanced button press feedback for suit buttons */
.btn-clubs:active,
.btn-diamonds:active,
.btn-hearts:active,
.btn-spades:active,
.btn-notrump:active,
.btn-clubs.pressed,
.btn-diamonds.pressed,
.btn-hearts.pressed,
.btn-spades.pressed,
.btn-notrump.pressed {
    transform: translateY(0) scale(0.98) !important;
    box-shadow: 0 2px 6px rgba(52, 152, 219, 0.4) !important;
}

/* Message Styles - Enhanced */
.error-message {
    background: linear-gradient(135deg, rgba(231, 76, 60, 0.15) 0%, rgba(231, 76, 60, 0.08) 100%);
    border: 1px solid rgba(231, 76, 60, 0.3);
    border-radius: 10px;
    padding: 10px 14px;
    margin: 10px 0;
    color: #c0392b;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    animation: shake 0.5s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-3px); }
    75% { transform: translateX(3px); }
}

.success-message {
    background: linear-gradient(135deg, rgba(39, 174, 96, 0.15) 0%, rgba(39, 174, 96, 0.08) 100%);
    border: 1px solid rgba(39, 174, 96, 0.3);
    border-radius: 10px;
    padding: 10px 14px;
    margin: 10px 0;
    color: #27ae60;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    animation: bounce 0.5s ease;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}

.info-message {
    background: linear-gradient(135deg, rgba(52, 152, 219, 0.15) 0%, rgba(52, 152, 219, 0.08) 100%);
    border: 1px solid rgba(52, 152, 219, 0.3);
    border-radius: 10px;
    padding: 10px 14px;
    margin: 10px 0;
    color: #3498db;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
}

/* Modal Styles - Enhanced */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
    padding: 15px;
    box-sizing: border-box;
}

@keyframes fadeIn {
    from { opacity: 0; backdrop-filter: blur(0px); }
    to { opacity: 1; backdrop-filter: blur(5px); }
}

.modal-content {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-radius: 16px;
    padding: 24px;
    max-width: 90%;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    color: #2c3e50;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.3);
    animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    -webkit-overflow-scrolling: touch;
}

@keyframes slideUp {
    from { transform: translateY(30px) scale(0.95); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}

.modal-content h3 {
    color: var(--accent-blue);
    margin-bottom: 18px;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.modal-content h4 {
    color: #2c3e50;
    margin: 16px 0 10px 0;
    font-size: 16px;
    font-weight: 600;
}

.modal-content p {
    margin: 10px 0;
    line-height: 1.5;
    font-size: 14px;
    color: #495057;
    font-weight: 500;
}

.modal-content ul {
    margin: 8px 0 8px 20px;
    color: #495057;
}

.modal-content li {
    margin: 4px 0;
    font-size: 13px;
}

.modal-content a {
    color: var(--accent-blue);
    text-decoration: none;
    font-weight: 600;
}

.modal-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 24px;
    flex-wrap: wrap;
}

.modal-btn {
    background: linear-gradient(135deg, var(--accent-blue) 0%, #2980b9 100%);
    border: none;
    border-radius: 10px;
    color: white;
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    touch-action: manipulation;
    min-height: 44px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 3px 12px rgba(52, 152, 219, 0.3);
    letter-spacing: -0.2px;
    flex: 1;
    min-width: 120px;
    max-width: 200px;
}

.modal-btn:active {
    transform: scale(0.96);
}

.modal-btn.close {
    background: linear-gradient(135deg, #95a5a6 0%, #7f8c8d 100%);
    box-shadow: 0 3px 12px rgba(149, 165, 166, 0.3);
}

/* Error Screen - Enhanced */
.error-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.error-content {
    text-align: center;
    color: var(--text-light);
    padding: 40px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    backdrop-filter: blur(10px);
}

.error-content h2 {
    color: var(--danger-red);
    margin-bottom: 20px;
    font-weight: 700;
}

.modal-button {
    background: linear-gradient(135deg, var(--accent-blue) 0%, #2980b9 100%);
    border: none;
    border-radius: 10px;
    color: white;
    padding: 14px 28px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    margin-top: 20px;
    touch-action: manipulation;
    min-height: 44px;
    box-shadow: 0 4px 16px rgba(52, 152, 219, 0.4);
}

/* ===== RESPONSIVE DESIGN - Optimized ===== */

/* Extra Small Mobile (320px - 360px) */
@media (max-width: 360px) {
    .calculator {
        padding: 12px;
        border-radius: 20px;
        max-width: 340px;
    }
    
    .display-panel {
        padding: 14px;
        margin-bottom: 8px;
        min-height: 120px;
    }
    
    .mode-title {
        font-size: 16px;
    }
    
    .score-display {
        font-size: 12px;
        padding: 8px 12px;
    }
    
    .control-bar {
        height: 34px;
        gap: 4px;
    }
    
    .control-item {
        padding: 0 8px;
        font-size: 11px;
        min-width: 45px;
        height: 26px;
    }
    
    .button-grid {
        gap: 8px;
        min-height: 240px;
        padding: 10px;
    }
    
    .btn {
        min-height: 38px;
        font-size: 14px;
        border-radius: 10px;
    }
    
    .suit-symbol {
        font-size: 20px !important;
    }
    
    .btn-notrump .suit-symbol {
        font-size: 14px !important;
    }
}

/* Standard Mobile (360px - 414px) */
@media (min-width: 360px) and (max-width: 414px) {
    .button-grid {
        gap: 9px;
        min-height: 260px;
    }
    
    .btn {
        min-height: 40px;
        font-size: 14px;
    }
    
    .suit-symbol {
        font-size: 22px !important;
    }
    
    .btn-notrump .suit-symbol {
        font-size: 16px !important;
    }
}

/* Large Mobile (414px - 480px) */
@media (min-width: 414px) and (max-width: 480px) {
    .calculator {
        max-width: 400px;
    }
    
    .button-grid {
        gap: 10px;
        min-height: 270px;
    }
    
    .btn {
        min-height: 42px;
        font-size: 15px;
    }
    
    .suit-symbol {
        font-size: 24px !important;
    }
    
    .btn-notrump .suit-symbol {
        font-size: 17px !important;
    }
}

/* Small Tablet Portrait (480px - 768px) */
@media (min-width: 480px) and (max-width: 768px) {
    .app-container {
        padding: 15px;
    }
    
    .calculator {
        max-width: 420px;
        padding: 18px;
    }
    
    .display-panel {
        padding: 18px;
        margin-bottom: 12px;
        min-height: 160px;
        font-size: 15px;
    }
    
    .mode-title {
        font-size: 18px;
    }
    
    .score-display {
        font-size: 13px;
    }
    
    .control-bar {
        height: 32px;
        gap: 8px;
    }
    
    .control-item {
        font-size: 12px;
        padding: 0 10px;
        min-width: 55px;
    }
    
    .button-grid {
        gap: 12px;
        min-height: 280px;
        padding: 15px;
    }
    
    .btn {
        min-height: 44px;
        font-size: 15px;
        border-radius: 13px;
    }
    
    .suit-symbol {
        font-size: 26px !important;
    }
    
    .btn-notrump .suit-symbol {
        font-size: 18px !important;
    }
}

/* Tablet and Desktop */
@media (min-width: 768px) {
    .calculator {
        max-width: 420px;
        padding: 20px;
    }
    
    .display-panel {
        padding: 20px;
        margin-bottom: 15px;
        min-height: 180px;
        font-size: 16px;
    }
    
    .mode-title {
        font-size: 20px;
    }
    
    .score-display {
        font-size: 14px;
    }
    
    .control-bar {
        height: 36px;
        gap: 10px;
    }
    
    .control-item {
        font-size: 13px;
        padding: 0 12px;
        min-width: 60px;
    }
    
    .button-grid {
        gap: 12px;
        min-height: 290px;
        padding: 14px;
    }
    
    .btn {
        min-height: 44px;
        font-size: 15px;
    }
    
    .suit-symbol {
        font-size: 26px !important;
    }
    
    .btn-notrump .suit-symbol {
        font-size: 18px !important;
    }
}

/* High Resolution Displays */
@media (min-width: 1024px) {
    .calculator {
        max-width: 450px;
        padding: 25px;
    }
    
    .button-grid {
        gap: 15px;
        min-height: 320px;
        padding: 20px;
    }
    
    .btn {
        min-height: 48px;
        font-size: 16px;
    }
    
    .suit-symbol {
        font-size: 28px !important;
    }
    
    .btn-notrump .suit-symbol {
        font-size: 20px !important;
    }
}

/* Mobile-specific modal adjustments */
@media (max-width: 480px) {
    .modal-overlay {
        padding: 5px;
        align-items: flex-start;
        padding-top: 20px;
    }
    
    .modal-content {
        max-height: 90vh;
        padding: 15px;
        border-radius: 8px;
        font-size: 14px;
    }
    
    .modal-content h3 {
        font-size: 16px;
        margin-bottom: 12px;
    }
    
    .modal-content h4 {
        font-size: 13px;
        margin: 12px 0 6px 0;
    }
    
    .modal-content p {
        font-size: 12px;
        line-height: 1.3;
    }
    
    .modal-content li {
        font-size: 12px;
    }
    
    .modal-buttons {
        flex-direction: column;
        gap: 8px;
    }
    
    .modal-btn {
        width: 100%;
        max-width: none;
        min-height: 48px;
        font-size: 16px;
    }
}

/* PWA specific fixes */
@media (display-mode: standalone) {
    html, body {
        overflow: hidden !important;
        position: fixed !important;
        width: 100% !important;
        height: 100% !important;
    }
    
    .app-container {
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }
}

/* Prevent zoom on input focus (mobile) */
input, select, textarea {
    font-size: 16px !important;
    zoom: 1.0;
    transform: scale(1);
}

/* Allow text selection only where needed */
input, textarea, [contenteditable="true"] {
    -webkit-user-select: text !important;
    -moz-user-select: text !important;
    -ms-user-select: text !important;
    user-select: text !important;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .calculator {
        background: rgba(44, 62, 80, 0.95);
    }
    
    .display-panel {
        background: #2c3e50;
        color: var(--text-light);
    }
    
    .modal-content {
        background: rgba(52, 73, 94, 0.95);
        color: var(--text-light);
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .btn:not(.disabled) {
        animation: none !important;
    }
    
    .btn-clubs:not(.disabled),
    .btn-diamonds:not(.disabled),
    .btn-hearts:not(.disabled), 
    .btn-spades:not(.disabled),
    .btn-notrump:not(.disabled) {
        animation: none !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .btn {
        border: 2px solid white;
    }
    
    .display-panel {
        border: 3px solid white;
    }
}

/* Additional utility classes */
.help-section {
    margin: 15px 0;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.help-section:last-child {
    border-bottom: none;
}

.scores-summary {
    background: rgba(40, 167, 69, 0.1);
    padding: 12px;
    border-radius: 6px;
    margin: 10px 0;
    border-left: 4px solid var(--success-green);
}

.deals-history {
    margin-top: 15px;
}

/* Loading states */
.loading-state {
    opacity: 0.6;
    pointer-events: none;
}

.loading-state .btn {
    background: #95a5a6 !important;
    cursor: not-allowed !important;
}

/* Touch feedback enhancements */
@media (hover: none) and (pointer: coarse) {
    .btn:active {
        background: rgba(0, 0, 0, 0.1) !important;
        transform: scale(0.95) !important;
    }
    
    .control-item:active {
        background: rgba(0, 0, 0, 0.1) !important;
        transform: scale(0.95) !important;
    }
}
/* Add this to your styles.css - Mobile Modal Scroll Fix */

/* Enhanced Modal Styles for Mobile Scrolling */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: flex-start; /* Changed from center to flex-start */
    z-index: 1000;
    animation: fadeIn 0.3s ease;
    padding: 15px;
    box-sizing: border-box;
    overflow-y: auto; /* Enable vertical scrolling */
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}

.modal-content {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-radius: 16px;
    padding: 24px;
    max-width: 90%;
    width: 100%;
    max-height: 85vh; /* Limit height to viewport */
    overflow-y: auto; /* Enable scrolling inside modal */
    color: #2c3e50;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.3);
    animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    -webkit-overflow-scrolling: touch; /* Smooth scrolling */
    margin-top: 20px; /* Add top margin for better positioning */
    margin-bottom: 20px; /* Add bottom margin */
}

/* Mobile-specific modal adjustments - Enhanced */
@media (max-width: 480px) {
    .modal-overlay {
        padding: 10px;
        align-items: flex-start;
        padding-top: 10px; /* Reduced top padding */
    }
    
    .modal-content {
        max-height: 90vh; /* More height on mobile */
        padding: 15px;
        border-radius: 12px;
        font-size: 14px;
        margin-top: 10px;
        margin-bottom: 10px;
    }
    
    .modal-content h3 {
        font-size: 16px;
        margin-bottom: 12px;
        position: sticky; /* Keep title visible while scrolling */
        top: 0;
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(20px);
        padding: 10px 0;
        margin: -15px -15px 12px -15px;
        padding-left: 15px;
        padding-right: 15px;
        border-radius: 12px 12px 0 0;
        z-index: 1;
    }
    
    .modal-content h4 {
        font-size: 13px;
        margin: 12px 0 6px 0;
    }
    
    .modal-content p {
        font-size: 12px;
        line-height: 1.4;
        margin: 8px 0;
    }
    
    .modal-content li {
        font-size: 12px;
        margin: 3px 0;
    }
    
    .modal-buttons {
        flex-direction: column;
        gap: 8px;
        position: sticky; /* Keep buttons visible */
        bottom: 0;
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(20px);
        padding: 15px 0 0 0;
        margin: 15px -15px -15px -15px;
        padding-left: 15px;
        padding-right: 15px;
        border-radius: 0 0 12px 12px;
    }
    
    .modal-btn {
        width: 100%;
        max-width: none;
        min-height: 48px;
        font-size: 16px;
        touch-action: manipulation;
    }
}

/* Pixel 9a specific fixes */
@media screen and (max-device-width: 430px) and (-webkit-device-pixel-ratio: 2.625) {
    .modal-overlay {
        height: 100vh;
        height: 100svh; /* Use small viewport height */
    }
    
    .modal-content {
        max-height: 85vh;
        max-height: 85svh; /* Use small viewport height */
    }
}

/* Force scrollbar visibility on mobile when needed */
@media (max-width: 480px) {
    .modal-content::-webkit-scrollbar {
        width: 8px;
        background: rgba(0, 0, 0, 0.1);
        border-radius: 4px;
    }
    
    .modal-content::-webkit-scrollbar-thumb {
        background: rgba(0, 0, 0, 0.3);
        border-radius: 4px;
    }
    
    .modal-content::-webkit-scrollbar-thumb:hover {
        background: rgba(0, 0, 0, 0.5);
    }
}

/* Prevent body scroll when modal is open */
body.modal-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}
    
    /* Specific fixes for score sheets and deal histories */
    .modal-body {
        max-height: 60vh !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        padding: 10px !important;
    }
    
    /* Make buttons sticky at bottom */
    .modal-buttons {
        position: sticky !important;
        bottom: 0 !important;
        background: rgba(255, 255, 255, 0.95) !important;
        backdrop-filter: blur(10px) !important;
        padding: 15px 0 5px 0 !important;
        margin: 10px -15px -15px -15px !important;
        border-top: 1px solid rgba(0, 0, 0, 0.1) !important;
    }
    
    /* Make title sticky at top */
    .modal-content h3 {
        position: sticky !important;
        top: 0 !important;
        background: rgba(255, 255, 255, 0.95) !important;
        backdrop-filter: blur(10px) !important;
        padding: 15px 0 10px 0 !important;
        margin: -15px -15px 10px -15px !important;
        border-bottom: 1px solid rgba(0, 0, 0, 0.1) !important;
        z-index: 10 !important;
    }
}

