* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    background-color: #f5f5f5;
    color: #333;
    overflow: hidden;
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
}

.screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: white;
    z-index: 100;
    overflow-y: auto;
}
.screen.hidden {
    display: none !important; /* Force hiding */
}
.hidden {
    display: none !important;
}

/* Auth Screen */
.auth-container {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    text-align: center;
    max-width: 400px;
    width: 100%;
}

.auth-container h2 {
    margin-bottom: 10px;
    color: #2481cc;
}

.auth-container p {
    margin-bottom: 20px;
    color: #666;
}

#nickname-input {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    margin-bottom: 15px;
    font-size: 16px;
}

/* Buttons */
.btn-primary, .btn-secondary, .btn-danger, .btn-menu {
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    margin: 5px 0;
    width: 100%;
}

.btn-primary {
    background-color: #2481cc;
    color: white;
}

.btn-primary:hover {
    background-color: #1c6cb7;
}

.btn-secondary {
    background-color: #e9ecef;
    color: #333;
}

.btn-secondary:hover {
    background-color: #dee2e6;
}

.btn-danger {
    background-color: #dc3545;
    color: white;
}

.btn-danger:hover {
    background-color: #c82333;
}

.btn-menu {
    background-color: white;
    color: #2481cc;
    border: 1px solid #2481cc;
}

.btn-menu:hover {
    background-color: #f0f7ff;
}

/* Main Menu */
.menu-container {
    text-align: center;
    max-width: 400px;
    width: 100%;
}

.menu-container h2 {
    margin-bottom: 30px;
    color: #2481cc;
    font-size: 28px;
}

.btn-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Game Screen */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 500px;
    margin-bottom: 20px;
}

.player-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: white;
    padding: 10px 15px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    min-width: 100px;
}

.vs-text {
    font-weight: bold;
    color: #666;
}

.game-board {
    width: 100%;
    max-width: 500px;
    aspect-ratio: 1 / 1;
    margin-bottom: 20px;
}

.board-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 8px;
    width: 100%;
    height: 100%;
    background-color: #2481cc;
    padding: 8px;
    border-radius: 12px;
}

.cell {
    background-color: white;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 2rem;
    font-weight: bold;
    transition: all 0.2s;
}

.cell:hover {
    background-color: #f8f9fa;
}

.cell.x {
    color: #ff6b6b;
}

.cell.o {
    color: #4ecdc4;
}

.cell.player1 {
    color: #4ecdc4; /* Color for X */
}

.cell.player2 {
    color: #ff6b6b; /* Color for O */
}

.game-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    width: 100%;
    max-width: 500px;
}

.stones-count {
    font-weight: bold;
    margin-bottom: 10px;
}

/* Profile Screen */
.profile-container {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    max-width: 500px;
    width: 100%;
    overflow-y: auto;
    max-height: 90vh;
}

.profile-info {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
}

.avatar-container {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    overflow: hidden;
    border: 3px solid #2481cc;
}

.avatar-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-details {
    flex: 1;
}

.profile-input {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-bottom: 10px;
    font-size: 16px;
}

.skin-selection {
    margin-bottom: 20px;
}

.skins-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-top: 10px;
}

.skin-item {
    border: 2px solid #ddd;
    border-radius: 8px;
    padding: 10px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.skin-item:hover {
    border-color: #2481cc;
}

.skin-item.selected {
    border-color: #2481cc;
    background-color: #f0f7ff;
}

.skin-item .skin-preview {
    font-size: 24px;
    margin-bottom: 5px;
}

.skin-item .skin-price {
    font-size: 12px;
    color: #666;
}

.profile-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Leaderboard Screen */
.leaderboard-container {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    max-width: 500px;
    width: 100%;
    overflow-y: auto;
    max-height: 90vh;
}

.leaderboard-tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 20px;
}

.tab-btn {
    padding: 8px 15px;
    border: 1px solid #ddd;
    background: white;
    border-radius: 4px;
    cursor: pointer;
}

.tab-btn.active {
    background-color: #2481cc;
    color: white;
    border-color: #2481cc;
}

.leaderboard-list {
    margin-bottom: 20px;
}

.leaderboard-item {
    display: flex;
    justify-content: space-between;
    padding: 10px;
    border-bottom: 1px solid #eee;
}

.leaderboard-item:first-child {
    font-weight: bold;
    background-color: #fff9e6;
}

.leaderboard-rank {
    font-weight: bold;
    width: 30px;
}

.leaderboard-name {
    flex: 1;
}

.leaderboard-score {
    font-weight: bold;
    color: #2481cc;
}

