:root {
    --bg-dark: #0f172a;
    --bg-darker: #020617;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --board-wood: #deae6c;
    --board-wood-dark: #b4854b;
    --board-shadow: rgba(0, 0, 0, 0.4);
    --grid-line: #5a3c1e;
    
    --stone-black: #111;
    --stone-black-shine: #444;
    --stone-white: #f5f5f5;
    --stone-white-edge: #d4d4d4;
    
    --accent-blue: #3b82f6;
    --accent-blue-hover: #2563eb;
    
    --board-size: min(90vw, 600px);
    --cell-size: calc(var(--board-size) / 15);
}

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

.hidden {
    display: none !important;
}

body {
    font-family: 'Outfit', sans-serif;
    background: radial-gradient(circle at center, var(--bg-dark), var(--bg-darker));
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
}

.app-container {
    width: 100%;
    max-width: 800px;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
}

header {
    text-align: center;
    animation: fadeInDown 0.8s ease-out;
}

h1 {
    font-size: 3.5rem;
    font-weight: 800;
    letter-spacing: 0.2em;
    background: linear-gradient(135deg, #fff, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
}

.subtitle {
    color: var(--text-muted);
    font-size: 1.1rem;
    font-weight: 300;
    letter-spacing: 0.05em;
}

.game-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: var(--board-size);
    background: rgba(255, 255, 255, 0.05);
    padding: 1rem 2rem;
    border-radius: 1rem;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    animation: fadeIn 1s ease-out;
}

.player {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    opacity: 0.5;
    transition: all 0.3s ease;
}

.player.active {
    opacity: 1;
    transform: scale(1.05);
}

.stone-preview {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    box-shadow: 2px 2px 5px rgba(0,0,0,0.3);
}

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

.stone-preview.white-stone {
    background: radial-gradient(circle at 30% 30%, #fff, var(--stone-white-edge));
}

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

.status-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    flex-grow: 1;
}

.status-message {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-main);
    text-align: center;
}

.timer-display {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--text-muted);
    min-width: 2.5rem;
    text-align: center;
    transition: color 0.3s ease;
    letter-spacing: 0.05em;
}

.timer-display.urgent {
    color: #ef4444;
    animation: timerUrgent 0.5s infinite alternate;
}

