#chess-gate {
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: #050505;
    color: #f5f5f0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    font-family: 'DotGothic16', 'JetBrains Mono', monospace;
    text-align: center;
    padding: 1.5rem;
    transition: opacity 0.6s ease;
}

#chess-gate.gate-hidden {
    opacity: 0;
    pointer-events: none;
}

#chess-gate .gate-stage {
    display: none;
    width: 100%;
    max-width: 480px;
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
}

#chess-gate .gate-stage.active {
    display: flex;
}

#chess-gate .gate-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #e60012;
    animation: gate-pulse 1.1s ease-in-out infinite;
}

@keyframes gate-pulse {
    0%, 100% { opacity: 0.35; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.4); }
}

#chess-gate .gate-msg {
    font-size: 1.15rem;
    letter-spacing: 0.05em;
    line-height: 1.6;
}

#chess-gate .gate-sub {
    font-size: 0.85rem;
    color: #8a8a8a;
    letter-spacing: 0.08em;
}

#chess-gate .side-choice {
    display: flex;
    gap: 1rem;
}

#chess-gate .side-btn {
    font-family: inherit;
    font-size: 0.95rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    background: transparent;
    color: #f5f5f0;
    border: 1px solid #e60012;
    padding: 0.9rem 1.4rem;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

#chess-gate .side-btn:hover {
    background: #e60012;
    color: #050505;
}

#chess-gate .side-btn .glyph {
    font-size: 1.6rem;
    display: block;
    margin-bottom: 0.3rem;
}

#chess-gate #cg-board-wrap {
    display: grid;
    grid-template-columns: repeat(8, minmax(28px, 46px));
    grid-template-rows: repeat(8, minmax(28px, 46px));
    border: 1px solid #e60012;
    transition: transform 0.5s ease;
    transform: scale(0.8);
}

#chess-gate.cg-board-grown #cg-board-wrap {
    transform: scale(1);
}

#chess-gate .cg-sq {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(1.1rem, 4vw, 1.9rem);
    cursor: default;
    user-select: none;
}

#chess-gate .cg-sq.light { background: #1c1c1c; }
#chess-gate .cg-sq.dark { background: #050505; }

#chess-gate .cg-sq.selectable { cursor: pointer; }

#chess-gate .cg-sq.selected {
    box-shadow: inset 0 0 0 2px #e60012;
}

#chess-gate .cg-sq.piece-white { color: #f5f5f0; }
#chess-gate .cg-sq.piece-black { color: #e60012; }

#chess-gate .cg-hint {
    min-height: 1.4em;
    font-size: 0.8rem;
    color: #8a8a8a;
    letter-spacing: 0.05em;
}

#chess-gate .cg-hint.error { color: #e60012; }

#chess-gate #cg-board-wrap.shake {
    animation: gate-shake 0.35s ease;
}

@keyframes gate-shake {
    0%, 100% { transform: scale(1) translateX(0); }
    25% { transform: scale(1) translateX(-6px); }
    75% { transform: scale(1) translateX(6px); }
}

#chess-gate .gate-win {
    font-size: 1.3rem;
    color: #e60012;
    letter-spacing: 0.08em;
}

@media (max-width: 480px) {
    #chess-gate #cg-board-wrap {
        grid-template-columns: repeat(8, minmax(24px, 38px));
        grid-template-rows: repeat(8, minmax(24px, 38px));
    }
}
