/* --- CORE SETUP --- */
body {
    margin: 0; padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: #000; 
    overflow-x: hidden; 
    overflow-y: auto; 
    width: 100%;
    overscroll-behavior-y: none;
    touch-action: manipulation;
    min-height: 100vh;
    min-height: 100svh;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* --- LAYER 0: NỀN NƯỚC (CLEAN MODE) --- */
#water-container {
    position: fixed; 
    top: 0; 
    left: 0; 
    width: 100%;
    height: 100vh;
    height: 100lvh; 
    z-index: -1;
    
    /* MẶC ĐỊNH: Ảnh NGANG */
    background-image: url('../images/bg-poster.webp');
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
    
    will-change: transform;
}

/* CHỈ KHI: Màn hình nhỏ VÀ Đang cầm dọc -> Ảnh DỌC */
@media (max-width: 768px) and (orientation: portrait) {
    #water-container {
        background-image: url('../images/bg-poster-m.webp');
    }
}

/* --- UI LAYER --- */
.ui-layer {
    position: relative; z-index: 20;
    width: 100%;
    min-height: 100svh;
    display: flex; flex-direction: column; justify-content: space-between;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    box-sizing: border-box;
}

.top-section {
    width: 100%; display: flex; flex-direction: column; align-items: center;
    position: relative; z-index: 30;
}

.icon-svg { display: inline-block; width: 1em; height: 1em; fill: currentColor; vertical-align: -0.125em; flex: 0 0 auto; }
.btn-leaf .icon-svg { width: 22px; height: 22px; }
.nav-item .icon-svg { width: 14px; height: 14px; }
.error-icon .icon-svg { width: 64px; height: 64px; }

.main-nav {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;

    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: nowrap;
    gap: 12px;

    padding: 15px calc(20px + env(safe-area-inset-right)) 15px calc(20px + env(safe-area-inset-left));
    box-sizing: border-box;
}

/* nav.php: .nav-left / .nav-right */
.nav-left,
.nav-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap;
}
.nav-right { justify-content: flex-end; }

/* Hơi chật: thu nhẹ (vẫn 1 hàng) */
.main-nav.is-condensed .nav-item {
    padding: 5px 10px;
    font-size: 11.5px;
    letter-spacing: 0.65px;
}

/* Quá chật: stack dọc nhưng pill vẫn fit theo chữ (không full-width) */
.main-nav.is-stacked {
    flex-direction: column;
    align-items: stretch;
    justify-content: center;
    gap: 10px;
}
.main-nav.is-stacked .nav-left,
.main-nav.is-stacked .nav-right {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.main-nav.is-stacked .nav-left { align-items: flex-start; }
.main-nav.is-stacked .nav-right { align-items: flex-end; }

/* OUTLINE PILL NAV BUTTONS (MAX TRANSPARENCY) */
.nav-item{
    position: relative;
    overflow: hidden;
    isolation: isolate;

    color: rgba(255,255,255,0.96);
    text-decoration: none;
    text-transform: uppercase;

    /* Nhỏ & lịch thiệp */
    font-size: clamp(13px, 0.55vw, 15px);
    font-weight: 700;
    letter-spacing: 0.75px;
    line-height: 1;

    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;

    padding: 6px 12px;
    margin: 0;
    border-radius: 999px;
    white-space: nowrap;

    /* 100% transparent: chữ như nằm trực tiếp trên nền */
    background: transparent;

    /* Viền ngoài + viền trong (double border) */
    border: 1px solid rgba(255,255,255,0.20);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.07);

    /* Bù độ đọc trên nền ảnh sáng/loang */
    text-shadow:
        0 1px 2px rgba(0,0,0,0.70),
        0 0 10px rgba(0,0,0,0.20);

    transition: border-color 0.18s ease, color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

/* khi stack: cho phép chữ xuống dòng, vẫn fit-content */
.main-nav.is-stacked .nav-item{
    white-space: normal;
    max-width: min(100%, 520px);
}

.nav-item:hover{
    transform: translateY(-1px);
    border-color: rgba(251,191,36,0.65);
    color: rgba(251,191,36,0.98);

    /* glow nhẹ cho cảm giác “premium” */
    box-shadow:
        inset 0 0 0 1px rgba(251,191,36,0.12),
        0 0 0 2px rgba(251,191,36,0.06);
}

.nav-item:active{
    transform: translateY(0px);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.10);
}

