* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #DAA520 0%, #CC5500 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.container {
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    width: 100%;
    max-width: 600px;
    padding: 40px;
    animation: slideIn 0.5s ease-out;
}

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

header {
    text-align: center;
    margin-bottom: 30px;
}

header h1 {
    color: #333;
    font-size: 2.5rem;
    background: linear-gradient(135deg, #DAA520 0%, #CC5500 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.player-setup {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.player-management, .game-setup {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 15px;
}

.player-management-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.btn-close {
    padding: 8px 15px;
    background: #6c757d;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-close:hover {
    background: #5a6268;
    transform: translateY(-1px);
}

.management-link {
    text-align: center;
    color: #DAA520;
    text-decoration: none;
    font-weight: 600;
    padding: 10px;
    display: block;
    transition: all 0.3s ease;
}

.management-link:hover {
    color: #CC5500;
    text-decoration: underline;
}

.management-actions {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 2px solid #e0e0e0;
    text-align: center;
}

.statistics-link {
    color: #DAA520;
    text-decoration: none;
    font-weight: 600;
    font-size: 1.1rem;
    transition: all 0.3s ease;
    display: inline-block;
    padding: 10px 20px;
    border: 2px solid #DAA520;
    border-radius: 8px;
}

.statistics-link:hover {
    color: #CC5500;
    border-color: #CC5500;
    background: rgba(218, 165, 32, 0.1);
}

.password-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    animation: fadeIn 0.3s ease;
}

.password-modal-content {
    background: white;
    border-radius: 15px;
    padding: 30px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    text-align: center;
}

.password-modal-content h3 {
    color: #333;
    font-size: 1.5rem;
    margin-bottom: 20px;
}

.password-input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 1.2rem;
    text-align: center;
    letter-spacing: 4px;
    margin-bottom: 15px;
    transition: all 0.3s ease;
    outline: none;
}

.password-input:focus {
    border-color: #DAA520;
    box-shadow: 0 0 0 3px rgba(218, 165, 32, 0.1);
}

.password-modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 20px;
}

.password-modal-buttons .btn {
    padding: 12px 30px;
    min-width: 100px;
}

.password-error {
    color: #dc3545;
    font-size: 0.9rem;
    margin-top: 10px;
    font-weight: 600;
}

.player-statistics {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 15px;
}

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

.statistics-header .btn-close {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    font-size: 24px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.statistics-header h2 {
    color: #333;
    font-size: 1.5rem;
    margin: 0;
}

.statistics-content {
    background: white;
    border-radius: 10px;
    padding: 20px;
    overflow-x: auto;
}

.stats-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 1rem;
}

.stats-table th {
    background: linear-gradient(135deg, #DAA520 0%, #CC5500 100%);
    color: white;
    padding: 12px;
    text-align: left;
    font-weight: 600;
    border-radius: 5px 5px 0 0;
}

.stats-table td {
    padding: 12px;
    border-bottom: 1px solid #e0e0e0;
}

.stats-table tr:last-child td {
    border-bottom: none;
}

.stats-table tr:hover {
    background: #f8f9fa;
}

.stats-table .computer-row {
    background: #fff3cd;
}

.stats-table .computer-row:hover {
    background: #ffeaa7;
}

.no-stats {
    text-align: center;
    color: #999;
    padding: 40px;
    font-style: italic;
}

.player-management h2, .game-setup h2 {
    color: #333;
    font-size: 1.5rem;
    margin-bottom: 10px;
}

.player-management h3 {
    color: #666;
    font-size: 1.1rem;
    margin-bottom: 10px;
}

.add-player-section {
    margin-bottom: 20px;
}

.input-with-button {
    display: flex;
    gap: 10px;
}

.input-with-button input {
    flex: 1;
}

.input-with-button .btn {
    padding: 12px 20px;
    white-space: nowrap;
}

.players-list-section {
    margin-top: 10px;
}

.players-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 300px;
    overflow-y: auto;
}

.player-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background: white;
    border-radius: 8px;
    border: 2px solid #e0e0e0;
    transition: all 0.3s ease;
}

.player-item:hover {
    border-color: #DAA520;
    box-shadow: 0 2px 8px rgba(218, 165, 32, 0.2);
}

.player-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.player-name {
    font-weight: 600;
    color: #333;
    font-size: 1rem;
}

.player-stats-small {
    font-size: 0.85rem;
    color: #666;
}

