@import url('https://fonts.googleapis.com/css2?family=Fredoka+One&family=Nunito:wght@600;800&display=swap');
@import url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css');

/* Disable mobile tap highlight and blue selection box */
* {
    -webkit-tap-highlight-color: transparent;
    -moz-tap-highlight-color: transparent;
    tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -moz-user-select: none;
    -webkit-user-select: none;
    user-select: none;
}

button {
    -webkit-tap-highlight-color: transparent;
    outline: none;
    border: none;
    background: none;
}

button:focus {
    outline: none;
}

button:active {
    outline: none;
}

:root {
    --bg-color: #FFD54F; /* Softer, warmer yellow */
    --primary: #FF6B6B; /* Vibrant Red/Pink */
    --secondary: #4ECDC4; /* Teal */
    --text: #2D3436;
    --board-color: #fff;
    --board-shadow: #E0E0E0;
    --p1-color: #FF4136; /* Classic Red */
    --p2-color: #FFDC00; /* Classic Yellow */
}

body {
    margin: 0;
    font-family: 'Comic Neue', 'Nunito', sans-serif;
    background-color: var(--bg-color);
    background-image: 
        radial-gradient(#fff 15%, transparent 16%),
        radial-gradient(#fff 15%, transparent 16%);
    background-size: 40px 40px;
    background-position: 0 0, 20px 20px;
    color: var(--text);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow: hidden; /* Disable all scrolling */
    touch-action: manipulation;
}

html {
    overflow-y: auto;
}

/* Allow scrolling on about and contact pages but disable horizontal scroll */
body.scrollable-page {
    overflow-x: hidden;
    overflow-y: auto;
    height: auto;
    display: block;
    align-items: flex-start;
    padding-bottom: 20px;
}

body.scrollable-page .app-container {
    min-height: 100vh;
    height: auto;
}
}

h1, h2, h3, button, .name, #timer {
    font-family: 'Fredoka One', cursive;
}

.app-container {
    width: 100%;
    max-width: 480px;
    height: 100%;
    max-height: 100vh;
    padding: 10px;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    position: relative;
}

/* Mobile-specific - utilize maximum space */
@media (max-width: 420px) {
    .app-container {
        padding: 5px;
        max-height: 100vh;
        height: 100vh;
    }
    
    header {
        padding: 5px 5px;
        margin-bottom: 3px;
    }
    
    .game-logo {
        font-size: 1.2rem;
        padding: 5px 8px 5px 8px;
    }
    
    /* Move game screen elements higher */
    #game-screen {
        padding-top: 5px;
        justify-content: flex-start;
    }
    
    /* Room code display smaller margin */
    .room-display {
        margin-bottom: 2px;
        padding: 4px 8px;
        font-size: 0.8rem;
    }
    
    /* Board with small equal padding on both sides */
    .board-wrapper {
        padding: 0 2px !important;
        display: flex;
        align-items: center;
        justify-content: center;
        max-width: 100% !important;
        width: 100% !important;
        min-height: 0;
        overflow: hidden;
    }
    
    .board {
        border-radius: 8px !important;
        padding: 6px !important;
        gap: 4px !important;
        width: 100% !important;
        max-width: 100% !important;
        aspect-ratio: 7/6 !important;
        height: auto !important;
        min-height: 0 !important;
        box-sizing: border-box !important;
        box-shadow: none !important;
    }
    
    .cell {
        width: 100% !important;
        height: 100% !important;
        aspect-ratio: 1;
    }
    
    /* Player info bar right above board */
    .player-info-bar {
        margin-bottom: 2px !important;
        padding: 0 2px;
        width: calc(100% - 4px) !important;
        max-width: calc(100% - 4px) !important;
        margin-left: auto !important;
        margin-right: auto !important;
        box-sizing: border-box;
    }
    
    .player-badge {
        padding: 5px 8px !important;
    }
    
    .player-name {
        font-size: 0.9rem !important;
    }
    
    #game-status {
        font-size: 0.85rem;
        margin: 2px 0;
    }
    
    /* Game buttons right below board on mobile */
    .game-buttons {
        display: flex !important;
        flex-direction: row;
        justify-content: center;
        gap: 8px;
        margin-top: 2px;
        margin-bottom: 2px;
        width: 100%;
        padding: 0 2px;
        box-sizing: border-box;
    }
    
    .game-buttons button {
        flex: 0 0 auto;
        padding: 12px 24px;
        font-size: 1rem;
        margin: 0 !important;
        border-radius: 25px;
    }
    
    #back-to-lobby {
        width: auto !important;
        flex: 0 0 auto;
        margin: 0 !important;
        padding: 12px 24px;
        font-size: 1rem;
    }
    
    #rematch-btn {
        width: auto !important;
        flex: 0 0 auto;
        margin: 0 !important;
        padding: 12px 24px;
        font-size: 1rem;
    }
}

