/* ================================================
   RESPONSIVE FIXES - Mobile & Desktop Friendly
   ================================================ */

/* Fix for select dropdowns - dark theme */
select {
    background: rgba(0, 0, 0, 0.5) !important;
    color: #fff !important;
    border: 2px solid rgba(255, 255, 255, 0.2) !important;
}

select option {
    background: #1a1a2e !important;
    color: #fff !important;
    padding: 10px !important;
}

select option:hover,
select option:focus,
select option:checked {
    background: #667eea !important;
    color: #fff !important;
}

/* Ensure dropdown arrow is visible */
select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e") !important;
    background-repeat: no-repeat !important;
    background-position: right 10px center !important;
    background-size: 20px !important;
    padding-right: 40px !important;
}

/* Reset body to prevent overflow issues */
body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    padding: 0;
    margin: 0;
}

/* Make page container fully responsive */
.page {
    display: none;
    width: 100%;
    max-width: 100%;
    padding: 0;
    margin: 0;
    min-height: 100vh;
}

.page.active {
    display: flex;
    flex-direction: column;
}

/* Login page responsive */
#login-page {
    padding: 20px;
    justify-content: center;
    align-items: center;
}

#login-page .glass-card {
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
    padding: 40px 20px;
}

/* App content takes full height */
#app-content {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ================================================
   NAVIGATION BAR - Responsive
   ================================================ */

nav {
    padding: 15px 20px !important;
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 15px !important;
    justify-content: space-between !important;
    align-items: center !important;
    background: rgba(255, 255, 255, 0.05) !important;
    backdrop-filter: blur(10px) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
}

/* Logo section */
nav>div:first-child {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    flex: 1 1 auto !important;
    min-width: 150px !important;
}

nav h2 {
    font-size: clamp(1.2rem, 4vw, 1.8rem) !important;
    margin: 0 !important;
    white-space: nowrap !important;
}

/* User info section */
nav>div:last-child {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    flex-wrap: wrap !important;
}

/* Balance indicator in nav */
nav>div:last-child>div:first-child {
    padding: 8px 15px !important;
    background: rgba(255, 255, 255, 0.1) !important;
    border-radius: 10px !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
}

#nav-balance {
    font-size: clamp(0.9rem, 2.5vw, 1.1rem) !important;
}

/* User avatar section */
nav>div:last-child>div:nth-child(2) {
    padding: 6px 12px !important;
    background: rgba(255, 255, 255, 0.05) !important;
    border-radius: 10px !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
}

#user-avatar {
    width: 28px !important;
    height: 28px !important;
    border-radius: 50% !important;
}

#user-name {
    font-size: clamp(0.85rem, 2vw, 1rem) !important;
    display: inline-block;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Logout button */
nav button {
    padding: 8px 15px !important;
    font-size: clamp(0.85rem, 2vw, 1rem) !important;
    background: rgba(255, 255, 255, 0.1) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    border-radius: 10px !important;
    color: #fff !important;
    cursor: pointer !important;
    white-space: nowrap !important;
}

/* ================================================
   TAB NAVIGATION - Responsive
   ================================================ */

nav+div {
    display: flex !important;
    justify-content: center !important;
    gap: 8px !important;
    padding: 15px 10px !important;
    background: rgba(255, 255, 255, 0.03) !important;
    flex-wrap: wrap !important;
}

.tab-btn {
    padding: 10px 20px !important;
    font-size: clamp(0.9rem, 2.5vw, 1.05rem) !important;
    border-radius: 10px !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    flex: 1 1 auto !important;
    min-width: 100px !important;
    max-width: 150px !important;
    transition: all 0.3s ease !important;
}

.tab-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    border: none !important;
    color: #fff !important;
}

.tab-btn:not(.active) {
    background: rgba(255, 255, 255, 0.1) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    color: #fff !important;
}

.tab-btn i {
    font-size: 1em !important;
    margin-right: 5px !important;
}

/* ================================================
   GAME CONTENT AREA - Responsive
   ================================================ */

/* Tab content containers */
.tab-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    max-width: 100%;
}

.tab-content .glass-card {
    max-width: 600px;
    margin: 0 auto;
    width: 100%;
}

/* Coin game specific */
.game-arena {
    height: auto !important;
    min-height: 250px !important;
    padding: 20px 10px !important;
}

.coin-container {
    width: clamp(120px, 30vw, 160px) !important;
    height: clamp(120px, 30vw, 160px) !important;
}

.coin-side {
    font-size: clamp(3rem, 8vw, 4rem) !important;
}

.result-message {
    font-size: clamp(1rem, 3vw, 1.2rem) !important;
    text-align: center !important;
    padding: 0 10px !important;
}

/* Bet controls */
.bet-controls {
    padding: 15px !important;
    margin-top: 20px !important;
}

.side-selector {
    display: flex !important;
    gap: 10px !important;
    margin-bottom: 15px !important;
}

.side-btn {
    flex: 1 !important;
    padding: 12px 10px !important;
    min-width: 80px !important;
}

.side-icon {
    font-size: clamp(1.2rem, 4vw, 1.5rem) !important;
}

.side-name {
    font-size: clamp(0.75rem, 2vw, 0.9rem) !important;
}

/* Input fields */
.bet-input-container {
    margin-bottom: 15px !important;
}

