/* ===========================================================================
   treasure777 — mobile-first casino UI
   ---------------------------------------------------------------------------
   Built mobile-up (no media query targets the smallest screen). Breakpoints:
     - default: <600px  (1-column phone layout, sticky bottom nav)
     - 600+:    tablet  (3-col grid, side nav appears, no bottom bar)
     - 900+:    laptop  (5-col grid, full sidebar)
     - 1280+:   desktop (6+ col grid, larger hero)
   =========================================================================== */

:root {
    /* Core palette — dark navy with treasure-gold accent. Industry-common
       for casino sites (high contrast keeps game tiles bright). */
    --bg-0: #07080b;          /* page background */
    --bg-1: #10131a;          /* surface 1 (cards, header bg) */
    --bg-2: #181c26;          /* surface 2 (raised cards) */
    --bg-3: #232838;          /* hover state, chip backgrounds */
    --border: #2a3043;
    --fg: #f4f6fb;
    --fg-dim: #9aa3b8;
    --fg-muted: #5d6478;

    --gold: #d4af37;
    --gold-bright: #ffd866;
    --gold-dim: #8a7426;
    --danger: #ef5350;
    --success: #2ecc71;

    /* Animation tokens */
    --t-fast: 120ms;
    --t-base: 220ms;
    --ease: cubic-bezier(0.2, 0.7, 0.2, 1);

    /* Mobile-safe bottom inset — used for sticky nav to clear iOS home bar */
    --safe-bottom: env(safe-area-inset-bottom, 0px);

    /* Sticky element heights — referenced by header offsets in JS too */
    --h-header: 56px;
    --h-bottom-nav: 64px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
    background: var(--bg-0);
    color: var(--fg);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    /* Make room for the sticky bottom nav on mobile so content isn't hidden */
    padding-bottom: calc(var(--h-bottom-nav) + var(--safe-bottom));
}
a { color: var(--gold); text-decoration: none; }
a:focus-visible, button:focus-visible, input:focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: 2px;
}

img { max-width: 100%; display: block; }

/* ---------------------------------------------------------------------------
   HEADER — sticky top bar with logo, balance pill, hamburger
   On desktop the hamburger disappears; nav links sit inline.
   --------------------------------------------------------------------------- */
.site-header {
    position: sticky; top: 0; z-index: 50;
    display: flex; align-items: center; gap: 0.75rem;
    height: var(--h-header);
    padding: 0 1rem;
    background: rgba(7, 8, 11, 0.92);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
}
.brand {
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    color: var(--fg);
    flex-shrink: 0;
}
.brand span { color: var(--gold); }

.hamburger {
    margin-left: auto;
    background: none; border: 0; color: var(--fg);
    width: 40px; height: 40px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    border-radius: 6px;
}
.hamburger:hover { background: var(--bg-2); }
.hamburger svg { width: 22px; height: 22px; }

/* Right-side cluster (balance pill + auth links / hamburger) */
.header-right {
    margin-left: auto;
    display: flex; align-items: center; gap: 0.5rem;
}
.balance-pill {
    background: var(--bg-2);
    border: 1px solid var(--gold-dim);
    color: var(--gold-bright);
    font-weight: 700;
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    font-size: 0.85rem;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.btn-ghost, .btn-primary {
    display: inline-flex; align-items: center;
    padding: 0.45rem 0.9rem;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.9rem;
    border: 0; cursor: pointer;
    transition: background var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
    text-decoration: none;
}
.btn-ghost {
    color: var(--fg);
    background: transparent;
    border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg-2); }
.btn-primary {
    color: var(--bg-0);
    background: var(--gold);
}
.btn-primary:hover { background: var(--gold-bright); transform: translateY(-1px); }

/* Desktop nav links — hidden on mobile, shown on tablet+ */
.nav-desktop { display: none; gap: 0.25rem; margin-left: 1rem; }
.nav-desktop a {
    color: var(--fg-dim);
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    font-weight: 500;
}
.nav-desktop a:hover { color: var(--fg); background: var(--bg-2); text-decoration: none; }

