/*
 * styles.css
 * ----------
 * Standalone layout and critical Tailwind compatibility fallback rules.
 *
 * These styles support the static browser build. They should not encode game
 * rules, simulation behavior, button logic, or canvas drawing decisions.
 */

/* Base page layout: lock the game to a full-window canvas experience. */
html, body, #root {
    margin: 0;
    width: 100vw;
    height: 100vh;
    min-width: 100vw;
    min-height: 100vh;
    overflow: hidden;
    background: #07111f;
}
body {
    font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: #f1f5f9;
}
canvas { display: block; }
::selection { background: rgba(251, 191, 36, 0.35); }
.no-cdn-note { padding: 20px; color: #fff; background: #07111f; }

/* Critical CDN/Tailwind compatibility fallback.
 * These rules cover the layout and exact classes needed for the static build
 * to remain readable if CDN styles are late. They are not a full Tailwind replacement.
 */
:root {
    color-scheme: dark;
    --gv-safe-top: env(safe-area-inset-top, 0px);
    --gv-safe-right: env(safe-area-inset-right, 0px);
    --gv-safe-bottom: env(safe-area-inset-bottom, 0px);
    --gv-safe-left: env(safe-area-inset-left, 0px);
    --gv-camera-pad-button-size: 46px;
    --gv-camera-pad-button-gap: 0.35rem;
    --gv-camera-pad-shell-gap: 0.5rem;
    --gv-camera-pad-shell-padding: 0.45rem;
}
#root { color: #f1f5f9; }

/* Critical full-screen canvas fallback if Tailwind CDN is late or unavailable. */
#root > div:first-child {
    position: relative;
    width: 100vw;
    height: 100vh;
    min-width: 100vw;
    min-height: 100vh;
    overflow: hidden;
    background: #020617;
    color: #f1f5f9;
}
#root canvas {
    position: absolute;
    inset: 0;
    width: 100vw !important;
    height: 100vh !important;
    display: block;
    touch-action: none;
}

/* Exact Tailwind opacity fallbacks used by the JSX.
     Keep these narrow and class-specific so fallback CSS does not alter game behavior. */
#root .bg-slate-950 { background-color: rgb(2 6 23); }
#root .bg-slate-950\/84 { background-color: rgb(2 6 23 / 0.84); }
#root .bg-slate-950\/88 { background-color: rgb(2 6 23 / 0.88); }
#root .bg-slate-950\/92 { background-color: rgb(2 6 23 / 0.92); }
#root .bg-slate-950\/94 { background-color: rgb(2 6 23 / 0.94); }

#root .bg-white\/10 { background-color: rgb(255 255 255 / 0.10); }
#root .bg-white\/15 { background-color: rgb(255 255 255 / 0.15); }
#root .hover\\:bg-white\/15:hover { background-color: rgb(255 255 255 / 0.15); }
#root .bg-white\/\[0\.04\] { background-color: rgb(255 255 255 / 0.04); }
#root .bg-white\/\[0\.06\] { background-color: rgb(255 255 255 / 0.06); }

#root .bg-black\/20 { background-color: rgb(0 0 0 / 0.20); }
#root .bg-black\/25 { background-color: rgb(0 0 0 / 0.25); }
#root .bg-black\/30 { background-color: rgb(0 0 0 / 0.30); }
#root .bg-black\/45 { background-color: rgb(0 0 0 / 0.45); }

#root .bg-slate-700\/40 { background-color: rgb(51 65 85 / 0.40); }

#root .bg-sky-300\/15 { background-color: rgb(125 211 252 / 0.15); }
#root .bg-sky-300\/20 { background-color: rgb(125 211 252 / 0.20); }
#root .hover\\:bg-sky-300\/30:hover { background-color: rgb(125 211 252 / 0.30); }
#root .bg-sky-400\/10 { background-color: rgb(56 189 248 / 0.10); }
#root .bg-sky-400\/15 { background-color: rgb(56 189 248 / 0.15); }

#root .bg-emerald-300\/15 { background-color: rgb(110 231 183 / 0.15); }
#root .bg-emerald-300\/20 { background-color: rgb(110 231 183 / 0.20); }
#root .hover\\:bg-emerald-300\/30:hover { background-color: rgb(110 231 183 / 0.30); }
#root .bg-emerald-400\/10 { background-color: rgb(52 211 153 / 0.10); }
#root .bg-emerald-400\/15 { background-color: rgb(52 211 153 / 0.15); }
#root .bg-emerald-400\/20 { background-color: rgb(52 211 153 / 0.20); }

#root .bg-amber-300\/10 { background-color: rgb(252 211 77 / 0.10); }
#root .bg-amber-300\/15 { background-color: rgb(252 211 77 / 0.15); }
#root .bg-amber-300\/20 { background-color: rgb(252 211 77 / 0.20); }
#root .hover\\:bg-amber-300\/30:hover { background-color: rgb(252 211 77 / 0.30); }
#root .bg-amber-400\/10 { background-color: rgb(251 191 36 / 0.10); }

