/* T3 Games Hub — liquid glass × Telegram theme
   Base DNA (radii, glass, gradients): TonStation-style globals */

:root {
    --bg: var(--tg-theme-bg-color, #0e0f13);
    --surface: var(--tg-theme-secondary-bg-color, #14171e);
    --text: var(--tg-theme-text-color, #ffffff);
    --hint: var(--tg-theme-hint-color, rgba(255, 255, 255, 0.5));
    --accent: var(--tg-theme-button-color, #0098eb);
    --accent-text: var(--tg-theme-button-text-color, #ffffff);

    --glass-bg: rgba(20, 23, 30, 0.6);
    --glass-blur: blur(20px) saturate(160%);
    --glass-shadow: 0 4px 24px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.06);

    --r-card: 24px;
    --r-btn: 16px;

    --safe-top: 0px;
    --content-safe-top: 0px;
}

@supports (background: color-mix(in srgb, red 50%, blue)) {
    :root {
        --glass-bg: color-mix(in srgb, var(--surface) 62%, transparent);
    }
}

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

html,
body {
    overscroll-behavior: none;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", "Segoe UI", sans-serif;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    overflow-x: hidden;
}

/* --- liquid background --- */
.bg {
    position: fixed;
    inset: 0;
    z-index: -1;
    overflow: hidden;
}

.blob {
    position: absolute;
    width: 60vmax;
    height: 60vmax;
    border-radius: 50%;
    opacity: 0.5;
    will-change: transform;
}

.b1 {
    background: radial-gradient(circle at 35% 35%, color-mix(in srgb, var(--accent) 36%, transparent), transparent 62%);
    top: -22vmax;
    left: -18vmax;
    animation: drift1 26s ease-in-out infinite alternate;
}

.b2 {
    background: radial-gradient(circle at 60% 40%, rgba(32, 202, 117, 0.2), transparent 60%);
    bottom: -26vmax;
    right: -20vmax;
    animation: drift2 32s ease-in-out infinite alternate;
}

.b3 {
    background: radial-gradient(circle at 50% 50%, rgba(123, 47, 190, 0.16), transparent 58%);
    top: 30%;
    left: 45%;
    width: 44vmax;
    height: 44vmax;
    animation: drift3 38s ease-in-out infinite alternate;
}

@keyframes drift1 { to { transform: translate(9vmax, 7vmax) scale(1.08); } }
@keyframes drift2 { to { transform: translate(-8vmax, -6vmax) scale(1.12); } }
@keyframes drift3 { to { transform: translate(-6vmax, 5vmax) scale(0.92); } }

@media (prefers-reduced-motion: reduce) {
    .blob { animation: none; }
}

/* --- layout / safe area --- */
.app {
    max-width: 520px;
    margin: 0 auto;
    padding: 24px 16px calc(28px + env(safe-area-inset-bottom, 0px));
    animation: fadeIn 0.35s ease-out;
}

/* mobile fullscreen: keep clear of Telegram's overlay controls (~120px) */
body.mobile .app {
    padding-top: max(calc(var(--safe-top) + var(--content-safe-top) + 12px), 112px);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- glass + liquid border --- */
.glass {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-radius: var(--r-card);
    box-shadow: var(--glass-shadow);
}

.liquid {
    position: relative;
}

.liquid::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 1px;
    background: linear-gradient(
        165deg,
        rgba(255, 255, 255, 0.35),
        rgba(255, 255, 255, 0.07) 28%,
        transparent 55%,
        color-mix(in srgb, var(--accent) 40%, transparent)
    );
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    mask-composite: exclude;
    pointer-events: none;
}

/* --- header --- */
.hdr {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 20px;
}

.ava {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #004a8a);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 18px;
    color: var(--accent-text);
    overflow: hidden;
    flex-shrink: 0;
}

.ava img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.liquid-ring {
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 55%, transparent), 0 4px 14px rgba(0, 0, 0, 0.4);
}

.hdr-text h1 {
    margin: 0;
    font-size: 20px;
    line-height: 1.2;
}

.hdr-text p {
    margin: 2px 0 0;
    font-size: 14px;
    color: var(--hint);
}

/* --- hero card --- */
.hero {
    overflow: hidden;
    margin-bottom: 24px;
}

.hero-art {
    position: relative;
    height: 210px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent);
}

.hero-glow {
    position: absolute;
    width: 340px;
    height: 340px;
    border-radius: 50%;
    background: radial-gradient(circle, color-mix(in srgb, var(--accent) 42%, transparent), transparent 65%);
    filter: blur(2px);
}

.hero-art img {
    position: relative;
    width: 168px;
    height: 168px;
    object-fit: contain;
    filter: drop-shadow(0 14px 28px rgba(0, 0, 0, 0.5));
    animation: float 5s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.hero-info {
    padding: 18px 18px 20px;
}

.hero-title-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.hero-info h2 {
    margin: 0;
    font-size: 24px;
}

.tag {
    margin: 6px 0 16px;
    font-size: 14px;
    color: var(--hint);
}

/* --- buttons / chips --- */
.btn-play {
    width: 100%;
    padding: 15px 20px;
    border: none;
    border-radius: var(--r-btn);
    background: linear-gradient(135deg, var(--accent) 0%, color-mix(in srgb, var(--accent) 55%, #003a6d) 100%);
    color: var(--accent-text);
    font-size: 17px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    box-shadow: 0 8px 22px color-mix(in srgb, var(--accent) 38%, transparent), inset 0 1px 0 rgba(255, 255, 255, 0.22);
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.btn-play:active {
    transform: scale(0.97);
    box-shadow: 0 4px 12px color-mix(in srgb, var(--accent) 30%, transparent);
}

.chip {
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}

.chip-live {
    background: linear-gradient(90deg, #20ca75, #018040);
    color: #fff;
    box-shadow: 0 0 12px rgba(32, 202, 117, 0.45);
}

.chip-soon {
    background: rgba(255, 255, 255, 0.08);
    color: var(--hint);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

/* --- coming soon grid --- */
.section-title {
    margin: 0 0 12px;
    font-size: 16px;
    color: var(--hint);
    font-weight: 600;
}

.soon-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.card {
    padding: 18px 14px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    transition: transform 0.12s ease;
}

.card:active {
    transform: scale(0.97);
}

.card img {
    width: 72px;
    height: 72px;
    object-fit: contain;
    filter: saturate(0.55) drop-shadow(0 8px 16px rgba(0, 0, 0, 0.4));
}

.card-name {
    font-size: 14px;
    font-weight: 600;
    text-align: center;
}

/* --- toast --- */
.toast {
    position: fixed;
    left: 50%;
    bottom: calc(28px + env(safe-area-inset-bottom, 0px));
    transform: translate(-50%, 20px);
    padding: 12px 20px;
    border-radius: var(--r-btn);
    font-size: 14px;
    font-weight: 600;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
    z-index: 10;
}

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

.ftr {
    margin-top: 28px;
    text-align: center;
    font-size: 12px;
    color: var(--hint);
    opacity: 0.7;
}

/* --- embedded game overlay --- */
.game-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.22s ease, transform 0.22s ease;
}

.game-overlay.open {
    opacity: 1;
    transform: translateY(0);
}

.game-bar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    padding: max(calc(var(--safe-top) + 6px), 8px) 12px 8px;
    background: transparent;
    pointer-events: none;
}

body.mobile .game-bar {
    padding-top: max(calc(var(--safe-top) + 8px), 56px);
}

.game-back {
    pointer-events: auto;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    box-shadow: var(--glass-shadow);
    color: var(--text);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
}

.game-frame {
    flex: 1 1 auto;
    width: 100%;
    border: none;
    background: var(--bg);
}