/* ---------------------------------------------------------------------------
   STICKY BOTTOM NAV — mobile only. Hidden on tablet+.
   Touch targets are 44×44px minimum per WCAG / Apple HIG.
   --------------------------------------------------------------------------- */
.bottom-nav {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
    height: var(--h-bottom-nav);
    padding-bottom: var(--safe-bottom);
    background: rgba(16, 19, 26, 0.96);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid var(--border);
    display: grid; grid-template-columns: repeat(5, 1fr);
}
.bottom-nav a {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px;
    color: var(--fg-dim);
    font-size: 0.65rem;
    font-weight: 600;
    text-decoration: none;
    min-height: 44px;
    transition: color var(--t-fast) var(--ease);
}
.bottom-nav a svg { width: 22px; height: 22px; }
.bottom-nav a.is-active { color: var(--gold); }
.bottom-nav a:hover { color: var(--fg); }

/* ---------------------------------------------------------------------------
   DRAWER — slide-in nav for mobile when hamburger is tapped
   --------------------------------------------------------------------------- */
.drawer-backdrop {
    position: fixed; inset: 0; z-index: 90;
    background: rgba(0, 0, 0, 0.6);
    opacity: 0; pointer-events: none;
    transition: opacity var(--t-base) var(--ease);
}
.drawer {
    position: fixed; top: 0; right: 0; bottom: 0; z-index: 100;
    width: min(320px, 86vw);
    background: var(--bg-1);
    border-left: 1px solid var(--border);
    transform: translateX(100%);
    transition: transform var(--t-base) var(--ease);
    display: flex; flex-direction: column;
    padding-top: var(--safe-bottom);
}
body.drawer-open .drawer { transform: translateX(0); }
body.drawer-open .drawer-backdrop { opacity: 1; pointer-events: auto; }
.drawer-head { display: flex; justify-content: space-between; align-items: center; padding: 1rem; border-bottom: 1px solid var(--border); }
.drawer-head .brand { font-size: 1.1rem; }
.drawer-close {
    background: none; border: 0; color: var(--fg-dim); cursor: pointer;
    width: 40px; height: 40px; display: flex; align-items: center; justify-content: center;
    border-radius: 6px;
}
.drawer nav { display: flex; flex-direction: column; padding: 0.5rem; }
.drawer nav a {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.85rem 1rem;
    color: var(--fg);
    border-radius: 8px;
    font-weight: 500;
}
.drawer nav a:hover { background: var(--bg-2); text-decoration: none; }
.drawer nav a svg { width: 20px; height: 20px; opacity: 0.7; }
.drawer nav .divider { height: 1px; background: var(--border); margin: 0.5rem 0; }

.lang-pick { padding: 1rem; border-top: 1px solid var(--border); margin-top: auto; }
.lang-pick a {
    display: inline-block;
    padding: 0.35rem 0.65rem;
    margin: 0.15rem;
    background: var(--bg-2);
    color: var(--fg-dim);
    border-radius: 6px;
    font-size: 0.75rem;
    text-transform: uppercase;
}
.lang-pick a.is-active { background: var(--gold); color: var(--bg-0); }

/* ---------------------------------------------------------------------------
   PAGE WRAPPER — caps the content width on wide screens
   --------------------------------------------------------------------------- */
main { padding: 0; margin: 0 auto; }
.container { padding: 1rem; }

/* ---------------------------------------------------------------------------
   HERO — promotional banner with treasure-gold gradient
   --------------------------------------------------------------------------- */
