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

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;600;700;900&display=swap');

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

header {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    padding: 1.5rem;
    text-align: center;
    color: white;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    font-weight: 700;
}

header p {
    font-weight: 400;
    opacity: 0.95;
    letter-spacing: 0.5px;
}

main {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.screen {
    display: none;
    background: white;
    border-radius: 20px;
    padding: 2rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 800px;
    width: 100%;
}

.screen.active {
    display: block;
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    justify-content: space-evenly;
    gap: 1rem;
    height: 100%;
}

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

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    color: #667eea;
    font-size: 1.2rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    border: 2px solid rgba(102, 126, 234, 0.3);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.btn-secondary:hover {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    transform: translateY(-3px);
    box-shadow: 0 8px 16px rgba(102, 126, 234, 0.4);
    border-color: #667eea;
}

/* Difficulty Selector Styles */
.difficulty-buttons {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-top: 1rem;
}

.btn-difficulty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.5rem 1rem;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    border: 2px solid transparent;
    transition: all 0.3s ease;
    gap: 0.5rem;
}

.btn-difficulty:hover {
    transform: translateY(-5px);
    border-color: #667eea;
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.3);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.btn-difficulty:hover .difficulty-icon,
.btn-difficulty:hover .difficulty-name,
.btn-difficulty:hover .difficulty-desc {
    color: white;
}

.difficulty-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.difficulty-name {
    font-size: 1.2rem;
    font-weight: 700;
    color: #333;
}

.difficulty-desc {
    font-size: 0.85rem;
    color: #666;
    font-weight: 400;
}

#difficulty-selector h3 {
    text-align: center;
    color: #667eea;
    margin: 1.5rem 0;
    font-size: 1.5rem;
}

#status-bar {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    margin-bottom: 2rem;
    padding: 1rem;
    background: #f5f5f5;
    border-radius: 10px;
    gap: 2rem;
}

.player-info {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.player-label {
    font-size: 1.3rem;
    font-weight: 600;
    color: #667eea;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.5rem;
    white-space: nowrap;
}

.score {
    font-size: 2.5rem;
    font-weight: 700;
    color: #667eea;
}

#turn-indicator {
    font-size: 1.6rem;
    font-weight: 600;
    color: #764ba2;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    padding: 0.5rem 1.5rem;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1), rgba(118, 75, 162, 0.1));
    border-radius: 25px;
    border: 2px solid rgba(118, 75, 162, 0.3);
    text-align: center;
    white-space: nowrap;
    min-width: 280px;
}

#game-board {
    background: linear-gradient(135deg, #8B4513 0%, #A0522D 100%);
    border-radius: 15px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: inset 0 4px 8px rgba(0, 0, 0, 0.3);
    display: flex;
    gap: 2rem;
    align-items: center;
}

.board-container {
    flex: 1;
}

