* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

:root {
    /* Project standard colors */
    --bg-primary: #0a0a1a;
    --bg-secondary: #12122a;
    --accent-gold: #ffd700;
    --accent-purple: #a855f7;
    --accent-cyan: #00d4ff;
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --text-muted: rgba(255, 255, 255, 0.4);

    /* Go game specific colors */
    --board-color: #dcb35c;
    --board-dark: #c9a24d;
    --line-color: #2a2318;
    --accent: #e6a23c;
    --accent-glow: rgba(230, 162, 60, 0.4);
    --black-stone: #1a1a1a;
    --black-stone-highlight: #3a3a3a;
    --white-stone: #f5f5f0;
    --white-stone-shadow: #c0c0b8;
}

body {
    font-family: 'Noto Sans KR', sans-serif;
    background: linear-gradient(135deg, var(--bg-primary), var(--bg-secondary));
    color: var(--text-primary);
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 20px;
    overflow-x: hidden;
}

/* Background Effects */
.bg-effects {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: -1;
    overflow: hidden;
}

.bg-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.4;
}

.bg-orb:nth-child(1) {
    width: 300px;
    height: 300px;
    background: var(--accent-purple);
    top: -100px;
    right: -100px;
    animation: float 8s ease-in-out infinite;
}

.bg-orb:nth-child(2) {
    width: 250px;
    height: 250px;
    background: var(--accent);
    bottom: -50px;
    left: -50px;
    animation: float 10s ease-in-out infinite reverse;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(30px, -30px); }
}

