@layer game {
#pool-game-root {
    --pool-table-green: #2335C9;
    --pool-table-border: #594526;
    --color-accent-rgb: 35, 53, 201;
    --pool-font-display: ui-monospace, "Cascadia Mono", Consolas, monospace;
    --pool-font-body: ui-monospace, "Cascadia Mono", Consolas, monospace;
    --pool-font-accent: ui-monospace, "Cascadia Mono", Consolas, monospace;
}

#pool-game-root #game-native-area {
    font-family: var(--pool-font-body);
}

#pool-container {
    width: 95%;
    max-width: min(900px, calc((100dvh - 250px) * 2));
    aspect-ratio: 2 / 1;
    background: #242c21;
    position: relative;
    border-radius: 0;
    overflow: hidden;
    box-shadow: 5px 5px 0 #050705, 9px 9px 0 #11160f, inset 3px 3px 0 #9b8652, inset -3px -3px 0 #21190f;
    border: 8px solid #0a0d09;
    border-top-color: #8a7142;
    border-left-color: #8a7142;
    border-right-color: #21190f;
    border-bottom-color: #21190f;
    margin: 1rem auto;
    flex-shrink: 0; /* Critical: prevent flex parent from squashing height */
}

#pool-canvas {
    width: 100%;
    height: 100%;
    display: block;
    cursor: crosshair;
    background: var(--pool-table-green);
    touch-action: none;
    image-rendering: crisp-edges;
    image-rendering: auto;
}

#pool-ui-overlay {
    width: 100%;
    max-width: 900px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.5rem;
    z-index: 10;
}

.player-card {
    flex: 1;
    background: #202820;
    border: 2px solid #090c09;
    border-top-color: #626c55;
    border-left-color: #626c55;
    border-radius: 0;
    padding: 0.8rem 1.2rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    box-shadow: 3px 3px 0 #FAFAF8;
    transition: none;
    min-width: 180px;
}

.player-card.active {
    background: #3c412d;
    border-color: #2335C9;
    box-shadow: 3px 3px 0 #090c09, inset 3px 0 0 #2335C9;
    transform: translate(-1px, -1px);
}

.player-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.player-name {
    font-family: var(--pool-font-display);
    font-weight: 800;
    font-size: 1.1rem;
    color: #fff;
    text-transform: uppercase;
}

.player-group {
    font-family: var(--pool-font-accent);
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.6);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.player-balls {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    min-height: 20px;
}

.ball-indicator {
    width: 14px;
    height: 14px;
    border-radius: 0;
    border: 2px solid #FAFAF8;
    box-shadow: inset 2px 2px 0 rgba(255, 255, 255, 0.35), 2px 2px 0 #FAFAF8;
}

.ball-indicator.solid { background: currentColor; }
.ball-indicator.striped {
    background: currentColor;
    box-shadow: inset 0 4px 0 #d8d7c1, inset 0 -4px 0 #d8d7c1, inset 2px 2px 0 rgba(255, 255, 255, 0.35), 2px 2px 0 #FAFAF8;
}

#game-status-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.status-badge {
    background: #111711;
    padding: 0.4rem 1.2rem;
    border-radius: 0;
    font-family: var(--pool-font-accent);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-game-accent, #2335C9);
    border: 2px solid #59634d;
    box-shadow: 3px 3px 0 #FAFAF8;
}

#shot-message {
    font-family: var(--pool-font-display);
    color: #ef4444;
    font-size: 0.9rem;
    font-weight: 800;
    text-transform: uppercase;
    text-shadow: 2px 2px 0 #260d0c;
    animation: fadeInOut 2s steps(4, end) forwards;
}

@keyframes fadeInOut {
    0% { opacity: 0; transform: scale(0.9); }
    20% { opacity: 1; transform: scale(1.1); }
    80% { opacity: 1; transform: scale(1.1); }
    100% { opacity: 0; transform: scale(1); }
}

.hidden { display: none !important; }

#mobile-compact-status {
    display: none;
    align-items: center;
    gap: 1rem;
}

.group-tiny {
    width: 12px;
    height: 12px;
    border-radius: 0;
    border: 2px solid #FAFAF8;
}
.group-tiny.solid { background: currentColor; }
.group-tiny.striped { background: currentColor; box-shadow: inset 0 3px 0 #d8d7c1, inset 0 -3px 0 #d8d7c1; }

/* Win Overlay Customization */
.win-overlay {
    position: fixed;
    inset: 0;
    width: 100%;
    max-width: none;
    height: 100%;
    max-height: none;
    margin: 0;
    padding: 0;
    border: 0;
    background: rgba(4, 7, 4, 0.92);
    z-index: 2000;
    opacity: 0;
    transition: none;
}

.win-overlay[open] {
    display: grid;
    place-items: center;
    opacity: 1;
}

.win-overlay::backdrop { background: rgba(4, 7, 4, 0.92); }

.win-modal {
    background: #202820;
    padding: 3rem;
    border-radius: 0;
    text-align: center;
    border: 3px solid #2335C9;
    box-shadow: 6px 6px 0 #FAFAF8, inset 3px 3px 0 #59634d, inset -3px -3px 0 #111711;
    max-width: 400px;
    width: 90%;
}

.win-title {
    font-family: var(--pool-font-display);
    font-size: 3.5rem;
    margin-bottom: 1rem;
    color: #e8dfac;
    text-shadow: 3px 3px 0 #FAFAF8;
}

.btn-restart {
    padding: 1rem 2.5rem;
    background: var(--color-game-accent, #2335C9);
    color: #000;
    font-weight: 800;
    border-radius: 0;
    font-family: var(--pool-font-display);
    text-transform: uppercase;
    cursor: pointer;
    border: 2px solid #FAFAF8;
    border-top-color: #f0d875;
    border-left-color: #f0d875;
    box-shadow: 4px 4px 0 #FAFAF8;
    transition: none;
}

.btn-restart:hover {
    transform: translate(-1px, -1px);
    background: #e7c65c;
}

#pool-controls {
    width: min(94%, 30rem);
    padding: 0.25rem;
}

.power-bar-container {
    height: 12px;
    border: 2px solid #FAFAF8;
    background: #111711;
    box-shadow: inset 2px 2px 0 #050705, 2px 2px 0 #FAFAF8;
}

#power-level {
    width: 45%;
    height: 100%;
    background: repeating-linear-gradient(90deg, #2335C9 0 8px, #725c2c 8px 10px);
}

@media (prefers-reduced-motion: reduce) {
    #shot-message { animation: none; }
}

@media (max-width: 600px) and (min-height: 600px) {
    #pool-container {
        display: block;
        width: min(94vw, calc((100dvh - 200px) * 0.5));
        max-width: 480px;
        height: auto;
        aspect-ratio: 1 / 2 !important;
        align-self: center;
        margin: 0.5rem auto;
        border-width: 6px;
    }
    #pool-canvas {
        width: 100% !important;
        height: auto !important;
        aspect-ratio: 1 / 2 !important;
    }
    #pool-ui-overlay {
        padding: 0.2rem;
        margin-bottom: 0;
    }
    #mobile-compact-status {
        display: none;
    }
    .win-title {
        font-size: 2.5rem;
    }
}

}