/* Extra small screens - smaller buttons */
@media (max-width: 360px) {
    .game-buttons {
        gap: 6px;
    }
    
    .game-buttons button,
    #back-to-lobby,
    #rematch-btn {
        padding: 10px 16px !important;
        font-size: 0.9rem !important;
    }
    
    .timer-badge {
        width: 45px !important;
        height: 45px !important;
    }
    
    .timer-badge #timer {
        font-size: 0.9rem !important;
    }
    
    .card {
        padding: 20px 15px !important;
    }
    
    #login-btn {
        padding: 14px !important;
        font-size: 1.2rem !important;
    }
    
    /* Ad container in footer on mobile */
    .ad-container {
        width: 100%;
        max-width: 320px;
        margin: 5px auto;
    }
    
    .ad-container ins {
        min-height: 50px;
    }
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding: 0;
    width: 100%;
    box-sizing: border-box;
}

h1 {
    font-size: 1.8rem; /* Slightly smaller to fit mobile */
    color: #fff;
    text-shadow: 3px 3px 0px rgba(0,0,0,0.1);
    letter-spacing: 1px;
}

h1.game-logo {
    white-space: nowrap;
    overflow: visible;
    text-overflow: none;
}

.edit-name-btn {
    background: none;
    border: none;
    color: #667eea;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 2px 5px;
    vertical-align: middle;
}

.edit-name-btn:hover {
    color: #764ba2;
}

#change-username-screen .card {
    padding: 20px;
}

#change-username-screen #save-new-username-btn {
    padding: 12px 20px;
    font-size: 1.1rem;
    margin-top: 10px;
}

#change-username-screen #cancel-change-username-btn {
    padding: 10px 20px;
    font-size: 1rem;
    margin-top: 8px;
}

.header-controls {
    display: flex;
    gap: 10px; /* Space between icons */
    flex-shrink: 0;
}

.icon-btn {
    background: white;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    border: none;
    font-size: 1.2rem;
    color: var(--text);
    cursor: pointer;
    box-shadow: 0 4px 0 rgba(0,0,0,0.1);
    transition: all 0.1s;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 0; /* Handled by gap */
}

.icon-btn:active {
    transform: translateY(4px);
    box-shadow: none;
}

/* Cards (Login, Lobby) */
.card {
    background: rgba(255, 255, 255, 0.95);
    padding: 30px;
    border-radius: 25px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.1);
    text-align: center;
    width: 100%;
    box-sizing: border-box;
    margin: auto 0; /* Center vertically in container */
    animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

h2 {
    color: var(--text);
    font-size: 1.8rem;
    margin-bottom: 20px;
}

/* Logo Styling */
.game-logo {
    font-family: 'Super Squad', 'Comic Neue', 'Fredoka One', cursive;
    font-size: 1.6rem;
    color: white;
    -webkit-text-stroke: 1.5px black;
    text-shadow: 3px 3px 0 rgba(0,0,0,0.3);
    margin: 0;
    padding: 8px 10px 8px 10px;
    animation: logoBounce 2s ease-in-out infinite;
    font-weight: 700;
    white-space: nowrap;
    max-width: 100%;
    box-sizing: border-box;
}

@media (max-width: 400px) {
    .game-logo {
        font-size: 1.3rem;
        padding: 6px 8px;
    }
}

@media (max-width: 350px) {
    .game-logo {
        font-size: 1.1rem;
        padding: 5px 6px;
    }
}

/* Overall Font */
@keyframes logoBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 10px;
    margin-bottom: 5px;
}

input {
    width: 100%;
    padding: 15px;
    border: 3px solid #eee;
    border-radius: 15px;
    font-size: 1.2rem;
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    text-align: center;
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.2s;
}

input:focus {
    border-color: var(--secondary);
}

button#login-btn, button#find-match-btn, button#play-now-btn, button#save-new-username-btn {
    background: var(--primary);
    color: white;
    width: 100%;
    padding: 16px 20px;
    font-size: 1.4rem;
    border: none;
    border-radius: 15px;
    margin-top: 15px;
    cursor: pointer;
    box-shadow: 0 6px 0 #D84343;
    transition: all 0.1s;
    font-family: 'Fredoka One', cursive;
}

button:active {
    transform: translateY(6px);
    box-shadow: none !important;
}

