:root {
    --bg-primary: #1a1210;
    --bg-secondary: #2c1f18;
    --bg-card: #3a2a1f;
    --text-primary: #f0e6d6;
    --text-secondary: #b8a490;
    --accent-primary: #d4a574;
    --accent-hover: #e0b888;
    --accent-danger: #e74c3c;
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    --radius: 12px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100dvh;
    user-select: none;
    -webkit-user-select: none;
    overflow: hidden;
}

#app {
    width: 100vw;
    height: 100dvh;
    position: relative;
}

/* Screens */
.screen {
    position: absolute;
    inset: 0;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.screen.active {
    display: flex;
}

/* Main Menu */
.menu-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 32px;
    padding: 24px;
}

.logo {
    text-align: center;
}

.logo-stones {
    display: flex;
    gap: 6px;
    justify-content: center;
    margin-bottom: 16px;
}

.logo-stones span {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: inline-block;
}

.stone-black {
    background: radial-gradient(circle at 35% 35%, #555, #111);
    box-shadow: 1px 1px 3px rgba(0,0,0,0.5);
}

.stone-white {
    background: radial-gradient(circle at 35% 35%, #fff, #ccc);
    box-shadow: 1px 1px 3px rgba(0,0,0,0.3);
    border: 1px solid rgba(0,0,0,0.1);
}

.logo h1 {
    font-size: 42px;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--accent-primary);
}

.tagline {
    font-size: 16px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Buttons */
.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 260px;
}

.btn {
    padding: 14px 24px;
    border: none;
    border-radius: var(--radius);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.btn-primary {
    background: var(--accent-primary);
    color: var(--bg-primary);
}

.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: #4a3a2f;
    transform: translateY(-1px);
}

.btn-tertiary {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--bg-card);
}

.btn-tertiary:hover {
    border-color: var(--text-secondary);
    color: var(--text-primary);
}

.btn-large {
    padding: 18px 24px;
    font-size: 18px;
}

.btn-control {
    background: var(--bg-card);
    color: var(--text-secondary);
    padding: 10px 20px;
    font-size: 14px;
}

.btn-control:hover {
    background: #4a3a2f;
    color: var(--text-primary);
}

.btn-back {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 8px;
    transition: all 0.2s;
    font-family: inherit;
}

.btn-back:hover {
    color: var(--text-primary);
    background: var(--bg-card);
}

/* Stats Bar */
.stats-bar {
    display: flex;
    gap: 32px;
    padding: 16px 24px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
}

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

.stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stat-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--accent-primary);
}

/* How to Play */
.info-container {
    max-width: 400px;
    padding: 24px;
}

.info-container h2 {
    font-size: 28px;
    margin: 16px 0 24px;
    color: var(--accent-primary);
}

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

.rule-item {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

.rule-num {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent-primary);
    color: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}

.rule-item p {
    color: var(--text-secondary);
    line-height: 1.5;
    font-size: 15px;
}

/* Game Screen */
.game-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    width: 100%;
    max-width: 580px;
}

.turn-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
    font-weight: 600;
}

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

.stone-indicator.black {
    background: radial-gradient(circle at 35% 35%, #555, #111);
}

.stone-indicator.white {
    background: radial-gradient(circle at 35% 35%, #fff, #ccc);
    border: 1px solid rgba(255,255,255,0.2);
}

.stone-indicator.thinking {
    animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.mode-badge {
    font-size: 12px;
    padding: 4px 10px;
    background: var(--bg-card);
    border-radius: 20px;
    color: var(--text-secondary);
}

.canvas-container {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    width: 100%;
    max-width: 580px;
    max-height: calc(100dvh - 120px);
    padding: 0 8px;
    min-height: 0;
}

#game-canvas {
    border-radius: 8px;
    box-shadow: var(--shadow);
    cursor: pointer;
}

.game-controls {
    display: flex;
    gap: 12px;
    padding: 12px 16px;
}

/* Modals */
.modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal.active {
    display: flex;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: var(--bg-secondary);
    padding: 32px;
    border-radius: 16px;
    text-align: center;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
    min-width: 280px;
}

.modal-content h2 {
    font-size: 26px;
    margin-bottom: 12px;
    color: var(--accent-primary);
}

.modal-content p {
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.gameover-moves {
    font-size: 14px;
    margin-bottom: 24px !important;
}

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

.modal-buttons .btn {
    min-width: 100px;
}

/* Online Lobby */
.lobby-sections {
    display: flex;
    flex-direction: column;
    gap: 24px;
    margin-top: 24px;
}

.lobby-section {
    background: var(--bg-secondary);
    padding: 20px;
    border-radius: var(--radius);
}

.lobby-section h3 {
    font-size: 18px;
    color: var(--accent-primary);
    margin-bottom: 8px;
}

.lobby-desc {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 12px;
    line-height: 1.4;
}

.lobby-divider {
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
}

.code-input-row {
    display: flex;
    gap: 10px;
}

.code-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid var(--bg-card);
    border-radius: var(--radius);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 6px;
    text-align: center;
    text-transform: uppercase;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}

.code-input:focus {
    border-color: var(--accent-primary);
}

.code-input::placeholder {
    color: var(--text-secondary);
    opacity: 0.4;
    letter-spacing: 6px;
}

.error-text {
    color: var(--accent-danger);
    font-size: 13px;
    min-height: 18px;
    margin-top: 8px;
}

.room-code-display {
    font-size: 48px;
    font-weight: 700;
    letter-spacing: 12px;
    color: var(--accent-primary);
    padding: 20px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    margin: 16px 0;
}

/* Responsive */
@media (max-width: 480px) {
    .menu-container {
        gap: 24px;
        padding: 16px;
    }

    .logo h1 {
        font-size: 32px;
    }

    .logo-stones span {
        width: 22px;
        height: 22px;
    }

    .menu-buttons {
        width: 100%;
        max-width: 260px;
    }

    .btn {
        padding: 12px 20px;
        font-size: 15px;
    }

    .btn-large {
        padding: 14px 20px;
        font-size: 16px;
    }

    .stats-bar {
        gap: 20px;
        padding: 12px 20px;
    }

    .stat-value {
        font-size: 18px;
    }

    .game-header {
        padding: 8px 12px;
    }

    .canvas-container {
        max-height: calc(100dvh - 100px);
        padding: 0 4px;
    }

    .game-controls {
        padding: 8px 12px;
    }

    .btn-control {
        padding: 8px 14px;
        font-size: 13px;
    }

    .info-container {
        max-width: 100%;
        padding: 16px;
    }

    .room-code-display {
        font-size: 36px;
        letter-spacing: 8px;
        padding: 14px;
    }

    .modal-content {
        padding: 24px;
        margin: 16px;
        min-width: auto;
    }
}
