:root {
    --gold: #d7aa52;
    --gold-soft: #f6dd96;
    --deep: #050403;
    --velvet: #25040a;
    --line: rgba(246, 221, 150, .28);
    --progress: 0;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden;
    background: #111;
    font-family: Arial, sans-serif;
}

#unity-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* When #unity-container is the fullscreen element, html/body are no longer
   painted behind it, so it needs its own background and explicit sizing. */
#unity-container:fullscreen,
#unity-container:-webkit-full-screen {
    width: 100%;
    height: 100%;
    background: #111;
}

#game-wrapper {
    position: relative;
    width: min(100%, calc(100vh * 16 / 9));
    height: min(100%, calc(100vw * 9 / 16));
}

/* When the wrapper is fullscreen, stretch to fill.
   We use a JS-managed class instead of :fullscreen pseudo-class so the rule
   reliably stops applying when fullscreen exits across all browsers. */
#game-wrapper.fullscreen-mode {
    width: 100%;
    height: 100%;
    background: #111;
}

#unity-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

#unity-iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: none;
    z-index: 10;

    opacity: 0;
    pointer-events: none;
    transition: opacity 0.6s ease;
}

/* ✅ Visibility toggle */
#unity-iframe.visible {
    opacity: 1;
    pointer-events: auto;
}

#loading-screen {
    position: absolute;
    inset: 0;
    overflow: hidden;
    isolation: isolate;
    background: #020101;
    color: #fff;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
    z-index: 1;
    transition: opacity 0.5s ease;
}

#loading-screen.fade-out {
    opacity: 0;
}

.cinema-bg {
    position: absolute;
    inset: -4%;
    background-image: url('img/casino-bg.png');
    background-size: cover;
    background-position: center 53%;
    transform: scale(1.04);
    filter: contrast(1.08) saturate(.92) brightness(.72);
    animation: slowPush 18s ease-in-out infinite alternate;
    z-index: -8;
}

.cinema-grade {
    position: absolute;
    inset: 0;
    z-index: -6;
    background:
        radial-gradient(circle at 50% 45%, rgba(255,190,88,.15), transparent 24%),
        radial-gradient(circle at 48% 70%, rgba(115,12,20,.30), transparent 32%),
        linear-gradient(90deg, rgba(0,0,0,.82), rgba(0,0,0,.16) 34%, rgba(0,0,0,.16) 66%, rgba(0,0,0,.82)),
        linear-gradient(180deg, rgba(0,0,0,.48), transparent 30%, rgba(0,0,0,.88));
}

.cinema-grade:after {
    content: "";
    position: absolute;
    inset: 0;
    background-image: linear-gradient(rgba(255,255,255,.018) 1px, transparent 1px);
    background-size: 100% 3px;
    mix-blend-mode: overlay;
    opacity: .18;
    pointer-events: none;
}

.volumetric-light {
    position: absolute;
    top: -20%;
    width: 34vw;
    height: 115vh;
    z-index: -5;
    opacity: .32;
    filter: blur(22px);
    background: linear-gradient(180deg, rgba(255,226,147,.48), rgba(255,194,91,.10) 40%, transparent 70%);
    transform-origin: top;
    animation: breathe 5.5s ease-in-out infinite;
}

.light-left { left: 15%; transform: rotate(14deg); }
.light-right { right: 12%; transform: rotate(-12deg); animation-delay: -2s; }

.floor-glass {
    position: absolute;
    left: 7%;
    right: 7%;
    bottom: -16%;
    height: 34%;
    z-index: -3;
    background: radial-gradient(ellipse at center, rgba(255,207,109,.16), transparent 62%);
    filter: blur(18px);
    opacity: .75;
    animation: floorPulse 6s ease-in-out infinite;
}

.gold-dust, .gold-dust:before, .gold-dust:after {
    position: absolute;
    inset: 0;
    content: "";
    z-index: -2;
    pointer-events: none;
    opacity: .55;
    background-image:
        radial-gradient(circle, rgba(255,219,143,.8) 0 1px, transparent 1.7px),
        radial-gradient(circle, rgba(255,255,255,.45) 0 1px, transparent 1.5px);
    background-size: 180px 180px, 260px 260px;
    background-position: 10% 20%, 70% 30%;
    animation: dustMove 22s linear infinite;
}