button:disabled {
    background: #ccc;
    box-shadow: none;
    transform: translateY(6px);
}

.error {
    color: var(--primary);
    font-weight: 800;
    margin-top: 15px;
}

/* Matchmaking UI */
.matchmaking-section {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 15px;
    border: 1px solid #dee2e6;
    margin-top: 20px;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);
}

.divider {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 15px 0;
    color: #adb5bd;
    font-weight: bold;
    font-size: 0.8rem;
}
.divider::before, .divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid #dee2e6;
}
.divider span { margin: 0 10px; }

.secondary-btn {
    background: var(--secondary);
    color: white;
    padding: 12px 20px;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    cursor: pointer;
    width: 100%;
    box-shadow: 0 4px 0 #3aa8a0;
    transition: transform 0.1s;
}
.secondary-btn:active { transform: translateY(4px); box-shadow: none; }
.secondary-btn:disabled { background: #ccc; box-shadow: none; transform: none; }

#cancel-room-btn {
    background: var(--primary);
    color: white;
    padding: 12px 20px;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    cursor: pointer;
    width: 100%;
    box-shadow: 0 4px 0 #cc5555;
    transition: transform 0.1s;
    margin-top: 10px;
}

#cancel-room-btn:active {
    transform: translateY(4px);
    box-shadow: none;
}

#cancel-room-btn.hidden {
    display: none;
}

.join-room-box {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}
.join-room-box input {
    flex: 1;
    padding: 10px;
    font-size: 1rem;
    margin: 0;
    border: 2px solid #dee2e6;
    border-radius: 10px;
    text-transform: uppercase;
    font-family: 'Courier New', monospace;
    font-weight: bold;
    letter-spacing: 1px;
}
.join-room-box button {
    flex: 0 0 auto;
    width: auto;
    margin: 0;
    padding: 10px 15px;
}

/* Bot UI */
.bot-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#bot-difficulty {
    padding: 12px;
    font-size: 1rem;
    border: 2px solid #dee2e6;
    border-radius: 12px;
    background: white;
    color: var(--text);
    font-family: 'Fredoka One', cursive;
    cursor: pointer;
    outline: none;
    text-align: center;
}

#bot-difficulty:focus {
    border-color: var(--secondary);
}

#play-bot-btn {
    background: linear-gradient(135deg, #6c5ce7, #a29bfe); /* Purple for Bot */
    box-shadow: 0 6px 0 #5f27cd;
    color: white;
    padding: 16px;
    font-size: 1.4rem;
    border: none;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.1s;
}
#play-bot-btn:active { transform: translateY(6px); box-shadow: none; }

/* Room code display */
#room-code-display {
    display: none;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 12px 20px;
    border-radius: 25px;
    font-family: 'Fredoka One', cursive;
    text-align: center;
    margin: 10px auto;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    transition: all 0.3s ease;
    width: fit-content;
    max-width: 90%;
    flex-direction: column;
    align-items: center;
}

#room-code-display.has-code {
    display: flex;
}

#room-code-display:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

#room-code-display:active {
    transform: translateY(0) scale(0.98);
}

#room-code-text {
    font-size: 1.5rem;
    letter-spacing: 2px;
    user-select: all;
}

#copy-hint {
    font-size: 0.8rem;
    opacity: 0.8;
    margin-top: 4px;
}

/* Player Info Bar - White flex box same width as board */
.player-info-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
    padding: 10px;
    border-radius: 15px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 400px;
    margin: 0 auto 12px auto;
    box-sizing: border-box;
}

/* Player Badge - Colored background matching coin color */
.player-badge {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 15px;
    border-radius: 10px;
    transition: all 0.3s ease;
}

.player-badge .player-name {
    font-family: 'Fredoka One', cursive;
    font-size: 0.95rem;
    white-space: nowrap;
}

/* Player 1 - Red Background (matches red coins) */
.player-badge.p1 {
    background: var(--p1-color);
    color: white;
}

.player-badge.p1.active {
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(255, 65, 54, 0.4);
}

/* Player 2 - Yellow Background (matches yellow coins) */
.player-badge.p2 {
    background: var(--p2-color);
    color: #5c4e00;
    text-shadow: 0 1px 0 rgba(255,255,255,0.4);
}

.player-badge.p2.active {
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(255, 220, 0, 0.4);
}

/* Timer Badge */
.timer-badge {
    flex: 0 0 50px;
    height: 50px;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0 8px;
}

.timer-badge .timer-svg {
    position: absolute;
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.timer-badge #timer {
    font-family: 'Fredoka One', cursive;
    font-size: 1.1rem;
    color: var(--text);
    z-index: 2;
}