/* Container */
.container {
    max-width: 500px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

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

.header-top {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 8px;
    position: relative;
}

.back-btn {
    position: absolute;
    left: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.3s;
    min-width: 44px;
    min-height: 44px;
    padding: 8px;
    border-radius: 8px;
}

.back-btn:hover {
    color: var(--accent-gold);
    background: rgba(255, 255, 255, 0.1);
}

.back-btn svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

h1 {
    font-family: 'Black Han Sans', sans-serif;
    font-size: 2rem;
    background: linear-gradient(135deg, var(--accent-gold), #ffaa00);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* Controls */
.controls {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}

.btn {
    padding: 8px 14px;
    font-size: 0.8rem;
    font-weight: 600;
    font-family: 'Jua', sans-serif;
    color: white;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 44px;
}

.btn:hover {
    background: var(--accent);
    border-color: var(--accent);
}

.btn.active {
    background: var(--accent);
    border-color: var(--accent);
}

/* Board Size Selector */
.board-size-selector {
    display: flex;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
}

.size-btn {
    padding: 6px 12px;
    font-size: 0.75rem;
    font-weight: 600;
    font-family: 'Jua', sans-serif;
    color: var(--text-secondary);
    background: rgba(168, 85, 247, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 44px;
}

.size-btn:hover {
    color: var(--text-primary);
    border-color: var(--accent);
}

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

/* Player Info */
.player-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
}

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

.player-stone {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid transparent;
    transition: all 0.3s ease;
}

.player-stone.black {
    background: radial-gradient(ellipse at 30% 30%, var(--black-stone-highlight), var(--black-stone));
    box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.player-stone.white {
    background: radial-gradient(ellipse at 30% 30%, var(--white-stone), var(--white-stone-shadow));
    box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.player.active .player-stone {
    border-color: var(--accent);
    box-shadow: 0 0 15px var(--accent-glow);
}

.player-details {
    display: flex;
    flex-direction: column;
}

.player-name {
    font-size: 0.9rem;
    font-weight: 600;
    font-family: 'Jua', sans-serif;
    color: var(--text-primary);
}

.player-status {
    font-size: 0.7rem;
    color: var(--text-secondary);
}

.player.active .player-status {
    color: var(--accent);
}

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

.capture-count {
    font-size: 1.4rem;
    font-weight: 700;
    font-family: 'Black Han Sans', sans-serif;
    color: var(--text-primary);
}

.capture-label {
    font-size: 0.6rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

/* Board */
.board-wrapper {
    position: relative;
    padding: 12px;
    background: var(--board-color);
    border-radius: 8px;
    box-shadow:
        0 0 0 4px var(--board-dark),
        0 20px 50px rgba(0, 0, 0, 0.5),
        inset 0 0 30px rgba(0, 0, 0, 0.1);
}

.board-container {
    position: relative;
}

.board {
    display: grid;
    position: relative;
    background: var(--board-color);
}

.board-lines {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

.intersection {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.intersection::before {
    content: '';
    position: absolute;
    background: var(--line-color);
    width: 100%;
    height: 1px;
    top: 50%;
    transform: translateY(-50%);
}

.intersection::after {
    content: '';
    position: absolute;
    width: 1px;
    height: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--line-color);
}

/* Edge adjustments */
.intersection.top::after { top: 50%; height: 50%; }
.intersection.bottom::after { bottom: 50%; height: 50%; }
.intersection.left::before { left: 50%; width: 50%; }
.intersection.right::before { right: 50%; width: 50%; }

/* Star points */
.intersection.star-point::before {
    z-index: 0;
}

.star-dot {
    position: absolute;
    width: 6px;
    height: 6px;
    background: var(--line-color);
    border-radius: 50%;
    z-index: 1;
}

/* Stones */
.stone {
    width: 90%;
    height: 90%;
    border-radius: 50%;
    position: relative;
    z-index: 2;
    transition: transform 0.1s ease;
}

.stone.black {
    background: radial-gradient(ellipse at 30% 30%, var(--black-stone-highlight), var(--black-stone));
    box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.stone.white {
    background: radial-gradient(ellipse at 30% 30%, var(--white-stone), var(--white-stone-shadow));
    box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.stone.last-move::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 30%;
    height: 30%;
    border-radius: 50%;
    background: var(--accent);
}

/* Preview stone */
.intersection:hover .preview-stone {
    opacity: 0.5;
}

.preview-stone {
    width: 90%;
    height: 90%;
    border-radius: 50%;
    position: absolute;
    opacity: 0;
    pointer-events: none;
    z-index: 1;
    transition: opacity 0.15s ease;
}

.preview-stone.black {
    background: radial-gradient(ellipse at 30% 30%, var(--black-stone-highlight), var(--black-stone));
}

.preview-stone.white {
    background: radial-gradient(ellipse at 30% 30%, var(--white-stone), var(--white-stone-shadow));
}

/* Status Bar */
.status-bar {
    width: 100%;
    padding: 10px 16px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.status-text {
    font-size: 0.85rem;
    font-weight: 600;
    font-family: 'Jua', sans-serif;
    color: var(--text-primary);
}

.pass-btn {
    padding: 8px 20px;
    font-size: 0.8rem;
    font-weight: 600;
    font-family: 'Jua', sans-serif;
    color: white;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 44px;
}

.pass-btn:hover {
    background: var(--accent);
    border-color: var(--accent);
}

/* Action Buttons in Status Bar */
.action-buttons {
    display: flex;
    gap: 8px;
}

.place-btn {
    padding: 8px 24px;
    font-size: 0.9rem;
    font-weight: 600;
    font-family: 'Jua', sans-serif;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    cursor: not-allowed;
    transition: all 0.2s ease;
    min-height: 44px;
}

.place-btn:disabled {
    opacity: 0.5;
}

.place-btn.active {
    color: var(--bg-primary);
    background: linear-gradient(135deg, var(--accent-gold), #ffaa00);
    border-color: var(--accent-gold);
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(255, 215, 0, 0.4);
    animation: place-btn-pulse 1s ease-in-out infinite;
}

.place-btn.active:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(255, 215, 0, 0.5);
}

@keyframes place-btn-pulse {
    0%, 100% { box-shadow: 0 4px 15px rgba(255, 215, 0, 0.4); }
    50% { box-shadow: 0 4px 25px rgba(255, 215, 0, 0.6); }
}

/* Move counter */
.move-counter {
    font-size: 0.75rem;
    color: var(--text-muted);
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
}

/* Game Over Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    backdrop-filter: blur(8px);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    text-align: center;
    padding: 40px;
    background: linear-gradient(135deg, #1a1a2e, #16162a);
    border-radius: 24px;
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.1),
        0 30px 60px rgba(0, 0, 0, 0.5);
    transform: scale(0.9);
    transition: transform 0.3s ease;
    min-width: 280px;
}

.modal-overlay.active .modal-content {
    transform: scale(1);
}

.modal-icon {
    font-size: 3.5rem;
    margin-bottom: 16px;
}

.modal-title {
    font-size: 1.6rem;
    font-weight: 800;
    font-family: 'Black Han Sans', sans-serif;
    color: var(--accent-gold);
    margin-bottom: 16px;
}

.score-display {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-bottom: 20px;
}

.score-item {
    text-align: center;
}

.score-stone {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    margin: 0 auto 8px;
}

.score-stone.black {
    background: radial-gradient(ellipse at 30% 30%, var(--black-stone-highlight), var(--black-stone));
}

.score-stone.white {
    background: radial-gradient(ellipse at 30% 30%, var(--white-stone), var(--white-stone-shadow));
}

.score-value {
    font-size: 1.8rem;
    font-weight: 700;
    font-family: 'Black Han Sans', sans-serif;
    color: var(--text-primary);
}

.score-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
}

.winner-text {
    font-size: 1rem;
    font-family: 'Jua', sans-serif;
    color: var(--accent);
    margin-bottom: 24px;
}

.modal-btn {
    padding: 14px 40px;
    font-size: 1rem;
    font-weight: 600;
    font-family: 'Jua', sans-serif;
    color: var(--bg-primary);
    background: linear-gradient(135deg, var(--accent-gold), #ffaa00);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 15px rgba(255, 215, 0, 0.3);
}

.modal-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 215, 0, 0.4);
}

/* Game Content */
.game-content {
    width: 100%;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 15px;
    padding: 25px;
    margin-top: 20px;
}

.game-content h2 {
    font-family: 'Jua', sans-serif;
    font-size: 1.2rem;
    color: var(--accent-gold);
    margin-bottom: 10px;
}

.game-content p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.6;
    margin-bottom: 15px;
}

.tip-box {
    background: rgba(255, 215, 0, 0.1);
    border-left: 3px solid var(--accent-gold);
    padding: 15px;
    border-radius: 0 10px 10px 0;
}

.tip-box p {
    margin-bottom: 8px;
}

.tip-box p:last-child {
    margin-bottom: 0;
}

/* Footer */
footer {
    width: 100%;
    text-align: center;
    padding: 20px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-top: 20px;
}

footer a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s;
}

footer a:hover {
    color: var(--accent-gold);
}

/* Responsive */
@media (max-width: 600px) {
    body {
        padding: 12px;
    }

    .container {
        gap: 10px;
    }

    .board-wrapper {
        padding: 8px;
    }

    .player-info {
        padding: 10px 12px;
    }

    .controls {
        gap: 6px;
    }

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

    .game-content {
        display: none;
    }

    footer {
        display: none;
    }
}

@media (max-width: 420px) {
    .header-top {
        flex-direction: column;
        gap: 8px;
    }

    .back-btn {
        position: static;
    }

    .board-size-selector {
        padding: 6px 10px;
    }

    .size-btn {
        padding: 4px 10px;
        font-size: 0.7rem;
    }
}

/* Start Overlay */
.start-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 10, 26, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.start-overlay.active {
    opacity: 1;
    visibility: visible;
}

.start-content {
    text-align: center;
    padding: 40px 30px;
    background: linear-gradient(135deg, var(--bg-secondary), #1a1a2e);
    border-radius: 24px;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.1), 0 30px 60px rgba(0, 0, 0, 0.5);
    max-width: 340px;
    width: 90%;
}

.start-icon {
    font-size: 4rem;
    margin-bottom: 16px;
}

.start-title {
    font-family: 'Black Han Sans', sans-serif;
    font-size: 2rem;
    color: var(--accent-gold);
    margin-bottom: 8px;
}

.start-subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 24px;
}

.mode-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

.mode-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 16px 24px;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Jua', sans-serif;
}

.mode-btn:hover {
    background: rgba(255, 215, 0, 0.1);
    border-color: var(--accent-gold);
    transform: translateY(-2px);
}

.mode-btn.selected {
    background: rgba(255, 215, 0, 0.15);
    border-color: var(--accent-gold);
}

.mode-icon {
    font-size: 1.5rem;
}

.mode-text {
    font-size: 1.1rem;
    color: var(--text-primary);
}

.difficulty-section {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.difficulty-section.hidden {
    display: none;
}

.difficulty-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 12px;
}

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

.difficulty-btn {
    padding: 12px 20px;
    font-size: 0.9rem;
    font-family: 'Jua', sans-serif;
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 80px;
}

.difficulty-btn:hover {
    background: rgba(168, 85, 247, 0.2);
    border-color: var(--accent-purple);
}

.difficulty-btn[data-difficulty="easy"]:hover {
    background: rgba(34, 197, 94, 0.2);
    border-color: #22c55e;
}

.difficulty-btn[data-difficulty="normal"]:hover {
    background: rgba(255, 215, 0, 0.2);
    border-color: var(--accent-gold);
}

.difficulty-btn[data-difficulty="hard"]:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: #ef4444;
}

/* Tap-Confirm Selected State */
.intersection.selected {
    z-index: 10;
}

.intersection.selected::before,
.intersection.selected::after {
    background: var(--accent-gold);
}

.intersection.selected .preview-stone {
    opacity: 0.8 !important;
    animation: pulse-confirm 0.8s ease-in-out infinite;
}

.tap-confirm-hint {
    position: absolute;
    bottom: -20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.6rem;
    color: var(--accent-gold);
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
}

.intersection.selected .tap-confirm-hint {
    opacity: 1;
}

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

/* AI thinking indicator */
.ai-thinking {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    padding: 20px 30px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 150;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s;
}

.ai-thinking.active {
    opacity: 1;
    visibility: visible;
}

.ai-thinking-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: var(--accent-gold);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.ai-thinking-text {
    color: var(--text-primary);
    font-family: 'Jua', sans-serif;
}

/* Continue Modal */
.continue-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.continue-modal.active {
    opacity: 1;
    visibility: visible;
}

.continue-modal-content {
    background: var(--bg-secondary);
    border-radius: 16px;
    padding: 30px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    max-width: 320px;
    width: 90%;
}

.continue-modal-title {
    font-family: 'Black Han Sans', sans-serif;
    font-size: 1.4rem;
    color: var(--text-primary);
    margin-bottom: 15px;
}

.continue-modal-score {
    font-family: 'Jua', sans-serif;
    font-size: 1.1rem;
    color: var(--accent-gold);
    margin-bottom: 25px;
}

.continue-modal-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.continue-btn {
    padding: 14px 30px;
    font-family: 'Jua', sans-serif;
    font-size: 1.1rem;
    font-weight: 600;
    background: linear-gradient(135deg, var(--accent), #9333ea);
    color: #fff;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.continue-btn:hover {
    transform: scale(1.03);
    box-shadow: 0 5px 20px var(--accent-glow);
}

.newgame-btn {
    padding: 12px 25px;
    font-family: 'Jua', sans-serif;
    font-size: 1rem;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-secondary);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.newgame-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: var(--text-primary);
}
