:root {
    --ink: #17314f;
    --ink-soft: #2b4b6d;
    --paper: #fffdf4;
    --paper-cool: #f7fcff;
    --sky: #72d8f3;
    --sky-dark: #3bbce4;
    --mint: #72dfa2;
    --mint-dark: #43bd78;
    --lemon: #ffdc62;
    --orange: #ff9d5c;
    --coral: #ff6f78;
    --pink: #ff8fc8;
    --purple: #9b82f4;
    --blue: #5da6ff;
    --white: #ffffff;
    --shadow: rgba(23, 49, 79, 0.22);
    --shadow-heavy: rgba(23, 49, 79, 0.38);
    --overlay: rgba(13, 38, 59, 0.64);
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --ui-font: ui-rounded, "Arial Rounded MT Bold", "Trebuchet MS", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --body-font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --card-radius: clamp(24px, 4.5vw, 44px);
    --button-radius: clamp(16px, 3vw, 24px);
    --screen-max-width: 1100px;
    --hud-height: 86px;
    --controls-height: 92px;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html,
body {
    width: 100%;
    height: 100%;
    min-height: 100%;
    max-height: 100dvh;
    margin: 0;
    padding: 0 !important;
    overflow: hidden;
    overscroll-behavior: none;
    background: #71d7f2;
    color: var(--ink);
    font-family: var(--body-font);
    touch-action: manipulation;
}

body {
    position: fixed !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    user-select: none;
    -webkit-user-select: none;
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    color: inherit;
}

button:focus-visible,
input:focus-visible,
[tabindex]:focus-visible {
    outline: 4px solid rgba(255, 220, 98, 0.95);
    outline-offset: 3px;
}

button:disabled {
    cursor: not-allowed;
    filter: grayscale(0.3);
    opacity: 0.54;
}

img,
svg,
canvas {
    display: block;
}

[hidden] {
    display: none !important;
}

.noscript-message {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: grid;
    place-items: center;
    padding: 24px;
    color: var(--ink);
    background: var(--paper);
    font: 800 20px/1.4 var(--ui-font);
    text-align: center;
}

.app-shell {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    isolation: isolate;
    background:
        linear-gradient(180deg, rgba(255,255,255,0.15), transparent 30%),
        linear-gradient(180deg, #72d8f3 0%, #9ae9d8 55%, #d7f8af 100%);
}

.ambient-background {
    position: absolute;
    inset: 0;
    z-index: -2;
    overflow: hidden;
    pointer-events: none;
    background-image: url('../images/assets/images/background-pattern.svg');
    background-repeat: repeat;
    background-size: 220px 220px;
}

.ambient-background::before,
.ambient-background::after {
    content: "";
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.22);
    filter: blur(1px);
}

.ambient-background::before {
    width: min(34vw, 420px);
    aspect-ratio: 1;
    left: -12vw;
    top: 26%;
}

.ambient-background::after {
    width: min(28vw, 340px);
    aspect-ratio: 1;
    right: -8vw;
    bottom: 8%;
}

.ambient-blob {
    position: absolute;
    border-radius: 50%;
    opacity: 0.32;
    filter: blur(2px);
}

.ambient-blob-a {
    width: clamp(180px, 35vw, 540px);
    height: clamp(180px, 35vw, 540px);
    left: 4%;
    top: -18%;
    background: #fff;
}

.ambient-blob-b {
    width: clamp(130px, 26vw, 420px);
    height: clamp(130px, 26vw, 420px);
    right: 2%;
    top: 26%;
    background: #fff6b9;
}

.ambient-blob-c {
    width: clamp(160px, 30vw, 480px);
    height: clamp(160px, 30vw, 480px);
    left: 24%;
    bottom: -18%;
    background: #c8f8ff;
}

.ambient-sparkles {
    position: absolute;
    inset: 0;
    opacity: 0.72;
    background:
        radial-gradient(circle at 8% 10%, rgba(255,255,255,0.74) 0 4px, transparent 5px),
        radial-gradient(circle at 88% 14%, rgba(255,255,255,0.58) 0 3px, transparent 4px),
        radial-gradient(circle at 15% 76%, rgba(255,255,255,0.42) 0 6px, transparent 7px),
        radial-gradient(circle at 92% 68%, rgba(255,255,255,0.5) 0 4px, transparent 5px),
        radial-gradient(circle at 54% 6%, rgba(255,255,255,0.34) 0 8px, transparent 9px);
}

.screen-root {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
}

.screen {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(8px) scale(0.995);
    transition: opacity 220ms ease, transform 260ms cubic-bezier(.2,.8,.2,1), visibility 0s linear 260ms;
}

.screen.is-active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: none;
    transition-delay: 0s;
}

.game-card {
    background: linear-gradient(180deg, rgba(255,255,255,0.985), rgba(255,253,244,0.975));
    border: clamp(3px, 0.4vw, 5px) solid var(--ink);
    border-radius: var(--card-radius);
    box-shadow:
        0 14px 0 rgba(23,49,79,0.17),
        0 24px 55px rgba(23,49,79,0.24),
        inset 0 3px 0 rgba(255,255,255,0.9);
}