/* Admin Screen */
.admin-container {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    max-width: 800px;
    width: 100%;
    overflow-y: auto;
    max-height: 90vh;
}

.admin-tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 20px;
    overflow-x: auto;
}

.admin-tab-btn {
    padding: 8px 15px;
    border: 1px solid #ddd;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    white-space: nowrap;
}

.admin-tab-btn.active {
    background-color: #2481cc;
    color: white;
    border-color: #2481cc;
}

.admin-tab-content {
    margin-bottom: 20px;
}

.broadcast-form textarea {
    width: 100%;
    height: 100px;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-bottom: 10px;
    resize: vertical;
}

.search-box {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.search-box input {
    flex: 1;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.user-item, .admin-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    border-bottom: 1px solid #eee;
}

.user-actions, .admin-actions {
    display: flex;
    gap: 5px;
}

.setting-item {
    margin-bottom: 15px;
}

.setting-item label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
}

.setting-item input {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

/* Waiting Screen */
.waiting-container {
    background: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    text-align: center;
    max-width: 400px;
    width: 100%;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #2481cc;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive adjustments */
@media (max-width: 480px) {
    .game-header {
        flex-direction: column;
        gap: 10px;
    }
    
    .profile-info {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
    
    .admin-tabs {
        flex-wrap: wrap;
    }
}

/* Animation for game results */
@keyframes celebrate {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.win-animation {
    animation: celebrate 0.5s ease-in-out 3;
}

.admin-only {
    display: none;
}
.admin-only:not(.hidden) {
    display: block;
}
.show-admin .admin-only {
    display: block;
}
/* Channel Verification Popup */
.channel-verification-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.channel-verification-content {
    background: white;
    padding: 20px;
    border-radius: 12px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.channel-verification-content h3 {
    margin-bottom: 15px;
    color: #2481cc;
}

.channel-list {
    margin: 15px 0;
}

.channel-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px;
    border-bottom: 1px solid #eee;
}

.channel-name {
    flex: 1;
    font-weight: 500;
}

.join-channel-btn, .verify-channel-btn {
    margin-left: 10px;
    padding: 8px 12px;
    white-space: nowrap;
}

.btn-success {
    background-color: #28a745;
    color: white;
}

.btn-success:hover {
    background-color: #218838;
}

.continue-btn {
    margin-top: 15px;
    width: 100%;
}

/* Channel Management Styles */
.channels-list {
    margin-bottom: 20px;
}

.channel-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    border-bottom: 1px solid #eee;
}

.channel-info {
    flex: 1;
}

.channel-name {
    font-weight: bold;
}

.channel-id, .channel-link {
    font-size: 12px;
    color: #666;
}

.add-channel-form {
    border-top: 1px solid #eee;
    padding-top: 20px;
}

.form-input {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-bottom: 10px;
}

.channel-required {
    margin-bottom: 10px;
}

.channel-required label {
    margin-left: 5px;
}


/* Add to style.css */
.dark-mode {
    background-color: #1a1a1a;
    color: #ffffff;
}

.dark-mode .auth-container,
.dark-mode .menu-container,
.dark-mode .profile-container,
.dark-mode .leaderboard-container,
.dark-mode .admin-container,
.dark-mode .waiting-container {
    background-color: #2d2d2d;
    color: #ffffff;
}

.dark-mode .btn-menu {
    background-color: #3d3d3d;
    color: #ffffff;
}

.dark-mode .cell {
    background-color: #3d3d3d;
}

/* Add dark mode toggle button */
.dark-mode-toggle {
    position: fixed;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    z-index: 1000;
}

/* Available move indicator */
.cell.available-move {
    background-color: #e8f5e8 !important;
    border: 2px dashed #4caf50;
}



/* Invalid move feedback */
.cell.invalid-move {
    animation: shake 0.5s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}
#waiting-screen {
    background: rgba(255, 255, 255, 0.98);
    z-index: 200; /* Higher than other screens */
}
/* Matchmaking timer */
#waiting-timer {
    font-size: 1.2em;
    margin: 10px 0;
    color: #666;
}

/* Bot suggestion buttons */
.waiting-message {
    text-align: center;
    padding: 20px;
}

.waiting-message button {
    margin: 10px;
    padding: 10px 20px;
}

/* Continue button */
.continue-menu-btn {
    display: block;
    width: 200px;
    margin: 20px auto;
}

/* Admin tabs */
.admin-tab-btn {
    padding: 10px 15px;
    margin: 0 5px;
    border: none;
    background: #f0f0f0;
    cursor: pointer;
}

.admin-tab-btn.active {
    background: #007bff;
    color: white;
}

.admin-tab-content {
    padding: 20px;
    border: 1px solid #ddd;
    margin-top: 10px;
}

/* Matchmaking UI */
.matchmaking-info {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 15px;
    margin: 10px 0;
}

.matchmaking-info p {
    margin: 5px 0;
    color: #6c757d;
}

.queue-stats {
    background: #e7f3ff;
    border: 1px solid #b8d4fd;
    border-radius: 8px;
    padding: 12px;
    margin: 10px 0;
}

.queue-stats p {
    margin: 4px 0;
    color: #0a58ca;
}

#bot-level-selector {
    position: absolute;
    background: white;
    border: 2px solid #ccc;
    border-radius: 10px;
    padding: 10px;
    z-index: 1000;
    margin-top: 5px;
}
.dark-mode #bot-level-selector {
    background: #333;
    border-color: #555;
}
.bot-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 15px 0;
}