/* Game Screen */
#game-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    width: 100%;
    padding-top: 10px;
}

.player.active {
    opacity: 1;
    transform: scale(1.1);
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

.player.p1.active {
    background: var(--p1-color);
    color: white;
}

.player.p2.active {
    background: var(--p2-color);
    color: #5c4e00; /* Darker text for Yellow BG */
}

.indicator {
    display: none; /* Hide old indicators */
}

.player .name {
    font-size: 1.1rem;
}

/* Timer Circle Base Styles */
.timer-circle-bg {
    fill: none;
    stroke: #eee;
    stroke-width: 6;
}

.timer-circle-fg {
    fill: none;
    stroke: var(--text);
    stroke-width: 6;
    stroke-linecap: round;
    stroke-dasharray: 163.36;
    stroke-dashoffset: 0;
}

/* Board */
.board-wrapper {
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    aspect-ratio: 7/6;
}

.board {
    background: white;
    padding: 10px;
    border-radius: 20px;
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    grid-template-rows: repeat(6, 1fr);
    gap: 8px;
    height: 100%;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    box-sizing: border-box;
    position: relative; /* Added for win-line positioning */
}

.cell {
    width: 100%;
    height: 100%;
    background: #f4f4f4;
    border-radius: 50%;
    position: relative;
    cursor: pointer;
    overflow: hidden;
    box-shadow: inset 0 3px 5px rgba(0,0,0,0.1);
}

/* TEXTURED CHIPS */
.chip {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    position: absolute;
    top: -100%;
    left: 0;
    box-shadow: 
        inset -2px -2px 5px rgba(0,0,0,0.3), /* Bevel bottom-right */
        inset 2px 2px 5px rgba(255,255,255,0.4), /* Highlight top-left */
        2px 4px 6px rgba(0,0,0,0.2); /* Drop shadow */
}

/* Red Chip Texture */
.chip.p1 { 
    background: #e74c3c; /* Base Red */
    background-image: 
        radial-gradient(circle at 30% 30%, rgba(255,255,255,0.4) 0%, transparent 20%), /* Shine */
        repeating-radial-gradient(
            rgba(0,0,0,0.1) 0, 
            rgba(0,0,0,0.1) 2px, 
            transparent 3px, 
            transparent 6px
        ); /* Concentric Rings */
    border: 2px solid #c0392b;
}

/* Yellow Chip Texture */
.chip.p2 { 
    background: #f1c40f; /* Base Yellow */
    background-image: 
        radial-gradient(circle at 30% 30%, rgba(255,255,255,0.6) 0%, transparent 20%), /* Shine */
        repeating-radial-gradient(
            rgba(200,150,0,0.15) 0, 
            rgba(200,150,0,0.15) 2px, 
            transparent 3px, 
            transparent 6px
        ); /* Concentric Rings */
    border: 2px solid #f39c12;
}

.drop-anim {
    animation: dropIn 0.5s cubic-bezier(0.5, 0, 0.2, 1) forwards;
}

@keyframes dropIn {
    0% { top: -200%; }
    60% { top: 0; }
    80% { top: -20%; }
    100% { top: 0; }
}

#game-status {
    text-align: center;
    font-size: 1.5rem;
    font-family: 'Fredoka One';
    margin-top: 20px;
    min-height: 2rem;
}

/* Leaderboard Modal */
#leaderboard-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(50, 50, 50, 0.95); /* Dark Gray Full Screen */
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
    backdrop-filter: blur(10px);
}

#leaderboard-screen .card {
    max-width: 500px;
    background: white;
}

.lb-card {
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 160px);
    overflow: hidden;
}

.lb-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    position: relative;
}

.lb-list {
    flex: 1;
    overflow-y: auto;
    margin: 0;
    scroll-behavior: smooth;
    padding-right: 5px;
    max-height: calc(100vh - 280px);
}

.lb-list::-webkit-scrollbar {
    width: 6px;
}

.lb-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.lb-list::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

.lb-list::-webkit-scrollbar-thumb:hover {
    background: #555;
}

.lb-item {
    background: #f9f9f9;
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    font-weight: 700;
    transition: all 0.3s;
}