.gold-dust:before { opacity: .28; background-size: 120px 120px, 310px 310px; animation-duration: 28s; animation-direction: reverse; }
.gold-dust:after { opacity: .18; filter: blur(1px); background-size: 90px 90px, 210px 210px; animation-duration: 16s; }

.npc-shadow {
    position: absolute;
    bottom: 14%;
    width: 42px;
    height: 140px;
    z-index: -1;
    border-radius: 46% 46% 16% 16%;
    background: linear-gradient(180deg, rgba(0,0,0,.05), rgba(0,0,0,.58));
    filter: blur(1px);
    opacity: 0;
    animation: npcCross 14s ease-in-out infinite;
}

.npc-a { left: -8%; animation-delay: 1.2s; }
.npc-b { right: -10%; height: 120px; width: 36px; animation-name: npcCrossReverse; animation-delay: 7s; }

.hero-loader {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 30px;
    transform: translateY(-1.5vh);
}

.crest {
    position: relative;
    width: min(33vw, 330px);
    aspect-ratio: 1;
    display: grid;
    place-items: center;
}

.progress-orbit {
    position: absolute;
    inset: 0;
    filter: drop-shadow(0 0 20px rgba(215,170,82,.22));
    animation: orbitFloat 6s ease-in-out infinite;
}

.orbit-svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.orbit-track { fill: none; stroke: rgba(246,221,150,.10); stroke-width: 1.5; stroke-dasharray: 2 10; }
.orbit-progress {
    fill: none;
    stroke: var(--gold-soft);
    stroke-width: 3.2;
    stroke-linecap: round;
    stroke-dasharray: 590;
    stroke-dashoffset: calc(590 - (590 * var(--progress) / 100));
    transition: stroke-dashoffset .45s cubic-bezier(.22,.61,.36,1);
    filter: drop-shadow(0 0 10px rgba(246,221,150,.65));
}

.orbit-dot {
    position: absolute;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--gold-soft);
    box-shadow: 0 0 18px var(--gold-soft);
    left: 50%;
    top: 50%;
    transform-origin: 0 0;
}

.dot-one { animation: dotOrbit 5.2s linear infinite; }
.dot-two { width: 4px; height: 4px; animation: dotOrbit 8s linear infinite reverse; opacity: .65; }

.metal-disc {
    position: absolute;
    width: 72%;
    aspect-ratio: 1;
    border-radius: 50%;
    background:
        radial-gradient(circle at 42% 32%, rgba(255,236,184,.18), rgba(255,207,107,.05) 31%, rgba(0,0,0,.44) 63%, rgba(0,0,0,.78)),
        conic-gradient(from 180deg, transparent, rgba(246,221,150,.23), transparent, rgba(135,81,22,.25), transparent);
    border: 1px solid rgba(246,221,150,.20);
    box-shadow: inset 0 0 60px rgba(0,0,0,.74), 0 34px 70px rgba(0,0,0,.55);
    backdrop-filter: blur(7px);
}

.logo-shell {
    position: relative;
    width: 62%;
    min-width: 190px;
    padding: 26px 25px;
    border-radius: 26px;
    overflow: hidden;
    background: transparent;
    border: none;
    box-shadow: none;
}

.logo {
    display: block;
    width: 100%;
    height: auto;
    filter: drop-shadow(0 0 18px rgba(190,255,121,.25)) drop-shadow(0 12px 18px rgba(0,0,0,.65));
}

.specular-sweep {
    position: absolute;
    top: -40%;
    bottom: -40%;
    left: -75%;
    width: 46%;
    transform: rotate(18deg);
    background: linear-gradient(90deg, transparent, rgba(255,255,255,.20), rgba(246,221,150,.34), transparent);
    animation: sweep 3.8s cubic-bezier(.2,.75,.24,1) infinite;
}

.copy-block {
    text-align: center;
    letter-spacing: .02em;
    transform: translateY(-12px);
}