.bot-options button {
    padding: 12px;
    font-size: 16px;
}

/* Friend System Styles */
.friends-container, .active-games-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
}

.friends-tabs {
    display: flex;
    margin-bottom: 20px;
    border-bottom: 1px solid #ddd;
}

.friends-tabs .tab-btn {
    flex: 1;
    padding: 10px;
    border: none;
    background: none;
    cursor: pointer;
    border-bottom: 2px solid transparent;
}

.friends-tabs .tab-btn.active {
    border-bottom-color: #007bff;
    color: #007bff;
}

.tab-content {
    margin-bottom: 20px;
}

.friend-item, .request-item, .game-item, .search-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    margin-bottom: 10px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.friend-info, .request-info, .game-info, .search-info {
    flex: 1;
}

.friend-name, .request-name, .search-name {
    font-weight: bold;
    font-size: 16px;
    margin-bottom: 5px;
}

.friend-elo, .request-elo, .search-elo {
    color: #666;
    font-size: 14px;
    margin-bottom: 5px;
}

.friend-status {
    font-size: 12px;
    padding: 2px 6px;
    border-radius: 12px;
    display: inline-block;
}

.friend-status.Online {
    background: #d4edda;
    color: #155724;
}

.friend-status.Offline {
    background: #f8d7da;
    color: #721c24;
}

.friend-status.Recently\ online {
    background: #fff3cd;
    color: #856404;
}

.friend-actions, .request-actions, .game-actions, .search-actions {
    display: flex;
    gap: 10px;
}

.search-box {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.search-box input {
    flex: 1;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.search-results {
    max-height: 400px;
    overflow-y: auto;
}

.game-status {
    font-size: 14px;
    color: #007bff;
    margin-bottom: 5px;
}

.game-time {
    font-size: 12px;
    color: #666;
}

/* Responsive design */
@media (max-width: 768px) {
    .friend-item, .request-item, .game-item, .search-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .friend-actions, .request-actions, .game-actions, .search-actions {
        width: 100%;
        justify-content: space-between;
    }
    
    .search-box {
        flex-direction: column;
    }
}

/* Stars Purchase Section */
.stars-purchase {
    margin: 20px 0;
    padding: 20px;
    background: var(--card-bg);
    border-radius: 10px;
    border: 1px solid var(--border-color);
}

.stars-purchase h3 {
    margin-bottom: 15px;
    color: var(--text-primary);
}

.stars-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    max-width: 400px;
    margin: 0 auto;
}

.stars-option {
    padding: 16px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    text-align: center;
    min-height: 60px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.stars-option:hover {
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.stars-option:active {
    transform: translateY(-1px);
    box-shadow: 0 2px 10px rgba(102, 126, 234, 0.3);
}

@media (max-width: 480px) {
    .stars-options {
        grid-template-columns: repeat(2, 1fr);
    }
}




/*game board*/
.cell.selected {
    border: 3px solid #ff9900;
    box-shadow: 0 0 10px rgba(255, 153, 0, 0.5);
}


.cell.winning {
    animation: pulse-win 1s infinite;
    background-color: rgba(76, 175, 80, 0.3);
}

@keyframes pulse-win {
    0% { background-color: rgba(76, 175, 80, 0.3); }
    50% { background-color: rgba(76, 175, 80, 0.7); }
    100% { background-color: rgba(76, 175, 80, 0.3); }
}

.phase-indicator {
    font-weight: bold;
    margin: 10px 0;
    padding: 5px;
    background: #f0f0f0;
    border-radius: 5px;
}

.dark-mode .phase-indicator {
    background: #333;
}