.lb-item-current {
    background: linear-gradient(135deg, #e3f2fd, #bbdefb);
    border: 2px solid #2196f3;
    box-shadow: 0 4px 15px rgba(33, 150, 243, 0.3);
}

.lb-pinned-user {
    background: linear-gradient(135deg, #fff9c4, #fff59d);
    border: 2px solid #fbc02d;
    border-radius: 10px;
    padding: 12px 15px;
    margin-top: 10px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(251, 192, 45, 0.3);
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lb-pinned-user:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(251, 192, 45, 0.4);
}

.lb-pinned-label {
    font-weight: 700;
    color: #f57f17;
    font-size: 0.9rem;
}

.lb-pinned-content {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 700;
}

/* Mobile leaderboard styles */
@media (max-width: 420px) {
    .lb-card {
        max-height: calc(100vh - 200px);
        padding: 12px;
        margin: 8px auto;
    }
    
    .lb-container {
        display: flex;
        flex-direction: column;
        height: 100%;
    }
    
    .lb-list {
        flex: 1;
        overflow-y: auto;
        max-height: calc(100vh - 320px);
        padding-right: 3px;
    }
    
    .lb-item {
        padding: 8px 10px;
        font-size: 0.85rem;
        margin-bottom: 6px;
    }
    
    .lb-pinned-user {
        padding: 8px 10px;
        margin-top: 6px;
        flex-shrink: 0;
    }
    
    .lb-rank {
        width: 20px;
        height: 20px;
        font-size: 0.7rem;
    }
}

@media (max-width: 360px) {
    .lb-card {
        max-height: calc(100vh - 180px);
    }
    
    .lb-list {
        max-height: calc(100vh - 280px);
    }
    
    .lb-item {
        padding: 6px 8px;
        font-size: 0.8rem;
    }
}

/* Winning Line */
.win-line {
    position: absolute;
    background: #fff;
    height: 12px;
    border-radius: 6px;
    z-index: 100;
    box-shadow: 0 0 10px #00FFFF, 0 0 20px #00FFFF; /* Stronger Neon */
    pointer-events: none;
}

/* SVG Overlay for Strike-Through */
.win-line-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 50;
    overflow: visible;
}

/* Board wrapper needs relative positioning for SVG overlay */
.board-wrapper {
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    aspect-ratio: 7/6;
    position: relative; /* Added for SVG overlay positioning */
}

/* Confetti Override */
#confetti-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 3000;
}

.lb-rank {
    background: var(--text);
    color: white;
    width: 25px;
    height: 25px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 0.8rem;
    margin-right: 10px;
}

#lb-back-btn {
    background: #555;
    box-shadow: 0 6px 0 #333;
}

#back-to-lobby {
    background: var(--secondary);
    font-size: 1rem;
    padding: 10px 25px;
    box-shadow: 0 5px 0 #3aa8a0;
    margin-top: 12px;
    width: auto;
    min-width: 160px;
    border-radius: 50px;
    border: none;
    color: white;
    cursor: pointer;
    font-family: 'Fredoka One';
    transition: transform 0.1s;
}

#back-to-lobby:active {
    transform: translateY(4px);
    box-shadow: none;
}

/* Toast Notifications */
#toast-container {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 5000;
}

.toast {
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 15px 25px;
    border-radius: 50px;
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    animation: slideUp 0.3s ease;
}

.toast p { margin: 0 0 10px 0; font-weight: bold; }
.toast-actions { display: flex; gap: 10px; }
.toast-actions button {
    padding: 8px 15px;
    font-size: 0.9rem;
    border-radius: 20px;
    cursor: pointer;
    border: none;
    margin: 0;
}
.toast-actions button:first-child { background: var(--secondary); color: white; }
.toast-actions button:last-child { background: var(--primary); color: white; }

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

#rematch-btn {
    background: var(--primary);
    font-size: 1rem;
    padding: 10px 25px;
    box-shadow: 0 5px 0 #D84343;
    margin-top: 12px;
    width: auto;
    min-width: 140px;
    border-radius: 50px;
    border: none;
    color: white;
    cursor: pointer;
    font-family: 'Fredoka One';
    transition: transform 0.1s;
}

#rematch-btn:active {
    transform: translateY(4px);
    box-shadow: none;
}

/* Utilities */
.hidden { display: none !important; }

