/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --board-bg: #DEB887;
    --board-line: #4A4A4A;
    --black-stone: #4A4A4A;
    --white-stone: #FFFFFF;
    --page-bg: #FFF8E7;
    --primary-btn: #5B7FD3;
    --danger-btn: #E57373;
    --success-color: #81C784;
    --text-color: #333333;
    --text-light: #666666;
    --border-radius: 12px;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--page-bg);
    color: var(--text-color);
    min-height: 100vh;
    overflow-x: hidden;
}

#app {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    padding: 10px;
    max-width: 600px;
    margin: 0 auto;
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 15px;
    width: 100%;
}

.title {
    font-size: 1.8rem;
    color: var(--text-color);
    margin-bottom: 10px;
    font-weight: 600;
}

.board-sizes {
    display: flex;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}

.size-btn {
    padding: 8px 16px;
    border: 1px solid #ddd;
    background: white;
    color: #666;
    border-radius: 20px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.size-btn:hover {
    background: #f5f5f5;
    border-color: #ccc;
}

.size-btn.active {
    background: #333;
    color: white;
    border-color: #333;
}

/* Score Board */
.score-board {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 400px;
    padding: 15px 20px;
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    margin-bottom: 15px;
}

.player {
    display: flex;
    align-items: center;
    gap: 8px;
}

.stone-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: inline-block;
}

.stone-icon.black {
    background: var(--black-stone);
    box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.stone-icon.white {
    background: var(--white-stone);
    border: 2px solid #333;
    box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.player-label {
    font-weight: 500;
    font-size: 1rem;
}

.score {
    font-size: 1.5rem;
    font-weight: 700;
    min-width: 30px;
    text-align: center;
}

.turn-indicator {
    font-size: 0.85rem;
    color: var(--text-light);
    padding: 5px 10px;
    background: #f5f5f5;
    border-radius: 15px;
}

.turn-indicator.black-turn {
    background: var(--black-stone);
    color: white;
}

.turn-indicator.white-turn {
    background: white;
    border: 2px solid var(--black-stone);
    color: var(--black-stone);
}

/* Board Container */
.board-container {
    width: 100%;
    max-width: 500px;
    aspect-ratio: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 15px;
}

#game-board {
    width: 100%;
    height: 100%;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    touch-action: manipulation;
}

/* Controls */
.controls {
    width: 100%;
    max-width: 400px;
}

.opponent-select {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 15px;
}

.opponent-select label {
    font-weight: 500;
}

.opponent-select select {
    padding: 8px 15px;
    border: 2px solid #ddd;
    border-radius: 20px;
    font-size: 1rem;
    background: white;
    cursor: pointer;
    outline: none;
}

.opponent-select select:focus {
    border-color: var(--primary-btn);
}

.game-buttons {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 25px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    outline: none;
}

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

.btn-undo {
    background: white;
    color: #666;
    border: 1px solid #ddd;
}

.btn-undo:hover {
    background: #f5f5f5;
}

.btn-surrender {
    background: white;
    color: #999;
    border: 1px solid #ddd;
}

.btn-surrender:hover {
    background: #f5f5f5;
}

.btn-new-game {
    background: #333;
    color: white;
    border: 1px solid #333;
}

.btn-new-game:hover {
    background: #444;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: var(--border-radius);
    text-align: center;
    max-width: 350px;
    width: 90%;
    animation: modalIn 0.3s ease;
}

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

.result-title {
    font-size: 1.5rem;
    margin-bottom: 20px;
}

.result-title.win {
    color: var(--success-color);
}

.result-title.lose {
    color: var(--danger-btn);
}

.final-score {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-bottom: 25px;
}

.score-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.5rem;
    font-weight: 700;
}

.vs {
    color: var(--text-light);
    font-size: 1rem;
}

.modal-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
}

.btn-replay {
    background: white;
    color: #666;
    border: 1px solid #ddd;
}

.btn-replay:hover {
    background: #f5f5f5;
}

.btn-play-again {
    background: #333;
    color: white;
    border: 1px solid #333;
}

.btn-play-again:hover {
    background: #444;
}

/* Replay Controls */
.replay-controls {
    width: 100%;
    max-width: 400px;
    background: white;
    padding: 20px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    margin-top: 15px;
}

.replay-controls.hidden {
    display: none;
}

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

.replay-header h3 {
    font-size: 1.1rem;
}

.btn-exit-replay {
    background: white;
    color: #666;
    border: 1px solid #ddd;
    padding: 8px 15px;
    font-size: 0.9rem;
}