#root .bg-rose-300 { background-color: rgb(253 164 175); }
#root .hover\\:bg-rose-200:hover { background-color: rgb(254 205 211); }
#root .bg-rose-400\/10 { background-color: rgb(251 113 133 / 0.10); }
#root .bg-rose-400\/15 { background-color: rgb(251 113 133 / 0.15); }
#root .hover\\:bg-rose-400\/25:hover { background-color: rgb(251 113 133 / 0.25); }

#root .bg-violet-300\/15 { background-color: rgb(196 181 253 / 0.15); }
#root .bg-violet-300\/20 { background-color: rgb(196 181 253 / 0.20); }
#root .bg-indigo-300\/10 { background-color: rgb(165 180 252 / 0.10); }
#root .bg-fuchsia-400\/10 { background-color: rgb(232 121 249 / 0.10); }

#root .border-white\/5 { border-color: rgb(255 255 255 / 0.05); }
#root .border-white\/10 { border-color: rgb(255 255 255 / 0.10); }
#root .border-sky-200\/20 { border-color: rgb(186 230 253 / 0.20); }
#root .border-sky-300\/15 { border-color: rgb(125 211 252 / 0.15); }
#root .border-sky-300\/20 { border-color: rgb(125 211 252 / 0.20); }
#root .border-emerald-200\/20 { border-color: rgb(167 243 208 / 0.20); }
#root .border-emerald-300\/10 { border-color: rgb(110 231 183 / 0.10); }
#root .border-emerald-300\/15 { border-color: rgb(110 231 183 / 0.15); }
#root .border-emerald-300\/20 { border-color: rgb(110 231 183 / 0.20); }
#root .border-amber-200\/15 { border-color: rgb(253 230 138 / 0.15); }
#root .border-amber-200\/20 { border-color: rgb(253 230 138 / 0.20); }
#root .border-amber-300\/15 { border-color: rgb(252 211 77 / 0.15); }
#root .border-rose-300\/15 { border-color: rgb(253 164 175 / 0.15); }
#root .border-rose-300\/20 { border-color: rgb(253 164 175 / 0.20); }
#root .border-fuchsia-300\/15 { border-color: rgb(240 171 252 / 0.15); }
#root .border-violet-200\/20 { border-color: rgb(221 214 254 / 0.20); }
#root .border-violet-200\/30 { border-color: rgb(221 214 254 / 0.30); }
#root .border-indigo-200\/15 { border-color: rgb(199 210 254 / 0.15); }

#root input, #root select, #root textarea { font: inherit; }

/* TV/couch camera controls. DOM buttons are used so remote cursors,
 * keyboard focus, and touch taps all share the same camera-only actions.
 */
#root .guildstead-camera-pad {
    position: absolute;
    left: 50%;
    bottom: max(0.75rem, var(--gv-safe-bottom));
    transform: translateX(-50%);
    z-index: 25;
    display: flex;
    align-items: center;
    gap: var(--gv-camera-pad-shell-gap);
    padding: var(--gv-camera-pad-shell-padding);
    border: 1px solid rgb(255 255 255 / 0.10);
    border-radius: 1.25rem;
    background: rgb(2 6 23 / 0.78);
    box-shadow: 0 18px 42px rgb(0 0 0 / 0.34);
    backdrop-filter: blur(12px);
    pointer-events: auto;
    user-select: none;
    touch-action: none;
}
#root .guildstead-camera-zoom-stack {
    display: grid;
    grid-template-rows: repeat(2, var(--gv-camera-pad-button-size));
    gap: var(--gv-camera-pad-button-gap);
}
#root .guildstead-camera-dpad {
    display: grid;
    grid-template-columns: repeat(3, var(--gv-camera-pad-button-size));
    grid-template-rows: repeat(3, var(--gv-camera-pad-button-size));
    gap: var(--gv-camera-pad-button-gap);
}
#root .guildstead-camera-button {
    min-width: var(--gv-camera-pad-button-size);
    min-height: var(--gv-camera-pad-button-size);
    border: 1px solid rgb(255 255 255 / 0.16);
    border-radius: 0.95rem;
    background: rgb(255 255 255 / 0.12);
    color: #fff3c4;
    font: 800 1.2rem/1 ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    cursor: pointer;
}
#root .guildstead-camera-button:hover,
#root .guildstead-camera-button:focus-visible {
    background: rgb(252 211 77 / 0.22);
    border-color: rgb(252 211 77 / 0.40);
    outline: 2px solid rgb(252 211 77 / 0.45);
    outline-offset: 2px;
}
#root .guildstead-camera-button:active {
    transform: translateY(1px);
    background: rgb(252 211 77 / 0.30);
}
#root .guildstead-camera-zoom-in { grid-row: 1; }
#root .guildstead-camera-zoom-out { grid-row: 2; }
#root .guildstead-camera-pan-up { grid-column: 2; grid-row: 1; }
#root .guildstead-camera-pan-left { grid-column: 1; grid-row: 2; }
#root .guildstead-camera-home { grid-column: 2; grid-row: 2; font-size: 1rem; }
#root .guildstead-camera-pan-right { grid-column: 3; grid-row: 2; }
#root .guildstead-camera-pan-down { grid-column: 2; grid-row: 3; }