.nav-item:focus-visible{
    outline: 2px solid rgba(251,191,36,0.55);
    outline-offset: 2px;
}

/* mobile: gọn hơn */
@media (max-width: 768px) {
    .main-nav{
        padding: 10px calc(15px + env(safe-area-inset-right)) 10px calc(15px + env(safe-area-inset-left));
        gap: 10px;
    }
    .nav-item{
        padding: 5px 10px;
        font-size: clamp(12px, 3.2vw, 12.5px);
        letter-spacing: 0.7px;
    }
}

/* Logo */
.logo-container {
    text-align: center; margin-top: 10px; position: relative; z-index: 30;
    transform: translate(-250px, 0px); 
}
.logo-img {
    max-width: 400px; height: auto; display: inline-block; transition: transform 0.3s;
}

@media (max-width: 768px) {
    .logo-container { transform: translate(-90px, 0px); margin-top: 80px; }
    .logo-img { max-width: 200px; }
}
@media (max-height: 600px) {
    .logo-img { max-width: 100px; }
}

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

.middle-section {
    flex-grow: 1; position: relative; display: flex; align-items: center; justify-content: center;
    min-height: 250px; z-index: 25;
}

.bottom-section {
    width: 100%; display: flex; flex-direction: column; align-items: center;
    background: none; padding-bottom: 10px; z-index: 35;
}

.dock-container {
    width: 90%; max-width: 380px; text-align: center; margin-bottom: 10px;
}

.footer-copyright {
    width: 100%; text-align: center;
    color: rgba(255, 255, 255, 0.9); font-size: 13px; font-weight: 600;
    text-shadow: 0 2px 4px #000000, 0 0 2px #000000;
    line-height: 1.4; padding-bottom: 5px;
}
.footer-copyright span { display: inline-block; margin: 0 5px; }