.hero {
    position: relative;
    margin: 0.75rem 1rem;
    padding: 1.5rem 1.25rem;
    border-radius: 14px;
    background:
        radial-gradient(ellipse at top right, rgba(212, 175, 55, 0.22), transparent 60%),
        linear-gradient(135deg, #1a2230 0%, #0e1118 100%);
    border: 1px solid var(--border);
    overflow: hidden;
}
.hero h1 {
    margin: 0 0 0.5rem; font-size: 1.5rem; line-height: 1.15;
    background: linear-gradient(90deg, var(--gold-bright), var(--gold));
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent;
}
.hero p { margin: 0 0 1rem; color: var(--fg-dim); font-size: 0.95rem; }
.hero .cta-row { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.hero::after {
    /* decorative ✦ shimmer in the corner */
    content: '';
    position: absolute;
    width: 200px; height: 200px;
    right: -60px; top: -60px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(212, 175, 55, 0.18), transparent 70%);
    pointer-events: none;
}

/* ---------------------------------------------------------------------------
   SEARCH BAR — sticky-ish under header
   --------------------------------------------------------------------------- */
.search-bar {
    display: flex; gap: 0.5rem;
    margin: 0.75rem 1rem;
}
.search-bar input {
    flex: 1;
    padding: 0.7rem 1rem;
    background: var(--bg-2);
    border: 1px solid var(--border);
    color: var(--fg);
    border-radius: 10px;
    font-size: 0.95rem;
}
.search-bar input::placeholder { color: var(--fg-muted); }
.search-bar input:focus { border-color: var(--gold-dim); outline: none; }

/* ---------------------------------------------------------------------------
   CATEGORY CHIPS — horizontal scroll on mobile, wrap on desktop
   --------------------------------------------------------------------------- */
.chips {
    display: flex; gap: 0.5rem;
    padding: 0.5rem 1rem;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
    flex-shrink: 0;
    padding: 0.5rem 1rem;
    background: var(--bg-2);
    color: var(--fg-dim);
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 600;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--t-fast) var(--ease);
    scroll-snap-align: start;
    white-space: nowrap;
    text-decoration: none;
}
.chip:hover { background: var(--bg-3); color: var(--fg); text-decoration: none; }
.chip.is-active {
    background: var(--gold);
    color: var(--bg-0);
    border-color: var(--gold-bright);
}

/* ---------------------------------------------------------------------------
   GAME GRID — 2 cols mobile → 3 tablet → 5 laptop → 6+ desktop
   --------------------------------------------------------------------------- */
.section-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.5rem 1rem 0.25rem;
}
.section-head h2 { margin: 0; font-size: 1.1rem; }
.section-head .all-link { color: var(--gold); font-size: 0.85rem; font-weight: 600; }

