/* ============================================================
   FILE: base.css
   MÔ TẢ: Các style nền tảng, layout, intro, utility bar,
           game cards và các style chung cho toàn bộ ứng dụng.
   ============================================================ */

/* ============================================================
   1. RESET & BASE
   ============================================================ */
*, *::before, *::after { margin:0; padding:0; box-sizing:border-box; }
html, body { width:100%; height:100%; overflow-x:hidden; font-family:'Segoe UI','Inter',system-ui,-apple-system,sans-serif; background:#0a0e17; }

/* ============================================================
   2. BACKGROUND CANVAS
   ============================================================ */
#bg {
  position:fixed; top:0; left:0; width:100%; height:100%; z-index:0;
  pointer-events:none; touch-action:none;
}

/* ============================================================
   3. INTRO OVERLAY
   ============================================================ */
#intro-overlay {
  position:fixed; top:0; left:0; width:100%; height:100%; background:#000;
  display:flex; justify-content:center; align-items:center; z-index:9999;
  transition:opacity 1.2s ease;
}
#petal-container {
  position:absolute; top:0; left:0; width:100%; height:100%;
  pointer-events:none; overflow:hidden; z-index:10;
}
.petal {
  position:absolute; top:-10%; width:15px; height:15px; background:pink;
  border-radius:50% 0 50% 0; opacity:0.8; animation:fall linear infinite;
}
@keyframes fall {
  0%   { transform:translateY(0) rotate(0deg); opacity:0.9; }
  100% { transform:translateY(110vh) rotate(720deg); opacity:0; }
}
.intro-text {
  position:relative; z-index:20; text-align:center; color:#fff;
  font-family:'Exo 2','Segoe UI',sans-serif; max-width:90vw; padding:0 1rem;
}
#intro-line1 {
  font-size:2.5rem; font-weight:700; min-height:3rem; display:inline-block;
  border-right:3px solid #fff; white-space:normal; word-break:break-word;
  animation:blink-caret 0.75s step-end infinite; margin-bottom:1.5rem; line-height:1.3;
  font-family:'Exo 2',sans-serif;
}
#intro-line2 {
  font-size:1.5rem; opacity:0; transition:opacity 1s ease;
  font-family:'Quicksand',sans-serif;
}
@keyframes blink-caret {
  from, to { border-color:transparent; } 50% { border-color:#fff; }
}
@media (max-width:600px) {
  #intro-line1 { font-size:6vw; }
  #intro-line2 { font-size:4.5vw; }
}

/* ============================================================
   4. MAIN CONTENT
   ============================================================ */
.content {
  position:relative; z-index:1; color:white; text-align:center; margin-top:25vh;
  transition:opacity 0.4s ease, transform 0.4s ease;
  text-shadow:0 4px 12px rgba(0,0,0,0.6);
}
.content.hide { opacity:0; pointer-events:none; transform:scale(0.95); }
.content h1 {
  font-size:clamp(2.5rem, 8vw, 5rem); font-weight:900; letter-spacing:0.05em;
  background:linear-gradient(135deg, #a0d2ff, #e0c3ff, #ffb3c6);
  -webkit-background-clip:text; -webkit-text-fill-color:transparent; background-clip:text;
  filter:drop-shadow(0 0 20px rgba(160,210,255,0.3));
  animation:titleGlow 3s ease-in-out infinite;
}
@keyframes titleGlow {
  0%,100% { filter:drop-shadow(0 0 20px rgba(160,210,255,0.3)); }
  50%     { filter:drop-shadow(0 0 35px rgba(200,180,255,0.6)); }
}
.content p {
  font-size:clamp(0.8rem, 2vw, 1rem); font-weight:400; letter-spacing:0.2em;
  color:rgba(255,255,255,0.55); margin-top:12px; text-transform:uppercase;
}

/* ============================================================
   5. UTILITY BAR & FILTER
   ============================================================ */
.utility-container {
  position:fixed; top:24px; left:24px; z-index:1000;
  display:flex; flex-direction:row; align-items:flex-start;
  gap:5px;
}
.toggle-btn {
  width:50px; height:50px; background:rgba(20,25,40,0.75); backdrop-filter:blur(20px);
  border:5px solid rgba(255,255,255,0.15); color:white; font-size:20px; border-radius:16px;
  cursor:pointer; transition:all 0.3s ease; display:flex; align-items:center; justify-content:center;
  box-shadow:0 8px 32px rgba(0,0,0,0.4); position:relative; z-index:1001;
}
.toggle-btn:hover {
  background:rgba(40,50,70,0.8); border-color:rgba(255,255,255,0.3);
  box-shadow:0 12px 40px rgba(100,150,255,0.25); transform:translateY(-2px);
}
.toggle-btn i { transition:transform 0.4s cubic-bezier(0.68,-0.55,0.27,1.55); }
.toggle-btn.active i { transform:rotate(90deg); }

.utility-bar {
  position:absolute; top:62px; left:0; width:380px; max-height:calc(100vh - 140px);
  overflow-y:auto; overflow-x:hidden; background:rgba(15,20,35,0.8); backdrop-filter:blur(30px);
  border:1px solid rgba(255,255,255,0.1); border-radius:20px; padding:20px;
  box-shadow:0 20px 60px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.05) inset;
  transform:translateY(-20px) scale(0.95); opacity:0; pointer-events:none;
  transition:all 0.4s cubic-bezier(0.16,1,0.3,1); display:flex; flex-direction:column; gap:16px;
}
.utility-bar.show { transform:translateY(0) scale(1); opacity:1; pointer-events:auto; }
.utility-bar::-webkit-scrollbar { width:5px; }
.utility-bar::-webkit-scrollbar-track { background:transparent; }
.utility-bar::-webkit-scrollbar-thumb { background:rgba(255,255,255,0.2); border-radius:99px; }

.filter-section { display:flex; flex-wrap:wrap; gap:8px; }
.filter-btn {
  padding:6px 14px; border-radius:99px; border:1px solid rgba(255,255,255,0.2);
  background:rgba(255,255,255,0.05); color:rgba(255,255,255,0.7); font-size:12px; font-weight:600;
  cursor:pointer; transition:all 0.25s ease; white-space:nowrap;
  backdrop-filter:blur(10px); letter-spacing:0.3px;
}
.filter-btn:hover { background:rgba(255,255,255,0.15); border-color:rgba(255,255,255,0.4); color:#fff; }
.filter-btn.active {
  background:rgba(120,160,255,0.25); border-color:rgba(150,180,255,0.6);
  color:#ffffff; box-shadow:0 0 15px rgba(100,150,255,0.3);
}

/* ============================================================
   6. GAME CARDS
   ============================================================ */
.games-grid { display:grid; grid-template-columns:1fr 1fr; gap:10px; }

.game-card {
  background:rgba(255,255,255,0.03); border:1px solid rgba(255,255,255,0.06);
  border-radius:16px; padding:14px 10px; display:flex; flex-direction:column; align-items:center;
  gap:8px; cursor:pointer; transition:all 0.3s ease; position:relative; overflow:hidden;
  animation:cardFadeIn 0.6s ease forwards; opacity:0; height:130px;
}
.game-card::before {
  content:''; position:absolute; inset:0; border-radius:inherit;
  background:radial-gradient(circle at 50% 0%, rgba(255,255,255,0.08), transparent 70%);
  opacity:0; transition:opacity 0.3s ease;
}
.game-card:hover {
  background:rgba(255,255,255,0.06); border-color:rgba(255,255,255,0.15);
  transform:translateY(-4px); box-shadow:0 12px 30px rgba(0,0,0,0.4), 0 0 20px rgba(100,150,255,0.1);
}
.game-card:hover::before { opacity:1; }
.game-card:active { transform:scale(0.96); }

.game-info {
  text-align:center; display:flex; flex-direction:column; align-items:center; gap:2px;
}
.game-name { font-size:11px; font-weight:700; color:rgba(255,255,255,0.85); letter-spacing:0.3px; white-space:nowrap; }
.game-genre {
  font-size:9px; font-weight:500; color:rgba(180,200,255,0.7); background:rgba(100,150,255,0.1);
  padding:2px 8px; border-radius:99px; letter-spacing:0.2px; text-transform:uppercase;
}

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

/* ============================================================
   7. BASE UTILITY BUTTON
   ============================================================ */
.util-btn {
  width:52px; height:52px; position:relative; padding:0;
  border:1px solid rgba(255,255,255,0.12); border-radius:12px;
  background:rgba(255,255,255,0.07); overflow:hidden; flex-shrink:0;
  touch-action:manipulation; cursor:pointer; appearance:none; -webkit-appearance:none;
  line-height:0; display:flex; align-items:center; justify-content:center;
}
.util-btn:hover { background:rgba(255,255,255,0.15); transform:scale(1.06); }
.util-btn:active { transform:scale(0.92); }
.tag {
  color:#2196f3; font-family:'Tahoma',sans-serif; font-size:10px;
  text-shadow:0 0 6px rgba(33,150,243,0.5);
}
.util-btn svg { display:block; overflow:visible; }

#skip-intro{
    position:absolute;
    right:24px;
    bottom:24px;

    display:flex;
    align-items:center;
    gap:8px;

    padding:10px 16px;

    border:1px solid rgba(255,255,255,.25);
    border-radius:999px;

    background:rgba(255,255,255,.08);
    backdrop-filter:blur(10px);
    -webkit-backdrop-filter:blur(10px);

    color:rgba(255,255,255,.8);
    font-family:inherit;
    font-size:12px;
    font-weight:700;
    letter-spacing:.8px;

    cursor:pointer;

    transition:
        background .2s ease,
        color .2s ease,
        transform .2s ease,
        border-color .2s ease;
}

#skip-intro:hover{
    background:rgba(255,255,255,.16);
    border-color:rgba(255,255,255,.45);
    color:#fff;
    transform:translateY(-2px);
}

