/* game.minhphu.io.vn — cung bang mau voi trang chu (menh Thuy) */
:root {
    --abyss: #03060f;
    --deep: #071226;
    --ocean: #0b2a5b;
    --wave: #1d6fff;
    --tide: #22c3ee;
    --mist: #8fd8ff;
    --silver: #dbe4f0;
    --steel: #8a9ab3;
}

*, *::before, *::after { box-sizing: border-box; }

html {
    background: var(--abyss);
    color-scheme: dark;
    scroll-behavior: smooth;
    overflow-x: clip;
}

body {
    margin: 0;
    overflow-x: clip;
    color: var(--silver);
    font: 400 17px/1.6 'Be Vietnam Pro', system-ui, sans-serif;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }

:focus-visible {
    outline: 2px solid var(--tide);
    outline-offset: 4px;
    border-radius: 6px;
}

::selection { background: rgb(34 195 238 / .4); color: #fff; }

/* Con tro giot nuoc, giong trang chu */
@media (pointer: fine) {
    html { cursor: url('/assets/cursors/drop.svg') 12 2, auto; }
    a, button { cursor: url('/assets/cursors/drop-hover.svg') 12 2, pointer; }
}

.text-water {
    background: linear-gradient(100deg, var(--silver) 0%, var(--mist) 25%, var(--tide) 45%, var(--wave) 65%, var(--silver) 100%);
    background-size: 200% auto;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    animation: shimmer 6s linear infinite;
}
@keyframes shimmer { to { background-position: 200% center; } }

/* ---------- Nen ---------- */
.backdrop {
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    overflow: hidden;
}
.backdrop::before,
.backdrop::after {
    content: '';
    position: absolute;
    width: 46rem;
    height: 46rem;
    border-radius: 50%;
    filter: blur(130px);
    animation: drift 14s ease-in-out infinite alternate;
}
.backdrop::before { left: -16rem; top: -12rem; background: rgb(29 111 255 / .28); }
.backdrop::after { right: -18rem; bottom: -14rem; background: rgb(34 195 238 / .18); animation-delay: -7s; }
@keyframes drift { to { transform: translate(6rem, 4rem); } }

/* Bong bong noi len */
.bubble {
    position: absolute;
    bottom: -40px;
    border-radius: 50%;
    border: 1px solid rgb(143 216 255 / .35);
    background: radial-gradient(circle at 35% 30%, rgb(255 255 255 / .35), transparent 60%);
    animation: rise linear infinite;
}
@keyframes rise {
    to { transform: translate(var(--sway, 20px), -110vh); opacity: 0; }
}

/* ---------- Thanh tren ---------- */
.topbar {
    position: fixed;
    inset: 0 0 auto;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    height: 64px;
    padding: 0 clamp(16px, 4vw, 48px);
    transition: background-color .4s, backdrop-filter .4s;
}
.topbar.is-scrolled {
    background: rgb(3 6 15 / .7);
    backdrop-filter: blur(14px);
}
.back {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px 8px 10px;
    border-radius: 999px;
    font-size: 15px;
    font-weight: 600;
    color: var(--silver);
    background: rgb(255 255 255 / .05);
    border: 1px solid rgb(143 216 255 / .15);
    transition: background-color .2s, border-color .2s;
}
.back:hover { background: rgb(255 255 255 / .1); border-color: rgb(143 216 255 / .35); }
.back svg { width: 18px; height: 18px; transition: transform .2s; }
.back:hover svg { transform: translateX(-3px); }

/* ---------- Trang game: canh 3D ---------- */
.scene {
    position: fixed;
    inset: 0;
    z-index: 0;
    width: 100%;
    height: 100%;
    display: block;
}
.scene.is-hover { cursor: url('/assets/cursors/drop-hover.svg') 12 2, pointer; }

.tree-page .topbar { z-index: 30; }

/* Loi gioi thieu: noi tren canh, mo dan khi cuon */
.intro {
    position: fixed;
    inset: 0;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 96px 20px 40px;
    text-align: center;
    pointer-events: none;
}
.intro h1 {
    margin: 0;
    font-size: clamp(72px, 16vw, 200px);
    font-weight: 900;
    line-height: .95;
    letter-spacing: -0.05em;
}
.intro p {
    max-width: 34ch;
    margin: 20px auto 0;
    font-size: clamp(17px, 2vw, 22px);
    color: var(--silver);
    text-shadow: 0 2px 20px var(--abyss);
}
.scroll-hint {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin-top: 44px;
    font-size: 13px;
    letter-spacing: .2em;
    text-transform: uppercase;
    color: var(--tide);
    pointer-events: auto;
}
.scroll-hint i {
    width: 2px;
    height: 48px;
    background: linear-gradient(var(--tide), transparent);
    animation: drip 1.8s ease-in-out infinite;
    transform-origin: top;
}
@keyframes drip {
    0% { transform: scaleY(0); opacity: 1; }
    70% { transform: scaleY(1); opacity: 1; }
    100% { transform: scaleY(1); opacity: 0; }
}

/* Khoang cuon: JS dat chieu cao theo so game */
.scroll-space { height: 400vh; pointer-events: none; }

/* Danh sach game: an khi canh 3D chay, hien thanh luoi khi khong co WebGL */
.has-scene .game-list {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
}
.game-list {
    position: relative;
    z-index: 5;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 20px;
    max-width: 960px;
    margin: 0 auto;
    padding: 70vh 20px 80px;
    list-style: none;
}
.game-list a,
.game-list li > span {
    display: block;
    padding: 12px 12px 16px;
    border-radius: 20px;
    border: 1px solid rgb(143 216 255 / .2);
    background: rgb(255 255 255 / .04);
    font-weight: 700;
    font-size: 20px;
}
.game-list img { border-radius: 12px; margin-bottom: 12px; }
.no-webgl .scene,
.no-webgl .hud,
.no-webgl .scroll-space { display: none; }
.no-webgl .intro { position: absolute; height: 70vh; }

/* Thanh duoi: game dang xem */
.hud {
    position: fixed;
    left: 50%;
    bottom: max(20px, env(safe-area-inset-bottom));
    z-index: 20;
    width: min(560px, calc(100% - 32px));
    padding: 14px 16px 16px 20px;
    border-radius: 22px;
    background: rgb(3 6 15 / .62);
    border: 1px solid rgb(143 216 255 / .18);
    backdrop-filter: blur(14px);
    transform: translate(-50%, 140%);
    opacity: 0;
    transition: transform .6s cubic-bezier(.2, .8, .2, 1), opacity .4s;
}
.hud.is-visible { transform: translate(-50%, 0); opacity: 1; }
.hud-bar {
    position: absolute;
    inset: 0 22px auto;
    height: 2px;
    overflow: hidden;
    border-radius: 2px;
    background: rgb(143 216 255 / .12);
}
.hud-bar i {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, var(--mist), var(--tide), var(--wave));
    transform-origin: left;
    transform: scaleX(0);
}
.hud-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.hud p { margin: 0; }
.hud-count { font-size: 13px; color: var(--steel); font-variant-numeric: tabular-nums; }
.hud-name { font-size: clamp(20px, 3vw, 26px); font-weight: 800; letter-spacing: -0.02em; line-height: 1.2; }
.hud-path { font-size: 14px; color: var(--tide); }
.hud-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex: none;
    padding: 12px 20px;
    border-radius: 999px;
    font-weight: 700;
    color: var(--abyss);
    background: linear-gradient(110deg, var(--mist), var(--tide), var(--wave));
    box-shadow: 0 10px 30px -10px rgb(34 195 238 / .8);
    transition: transform .25s;
}
.hud-link:hover { transform: translateX(3px); }
.hud-link svg { width: 18px; height: 18px; }
.hud-link[hidden] { display: none; }