/* Responsive Design for Small Screens */
@media (max-width: 400px) {
    .app-container {
        padding: 10px;
        max-height: 100vh;
    }
    
    header {
        margin-bottom: 8px;
    }
    
    h1 {
        font-size: 1.4rem;
    }
    
    .icon-btn {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }
    
    .card {
        padding: 20px 15px;
        border-radius: 20px;
    }
    
    h2 {
        font-size: 1.4rem;
    }
    
    button#login-btn, button#find-match-btn {
        font-size: 1.2rem;
        padding: 14px;
    }
    
    .matchmaking-section {
        padding: 15px 10px;
    }
    
    /* Responsive player info bar */
    .player-info-bar {
        padding: 8px;
        border-radius: 12px;
        margin-bottom: 10px;
        width: calc(100% - 6px) !important;
    }
    
    .player-badge {
        padding: 6px 12px;
    }
    
    .player-badge .player-name {
        font-size: 1rem !important;
    }
    
    .timer-badge {
        flex: 0 0 44px;
        height: 44px;
        margin: 0 6px;
    }
    
    .timer-badge #timer {
        font-size: 1rem;
    }
    
    /* Board is handled by mobile query - only adjust spacing here */
    #game-status {
        font-size: 1.2rem;
        margin-top: 12px;
        margin-bottom: 5px;
    }
    
    #back-to-lobby {
        font-size: 1rem;
        padding: 10px 20px;
        margin: 8px 0 5px 0;
    }
    
    #rematch-btn {
        font-size: 1rem;
        padding: 12px 25px;
    }
    
    .lb-header {
        font-size: 1.2rem;
        padding: 15px;
        margin: -15px -15px 15px -15px;
        border-radius: 12px 12px 0 0;
        width: calc(100% + 30px);
        box-sizing: border-box;
    }
    
    .lb-list {
        max-height: 55vh;
    }
}

@media (max-height: 700px) {
    .card {
        padding: 15px;
        margin: 10px 0;
    }
    
    h2 {
        margin-bottom: 15px;
    }
    
    /* Responsive player info bar for shorter screens */
    .player-info-bar {
        margin-bottom: 8px;
        padding: 6px;
        width: calc(100% - 6px) !important;
    }
    
    .player-badge {
        padding: 5px 8px;
    }
    
    .player-badge .player-name {
        font-size: 1rem !important;
    }
    
    .timer-badge {
        flex: 0 0 38px;
        height: 38px;
    }
    
    .timer-badge #timer {
        font-size: 0.9rem;
    }
    
    /* Don't override board size */
    #game-status {
        font-size: 1rem;
        margin-top: 8px;
        min-height: 1.5rem;
    }
    
    .board-wrapper {
        max-width: 320px;
    }
}

@media (max-width: 360px) {
    /* Board handled by mobile query - only adjust spacing */
    .player-info-bar {
        padding: 5px;
        border-radius: 10px;
        margin-bottom: 6px;
    }
    
    .player-badge {
        padding: 4px 6px;
    }
    
    .player-badge .player-name {
        font-size: 0.9rem !important;
    }
    
    .timer-badge {
        flex: 0 0 34px;
        height: 34px;
        margin: 0 4px;
    }
    
    .timer-badge #timer {
        font-size: 0.8rem;
    }
}

/* Animations */
@keyframes drawSVGLine {
    to { stroke-dashoffset: 0; }
}

/* Leaderboard Card */
.lb-card {
    background: white;
}

.lb-header {
    background: linear-gradient(135deg, #FFD54F, #FFB300);
    color: #5D4037;
    padding: 20px;
    border-radius: 15px 15px 0 0;
    font-family: 'Fredoka One', cursive;
    font-size: 1.5rem;
    text-align: center;
    margin: -20px -20px 20px -20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: 0 4px 15px rgba(255, 179, 0, 0.3);
    width: calc(100% + 40px);
    box-sizing: border-box;
}

.lb-header i {
    font-size: 1.8rem;
}

#lb-back-btn {
    margin-top: 15px;
    background: #FFD54F;
    box-shadow: 0 4px 0 #FFB300;
    color: #5D4037;
}

#lb-back-btn:active {
    transform: translateY(4px);
    box-shadow: none;
}

/* Google Sign-In Button */
.google-btn {
    background: white;
    color: #757575;
    width: 100%;
    padding: 14px 25px;
    border: 2px solid #ddd;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-sizing: border-box;
}

.google-btn:hover {
    background: #f8f8f8;
    border-color: #ccc;
    transform: translateY(-2px);
}

.google-btn i {
    font-size: 1.3rem;
}

/* App Footer - Sticky at bottom */
.app-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    padding: 10px 15px 15px;
    text-align: center;
    z-index: 50;
    background: linear-gradient(to top, rgba(255,213,79,0.95) 0%, rgba(255,213,79,0) 100%);
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 15px;
}

.app-footer .footer-link {
    color: var(--text);
    text-decoration: none;
    font-weight: 700;
    font-size: 0.9rem;
    transition: color 0.3s;
    font-family: 'Fredoka One', cursive;
    background: white;
    padding: 10px 25px;
    border-radius: 25px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.app-footer .footer-link:hover {
    transform: translateY(-3px);
    color: var(--primary);
    box-shadow: 0 6px 20px rgba(0,0,0,0.15);
}

.footer-divider {
    display: none;
}

/* Page Styles - About & Contact (Transparent, Centered, Sticky Footer) */
.page-wrapper {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    padding: 20px;
    box-sizing: border-box;
}
}