#skip-intro:active{
    transform:scale(.95);
}

#skip-intro i{
    font-size:11px;
}

/* ============================================================
   CHILL BAR
   ============================================================ */

.chill-bar{
    position: absolute;

    left: 50%;
    bottom: 75px;

    width: 250px;
    max-height: calc(100vh - 110px);

    padding: 8px;

    background: rgba(12, 16, 24, .88);

    border: 1px solid rgba(255,255,255,.10);
    border-radius: 18px;

    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);

    box-shadow:
        0 15px 45px rgba(0,0,0,.35),
        inset 0 1px 0 rgba(255,255,255,.05);

    overflow-y: auto;
    overflow-x: hidden;

    opacity: 0;
    visibility: hidden;
    pointer-events: none;

    transform: translateX(-50%) translateY(15px);

    transition:
        opacity .25s ease,
        transform .25s ease,
        visibility .25s ease;

    z-index: 1000;
}

.chill-bar.open{
    opacity: 1;
    visibility: visible;
    pointer-events: auto;

    transform: translateX(-50%) translateY(0);
}


/* ============================================================
   DANH SÁCH GAME
   ============================================================ */

.chill-games{
    display: flex;
    flex-direction: column;
    gap: 6px;
}


/* ============================================================
   GAME BUTTON
   ============================================================ */