.btn-exit-replay:hover {
    background: #f5f5f5;
}

.replay-slider {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.replay-slider input[type="range"] {
    flex: 1;
    height: 8px;
    border-radius: 4px;
    background: #ddd;
    outline: none;
    -webkit-appearance: none;
}

.replay-slider input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #333;
    cursor: pointer;
}

.btn-prev, .btn-next {
    background: white;
    color: #666;
    border: 1px solid #ddd;
    padding: 10px 15px;
    font-size: 0.9rem;
}

.btn-prev:hover, .btn-next:hover {
    background: #f5f5f5;
}

.move-counter {
    text-align: center;
    color: var(--text-light);
    font-size: 0.9rem;
}

/* Footer */
.footer {
    margin-top: auto;
    padding: 15px;
    display: flex;
    justify-content: center;
    gap: 15px;
}

.lang-btn, .sound-btn {
    padding: 8px 15px;
    border: 2px solid #ddd;
    background: white;
    border-radius: 20px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.lang-btn:hover, .sound-btn:hover {
    border-color: var(--primary-btn);
}

.sound-btn.muted {
    opacity: 0.5;
}

.support-btn {
    padding: 8px 15px;
    border: 1px solid #ddd;
    background: white;
    color: #666;
    border-radius: 20px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    font-weight: 500;
}

.support-btn:hover {
    background: #f5f5f5;
}

.feedback-btn {
    padding: 8px 15px;
    border: 1px solid #ddd;
    background: white;
    color: #666;
    border-radius: 20px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    font-weight: 500;
}

.feedback-btn:hover {
    background: #f5f5f5;
}

/* Support Modal */
.support-modal .modal-content {
    max-width: 360px;
    text-align: center;
    position: relative;
}

.support-modal-content {
    padding: 25px 20px;
}

.modal-close {
    position: absolute;
    top: 10px;
    right: 15px;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #999;
    transition: color 0.2s;
}

.modal-close:hover {
    color: #333;
}

.support-title {
    color: #333;
    margin-bottom: 8px;
    font-size: 1.4rem;
}

.support-desc {
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 20px;
}

.qr-codes {
    display: flex;
    justify-content: center;
    gap: 20px;
}

.qr-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.qr-item img {
    width: 180px;
    height: 180px;
    object-fit: cover;
    border-radius: 12px;
    border: 1px solid #ddd;
}

.qr-item span {
    font-size: 0.9rem;
    color: #666;
    font-weight: 500;
}

.qr-tip {
    margin-top: 15px;
    font-size: 0.8rem;
    color: #999;
}

/* Responsive Design */
@media (min-width: 768px) {
    #app {
        padding: 20px;
    }

    .title {
        font-size: 2.2rem;
    }

    .size-btn {
        padding: 10px 20px;
        font-size: 1rem;
    }

    .score-board {
        padding: 20px 30px;
    }

    .board-container {
        max-width: 500px;
    }

    .btn {
        padding: 15px 30px;
    }
}

@media (max-width: 375px) {
    .title {
        font-size: 1.5rem;
    }

    .size-btn {
        padding: 6px 12px;
        font-size: 0.8rem;
    }

    .score-board {
        padding: 10px 15px;
    }

    .btn {
        padding: 10px 18px;
        font-size: 0.9rem;
    }
}

/* Animations */
@keyframes stoneDrop {
    0% {
        transform: translateY(-20px);
        opacity: 0;
    }
    60% {
        transform: translateY(5px);
    }
    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes stoneFadeOut {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(0.5);
    }
}

/* Toast Notification */
.toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    background: rgba(0, 0, 0, 0.85);
    color: white;
    padding: 20px 40px;
    border-radius: 12px;
    font-size: 1.2rem;
    font-weight: 600;
    z-index: 900;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    text-align: center;
    max-width: 80%;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.toast.show {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

.toast.toast-warning {
    background: rgba(230, 126, 34, 0.95);
}

.toast.toast-info {
    background: rgba(52, 152, 219, 0.95);
}

.toast.toast-success {
    background: rgba(46, 204, 113, 0.95);
}

.toast.toast-error {
    background: rgba(231, 76, 60, 0.95);
}

/* Pass indicator in turn display */
.turn-indicator.passed {
    background: #ffeaa7;
    color: #d35400;
    animation: pulse 1s ease-in-out infinite;
}

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

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

.disabled {
    opacity: 0.5;
    pointer-events: none;
}