/* Giftcode */
.giftcode-box {
    display: flex; justify-content: space-between; align-items: center;
    background: rgba(0,0,0,0.6); border: 1px solid rgba(251, 191, 36, 0.3);
    border-radius: 8px; padding: 10px 15px; margin-bottom: 15px;
    backdrop-filter: blur(10px);
}
.gift-text { color: #fbbf24; font-weight: bold; font-size: 14px; font-family: monospace; letter-spacing: 1px; }
.gift-btn { 
    background: #fbbf24; border: none; padding: 6px 15px; 
    border-radius: 4px; font-weight: bold; cursor: pointer; font-size: 12px;
    color: #000; min-width: 60px;
    transition: all 0.3s;
}
.gift-btn.copied { background: #22c55e; color: white; }
.gift-btn.mission-mode { background: #2563eb; color: #fff; animation: pulse-btn 2s infinite; }
@keyframes pulse-btn {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.7); }
    70% { transform: scale(1.05); box-shadow: 0 0 0 10px rgba(37, 99, 235, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(37, 99, 235, 0); }
}

.btn-leaf {
    position: relative; display: flex; align-items: center; justify-content: center; gap: 10px;
    width: 100%; padding: 16px; margin-bottom: 12px;
    border-radius: 20px 50px 20px 50px !important;
    background: rgba(255, 255, 255, 0.1); backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    color: white; font-weight: 800; text-transform: uppercase; text-decoration: none;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3); transition: transform 0.1s; box-sizing: border-box;
    font-family: inherit;
}
.is-ios .btn-android, .is-ios .apk-container { display: none !important; }
.is-android .btn-ios { display: none !important; }
.btn-android { border-radius: 50px 20px 50px 20px !important; color: #fbbf24; border-color: rgba(251,191,36,0.6); background: rgba(0, 0, 0, 0.4); }
.btn-leaf::before {
    content: ''; position: absolute; inset: -4px; border-radius: inherit;
    border: 2px solid rgba(255,255,255,0.6); opacity: 0; z-index: -1;
    animation: ripple-local 1.2s infinite;
}
.btn-android::before { border-color: rgba(251,191,36,0.6); }
@keyframes ripple-local { 0% { transform: scale(1); opacity: 0.8; } 100% { transform: scale(1.15); opacity: 0; } }
.btn-leaf:active { transform: scale(0.95); background: rgba(255,255,255,0.2); }

@media (max-width: 768px) {
    .logo-img { max-width: 260px; }
    .slogan-text { font-size: 10px; letter-spacing: 1px; }
    .main-nav { padding: 10px 15px; }
    .nav-item { padding: 6px 12px; font-size: 10px; }
}
@media (max-height: 700px) {
    .logo-img { max-width: 200px; }
    .dock-container { margin-bottom: 5px; }
}

/* Các class trang con */
.page-container {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    /* Safe-area aware padding (notch / dynamic island / hole‑punch) */
    padding: 20px calc(20px + env(safe-area-inset-right)) 20px calc(20px + env(safe-area-inset-left));
    box-sizing: border-box;
    flex-grow: 1;
}

/* Extra safety for short landscape viewports */
@media (orientation: landscape) and (max-height: 480px) {
    .page-container {
        padding-top: 14px;
        padding-bottom: 14px;
        padding-left: calc(14px + env(safe-area-inset-left));
        padding-right: calc(14px + env(safe-area-inset-right));
    }
}

.page-title { text-align: center; margin-bottom: 30px; text-transform: uppercase; letter-spacing: 1px; }
.page-title h2 { font-size: 2rem; margin: 0; color: #fff; text-shadow: 0 2px 10px rgba(0,0,0,0.8); }
.page-title h3 { font-size: 0.8rem; margin: 0; color: #fff; text-shadow: 0 2px 10px rgba(0,0,0,0.8); }
.page-title span { color: #fbbf24; }
.grid-2-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.glass-panel { background: rgba(0, 0, 0, 0.6); border: 1px solid rgba(255, 255, 255, 0.15); border-radius: 16px; padding: 25px; backdrop-filter: blur(10px); box-shadow: 0 10px 30px rgba(0,0,0,0.3); color: #e5e7eb; height: 100%; box-sizing: border-box; transition: transform 0.3s, border-color 0.3s; }
.glass-panel:hover { border-color: rgba(251, 191, 36, 0.4); transform: translateY(-2px); }
.panel-heading { text-transform: uppercase; letter-spacing: 1px; font-size: 10px; color: #9ca3af; margin-bottom: 5px; font-weight: bold; }
.panel-title { font-size: 1.5rem; color: #fff; margin: 0 0 15px 0; font-weight: 700; }
.panel-title span { color: #fbbf24; }
.panel-text { font-size: 14px; line-height: 1.6; color: #d1d5db; margin-bottom: 15px; }
.feature-list { list-style: none; padding: 0; margin: 0; }
.feature-list li { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 8px; font-size: 13px; color: #e5e7eb; }
.feature-dot { margin-top: 5px; width: 6px; height: 6px; border-radius: 50%; background: #fbbf24; box-shadow: 0 0 5px #fbbf24; flex-shrink: 0; }
.timeline { border-left: 2px solid rgba(255,255,255,0.1); padding-left: 20px; margin-top: 20px; }
.timeline-item { position: relative; margin-bottom: 20px; }
.timeline-item::before { content: ''; position: absolute; left: -26px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: #fbbf24; box-shadow: 0 0 10px rgba(251, 191, 36, 0.5); }
.timeline-year { font-size: 11px; font-weight: 800; color: #fbbf24; text-transform: uppercase; letter-spacing: 1px; }
.timeline-desc { font-size: 13px; color: #ccc; margin-top: 2px; }
.hl-tag { display: inline-block; padding: 4px 10px; background: rgba(251, 191, 36, 0.2); border: 1px solid rgba(251, 191, 36, 0.4); color: #fbbf24; font-size: 10px; font-weight: bold; border-radius: 4px; margin: 2px; text-transform: uppercase; }
.contact-link { color: #fbbf24; text-decoration: none; font-weight: bold; transition: 0.2s; }
.contact-link:hover { text-decoration: underline; color: #fff; }

@media (max-width: 768px) {
    .grid-2-col { grid-template-columns: 1fr; }
    .page-title h2 { font-size: 1.5rem; }
    .glass-panel { padding: 20px; }
    .page-container { padding: 10px; padding-bottom: 80px; }
}