.capture-bowl {
    width: 140px;
    height: 200px;
    background: linear-gradient(135deg, #654321 0%, #3e2723 100%);
    border-radius: 15px;
    box-shadow: inset 0 6px 12px rgba(0, 0, 0, 0.6), 0 4px 8px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem 0.5rem;
    position: relative;
}

.capture-bowl-north {
    background: linear-gradient(135deg, #5a3a2a 0%, #3e2723 100%);
}

.capture-bowl-south {
    background: linear-gradient(135deg, #6b4423 0%, #4a3020 100%);
}

.capture-label {
    font-size: 0.85rem;
    color: #FFD700;
    font-weight: 600;
    text-align: center;
    margin-bottom: 0.5rem;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
    word-break: break-word;
}

.capture-seeds {
    flex: 1;
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    padding: 0.5rem;
    justify-content: center;
    align-content: flex-start;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
}

.capture-seeds::-webkit-scrollbar {
    width: 4px;
}

.capture-seeds::-webkit-scrollbar-thumb {
    background: #8B4513;
    border-radius: 2px;
}

.capture-count {
    font-size: 1.5rem;
    font-weight: 700;
    color: #FFD700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
    margin-top: 0.5rem;
}

.captured-seed {
    width: 8px;
    height: 10px;
    background: radial-gradient(ellipse at 30% 20%, #D2691E, #8B4513, #654321);
    border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
    box-shadow: 0 1px 2px rgba(0,0,0,0.4), inset 0 1px 1px rgba(255,255,255,0.2);
    animation: captureAppear 0.3s ease-out;
}

@keyframes captureAppear {
    0% {
        transform: scale(0) translateY(-20px);
        opacity: 0;
    }
    50% {
        transform: scale(1.2) translateY(-10px);
    }
    100% {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

.board-row {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 1rem;
    margin-bottom: 1rem;
}

.board-row:last-child {
    margin-bottom: 0;
}

.hole {
    aspect-ratio: 1;
    background: radial-gradient(circle, #654321 0%, #3e2723 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: box-shadow 0.3s;
    box-shadow: inset 0 4px 8px rgba(0, 0, 0, 0.5);
    position: relative;
    flex-wrap: wrap;
    padding: 8px;
    overflow: visible;
}

.hole.disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

.hole.playable {
    box-shadow: inset 0 4px 8px rgba(0, 0, 0, 0.5), 0 0 15px rgba(255, 215, 0, 0.7);
}

.hole.opponent-turn {
    box-shadow: inset 0 4px 8px rgba(0, 0, 0, 0.5), 0 0 20px rgba(144, 238, 144, 0.8);
}

.hole.animating {
    animation: seedDrop 0.3s ease-out;
}

.seed {
    position: absolute;
    width: 8px;
    height: 8px;
    background: #FFD700;
    border-radius: 50%;
    pointer-events: none;
    animation: drop 0.5s ease-in forwards;
}

.seed-count {
    font-size: 1.5rem;
    font-weight: 700;
    color: #FFD700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.visual-seed {
    width: 10px;
    height: 12px;
    background: radial-gradient(ellipse at 30% 20%, #D2691E, #8B4513, #654321);
    border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
    margin: 1px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.4), inset 0 1px 1px rgba(255,255,255,0.2);
    position: relative;
    animation: seedAppear 0.3s ease-out;
}

.visual-seed::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 2px;
    height: 2px;
    background: rgba(255,255,255,0.3);
    border-radius: 50%;
}

@keyframes seedAppear {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.seed.animating {
    animation: seedDrop 0.3s ease-out;
}

#seed-hand {
    position: fixed;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 1001;
    transition: top 0.1s, left 0.1s;
}

.seed {
    position: absolute;
    width: 12px;
    height: 12px;
    background: #FFD700;
    border-radius: 50%;
    pointer-events: none;
    transition: top 0.4s ease-out, left 0.4s ease-out;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
    z-index: 1002;
}

.seed.in-hand {
    transition: top 0.5s ease-in-out, left 0.5s ease-in-out;
}

@keyframes grab {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    100% {
        transform: scale(0.5);
        opacity: 0.8;
    }
}

.seed-count {
    font-size: 1.5rem;
    font-weight: bold;
    color: #FFD700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    transition: all 0.3s ease;
}

.seed-count.active-move {
    animation: digitGlow 1s ease-out;
}

.seed-count.ai-move {
    animation: aiDigitGlow 1s ease-out;
}

@keyframes digitGlow {
    0%, 100% {
        color: #FFD700;
        text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    }
    50% {
        color: #87CEEB;
        text-shadow: 0 0 10px rgba(135, 206, 235, 0.6), 2px 2px 4px rgba(0, 0, 0, 0.5);
    }
}

@keyframes aiDigitGlow {
    0%, 100% {
        color: #FFD700;
        text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    }
    50% {
        color: #9370DB;
        text-shadow: 0 0 10px rgba(147, 112, 219, 0.6), 2px 2px 4px rgba(0, 0, 0, 0.5);
    }
}

.game-controls {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    overflow-y: auto;
    padding: 1rem;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    padding: 2rem;
    border-radius: 15px;
    max-width: 500px;
    width: 90%;
    text-align: center;
    margin: auto;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-content h2 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: #667eea;
}

.modal-content .btn {
    min-width: 200px;
    padding: 1rem 2rem;
    font-size: 1.1rem;
}

.rules-content {
    max-width: 600px;
    text-align: left;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
}

.rules-content h2 {
    text-align: center;
    font-size: 2rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    color: #667eea;
}

.rules-section {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 10px;
    border-left: 4px solid #667eea;
}

.rules-section h3 {
    color: #667eea;
    margin-bottom: 0.75rem;
    font-size: 1.2rem;
    font-weight: 600;
}

.rules-section p {
    color: #555;
    line-height: 1.8;
    font-size: 0.95rem;
    font-weight: 400;
}

.rules-content .btn {
    width: 100%;
    margin-top: 1rem;
}

.close-icon {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #999;
    cursor: pointer;
    padding: 0.5rem;
    line-height: 1;
    transition: color 0.2s;
}

.close-icon:hover {
    color: #667eea;
}

#winner-text {
    font-size: 2.5rem;
    font-weight: 900;
    background: linear-gradient(135deg, #FFD700, #FFA500, #FF6347);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 1.5rem 0;
    text-transform: uppercase;
    letter-spacing: 2px;
    animation: victoryPulse 1.5s ease-in-out infinite;
}

#final-scores {
    font-size: 1.5rem;
    font-weight: 700;
    color: #667eea;
    margin: 1rem 0 2rem 0;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
    line-height: 1.6;
}

#game-over-modal .modal-content {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

#game-over-modal .btn {
    width: 100%;
    max-width: 250px;
    margin: 0 auto;
}

@keyframes victoryPulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

#multiplayer-modal .modal-content {
    max-width: 450px;
    padding: 2.5rem;
    max-height: 90vh;
    overflow-y: auto;
}

#qr-code-container {
    text-align: center;
    margin: 1.5rem 0;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 10px;
}

#qr-code {
    display: inline-block;
    padding: 0.5rem;
    background: white;
    border-radius: 8px;
}

#qr-code img {
    display: block;
}