/* ============================================================
   CHILL GAME BUTTON (kết hợp với util-btn)
   ============================================================ */
.chill-games {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.util-btn.chill-game-btn {
    width: 100%;
    min-height: 52px;
    height: auto;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    border: 1px solid rgba(255,255,255,.07);
    border-radius: 12px;
    background: rgba(255,255,255,.045);
    color: #fff;
    cursor: pointer;
    transition:
        background .18s ease,
        border-color .18s ease,
        transform .18s ease;
  line-height: normal;      /* Reset line-height từ util-btn */
    
    font-size: 13px;          
}

.util-btn.chill-game-btn:hover {
    background: rgba(255,255,255,.09);
    border-color: rgba(255,255,255,.15);
    transform: translateX(2px);
}

.util-btn.chill-game-btn:active {
    transform: scale(.98);
}

/* ICON */
.chill-game-icon {
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border-radius: 0px;
    background: rgba(255,255,255,.07);
    font-size: 21px;
}

/* TÊN GAME */
.chill-game-name {
    flex: 1;
    margin-left: 10px;
    text-align: left;
    font-family: 'Quicksand', sans-serif;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}


/* TÊN GAME */

.chill-game-name{
    flex: 1;

    margin-left: 10px;

    text-align: left;

    font-family: 'Quicksand', sans-serif;
    font-size: 13px;
    font-weight: 600;

    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}


/* MŨI TÊN */

.chill-game-btn > i{
    margin-left: 8px;
    font-size: 10px;

    opacity: .35;

    transition:
        opacity .18s ease,
        transform .18s ease;
}

.chill-game-btn:hover > i{
    opacity: .8;
    transform: translateX(2px);
}


/* SCROLLBAR */

.chill-bar::-webkit-scrollbar{
    width: 4px;
}

.chill-bar::-webkit-scrollbar-track{
    background: transparent;
}

.chill-bar::-webkit-scrollbar-thumb{
    background: rgba(255,255,255,.15);
    border-radius: 10px;
}

/* ============================================================
   LOADING OVERLAY
   ============================================================ */
#loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 10000;
    display: flex;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.loading-content {
    text-align: center;
    color: white;
    font-family: 'Exo 2', sans-serif;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    margin: 0 auto 20px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top: 4px solid #a0d2ff;
    border-right: 4px solid #e0c3ff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-text {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 2px;
    margin-bottom: 8px;
    color: rgba(255, 255, 255, 0.9);
}

.loading-dots span {
    animation: blinkDots 1.5s infinite;
    font-size: 24px;
    display: inline-block;
}

.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes blinkDots {
    0%, 20% { opacity: 0; }
    50% { opacity: 1; }
    100% { opacity: 0; }
}

.loading-game-name {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 20px;
    font-weight: 500;
}

.loading-progress {
    width: 200px;
    height: 3px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 99px;
    margin: 0 auto;
    overflow: hidden;
}

.loading-progress-bar {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #a0d2ff, #e0c3ff, #ffb3c6);
    border-radius: 99px;
    animation: progress 2s ease-in-out forwards;
}

@keyframes progress {
    0% { width: 0%; }
    25% {width: 33%;}
    50% { width: 70%; }
    75% {width: 90%;}
    90% {width: 95%;}
    100% { width: 100%; }
}

/* ============================================================
   THANH ĐỘ KHÓ
   ============================================================ */

/* ============================================================
   ĐỘ KHÓ
   ============================================================ */

.game-difficulty{
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 6px;

    white-space: nowrap;
}


/* Chữ "Độ khó:" */

.difficulty-label{
    font-size: 10px;
    font-weight: 500;

    color: rgba(255,255,255,.55);

    flex-shrink: 0;
}


/* Thanh chứa 5 khúc */

.difficulty-bar{
    display: flex;
    align-items: center;
    gap: 2px;

    flex-shrink: 0;
}


/* ============================================================
   KHÚC ĐỘ KHÓ
   ============================================================ */

.difficulty-segment{
    width: 12px;
    height: 4px;

    border-radius: 999px;

    background: rgba(255,255,255,.10);

    box-shadow:
        inset 0 1px 2px rgba(0,0,0,.25);

    transition:
        background .25s ease,
        box-shadow .25s ease;
}


/* ============================================================
   1 — XANH DƯƠNG
   ============================================================ */

.difficulty-segment.blue{
    background: #2196f3;

    box-shadow:
        0 0 5px rgba(33,150,243,.75);
}


/* ============================================================
   2 — XANH LÁ
   ============================================================ */

.difficulty-segment.green{
    background: #4caf50;

    box-shadow:
        0 0 5px rgba(76,175,80,.75);
}


/* ============================================================
   3 — VÀNG
   ============================================================ */

.difficulty-segment.yellow{
    background: #ffca28;

    box-shadow:
        0 0 5px rgba(255,202,40,.75);
}


/* ============================================================
   4 — CAM
   ============================================================ */

.difficulty-segment.orange{
    background: #ff8c00;

    box-shadow:
        0 0 5px rgba(255,140,0,.75);
}


/* ============================================================
   5 — ĐỎ
   ============================================================ */

.difficulty-segment.red{
    background: #f44336;

    box-shadow:
        0 0 6px rgba(244,67,54,.80);
}
/* ============================================================
   9. RESPONSIVE ADJUSTMENTS
   ============================================================ */
@media (max-width:480px) {
  .utility-bar { width:320px; padding:14px; }
  .games-grid { gap:6px; }
  .game-card { padding:10px 6px; }
}