.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

.icon-slot,
.button-icon {
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
}

.icon-slot svg,
.button-icon svg {
    width: 100%;
    height: 100%;
    fill: currentColor;
}

.icon-cut {
    fill: var(--paper);
}

.screen-header {
    position: relative;
    z-index: 20;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: clamp(10px, 2.4vw, 22px);
    width: min(calc(100% - 24px - var(--safe-left) - var(--safe-right)), var(--screen-max-width));
    margin: 0 auto;
    padding-top: calc(12px + var(--safe-top));
}

.screen-heading {
    min-width: 0;
    text-align: center;
}

.screen-heading h1 {
    margin: 0;
    font: 900 clamp(24px, 5vw, 42px)/1 var(--ui-font);
    letter-spacing: -0.03em;
    text-transform: uppercase;
    text-shadow: 0 3px 0 rgba(255,255,255,0.55);
}

.screen-heading p {
    margin: 6px 0 0;
    color: var(--ink-soft);
    font-size: clamp(12px, 2.4vw, 15px);
    font-weight: 800;
}

.canvas-stage {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 160px;
    overflow: hidden;
    touch-action: none;
    border-radius: clamp(16px, 3vw, 28px);
    background: transparent;
}

.game-canvas {
    position: absolute;
    left: 0;
    top: 0;
    display: block;
    background: transparent;
    touch-action: none;
}

.effects-canvas {
    pointer-events: none;
    background: transparent;
}

.fatal-error {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: grid;
    place-content: center;
    gap: 12px;
    padding: 32px;
    background: var(--paper);
    text-align: center;
}

.fatal-error h1 {
    margin: 0;
    font: 900 32px/1.1 var(--ui-font);
}

.fatal-error p {
    margin: 0;
    color: var(--ink-soft);
    font-weight: 700;
}

.fatal-error button {
    justify-self: center;
    min-width: 140px;
    margin-top: 10px;
    padding: 14px 22px;
    border: 3px solid var(--ink);
    border-radius: 16px;
    background: var(--mint);
    color: var(--ink);
    font: 900 17px/1 var(--ui-font);
    cursor: pointer;
}

.high-contrast {
    --ink: #071b2c;
    --ink-soft: #153751;
    --shadow: rgba(0, 0, 0, 0.35);
    --shadow-heavy: rgba(0, 0, 0, 0.54);
}

.high-contrast .game-card,
.high-contrast .modal-card {
    border-width: 5px;
}

.reduced-motion *,
.reduced-motion *::before,
.reduced-motion *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
}

/* Ultra-narrow and accessibility zoom fallback. */
@media (max-width: 319px) {
    :root { --card-radius: 20px; --button-radius: 14px; }
    .app-shell, .screen-root, .screen { min-width: 0; }
    .game-card { border-width: 3px; }
}

.high-contrast {
    --ink: #071c31;
    --ink-soft: #17314f;
    --shadow: rgba(7, 28, 49, 0.34);
    --shadow-heavy: rgba(7, 28, 49, 0.52);
}
.high-contrast .game-card,
.high-contrast .modal-card,
.high-contrast .game-button,
.high-contrast .icon-button { border-color: #071c31; }

/* QuickGameRoom persistent company branding ------------------------------
   This layer is intentionally decorative, non-interactive, and positioned
   behind all gameplay UI so it cannot block taps, clicks, or keyboard use. */
.app-shell::before {
    content: "";
    position: absolute;
    inset: -15%;
    z-index: 0;
    pointer-events: none;
    opacity: 0.045;
    background: url('../images/assets/images/quickgameroom-icon.svg') repeat;
    background-size: 320px 320px;
    transform: rotate(-10deg);
}

.company-watermark-layer {
    display: none;
}

.company-watermark {
    position: absolute;
    display: block;
    width: clamp(300px, 48vw, 720px);
    height: auto;
    opacity: 0.035;
    filter: grayscale(0.12) saturate(0.82);
}

.company-watermark-primary {
    left: 50%;
    top: 49%;
    transform: translate(-50%, -50%) rotate(-7deg);
}

.company-watermark-secondary {
    right: -10%;
    bottom: -18%;
    width: clamp(190px, 28vw, 460px);
    opacity: 0.026;
    transform: rotate(12deg);
}

.company-corner-brand {
    position: absolute;
    top: calc(8px + var(--safe-top));
    right: calc(10px + var(--safe-right));
    z-index: 1;
    width: clamp(34px, 5vw, 52px);
    opacity: 0.62;
    pointer-events: none;
    user-select: none;
    filter: drop-shadow(0 3px 0 rgba(23, 49, 79, 0.14));
}

.company-corner-brand img,
.company-watermark-layer img {
    display: block;
    width: 100%;
    height: auto;
}