/* The anh dung o trang chi tiet game */
.thumb {
    position: relative;
    overflow: hidden;
    border-radius: 16px;
    aspect-ratio: 4 / 3;
    background: var(--deep);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }

/* Click ban nuoc */
.ripple {
    position: fixed;
    width: 10px;
    height: 10px;
    margin: -5px 0 0 -5px;
    border-radius: 50%;
    border: 1.5px solid var(--mist);
    pointer-events: none;
    z-index: 60;
    animation: ripple .7s ease-out forwards;
}
@keyframes ripple { to { transform: scale(7); opacity: 0; } }
.droplet {
    position: fixed;
    width: 8px;
    height: 11px;
    margin: -5px 0 0 -4px;
    border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
    background: radial-gradient(circle at 35% 35%, #fff, var(--mist) 45%, var(--tide));
    box-shadow: 0 0 6px rgb(143 216 255 / .6);
    pointer-events: none;
    z-index: 60;
}

/* ---------- Trang chi tiet game ---------- */
.game-page {
    min-height: 100svh;
    display: grid;
    place-items: center;
    padding: 96px clamp(16px, 4vw, 48px) 64px;
}
.game-panel {
    width: min(720px, 100%);
    text-align: center;
}
.game-panel .thumb {
    border: 1px solid rgb(143 216 255 / .2);
    box-shadow: 0 30px 90px -30px rgb(29 111 255 / .7);
    animation: float 6s ease-in-out infinite;
}
@keyframes float { 50% { transform: translateY(-10px); } }
.game-panel h1 {
    margin: 40px 0 0;
    font-size: clamp(44px, 8vw, 88px);
    font-weight: 900;
    line-height: 1;
    letter-spacing: -0.03em;
}
.game-panel p {
    max-width: 46ch;
    margin: 16px auto 0;
    color: var(--steel);
}
.status {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-top: 28px;
    padding: 10px 20px;
    border-radius: 999px;
    border: 1px solid rgb(143 216 255 / .25);
    color: var(--mist);
    font-weight: 600;
}
.status i {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--tide);
    box-shadow: 0 0 0 0 rgb(34 195 238 / .7);
    animation: pulse 1.8s infinite;
}
@keyframes pulse { 70% { box-shadow: 0 0 0 12px rgb(34 195 238 / 0); } 100% { box-shadow: 0 0 0 0 rgb(34 195 238 / 0); } }
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 32px;
    padding: 14px 24px;
    border-radius: 999px;
    font-weight: 600;
    color: var(--abyss);
    background: linear-gradient(110deg, var(--mist), var(--tide), var(--wave));
    box-shadow: 0 10px 40px -10px rgb(34 195 238 / .7);
    transition: transform .3s, box-shadow .3s;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 16px 50px -10px rgb(34 195 238 / .9); }

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
    }
}