/* Mobile/browser shell adjustments. These styles only affect UI layout and
 * input surfaces; they do not encode simulation or gameplay rules.
 */
#root .guildstead-orientation-overlay {
    display: none;
}

@media (pointer: coarse) and (orientation: portrait) {
    #root .guildstead-orientation-overlay {
        display: flex;
    }
}

@media (pointer: coarse) and (orientation: landscape) {
    #root {
        --gv-camera-pad-button-size: 44px;
        --gv-camera-pad-button-gap: 0.35rem;
        --gv-camera-pad-shell-gap: 0.4rem;
        --gv-camera-pad-shell-padding: 0.4rem;
    }

    #root .guildstead-topbar {
        left: max(0.75rem, var(--gv-safe-left));
        right: max(0.75rem, var(--gv-safe-right));
        top: max(0.5rem, var(--gv-safe-top));
        gap: 0.5rem;
    }

    #root .guildstead-hud-panel {
        max-width: min(72vw, 640px);
        padding: 0.65rem 0.75rem;
    }

    #root .guildstead-hud-panel button,
    #root .guildstead-reset-panel button,
    #root .guildstead-orientation-overlay button {
        min-height: 34px;
    }

    #root .guildstead-camera-pad {
        bottom: max(0.5rem, var(--gv-safe-bottom));
    }

    #root .guildstead-reset-panel {
        padding: 0.4rem;
    }

    #root .guildstead-help-panel {
        max-width: min(30vw, 260px);
        right: max(0.75rem, var(--gv-safe-right));
        bottom: max(0.75rem, var(--gv-safe-bottom));
        padding: 0.65rem;
    }

    #root .guildstead-news-panel {
        max-width: min(42vw, 460px);
        left: max(0.75rem, var(--gv-safe-left));
        bottom: max(0.75rem, var(--gv-safe-bottom));
        padding: 0.65rem;
    }

    #root .guildstead-floating-window {
        top: max(4.75rem, var(--gv-safe-top));
        right: max(0.75rem, var(--gv-safe-right));
        width: min(420px, calc(100vw - 1.5rem));
        max-height: calc(100vh - 5.5rem);
    }

    #root .guildstead-floating-body {
        max-height: calc(100vh - 9rem);
        padding: 0.85rem;
    }

    #root .guildstead-confirm-dialog {
        width: min(420px, calc(100vw - 1.5rem));
        max-height: calc(100vh - 1.5rem);
        overflow-y: auto;
    }
}

@media (pointer: coarse) and (orientation: landscape) and (max-height: 640px) {
    #root {
        --gv-camera-pad-button-size: clamp(38px, 8vh, 42px);
        --gv-camera-pad-button-gap: 0.25rem;
        --gv-camera-pad-shell-gap: 0.32rem;
        --gv-camera-pad-shell-padding: 0.32rem;
    }

    #root .guildstead-topbar {
        left: max(0.5rem, var(--gv-safe-left));
        right: max(0.5rem, var(--gv-safe-right));
        top: max(0.4rem, var(--gv-safe-top));
        gap: 0.45rem;
    }

    #root .guildstead-hud-panel {
        max-width: min(68vw, 600px);
        padding: 0.55rem 0.65rem;
    }

    #root .guildstead-help-panel {
        max-width: min(28vw, 240px);
        padding: 0.55rem;
    }

    #root .guildstead-news-panel {
        max-width: min(38vw, 400px);
        padding: 0.55rem;
    }
}

@media (pointer: coarse) and (orientation: landscape) and (max-height: 520px) {
    #root {
        --gv-camera-pad-button-size: clamp(38px, 8vh, 40px);
        --gv-camera-pad-button-gap: 0.22rem;
        --gv-camera-pad-shell-padding: 0.28rem;
    }

    #root .guildstead-help-panel {
        display: none;
    }

    #root .guildstead-news-panel {
        max-width: min(40vw, 380px);
        font-size: 0.85rem;
    }

    #root .guildstead-camera-pad {
        transform: translateX(-50%);
        transform-origin: bottom center;
    }

    #root .guildstead-floating-window {
        top: max(4.25rem, var(--gv-safe-top));
        max-height: calc(100vh - 4.75rem);
    }

    #root .guildstead-floating-body {
        max-height: calc(100vh - 8rem);
    }
}
