:root {
    --bg-color: #0d1117;
    --panel-bg: rgba(22, 27, 34, 0.75);
    --panel-border: rgba(255, 255, 255, 0.1);
    --text-color: #e6edf3;
    --primary-color: #58a6ff;
    --primary-hover: #3182ce;
    --accent-color: #238636;
    --board-bg: #161b22; 
    --board-line: #30363d;
}

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

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background-image: 
        radial-gradient(circle at 15% 50%, rgba(88, 166, 255, 0.08), transparent 30%),
        radial-gradient(circle at 85% 30%, rgba(35, 134, 54, 0.08), transparent 30%);
}

#app {
    width: 100%;
    max-width: 800px;
    padding: 20px;
    position: relative;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0 20px 0;
}

h1 {
    font-size: 2.2rem;
    font-weight: 800;
    background: linear-gradient(90deg, #58a6ff, #62b1f6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-right: auto;
}

.status-badge {
    padding: 6px 14px;
    border-radius: 20px;
    background: rgba(46, 160, 67, 0.15);
    color: #3fb950;
    font-size: 0.85rem;
    font-weight: 600;
    border: 1px solid rgba(46, 160, 67, 0.3);
}
.status-badge.offline {
    background: rgba(139, 148, 158, 0.15);
    color: #8b949e;
    border-color: rgba(139, 148, 158, 0.3);
}
.status-badge.error {
    background: rgba(248, 81, 73, 0.15);
    color: #ff7b72;
    border-color: rgba(248, 81, 73, 0.3);
}

.hidden { display: none !important; }

/* Glassmorphism Overlays */
.glass-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(12px);
    z-index: 10;
}

.glass-panel {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 16px;
    padding: 40px;
    width: 90%;
    max-width: 420px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.6);
    text-align: center;
    animation: fadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.glass-panel h2 {
    margin-bottom: 25px;
    font-size: 1.8rem;
    font-weight: 600;
}

.glass-panel h3 {
    margin-bottom: 15px;
    font-size: 1.2rem;
    color: #c9d1d9;
}

.menu-options, .online-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.glass-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--panel-border);
    color: var(--text-color);
    padding: 14px 20px;
    border-radius: 10px;
    font-family: inherit;
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
}

.glass-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.glass-btn.primary {
    background: var(--primary-color);
    color: #0d1117;
    border-color: var(--primary-hover);
}

.glass-btn.primary:hover {
    background: var(--primary-hover);
    box-shadow: 0 6px 20px rgba(88, 166, 255, 0.3);
}

.glass-input {
    background: rgba(0,0,0,0.4);
    border: 1px solid var(--panel-border);
    color: var(--text-color);
    padding: 14px;
    border-radius: 8px;
    font-family: inherit;
    font-size: 1.1rem;
    width: 100%;
    outline: none;
    text-align: center;
    transition: all 0.2s;
}
.glass-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(88, 166, 255, 0.25);
}

.divider {
    margin: 20px 0;
    color: #8b949e;
    font-size: 0.9rem;
    position: relative;
    font-weight: 600;
}
.divider::before, .divider::after {
    content: "";
    position: absolute;
    top: 50%;
    width: 40%;
    height: 1px;
    background: var(--panel-border);
}
.divider::before { left: 0; }
.divider::after { right: 0; }

/* Game View */
#game-view {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 25px;
    flex: 1;
}

.game-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 500px;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 14px;
    padding: 15px 25px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.player-card {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 600;
    opacity: 0.5;
    transition: opacity 0.3s, text-shadow 0.3s;
}
.player-card.active {
    opacity: 1;
    color: var(--primary-color);
    text-shadow: 0 0 10px rgba(88, 166, 255, 0.4);
}

.message-area {
    font-size: 1.2rem;
    font-weight: 800;
    text-align: center;
    flex: 1;
}

/* Board */
.board-container {
    background: #0d1117;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 12px 35px rgba(0,0,0,0.6), inset 0 0 0 1px rgba(255,255,255,0.05);
}

#board {
    display: grid;
    grid-template-columns: repeat(15, 1fr);
    grid-template-rows: repeat(15, 1fr);
    background-color: var(--board-bg);
    border: 1px solid var(--board-line);
    width: min(90vw, 550px);
    height: min(90vw, 550px);
    position: relative;
}

.cell {
    position: relative;
    cursor: pointer;
}
.cell::before, .cell::after {
    content: '';
    position: absolute;
    background-color: var(--board-line);
    z-index: 1;
}
.cell::before { top: 50%; left: 0; right: 0; height: 1px; }
.cell::after { left: 50%; top: 0; bottom: 0; width: 1px; }

/* Grid edges fix */
.cell.col-0::before { left: 50%; }
.cell.col-14::before { right: 50%; }
.cell.row-0::after { top: 50%; }
.cell.row-14::after { bottom: 50%; }

/* Hoshi points (stars) */
.cell.hoshi::after {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    width: 10px; height: 10px;
    background-color: var(--board-line);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    z-index: 2;
}

.stone {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    width: 85%;
    height: 85%;
    border-radius: 50%;
    z-index: 3;
    pointer-events: none;
    box-shadow: 0 4px 8px rgba(0,0,0,0.6);
}
.stone.static {
    position: relative;
    top: auto; left: auto; transform: none; width: 20px; height: 20px; display: inline-block;
}

.stone.black {
    background: radial-gradient(circle at 35% 35%, #555, #000);
    border: 1px solid #111;
    animation: popIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.stone.white {
    background: radial-gradient(circle at 35% 35%, #fff, #b9c1cb);
    border: 1px solid #c9d1d9;
    animation: popIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes popIn {
    to { transform: translate(-50%, -50%) scale(1); }
}

.cell:hover .stone.ghost {
    background: rgba(255, 255, 255, 0.1);
    transform: translate(-50%, -50%) scale(1);
    box-shadow: none;
    border: none;
}
.cell:hover .stone.ghost.black-turn {
    background: rgba(17, 17, 17, 0.4);
}

.game-actions {
    width: 100%;
    display: flex;
    justify-content: center;
}
#btn-menu { max-width: 250px; }