.board-container {
    padding: 1rem;
    background: linear-gradient(145deg, rgba(255,255,255,0.05), rgba(0,0,0,0.2));
    border-radius: 1.5rem;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    border: 1px solid rgba(255,255,255,0.05);
    animation: zoomIn 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.board {
    width: var(--board-size);
    height: var(--board-size);
    background: linear-gradient(135deg, var(--board-wood), var(--board-wood-dark));
    border-radius: 0.5rem;
    box-shadow: inset 0 0 20px rgba(0,0,0,0.3), 0 10px 30px var(--board-shadow);
    position: relative;
    cursor: crosshair;
}

/* Grid Lines */
.board::before {
    content: '';
    position: absolute;
    top: calc(var(--cell-size) / 2);
    left: calc(var(--cell-size) / 2);
    right: calc(var(--cell-size) / 2);
    bottom: calc(var(--cell-size) / 2);
    background-image: 
        linear-gradient(var(--grid-line) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
    background-size: var(--cell-size) var(--cell-size);
    z-index: 1;
}

/* Star points (Hwajeom) */
.star-point {
    position: absolute;
    width: 6px;
    height: 6px;
    background: var(--grid-line);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    z-index: 2;
}

.cell {
    position: absolute;
    width: var(--cell-size);
    height: var(--cell-size);
    z-index: 3;
    display: flex;
    justify-content: center;
    align-items: center;
}

.cell::after {
    content: '';
    width: 80%;
    height: 80%;
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
}

.board[data-turn="black"] .cell:not(.has-stone):hover::after {
    background: radial-gradient(circle at 30% 30%, var(--stone-black-shine), var(--stone-black));
    opacity: 0.3;
}

.board[data-turn="white"] .cell:not(.has-stone):hover::after {
    background: radial-gradient(circle at 30% 30%, #fff, var(--stone-white-edge));
    opacity: 0.4;
}

.stone {
    width: 85%;
    height: 85%;
    border-radius: 50%;
    box-shadow: 2px 3px 5px rgba(0,0,0,0.4), inset -2px -2px 5px rgba(0,0,0,0.2);
    position: absolute;
    z-index: 4;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    animation: placeStone 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.stone.black {
    background: radial-gradient(circle at 30% 30%, var(--stone-black-shine), var(--stone-black));
}

.stone.white {
    background: radial-gradient(circle at 30% 30%, #fff, var(--stone-white-edge));
}

/* Winning indicator */
.stone.winning {
    animation: winPulse 1.5s infinite alternate;
    box-shadow:
        0 0 0 3px rgba(251, 191, 36, 1),
        0 0 12px 4px rgba(251, 191, 36, 0.8),
        0 0 28px 8px rgba(251, 191, 36, 0.4);
}

/* Winning line */
.win-line {
    position: absolute;
    height: 5px;
    background: linear-gradient(90deg, rgba(251,191,36,0.2), rgba(251,191,36,1) 20%, rgba(251,191,36,1) 80%, rgba(251,191,36,0.2));
    border-radius: 3px;
    transform-origin: left center;
    z-index: 10;
    box-shadow: 0 0 8px 3px rgba(251, 191, 36, 0.7), 0 0 20px 6px rgba(251, 191, 36, 0.35);
    animation: winLineAppear 0.35s cubic-bezier(0.22, 1, 0.36, 1) forwards;
    transform-box: fill-box;
}

@keyframes winLineAppear {
    from { clip-path: inset(0 100% 0 0); }
    to   { clip-path: inset(0 0% 0 0); }
}

.controls {
    margin-top: 1rem;
    display: flex;
    gap: 0.75rem;
    animation: fadeInUp 0.8s ease-out;
}

.btn {
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    padding: 0.8rem 2rem;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn.primary {
    background: var(--accent-blue);
    color: white;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.4);
}

.btn.primary:hover {
    background: var(--accent-blue-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.6);
}

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

.btn.large {
    font-size: 1.2rem;
    padding: 1rem 3rem;
}

/* Modals / Overlays */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal {
    background: #1e293b;
    padding: 3rem;
    border-radius: 1.5rem;
    text-align: center;
    border: 1px solid rgba(255,255,255,0.1);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    transform: translateY(0);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.overlay.hidden .modal {
    transform: translateY(50px);
}

.modal h2 {
    font-size: 3rem;
    margin-bottom: 0.5rem;
    background: linear-gradient(to right, #fbbf24, #f59e0b);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.modal p {
    font-size: 1.5rem;
    color: var(--text-muted);
    margin-bottom: 2rem;
}

/* Mode Selection - 완전 독립 스타일 (overlay 클래스 미사용) */
#mode-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(2, 6, 23, 0.92);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

#mode-overlay.hidden {
    display: none;
}

#mode-card {
    background: #1e293b;
    padding: 3rem 4rem;
    border-radius: 1.5rem;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.mode-title {
    font-size: 3rem;
    font-weight: 800;
    letter-spacing: 0.2em;
    background: linear-gradient(135deg, #fff, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
}

.mode-subtitle {
    font-size: 1.1rem;
    color: var(--text-muted);
    margin-bottom: 2.5rem;
}

.mode-buttons {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
}

.mode-btn {
    background: rgba(255, 255, 255, 0.06);
    color: #f8fafc;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 1rem;
    padding: 1.5rem 2rem;
    width: 160px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-family: 'Outfit', sans-serif;
    transition: background 0.2s, border-color 0.2s, transform 0.2s, box-shadow 0.2s;
}

.mode-btn:hover {
    background: rgba(59, 130, 246, 0.25);
    border-color: #3b82f6;
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(59, 130, 246, 0.35);
}

.mode-icon {
    font-size: 2rem;
    line-height: 1;
}

.mode-label {
    font-size: 1.1rem;
    font-weight: 700;
    -webkit-text-fill-color: var(--text-main);
}

.mode-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 400;
    -webkit-text-fill-color: var(--text-muted);
}

/* Game Nav */
.game-nav {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 0.75rem;
    padding: 0.35rem;
    animation: fadeIn 0.6s ease-out;
}
.lang-toggle-btn {
    margin-left: auto;
    background: rgba(255,255,255,0.07);
    border: 1px solid rgba(255,255,255,0.15);
    color: var(--text-muted);
    padding: 0.25rem 0.65rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 700;
    font-family: inherit;
    letter-spacing: 0.03em;
    transition: background 0.2s, color 0.2s;
    white-space: nowrap;
}
.lang-toggle-btn:hover {
    background: rgba(255,255,255,0.15);
    color: var(--text-main);
}
.hub-lang-btn {
    position: absolute;
    top: 1.2rem;
    right: 1.5rem;
    background: rgba(255,255,255,0.07);
    border: 1px solid rgba(255,255,255,0.15);
    color: var(--text-muted);
    padding: 0.3rem 0.75rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 700;
    font-family: inherit;
    transition: background 0.2s, color 0.2s;
}
.hub-lang-btn:hover {
    background: rgba(255,255,255,0.15);
    color: var(--text-main);
}

.game-nav-item {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
    padding: 0.4rem 1rem;
    border-radius: 0.5rem;
    transition: background 0.2s, color 0.2s;
}

.game-nav-item:hover {
    background: rgba(255,255,255,0.08);
    color: var(--text-main);
}

.game-nav-item.active {
    background: var(--accent-blue);
    color: #fff;
}

/* Difficulty buttons */
.difficulty-buttons {
    gap: 0.8rem;
}

.difficulty-buttons .mode-btn {
    width: 110px;
    padding: 1.2rem 1rem;
}

.mode-back-btn {
    margin-top: 1.2rem;
    background: none;
    border: none;
    color: var(--text-muted);
    font-family: 'Outfit', sans-serif;
    font-size: 0.9rem;
    cursor: pointer;
    transition: color 0.2s;
}

.mode-back-btn:hover {
    color: var(--text-main);
}

/* Game How-To section */
.game-how-to {
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.07);
    border-radius: 1rem;
    padding: 1.25rem 1.5rem;
    width: 100%;
    max-width: var(--board-size);
    animation: fadeIn 1s ease-out;
}
.game-how-to h3 {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.7rem;
}
.game-how-to ul { list-style: none; display: flex; flex-direction: column; gap: 0.4rem; }
.game-how-to li {
    font-size: 0.83rem;
    color: var(--text-muted);
    padding-left: 1rem;
    position: relative;
    line-height: 1.55;
}
.game-how-to li::before { content: '▸'; position: absolute; left: 0; color: var(--accent-blue); font-size: 0.7rem; top: 0.22em; }

/* Generic mode overlay for all games */
.game-mode-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(2,6,23,0.92);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}
.game-mode-overlay.hidden { display: none; }
.game-mode-card {
    background: #1e293b;
    padding: 3rem 4rem;
    border-radius: 1.5rem;
    text-align: center;
    border: 1px solid rgba(255,255,255,0.1);
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.5);
}

/* Animations */
@keyframes placeStone {
    0% { transform: translate(-50%, -50%) scale(0); }
    100% { transform: translate(-50%, -50%) scale(1); }
}

@keyframes winPulse {
    0% { box-shadow: 0 0 10px 5px rgba(251, 191, 36, 0.4); }
    100% { box-shadow: 0 0 20px 10px rgba(251, 191, 36, 0.8); }
}

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

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

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

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

@keyframes timerUrgent {
    from { transform: scale(1); }
    to { transform: scale(1.15); }
}

.btn.secondary {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-muted);
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.btn.secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    color: var(--text-main);
    transform: translateY(-2px);
}

.btn-full {
    width: 100%;
    margin-top: 0.5rem;
}

footer {
    color: var(--text-muted);
    font-size: 0.85rem;
    text-align: center;
    animation: fadeIn 1.2s ease-out;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.footer-nav {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.footer-nav a {
    color: var(--accent-blue);
    text-decoration: none;
    font-size: 0.85rem;
    transition: color 0.2s;
}

.footer-nav a:hover {
    color: var(--accent-blue-hover);
}

.footer-sep {
    color: var(--text-muted);
    opacity: 0.5;
}

.footer-copy {
    color: var(--text-muted);
    font-size: 0.8rem;
    opacity: 0.6;
}


/* Responsive */
@media (max-width: 600px) {
    .app-container { padding: 1rem; }
    h1 { font-size: 2.5rem; }
    .game-info { flex-direction: column; gap: 1rem; padding: 1rem; }
    .status-center { order: -1; margin-bottom: 0.5rem; }
    .lang-toggle-btn { margin-left: 0; }
}