.loading-message {
    margin: 0;
    font-size: clamp(20px, 2.4vw, 34px);
    font-weight: 500;
    text-shadow: 0 8px 24px rgba(0,0,0,.8);
}

.subcopy {
    margin: 8px 0 0;
    color: rgba(255,241,207,.58);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .42em;
}

.minimal-hud {
    position: absolute;
    right: 34px;
    bottom: 28px;
    display: flex;
    align-items: center;
    gap: 13px;
    padding: 12px 15px;
    border: 1px solid rgba(246,221,150,.13);
    border-radius: 999px;
    background: rgba(0,0,0,.28);
    backdrop-filter: blur(10px);
    color: rgba(255,241,207,.75);
    letter-spacing: .16em;
    font-size: 11px;
    box-shadow: 0 14px 48px rgba(0,0,0,.45);
}

.percent { font-size: 13px; color: var(--gold-soft); min-width: 38px; text-align: right; }
.divider { width: 1px; height: 14px; background: rgba(246,221,150,.22); }

@keyframes slowPush { from { transform: scale(1.035) translate3d(-.5%,0,0); } to { transform: scale(1.095) translate3d(.5%,-1%,0); } }
@keyframes breathe { 0%,100% { opacity: .22; } 50% { opacity: .43; } }
@keyframes floorPulse { 0%,100% { opacity: .48; transform: scaleX(.95); } 50% { opacity: .78; transform: scaleX(1.05); } }
@keyframes dustMove { to { background-position: 10% -180%, 70% -130%; } }
@keyframes npcCross { 0%,14% { transform: translateX(0) scale(.85); opacity: 0; } 25% { opacity: .32; } 55% { opacity: .22; } 75%,100% { transform: translateX(118vw) scale(1.08); opacity: 0; } }
@keyframes npcCrossReverse { 0%,20% { transform: translateX(0) scale(.8); opacity: 0; } 31% { opacity: .25; } 55% { opacity: .18; } 78%,100% { transform: translateX(-118vw) scale(1.05); opacity: 0; } }
@keyframes orbitFloat { 0%,100% { transform: translateY(0) scale(1); } 50% { transform: translateY(-6px) scale(1.012); } }
@keyframes dotOrbit { from { transform: rotate(0deg) translateX(47%); } to { transform: rotate(360deg) translateX(47%); } }
@keyframes sweep { 0% { left: -80%; opacity: 0; } 12% { opacity: 1; } 42%,100% { left: 130%; opacity: 0; } }

@media (max-width: 760px) {
    .crest { width: min(60vw, 280px); }
    .logo-shell { min-width: 165px; padding: 20px; }
    .subcopy { letter-spacing: .22em; }
    .minimal-hud { right: 18px; bottom: 18px; }
}

@media (prefers-reduced-motion: reduce) {
    #loading-screen *, #loading-screen *:before, #loading-screen *:after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition: none !important;
    }
}

#iframe-overlay {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    z-index: 11;

    opacity: 0;
    pointer-events: none;
}

#rotate-message {
    display: none;
    position: fixed;
    inset: 0;
    background: #111;
    color: #fff;
    font-size: 32px;
    z-index: 10000;
    align-items: center;
    justify-content: center;
    text-align: center;
    flex-direction: column;
}

#rotate-icon {
    width: 120px;
    height: auto;
    margin-bottom: 20px;
}

@media (orientation: portrait) {
    #rotate-message {
        display: flex;
    }

    #unity-container {
        display: none;
    }
}

/* ✅ iOS home screen toast */
#ios-toast {
    display: none;
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.85);
    color: #fff;
    font-size: 14px;
    padding: 12px 40px 12px 16px;
    border-radius: 10px;
    z-index: 9999;
    max-width: 90%;
    text-align: center;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.15);
}

#ios-toast.visible {
    display: block;
}

#ios-toast-close {
    position: absolute;
    top: 8px;
    right: 10px;
    background: none;
    border: none;
    color: #aaa;
    font-size: 16px;
    cursor: pointer;
    padding: 0 4px;
}
