/* Ô Ăn Quan - Professional V4.5 Premium Styles */
:root {
    --primary: #ef4444;
    --secondary: #3b82f6;
    --bg: #0f172a;
    --card: #1e293b;
    --text: #f8fafc;
    --border: #334155;
    --accent: #6366f1;
    --success: #10b981;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body,
html {
    width: 100%;
    height: 100%;
    font-family: 'Plus Jakarta Sans', sans-serif;
    background-color: var(--bg);
    color: var(--text);
    overflow: hidden;
    position: fixed;
    /* Stop bouncing on iOS */
}

.page {
    width: 100%;
    height: 100%;
    display: none;
    padding: 0;
    overflow-y: auto;
}

.page.active {
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Auth */
.auth-card {
    max-width: 420px;
    margin: auto;
    text-align: center;
}

/* Lobby */
.lobby-container {
    width: 100%;
    max-width: 1000px;
    padding: 40px 20px;
}

.lobby-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 40px;
    gap: 20px;
}

.lobby-header h1 {
    font-size: 2.2rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lobby-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 24px;
}

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 32px;
    padding: 28px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}

.card-title {
    font-size: 1.2rem;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-stack {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.join-box {
    display: flex;
    gap: 8px;
}

.join-box .input-field {
    margin: 0;
    flex: 1;
}

.separator {
    opacity: 0.1;
    margin: 10px 0;
}

.public-list {
    max-height: 280px;
    overflow-y: auto;
    padding-right: 8px;
}

.empty-msg {
    opacity: 0.3;
    text-align: center;
    padding: 40px;
}

/* Game */
#gamePage {
    background: #000;
    justify-content: center;
    position: relative;
    padding: 0;
    overflow: hidden;
}

#gameUIHeader {
    position: absolute;
    top: 24px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 100;
    pointer-events: none;
}

#roomBadge {
    background: rgba(15, 23, 42, 0.9);
    padding: 6px 20px;
    border-radius: 99px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    font-weight: 800;
    font-size: 11px;
    letter-spacing: 2px;
    color: var(--accent);
    backdrop-filter: blur(10px);
    pointer-events: auto;
}

.score-row {
    display: flex;
    gap: 16px;
    margin-top: 16px;
    width: 100%;
    max-width: 600px;
    justify-content: center;
    pointer-events: auto;
}

.score-card {
    flex: 1;
    max-width: 180px;
    padding: 12px;
    border-radius: 20px;
    border: 2px solid transparent;
    text-align: center;
    transition: 0.3s;
}

.score-card.p1 {
    background: rgba(239, 68, 68, 0.1);
}

.score-card.p2 {
    background: rgba(59, 130, 246, 0.1);
}

.score-card .p-label {
    font-size: 10px;
    font-weight: 800;
    opacity: 0.6;
    text-transform: uppercase;
    display: block;
}

.score-card .p-val {
    font-size: 32px;
    font-weight: 900;
}

#turnStatus {
    margin-top: 16px;
    font-weight: 800;
    font-size: 11px;
    letter-spacing: 4px;
    text-transform: uppercase;
}

#gameContainer {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

canvas {
    max-width: 100%;
    max-height: 80vh;
    object-fit: contain;
}

#gameBottomUI {
    position: absolute;
    bottom: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    z-index: 100;
}

.spectator-badge {
    background: rgba(255, 255, 255, 0.05);
    padding: 10px 18px;
    border-radius: 14px;
    font-weight: 700;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-square {
    width: 48px;
    height: 48px;
    padding: 0 !important;
    border-radius: 14px !important;
}

/* Components */
.input-field {
    width: 100%;
    padding: 16px;
    border-radius: 14px;
    background: #0f172a;
    border: 1px solid var(--border);
    color: white;
    font-size: 16px;
    outline: none;
    transition: 0.2s;
}

.input-field:focus {
    border-color: var(--accent);
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.3);
}

.btn {
    padding: 14px 24px;
    border-radius: 16px;
    font-weight: 800;
    cursor: pointer;
    border: none;
    transition: 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-secondary {
    background: var(--secondary);
    color: white;
}

.btn-outline {
    background: transparent;
    border: 1.5px solid var(--border);
    color: white;
}

.btn:hover {
    transform: translateY(-2px);
    filter: brightness(1.2);
}

/* Modals */
.modal-wrapper {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(12px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-card {
    max-width: 440px;
    width: 100%;
}

.checkbox-group {
    display: flex;
    gap: 24px;
    padding: 10px 0;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    cursor: pointer;
}

.modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

.modal-actions .btn {
    flex: 1;
}

@media (max-width: 600px) {
    .lobby-header {
        flex-direction: column;
        text-align: center;
    }

    .lobby-header h1 {
        font-size: 1.8rem;
    }

    .lobby-grid {
        grid-template-columns: 1fr;
    }

    .score-row {
        padding: 0 20px;
    }

    .score-card {
        max-width: 140px;
        padding: 8px;
    }

    .score-card .p-val {
        font-size: 24px;
    }
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--sub);
}