.bet-input-container input {
    width: 100% !important;
    padding: 12px 15px 12px 40px !important;
    font-size: clamp(1rem, 3vw, 1.1rem) !important;
}

.flip-button {
    width: 100% !important;
    padding: 15px !important;
    font-size: clamp(1rem, 3vw, 1.2rem) !important;
}

/* ================================================
   WALLET &  HISTORY SECTIONS
   ================================================ */

.balance-card {
    padding: 20px 15px !important;
    margin-bottom: 20px !important;
}

.balance {
    font-size: clamp(2rem, 6vw, 2.5rem) !important;
}

.input-wrapper {
    display: flex !important;
    gap: 8px !important;
    flex-direction: column !important;
}

.input-wrapper input {
    width: 100% !important;
}

.input-wrapper .action-btn {
    width: 100% !important;
    padding: 12px !important;
}

/* Provably Fair Section */
.provably-fair-section {
    padding: 15px !important;
    margin-top: 20px !important;
}

.fair-value {
    font-size: clamp(0.8rem, 2.2vw, 0.9rem) !important;
    word-break: break-all !important;
}

/* ================================================
   MOBILE SPECIFIC FIXES (< 768px)
   ================================================ */

@media (max-width: 768px) {

    /* Hide user avatar on very small screens */
    #user-avatar {
        width: 24px !important;
        height: 24px !important;
    }

    #user-name {
        max-width: 80px;
    }

    /* Stack navigation items on mobile */
    nav {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 10px !important;
        padding: 10px 15px !important;
    }

    nav>div:first-child,
    nav>div:last-child {
        justify-content: center !important;
        width: 100% !important;
    }

    nav>div:last-child {
        justify-content: space-around !important;
    }

    /* Full width tabs on mobile */
    nav+div {
        gap: 5px !important;
        padding: 10px 5px !important;
    }

    .tab-btn {
        flex: 1 1 30% !important;
        min-width: unset !important;
        max-width: unset !important;
        padding: 10px 15px !important;
    }

    /* Reduce padding on mobile */
    .tab-content {
        padding: 15px 10px !important;
    }

    .glass-card {
        padding: 20px 15px !important;
    }

    /* Better input spacing on mobile */
    .input-wrapper {
        gap: 10px !important;
    }
}

/* ================================================
   TABLET (768px - 1024px)
   ================================================ */

@media (min-width: 768px) and (max-width: 1024px) {
    .page {
        max-width: 100%;
    }

    nav {
        padding: 15px 30px !important;
    }

    .tab-content {
        padding: 25px 20px !important;
    }

    .tab-content .glass-card {
        max-width: 700px;
    }
}

/* ================================================
   DESKTOP (> 1024px)
   ================================================ */

@media (min-width: 1024px) {
    #app-content {
        max-width: 1400px;
        margin: 0 auto;
    }

    nav {
        padding: 20px 40px !important;
    }

    .tab-content {
        padding: 30px !important;
    }

    .tab-content .glass-card {
        max-width: 800px;
    }

    .input-wrapper {
        flex-direction: row !important;
    }

    .input-wrapper input {
        flex: 1 !important;
    }

    .input-wrapper .action-btn {
        width: auto !important;
        min-width: 120px !important;
    }
}

/* ================================================
   SMALL MOBILE (< 400px)
   ================================================ */

@media (max-width: 400px) {
    nav h2 {
        font-size: 1.1rem !important;
    }

    #nav-balance {
        font-size: 0.85rem !important;
    }

    #user-name {
        display: none !important;
        /* Hide username on very small screens */
    }

    .tab-btn {
        padding: 8px 12px !important;
        font-size: 0.85rem !important;
    }

    .tab-btn i {
        margin-right: 3px !important;
    }

    .coin-container {
        width: 100px !important;
        height: 100px !important;
    }

    .coin-side {
        font-size: 2.5rem !important;
    }

    .glass-card {
        padding: 15px 10px !important;
        border-radius: 16px !important;
    }
}

/* ================================================
   FIX OVERLAPPING ISSUES
   ================================================ */

/* Prevent all elements from causing horizontal scroll */
* {
    max-width: 100%;
}

/* Ensure images don't overflow */
img {
    max-width: 100%;
    height: auto;
}

/* Fix button text wrapping */
button {
    word-wrap: break-word;
    hyphens: auto;
}

/* Ensure modals are responsive */
.modal {
    padding: 10px !important;
}

.modal-content {
    max-width: 95% !important;
    padding: 20px !important;
}

/* Fix fair section on mobile */
.fair-item {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 5px;
}

@media (min-width: 480px) {
    .fair-item {
        flex-direction: row;
        align-items: center !important;
    }
}

/* Prevent text overflow */
.fair-value,
.fair-label {
    overflow-wrap: break-word;
    word-wrap: break-word;
    word-break: break-word;
}

/* ================================================
   ACCESSIBILITY IMPROVEMENTS
   ================================================ */

/* Better tap targets for mobile */
@media (max-width: 768px) {

    button,
    .side-btn,
    .tab-btn {
        min-height: 44px !important;
        /* iOS recommended tap target */
    }
}

/* Focus states for keyboard navigation */
button:focus,
input:focus,
.tab-btn:focus,
.side-btn:focus {
    outline: 2px solid #667eea !important;
    outline-offset: 2px !important;
}