/* ---------- Trang demo (tam thoi, de duyet hieu ung) ---------- */
.demo-nav {
    position: fixed;
    top: 12px;
    right: clamp(12px, 3vw, 40px);
    z-index: 31;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
    max-width: calc(100% - 180px);
}
.demo-nav a {
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    color: var(--steel);
    background: rgb(3 6 15 / .6);
    border: 1px solid rgb(143 216 255 / .15);
    backdrop-filter: blur(8px);
}
.demo-nav a:hover { color: var(--silver); }
.demo-nav a[aria-current] { color: var(--abyss); background: var(--tide); border-color: var(--tide); }
.demo-tag { margin-top: 18px !important; font-size: 14px !important; letter-spacing: .08em; color: var(--tide) !important; text-transform: uppercase; }
@media (max-width: 640px) {
    .demo-nav { top: 60px; left: 12px; right: 12px; max-width: none; justify-content: flex-start; }
    .demo-nav a { font-size: 12px; padding: 5px 10px; }
}

.demo-index { max-width: 1040px; margin: 0 auto; padding: 120px 20px 80px; }
.demo-index h1 { margin: 0; font-size: clamp(44px, 8vw, 88px); font-weight: 900; letter-spacing: -0.03em; line-height: 1; }
.demo-index > p { max-width: 60ch; color: var(--steel); }
.demo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; margin-top: 40px; }
.demo-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 22px;
    border-radius: 22px;
    background: rgb(255 255 255 / .04);
    border: 1px solid rgb(143 216 255 / .16);
    transition: transform .3s, border-color .3s, background-color .3s;
}
.demo-card:hover { transform: translateY(-4px); border-color: rgb(143 216 255 / .45); background: rgb(255 255 255 / .07); }
.demo-num {
    display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%;
    font-weight: 800; color: var(--abyss); background: linear-gradient(135deg, var(--mist), var(--tide), var(--wave));
}
.demo-name { font-size: 22px; font-weight: 800; letter-spacing: -0.01em; }
.demo-desc { font-size: 15px; color: var(--steel); line-height: 1.55; }