.game-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.6rem;
    padding: 0.5rem 1rem 1.5rem;
}
.game-card {
    position: relative;
    background: var(--bg-2);
    border-radius: 10px;
    overflow: hidden;
    display: block;
    transition: transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.game-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
    text-decoration: none;
}
.game-card:active { transform: translateY(0); }
.game-card__img {
    width: 100%;
    aspect-ratio: 1 / 1;          /* square — Fundist tiles are usually square */
    object-fit: cover;
    background: var(--bg-3);
}
.game-card__body {
    padding: 0.5rem 0.6rem 0.65rem;
}
.game-card__title {
    color: var(--fg);
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.25;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
}
.game-card__provider {
    color: var(--fg-muted);
    font-size: 0.7rem;
    font-weight: 500;
    margin-top: 2px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.game-card__badge {
    position: absolute;
    top: 0.4rem; left: 0.4rem;
    padding: 0.15rem 0.45rem;
    background: var(--gold);
    color: var(--bg-0);
    font-size: 0.6rem;
    font-weight: 800;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ---------------------------------------------------------------------------
   PROVIDER STRIP — quick filter chips/logos in a row
   --------------------------------------------------------------------------- */
.providers {
    display: flex; gap: 0.4rem;
    padding: 0.5rem 1rem 1rem;
    overflow-x: auto;
    scrollbar-width: none;
}
.providers::-webkit-scrollbar { display: none; }
.providers a {
    flex-shrink: 0;
    padding: 0.55rem 1rem;
    background: var(--bg-2);
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--fg-dim);
    white-space: nowrap;
    border: 1px solid var(--border);
    text-decoration: none;
}
.providers a:hover { color: var(--fg); border-color: var(--gold-dim); text-decoration: none; }

/* ---------------------------------------------------------------------------
   AUTH / ACCOUNT FORMS — full-width on mobile, card on desktop
   --------------------------------------------------------------------------- */
.auth-card {
    margin: 1rem;
    padding: 1.5rem 1.25rem;
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: 14px;
}
.auth-card h1 { margin: 0 0 1rem; font-size: 1.5rem; }
.auth-card label {
    display: block;
    margin: 0.75rem 0 0.25rem;
    font-size: 0.85rem;
    color: var(--fg-dim);
    font-weight: 600;
}
.auth-card input, .auth-card select {
    width: 100%;
    padding: 0.75rem 0.9rem;
    background: var(--bg-2);
    border: 1px solid var(--border);
    color: var(--fg);
    border-radius: 8px;
    font-size: 1rem;
}
.auth-card input:focus, .auth-card select:focus {
    border-color: var(--gold-dim); outline: none;
}
.auth-card button {
    width: 100%;
    margin-top: 1.25rem;
    padding: 0.85rem;
    background: var(--gold);
    color: var(--bg-0);
    border: 0;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: background var(--t-fast) var(--ease);
}
.auth-card button:hover { background: var(--gold-bright); }
.auth-card .tos { color: var(--fg-muted); font-size: 0.8rem; margin: 0.75rem 0 0; }
.auth-card .alt {
    margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--border);
    color: var(--fg-dim); font-size: 0.9rem; text-align: center;
}
.error {
    color: var(--danger);
    background: rgba(239, 83, 80, 0.1);
    border: 1px solid rgba(239, 83, 80, 0.3);
    padding: 0.7rem 0.9rem;
    border-radius: 8px;
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

/* Reusable card wrapper for account/play pages */
.card {
    margin: 1rem;
    padding: 1.25rem;
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: 14px;
}
.card h2 { margin-top: 0; font-size: 1.1rem; }
.muted { color: var(--fg-dim); font-size: 0.9rem; }

/* ---------------------------------------------------------------------------
   GAME PLAY VIEW — fullscreen frame on mobile, contained on desktop
   --------------------------------------------------------------------------- */
.game-frame {
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #000;
    overflow: hidden;
}
.game-frame iframe, .game-frame > div {
    width: 100%; height: 100%; border: 0;
}
.game-toolbar {
    display: flex; justify-content: space-between; align-items: center;
    padding: 0.5rem 1rem;
    background: var(--bg-1);
    border-bottom: 1px solid var(--border);
}
.game-toolbar a { font-size: 0.9rem; color: var(--fg-dim); }

/* ---------------------------------------------------------------------------
   FOOTER — kept minimal on mobile, expanded on desktop
   --------------------------------------------------------------------------- */
footer {
    border-top: 1px solid var(--border);
    padding: 1.5rem 1rem 1rem;
    color: var(--fg-muted);
    font-size: 0.8rem;
    text-align: center;
}
footer .age { color: var(--gold); font-weight: 700; }

/* ---------------------------------------------------------------------------
   RESPONSIVE BREAKPOINTS
   Mobile-first: each query progressively enhances.
   --------------------------------------------------------------------------- */

/* 600+ : tablet — bottom nav goes away, desktop nav appears, 3-col grid */
@media (min-width: 600px) {
    body { padding-bottom: 0; }
    .bottom-nav { display: none; }
    .hamburger { display: none; }
    .nav-desktop { display: flex; }
    .game-grid { grid-template-columns: repeat(3, 1fr); gap: 0.75rem; }
    .hero { margin: 1rem; padding: 2rem 1.5rem; }
    .hero h1 { font-size: 2rem; }
    .container { padding: 1.5rem; }
}

/* 900+ : laptop — 5 columns, larger hero */
@media (min-width: 900px) {
    main { max-width: 1400px; }
    .game-grid { grid-template-columns: repeat(5, 1fr); }
    .hero { padding: 3rem 2rem; }
    .hero h1 { font-size: 2.4rem; }
    .game-card__title { font-size: 0.9rem; }
}

/* 1280+ : wide desktop — 6 columns and breathing room */
@media (min-width: 1280px) {
    .game-grid { grid-template-columns: repeat(6, 1fr); }
}

/* Respect reduced-motion preferences */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