.back-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 15px rgba(0,0,0,0.2);
}

.page-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
    padding-top: 60px;
}

.page-title {
    font-family: 'Fredoka One', cursive;
    font-size: 2.5rem;
    color: var(--text);
    margin-bottom: 25px;
    text-shadow: 3px 3px 0 #fff;
    text-align: center;
}

.about-section, .contact-section {
    width: 100%;
    text-align: center;
}

.about-icon, .contact-icon {
    width: 90px;
    height: 90px;
    background: linear-gradient(135deg, var(--primary), #FF8A65);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    box-shadow: 0 8px 20px rgba(255, 65, 54, 0.35);
}

.about-icon i, .contact-icon i {
    font-size: 2.8rem;
    color: white;
}

.about-section h2, .contact-section h2 {
    font-family: 'Fredoka One', cursive;
    color: var(--text);
    margin-bottom: 10px;
    font-size: 1.5rem;
}

.connect-guy-title {
    font-size: 1.8rem !important;
    background: linear-gradient(135deg, var(--primary), #FF8A65);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: none !important;
}

.about-tagline {
    font-size: 1.1rem;
    color: #555;
    margin-bottom: 25px;
    font-weight: 600;
}

.about-content {
    text-align: left;
    background: rgba(255, 255, 255, 0.85);
    border-radius: 20px;
    padding: 25px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.1);
}

.about-content p {
    margin-bottom: 15px;
    line-height: 1.6;
    color: #444;
}

.about-content h3 {
    font-family: 'Fredoka One', cursive;
    color: var(--primary);
    margin: 25px 0 15px;
    font-size: 1.3rem;
}

.feature-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.feature-list li {
    padding: 12px 0;
    border-bottom: 1px solid rgba(0,0,0,0.08);
    display: flex;
    align-items: center;
    gap: 12px;
    color: #444;
}

.feature-list li:last-child {
    border-bottom: none;
}

.feature-list li i {
    color: var(--primary);
    font-size: 1.2rem;
    width: 25px;
}

.social-link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 20px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 12px;
}

.social-link i {
    font-size: 1.6rem;
    color: #E1306C;
}

.social-link a {
    color: var(--text);
    text-decoration: none;
    font-weight: 700;
    font-size: 1.1rem;
}

.contact-intro {
    font-size: 1.1rem;
    color: #555;
    margin-bottom: 30px;
    font-weight: 600;
}

.contact-methods {
    display: grid;
    gap: 20px;
    margin-bottom: 30px;
}

.contact-card {
    background: rgba(255, 255, 255, 0.85);
    border-radius: 18px;
    padding: 25px;
    text-align: center;
    box-shadow: 0 6px 20px rgba(0,0,0,0.08);
}

.contact-card-icon {
    width: 65px;
    height: 65px;
    background: linear-gradient(135deg, var(--secondary), #45B7AA);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 15px;
}

.contact-card-icon i {
    font-size: 1.6rem;
    color: white;
}

.contact-card h3 {
    font-family: 'Fredoka One', cursive;
    color: var(--text);
    margin: 0 0 8px;
    font-size: 1.2rem;
}

.contact-card p {
    color: #666;
    font-size: 0.9rem;
    margin: 0 0 10px;
}

.contact-link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 700;
}

.contact-info {
    color: var(--secondary);
    font-weight: 600;
    font-size: 0.9rem;
}

.contact-note {
    background: rgba(255, 243, 224, 0.9);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    align-items: flex-start;
    gap: 15px;
    text-align: left;
}

.contact-note i {
    color: #FF9800;
    font-size: 1.3rem;
    margin-top: 3px;
}

.contact-note p {
    margin: 0;
    color: #555;
    font-size: 0.95rem;
    line-height: 1.5;
}

/* Page Footer */
.page-footer {
    position: relative;
    width: 100%;
    padding: 30px 20px 20px;
    text-align: center;
    z-index: 50;
}

.page-footer .footer-link {
    display: inline-block;
    background: white;
    padding: 15px 40px;
    border-radius: 30px;
    color: var(--text);
    text-decoration: none;
    font-weight: 700;
    font-size: 1.1rem;
    box-shadow: 0 6px 20px rgba(0,0,0,0.15);
    transition: all 0.3s;
    font-family: 'Fredoka One', cursive;
}