.qr-label {
    margin-top: 0.75rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: #667eea;
}

#multiplayer-modal h2 {
    font-size: 2rem;
    font-weight: 600;
    margin-bottom: 2rem;
}

.share-instruction {
    font-size: 1rem;
    font-weight: 500;
    color: #555;
    margin-bottom: 1rem;
}

#invite-link {
    width: 100%;
    padding: 1rem;
    margin-bottom: 1.5rem;
    border: 2px solid #667eea;
    border-radius: 8px;
    font-size: 0.9rem;
    background: #f8f9fa;
    color: #333;
    text-align: center;
    font-family: 'Inter', monospace;
}

#invite-link:focus {
    outline: none;
    border-color: #764ba2;
    background: #fff;
}

.status-text {
    font-size: 1rem;
    font-weight: 500;
    color: #764ba2;
    margin: 1.5rem 0;
    padding: 1rem;
    background: rgba(118, 75, 162, 0.1);
    border-radius: 8px;
}

#session-create {
    margin-bottom: 1.5rem;
}

#btn-copy-link {
    width: 100%;
    margin-bottom: 0.5rem;
    font-size: 1.05rem;
}

#btn-close-modal {
    width: 100%;
    font-size: 1rem;
}

.hidden {
    display: none;
}

footer {
    background: rgba(0, 0, 0, 0.2);
    color: white;
    text-align: center;
    padding: 1rem;
}

footer p {
    font-weight: 400;
    opacity: 0.95;
    letter-spacing: 0.3px;
}

@media (max-width: 768px) {
    header {
        padding: 0.75rem;
    }

    header h1 {
        font-size: 1.5rem;
        margin-bottom: 0.25rem;
    }

    header p {
        font-size: 0.85rem;
    }

    main {
        padding: 0.5rem;
    }

    .screen {
        padding: 0.75rem;
        border-radius: 15px;
    }

    #status-bar {
        grid-template-columns: 1fr;
        gap: 0.75rem;
        padding: 0.75rem;
        margin-bottom: 1rem;
    }

    .player-label {
        font-size: 0.85rem;
        font-weight: 600;
        letter-spacing: 0.5px;
        margin-bottom: 0.25rem;
    }

    .score {
        font-size: 1.75rem;
    }

    #turn-indicator {
        font-size: 1rem;
        font-weight: 600;
        letter-spacing: 0.5px;
        padding: 0.5rem 1rem;
        border-width: 2px;
        min-width: auto;
        order: -1;
    }

    #game-board {
        flex-direction: column-reverse;
        gap: 0.75rem;
        padding: 0.75rem;
        margin-bottom: 0.75rem;
    }

    .board-container {
        padding: 0 0.5rem;
    }

    .capture-bowl {
        width: 100%;
        height: 60px;
        flex-direction: row;
        border-radius: 40px;
        padding: 0.4rem 0.75rem;
    }

    .capture-label {
        writing-mode: horizontal-tb;
        margin-bottom: 0;
        margin-right: 0.4rem;
        min-width: 70px;
        font-size: 0.75rem;
    }

    .capture-seeds {
        flex-direction: row;
        height: auto;
        max-height: 50px;
        padding: 0.3rem;
    }

    .capture-count {
        margin-top: 0;
        margin-left: 0.4rem;
        font-size: 1rem;
    }

    .board-row {
        gap: 0.3rem;
    }

    .hole {
        min-width: 40px;
        min-height: 40px;
        aspect-ratio: 1;
        padding: 4px;
    }

    .seed-count {
        font-size: 1rem;
        min-width: 2ch;
        text-align: center;
    }

    .board-row {
        width: 100%;
        max-width: 100%;
    }

    .game-controls {
        gap: 0.5rem;
    }

    .btn-secondary {
        font-size: 0.9rem;
        padding: 0.6rem 1rem;
        letter-spacing: 0.5px;
    }

    .difficulty-buttons {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .btn-difficulty {
        padding: 1rem 0.75rem;
    }

    .difficulty-icon {
        font-size: 2rem;
    }

    .difficulty-name {
        font-size: 1rem;
    }

    .difficulty-desc {
        font-size: 0.75rem;
    }
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

@keyframes seedDrop {
    0% {
        transform: scale(1.2);
        box-shadow: 0 0 30px rgba(255, 215, 0, 0.8);
    }
    100% {
        transform: scale(1);
        box-shadow: inset 0 4px 8px rgba(0, 0, 0, 0.5);
    }
}

@keyframes drop {
    0% {
        transform: translateY(-50px) scale(0);
        opacity: 0;
    }
    50% {
        opacity: 1;
    }
    100% {
        transform: translateY(0) scale(1);
        opacity: 0;
    }
}

.hole.active {
    animation: pulse 1s infinite;
}
