/* Grid Block 3D — page chrome for the canvas stage and the game's overlays.
   The 3D scene itself (board, pieces, highlights, particles) is drawn by
   public/js/puzzles/gridblock3d/app.js; everything here is DOM chrome. */

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

body {
    min-height: 100vh;
    display: flex;
    /* Centring and overflow: hidden removed to match the shared framed play
       stage (unified-3d-game.css): the stage pins itself under the header and
       recentres around the fixed sidebar, and a viewport-hidden overflow
       locked wheel/touch scrolling to the About section below the game. */
    background: var(--page-background);
    perspective: 1200px;
}

.game-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    transform-style: preserve-3d;
    min-height: 0;
    overflow: hidden;
}

#threeCanvas {
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
}

.stat-span-all {
    grid-column: 1 / -1;
}

.modal-title-success {
    font-family: var(--news-font-display);
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-primary);
    font-size: var(--font-size-2xl);
    margin-bottom: var(--spacing-md);
}

.modal-copy-muted {
    color: var(--color-text-secondary);
    margin-bottom: var(--spacing-lg);
}

/* ==================== ON-STAGE HUD ==================== */

.gb3d-hud {
    position: absolute;
    top: 18px;
    right: 18px;
    z-index: 5000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: flex-end;
    pointer-events: none;
}

.gb3d-hud-chip {
    pointer-events: auto;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 13px;
    background: var(--news-paper);
    color: var(--news-ink);
    border: 1.5px solid var(--news-ink);
    border-radius: 999px;
    font: 800 12px/1 var(--news-font-body, inherit);
    letter-spacing: 0.04em;
    box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.30);
    cursor: default;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.2s ease,
                background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.gb3d-hud-chip svg {
    flex: 0 0 auto;
}

button.gb3d-hud-btn {
    cursor: pointer;
}

button.gb3d-hud-btn:hover:not(:disabled) {
    background: var(--news-ink);
    color: var(--news-paper);
    transform: translate(-1px, -1px);
    box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.30);
}

button.gb3d-hud-btn:active:not(:disabled) {
    transform: translate(1px, 1px);
    box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.30);
}

button.gb3d-hud-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    box-shadow: none;
}

button.gb3d-hud-btn:focus-visible {
    outline: 2px solid var(--news-accent);
    outline-offset: 2px;
}

/* Sound chip icon states */
#gb3d-sound-btn .gb3d-icon-sound-off {
    display: none;
}

#gb3d-sound-btn.muted .gb3d-icon-sound-on {
    display: none;
}

#gb3d-sound-btn.muted .gb3d-icon-sound-off {
    display: block;
}

@media (max-width: 768px) {
    /* Thumb zone: the HUD lives bottom-left (mirroring the FAB stack on the
       right) so undo is reachable one-handed, and it never collides with the
       site's mobile timer pill under the header. */
    .gb3d-hud {
        top: auto;
        right: auto;
        bottom: 24px;
        left: 12px;
        flex-direction: row;
        align-items: center;
        gap: 8px;
    }

    .gb3d-hud-chip {
        padding: 12px;
        font-size: 12px;
    }

    /* Icon-only chips on mobile so the row never reaches the FAB stack. */
    .gb3d-hud-chip span {
        display: none;
    }

    #gb3d-pieces-chip span {
        display: inline;
    }
}

/* ==================== TOAST ==================== */

.gb3d-toast {
    position: absolute;
    top: 18px;
    left: 50%;
    transform: translate(-50%, -12px);
    z-index: 5200;
    background: var(--news-paper);
    color: var(--news-ink);
    border: 1.5px solid var(--news-ink);
    box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.30);
    padding: 9px 18px;
    font: 700 13px/1.3 var(--news-font-body, inherit);
    letter-spacing: 0.02em;
    border-radius: 999px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease, transform 0.22s ease;
    max-width: min(80%, 420px);
    text-align: center;
}

.gb3d-toast.show {
    opacity: 1;
    transform: translate(-50%, 0);
}

/* ==================== COACH MARK ==================== */

.gb3d-coach {
    position: absolute;
    bottom: 34px;
    left: 50%;
    transform: translate(-50%, 10px);
    z-index: 5100;
    background: var(--news-ink);
    color: var(--news-paper);
    border-radius: 999px;
    padding: 10px 20px;
    font: 700 13px/1.35 var(--news-font-body, inherit);
    letter-spacing: 0.02em;
    box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.30);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease, transform 0.4s ease;
    max-width: min(86%, 460px);
    text-align: center;
}

.gb3d-coach.show {
    opacity: 1;
    transform: translate(-50%, 0);
}

@media (max-width: 768px) {
    /* Declared after the base rule so the cascade actually wins: the coach
       must clear the bottom-left HUD row and the right-hand FABs. */
    .gb3d-coach {
        bottom: 118px;
        font-size: 14px;
        padding: 11px 20px;
    }
}

/* ==================== WIN RECAP ==================== */

.gb3d-stars {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: var(--spacing-sm, 8px);
}

.gb3d-star {
    font-size: 34px;
    line-height: 1;
    color: transparent;
    -webkit-text-stroke: 1.5px var(--news-ink-light);
    opacity: 0.55;
    transform: scale(1);
}

.gb3d-star.lit {
    color: #f5b921;
    -webkit-text-stroke: 1.5px #b8860b;
    opacity: 1;
}

.gb3d-star.pop {
    animation: gb3dStarPop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes gb3dStarPop {
    0% { transform: scale(0.2) rotate(-25deg); }
    70% { transform: scale(1.25) rotate(6deg); }
    100% { transform: scale(1) rotate(0deg); }
}

.gb3d-perfect {
    display: block;
    font: 800 12px/1.3 var(--news-font-body, inherit);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--news-accent);
    margin-bottom: var(--spacing-sm, 8px);
}

.gb3d-recap {
    display: flex;
    justify-content: center;
    gap: 26px;
    margin: 0 0 var(--spacing-lg);
}

.gb3d-recap-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 64px;
}

.gb3d-recap-label {
    font: 700 10px/1 var(--news-font-body, inherit);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--color-text-muted);
}

.gb3d-recap-value {
    font: 800 20px/1.1 var(--news-font-display, inherit);
    color: var(--color-text-primary);
    font-variant-numeric: tabular-nums;
}

.gb3d-modal-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

/* Comfortable close target on this page's win / dead-end dialogs. */
.modal-overlay .modal-close {
    min-width: 44px;
    min-height: 44px;
    line-height: 1;
}

/* ==================== MOTION SAFETY ==================== */

@media (prefers-reduced-motion: reduce) {
    .gb3d-hud-chip,
    .gb3d-toast,
    .gb3d-coach,
    .gb3d-star {
        transition: none;
        animation: none;
    }
}