.page-footer .footer-link:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 8px 25px rgba(0,0,0,0.2);
    color: var(--primary);
}

.copyright {
    margin-top: 20px;
    color: #666;
    font-size: 0.85rem;
    font-weight: 600;
}

/* Back Button Styled */
.back-btn {
    position: fixed;
    top: 20px;
    left: 20px;
    background: white;
    border: none;
    width: 50px;
    height: 50px;
    border-radius: 15px;
    font-size: 1.3rem;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(0,0,0,0.2);
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    color: var(--text);
}

.back-btn:hover {
    transform: translateY(-3px) scale(1.1);
    box-shadow: 0 10px 30px rgba(0,0,0,0.25);
    color: var(--primary);
}

.back-btn:active {
    transform: scale(0.95);
}

/* Mobile Footer Styles - Plain text links */
@media (max-width: 420px) {
    .app-footer {
        padding: 10px 15px;
        gap: 20px;
        background: transparent;
    }
    
    .app-footer .footer-link {
        font-size: 0.85rem;
        padding: 0;
        background: transparent;
        box-shadow: none;
        color: #000;
        font-weight: 600;
    }
    
    .app-footer .footer-link:hover {
        color: var(--primary);
        transform: none;
        box-shadow: none;
    }
}

@media (max-width: 360px) {
    .app-footer {
        gap: 15px;
    }
    
    .app-footer .footer-link {
        font-size: 0.8rem;
    }
}

@media (max-width: 320px) {
    .app-footer {
        gap: 12px;
        flex-wrap: wrap;
    }
    
    .app-footer .footer-link {
        font-size: 0.75rem;
    }
}

/* Page Footer Mobile Styles */
@media (max-width: 420px) {
    .page-footer {
        padding: 20px 15px 15px;
    }
    
    .page-footer .footer-link {
        padding: 12px 30px;
        font-size: 1rem;
    }
}

@media (max-width: 360px) {
    .page-footer .footer-link {
        padding: 10px 25px;
        font-size: 0.9rem;
    }
    
    .copyright {
        font-size: 0.75rem;
    }
}

/* Center page footer links */
.page-footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.page-footer .footer-link {
    margin: 0 auto;
}

/* Privacy Policy Page Styles */
.privacy-section {
    width: 100%;
    text-align: center;
}

.privacy-icon {
    width: 90px;
    height: 90px;
    background: linear-gradient(135deg, var(--secondary), #26A69A);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    box-shadow: 0 8px 20px rgba(78, 205, 196, 0.35);
}

.privacy-icon i {
    font-size: 2.8rem;
    color: white;
}

.privacy-tagline {
    font-size: 1.1rem;
    color: #555;
    margin-bottom: 25px;
    font-weight: 600;
}

.privacy-section .about-content h3 {
    color: var(--secondary);
    margin-top: 25px;
    margin-bottom: 12px;
    font-size: 1.3rem;
}

.privacy-section .about-content p {
    margin-bottom: 15px;
    line-height: 1.7;
    color: #444;
}

.privacy-section .about-content ul {
    text-align: left;
    margin-left: 0;
    padding-left: 0;
    list-style: none;
}

.privacy-section .about-content ul li {
    margin-bottom: 12px;
    padding-left: 30px;
    position: relative;
}

.privacy-section .about-content ul li i {
    position: absolute;
    left: 0;
    color: var(--secondary);
    width: 20px;
    text-align: center;
}

/* Page footer with multiple links */
.page-footer {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 15px;
    padding: 30px 20px 20px;
    width: 100%;
    box-sizing: border-box;
}

.page-footer .footer-link {
    margin: 0;
}

.page-footer .copyright {
    width: 100%;
    text-align: center;
    margin-top: 15px;
}

@media (max-width: 420px) {
    .page-footer {
        gap: 20px;
        padding: 20px 15px 15px;
        background: transparent;
        justify-content: center;
        align-items: center;
    }
    
    .page-footer .footer-link {
        padding: 0;
        font-size: 0.9rem;
        background: transparent;
        box-shadow: none;
        color: #000;
        font-weight: 600;
        margin: 0;
    }
    
    .page-footer .footer-link:hover {
        color: var(--primary);
        transform: none;
        box-shadow: none;
    }
}

@media (max-width: 360px) {
    .page-footer {
        gap: 15px;
        padding: 20px 10px 15px;
    }
    
    .page-footer .footer-link {
        font-size: 0.85rem;
    }
}

@media (max-width: 320px) {
    .page-footer {
        gap: 12px;
        padding: 20px 5px 15px;
    }
    
    .page-footer .footer-link {
        font-size: 0.8rem;
    }
}
