/* The orientation gate for the side games: they are played sideways, like
   the game and the Den, and a phone held upright sees only this; the game
   behind it is hidden and (sidegame.js gated()) paused and not drawn. Pure
   CSS on a media query, linked in <head>, so it is up on the first frame,
   before three.js or PlayCanvas arrive. The query is the game's own
   (index.html #rotate-gate) and matches sidegame.js GATE_QUERY;
   test/sidegame.test.mjs checks they agree. Each page sets --gate-bg and
   --gate-ink to its own colours. */
@media (pointer: coarse) and (orientation: portrait) {
    body > * { visibility: hidden !important; }
    body::after {
        content: "Turn your phone sideways";
        position: fixed; inset: 0; z-index: 1000;
        display: flex; align-items: center; justify-content: center;
        padding: 96px 24px 0;
        background: var(--gate-bg, #17263a); color: var(--gate-ink, #fff1d3);
        font: 700 20px/1.3 system-ui, -apple-system, "Segoe UI", sans-serif;
        text-align: center;
    }
    body::before {
        content: "";
        position: fixed; z-index: 1001; left: 50%; top: 50%;
        box-sizing: border-box; width: 46px; height: 76px; margin: -62px 0 0 -23px;
        border: 4px solid var(--gate-ink, #fff1d3); border-radius: 10px;
        animation: sidegame-sideways 2.4s ease-in-out infinite;
    }
}
/* Upright to sideways: the turn the player is asked to make. */
@keyframes sidegame-sideways {
    0%, 30% { transform: rotate(0deg); }
    55%, 85% { transform: rotate(-90deg); }
    100% { transform: rotate(0deg); }
}
@media (prefers-reduced-motion: reduce) {
    body::before { animation: none; transform: rotate(-90deg); }
}

/* Leaderboards (sidegame.js leaderboard()). The panel and its menu button, in
   the page's own colours: --gate-bg, --gate-ink, and --board-accent for the
   title, the player's own row and the button's edge. */
.sg-top {
    font: 700 13px/1 system-ui, -apple-system, "Segoe UI", sans-serif; letter-spacing: .08em; text-transform: uppercase;
    padding: 9px 14px; border: 2px solid var(--board-accent, #ffcf72); border-radius: 999px;
    background: transparent; color: var(--gate-ink, #fff1d3); cursor: pointer; pointer-events: auto;
}
.sg-top:hover, .sg-top:focus-visible { background: var(--board-accent, #ffcf72); color: var(--gate-bg, #17263a); outline: 0; }
.sg-board {
    position: fixed; inset: 0; z-index: 900; display: flex; align-items: center; justify-content: center;
    padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--gate-bg, #17263a) 82%, transparent);
    font: 600 15px/1.25 system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--gate-ink, #fff1d3);
}
.sg-board[hidden] { display: none; }
.sg-board section {
    position: relative; box-sizing: border-box; width: min(380px, 100%); max-height: 100%; overflow: auto; padding: 22px 22px 18px;
    background: var(--gate-bg, #17263a); border: 2px solid var(--board-accent, #ffcf72); border-radius: 14px;
    box-shadow: 6px 6px 0 var(--board-accent, #ffcf72);
}
.sg-board h2 { margin: 0 0 12px; font-size: 22px; line-height: 1; text-transform: uppercase; letter-spacing: .04em; color: var(--board-accent, #ffcf72); }
.sg-board ol { margin: 0; padding: 0; list-style: none; min-height: 40px; }
.sg-board li { display: grid; grid-template-columns: 2.2em 1fr auto; gap: 8px; align-items: baseline; padding: 6px 8px; border-radius: 6px; font-variant-numeric: tabular-nums; }
.sg-board li i { font-style: normal; opacity: .6; }
.sg-board li span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sg-board li.me { background: var(--board-accent, #ffcf72); color: var(--gate-bg, #17263a); }
.sg-board li.me i { opacity: .8; }
.sg-board p { margin: 12px 0 0; min-height: 1.25em; font-size: 13px; opacity: .8; font-variant-numeric: tabular-nums; }
.sg-close {
    position: absolute; right: 10px; top: 10px; width: 36px; height: 36px; border: 0; border-radius: 50%;
    background: transparent; color: inherit; font: 400 26px/1 system-ui, sans-serif; cursor: pointer;
}
.sg-close:hover, .sg-close:focus-visible { background: var(--board-accent, #ffcf72); color: var(--gate-bg, #17263a); outline: 0; }