.btn-delete {
    padding: 8px 15px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-delete:hover {
    background: #c82333;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(220, 53, 69, 0.3);
}

.computer-badge {
    padding: 6px 12px;
    background: #DAA520;
    color: white;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
}

.no-players {
    text-align: center;
    color: #999;
    padding: 20px;
    font-style: italic;
}

.player-select {
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 1rem;
    background: white;
    transition: all 0.3s ease;
    outline: none;
    cursor: pointer;
}

.player-select:focus {
    border-color: #DAA520;
    box-shadow: 0 0 0 3px rgba(218, 165, 32, 0.1);
}

.input-group:has(#computerDifficulty) {
    margin-top: 10px;
}

.input-group:has(#computerDifficulty) label {
    font-size: 0.95rem;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.input-group label {
    font-weight: 600;
    color: #333;
    font-size: 1rem;
}

.input-group input {
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 1rem;
    transition: all 0.3s ease;
    outline: none;
}

.input-group input:focus {
    border-color: #DAA520;
    box-shadow: 0 0 0 3px rgba(218, 165, 32, 0.1);
}

.btn {
    padding: 15px 30px;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    outline: none;
}

.btn-primary {
    background: linear-gradient(135deg, #DAA520 0%, #CC5500 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(218, 165, 32, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(108, 117, 125, 0.4);
}

.btn-secondary:active {
    transform: translateY(0);
}

.hidden {
    display: none !important;
}

.game-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.game-info {
    text-align: center;
}

.current-player {
    font-size: 1.3rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 15px;
}

.current-player.active-x {
    color: #DAA520;
}

.current-player.active-o {
    color: #CC5500;
}

.player-scores {
    display: flex;
    justify-content: space-around;
    gap: 20px;
    margin-bottom: 10px;
}

.score {
    font-size: 1rem;
    color: #666;
    font-weight: 500;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.stats {
    display: flex;
    gap: 10px;
    font-size: 0.9rem;
    color: #888;
}

.stats span {
    font-weight: 600;
}

.board-container {
    position: relative;
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    aspect-ratio: 1;
}

.game-board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 0;
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 0;
    width: 100%;
    height: 100%;
}

.cell {
    background: white;
    border: none;
    border-radius: 0;
    font-size: 3rem;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1;
    position: relative;
}

/* Wood-like right border using pseudo-element */
.cell:not(:nth-child(3n))::after {
    content: '';
    position: absolute;
    right: -6px;
    top: -1px;
    bottom: -1px;
    width: 12px;
    background: linear-gradient(
        to right,
        #654321 0%,
        #8B4513 15%,
        #A0522D 30%,
        #8B4513 45%,
        #654321 60%,
        #8B4513 75%,
        #A0522D 90%,
        #8B4513 100%
    );
    box-shadow: 
        inset -3px 0 6px rgba(0, 0, 0, 0.4),
        inset 2px 0 3px rgba(255, 255, 255, 0.1),
        2px 0 4px rgba(0, 0, 0, 0.3);
    pointer-events: none;
    z-index: 2;
}

/* Wood-like bottom border using pseudo-element */
.cell:not(:nth-child(n+7))::before {
    content: '';
    position: absolute;
    bottom: -6px;
    left: -1px;
    right: -1px;
    height: 12px;
    background: linear-gradient(
        to bottom,
        #654321 0%,
        #8B4513 15%,
        #A0522D 30%,
        #8B4513 45%,
        #654321 60%,
        #8B4513 75%,
        #A0522D 90%,
        #8B4513 100%
    );
    box-shadow: 
        inset 0 -3px 6px rgba(0, 0, 0, 0.4),
        inset 0 2px 3px rgba(255, 255, 255, 0.1),
        0 2px 4px rgba(0, 0, 0, 0.3);
    pointer-events: none;
    z-index: 2;
}

.cell:nth-child(3n) {
    border-right: none;
}

.cell:nth-child(n+7) {
    border-bottom: none;
}

.cell:hover:not(.disabled) {
    background: #f0f0f0;
    box-shadow: inset 0 0 0 3px rgba(218, 165, 32, 0.3);
}

.cell.disabled {
    cursor: not-allowed;
}

.cell.disabled:hover {
    background: white;
    box-shadow: none;
}

.cell.x {
    color: #DAA520;
}

.cell.o {
    color: #CC5500;
}

.win-line {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

.game-message {
    text-align: center;
    font-size: 1.2rem;
    font-weight: 600;
    min-height: 30px;
    padding: 10px;
    border-radius: 10px;
}

.game-message.winner {
    color: #28a745;
    background: #d4edda;
}

.game-message.clickable-message {
    cursor: pointer;
    transition: transform 0.2s ease;
}

.game-message.clickable-message:hover {
    transform: scale(1.05);
}

.game-message.draw {
    color: #856404;
    background: #fff3cd;
}

.game-difficulty-group {
    text-align: center;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 10px;
    margin: 10px 0;
}

.game-difficulty-group label {
    display: block;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
    font-size: 0.95rem;
}

.game-difficulty-group .player-select {
    max-width: 200px;
    margin: 0 auto;
}

.game-controls {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.game-controls .btn {
    flex: 1;
    max-width: 200px;
}

.btn-disabled {
    opacity: 0.5;
    cursor: not-allowed !important;
    pointer-events: none;
}

.btn-disabled:hover {
    transform: none !important;
    box-shadow: none !important;
}

.meme-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

.meme-popup-content {
    position: relative;
    background: white;
    border-radius: 15px;
    padding: 20px;
    max-width: 90%;
    max-height: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.meme-popup-content img {
    max-width: 100%;
    max-height: 70vh;
    border-radius: 10px;
    display: block;
    margin-bottom: 15px;
}

.meme-message {
    text-align: center;
    font-size: 1.3rem;
    font-weight: 600;
    color: #DAA520;
    padding: 15px;
    background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
    border-radius: 10px;
    border: 2px solid #DAA520;
}

.meme-message span {
    color: #CC5500;
    text-transform: uppercase;
}

.meme-close-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 50%;
    width: 35px;
    height: 35px;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 1001;
}

.meme-close-btn:hover {
    background: #c82333;
    transform: scale(1.1);
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@media (max-width: 600px) {
    .container {
        padding: 20px;
    }

    header h1 {
        font-size: 2rem;
    }

    .cell {
        font-size: 2.5rem;
    }

    .game-controls {
        flex-direction: column;
    }

    .game-controls .btn {
        max-width: 100%;
    }
}
