:root {
  --text: #f4f6ff;
  --muted: rgba(235, 240, 255, .72);
  --accent: #b4c0ff;
  --accent2: #8fd6ff;
  --glass: rgba(18, 24, 60, .38);
  --glass-line: rgba(200, 215, 255, .22);
  --serif: "Cormorant Garamond", "Times New Roman", serif;
  --sans: "Quicksand", "Segoe UI", Arial, sans-serif;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--sans); color: var(--text);
  min-height: 100vh; background: #080c1e;
  animation: pageIn .7s ease both;
}
body.home { overflow: hidden; height: 100vh; }
body.leaving { opacity: 0; transition: opacity .3s ease; }
@keyframes pageIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(22px); } to { opacity: 1; transform: none; } }
a { color: inherit; text-decoration: none; }

/* ---------- Nền ---------- */
#bg-video { position: fixed; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: -3; }
.overlay {
  position: fixed; inset: 0; z-index: -2;
  background:
    radial-gradient(ellipse at 20% 40%, rgba(10,14,50,.55), transparent 60%),
    linear-gradient(to bottom, rgba(5,8,30,.45), rgba(5,8,30,.1) 35%, rgba(5,8,30,.5));
}
body:not(.home) .overlay { background: linear-gradient(rgba(5,8,30,.62), rgba(5,8,30,.55)); backdrop-filter: blur(3px); }
#sparkles { position: fixed; inset: 0; z-index: -1; pointer-events: none; }

/* ---------- Kính mờ ---------- */
.glass {
  background: var(--glass);
  border: 1px solid var(--glass-line);
  border-radius: 20px;
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  box-shadow: 0 10px 40px rgba(0,0,0,.28), inset 0 1px 0 rgba(255,255,255,.08);
}

/* ---------- Thanh trên ---------- */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 10;
  height: 84px; padding: 0 4vw;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  background: linear-gradient(rgba(4,6,24,.55), transparent);
}
.logo {
  font-family: var(--serif); font-weight: 600; font-size: 2rem;
  letter-spacing: .28em; justify-self: start; margin-left: 2vw;
  text-shadow: 0 0 18px rgba(160,180,255,.7);
}
.nav { display: flex; gap: 2.6rem; }
.nav a {
  position: relative; padding: .4rem 0;
  font-size: 1rem; font-weight: 500; letter-spacing: .08em; opacity: .85;
  transition: opacity .25s;
}
.nav a::after {
  content: ""; position: absolute; left: 50%; bottom: -2px; width: 0; height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  border-radius: 2px; box-shadow: 0 0 10px var(--accent);
  transition: width .3s, left .3s;
}
.nav a:hover, .nav a.active { opacity: 1; }
.nav a:hover::after, .nav a.active::after { width: 100%; left: 0; }

.mini {
  justify-self: end; display: flex; align-items: center; gap: .7rem;
  padding: .55rem .9rem .55rem .6rem; border-radius: 999px; font-size: .85rem;
}
.mini .dot-av { position: relative; transition: box-shadow .4s; width: 36px; height: 36px; border-radius: 50%; overflow: hidden; background: #2b3470; display: grid; place-items: center; font-weight: 600; }
.mini img { width: 100%; height: 100%; object-fit: cover; }
.mini b { display: block; font-weight: 600; line-height: 1.1; }
.mini.clickable { cursor: pointer; transition: transform .25s, border-color .25s, box-shadow .25s; }
.mini.clickable:hover { transform: translateY(-2px); border-color: rgba(190,205,255,.65); box-shadow: 0 8px 30px rgba(90,110,255,.4); }
.mini .mini-text { min-width: 0; }
.mini small { display: block; color: var(--muted); font-size: .72rem; max-width: 170px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini .on { width: 9px; height: 9px; border-radius: 50%; background: #5ee68b; box-shadow: 0 0 8px #5ee68b; }

/* ---------- Trang chủ ---------- */
.home main.home, main.home {
  position: fixed; top: 21vh; left: 8vw; width: min(480px, 84vw);
  text-align: center; text-shadow: 0 2px 18px rgba(0,0,0,.5);
  animation: fadeUp 1s .2s both;
}
.qmark {
  display: block; font-family: var(--serif); font-size: 6rem; line-height: .6; height: 3rem;
  color: var(--accent); opacity: .65; text-shadow: 0 0 30px var(--accent);
}
#quote {
  font-family: var(--serif); font-style: italic; font-weight: 400;
  font-size: clamp(1.9rem, 3vw, 2.7rem); line-height: 1.25; letter-spacing: .01em;
  cursor: pointer; min-height: 3.4em; display: flex; align-items: center; justify-content: center;
  transition: opacity .6s ease, transform .6s ease;
}
#author { margin-top: .6rem; font-size: 1rem; letter-spacing: .12em; color: var(--accent); transition: opacity .6s; min-height: 1.4em; }
#quote.fade, #author.fade { opacity: 0; }
#quote.fade { transform: translateY(8px); }

.menu { list-style: none; margin-top: 2.4rem; }
.menu li { margin: 1.2rem 0; }
.menu a {
  position: relative; display: inline-block; padding: .2rem .3rem;
  font-family: var(--serif); font-size: 1.7rem; letter-spacing: .08em;
  transition: transform .25s, text-shadow .25s;
}
.menu a::after {
  content: ""; position: absolute; left: 50%; bottom: 0; width: 0; height: 1px;
  background: var(--accent); transition: width .3s, left .3s;
}
.menu a:hover { transform: translateY(-2px); text-shadow: 0 0 16px var(--accent); }
.menu a:hover::after { width: 100%; left: 0; }

/* ---------- Trang phụ ---------- */
.page { max-width: 1040px; margin: 0 auto; padding: 130px 24px 90px; }
.title {
  font-family: var(--serif); font-weight: 600; font-size: clamp(2.6rem, 5vw, 3.8rem);
  letter-spacing: .06em; margin-bottom: 2rem; text-shadow: 0 0 24px rgba(160,180,255,.5);
}
.title small {
  display: block; font-family: var(--sans); font-size: .85rem; font-weight: 500;
  letter-spacing: .35em; text-transform: uppercase; color: var(--accent); margin-top: .3rem;
}
.reveal { animation: fadeUp .8s var(--d, 0s) both; }

/* Giới thiệu */
.about { display: grid; grid-template-columns: 220px 1fr; gap: 2.4rem; padding: 2.4rem; }
.avatar-wrap {
  width: 200px; height: 200px; border-radius: 50%; padding: 4px; align-self: start;
  background: conic-gradient(from 0deg, var(--accent), var(--accent2), #d6a8ff, var(--accent));
  box-shadow: 0 0 40px rgba(150,170,255,.45);
  animation: spin 14s linear infinite;
}
.avatar-wrap img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; background: #1b2150; animation: spin 14s linear infinite reverse; }
@keyframes spin { to { transform: rotate(360deg); } }
.about-body h3 { font-family: var(--serif); font-size: 2.4rem; font-weight: 600; letter-spacing: .04em; }
.tagline { color: var(--accent); letter-spacing: .12em; margin: .2rem 0 1.2rem; }
#bio p { line-height: 1.8; color: var(--muted); margin-bottom: .8rem; }
.info { display: grid; grid-template-columns: repeat(2, 1fr); gap: .8rem 1.6rem; margin: 1.4rem 0; }
.info div { padding: .7rem 1rem; border-radius: 12px; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.08); }
.info dt { font-size: .72rem; letter-spacing: .2em; text-transform: uppercase; color: var(--accent); }
.info dd { margin-top: .15rem; }
.chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.chips span {
  padding: .35rem .95rem; border-radius: 999px; font-size: .88rem;
  background: rgba(150,170,255,.14); border: 1px solid rgba(180,192,255,.35);
  transition: transform .2s, background .2s;
}
.chips span:hover { transform: translateY(-2px); background: rgba(150,170,255,.28); }

/* Lưới thẻ (dự án + social) */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 1.3rem; }
.card {
  display: flex; flex-direction: column; gap: .7rem; padding: 1.4rem;
  animation: fadeUp .7s var(--d, 0s) both;
  transition: transform .3s, border-color .3s, box-shadow .3s;
}
.card:hover { transform: translateY(-6px); border-color: rgba(190,205,255,.6); box-shadow: 0 16px 50px rgba(90,110,255,.3); }
.card h4 { font-size: 1.15rem; font-weight: 600; word-break: break-word; }
.card p { color: var(--muted); font-size: .92rem; line-height: 1.6; flex: 1; }
.meta { display: flex; flex-wrap: wrap; gap: .4rem 1rem; font-size: .82rem; color: var(--muted); align-items: center; }
.lang::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--c, #aaa); margin-right: .35rem; }
.topics { display: flex; flex-wrap: wrap; gap: .35rem; }
.topics span { font-size: .72rem; padding: .15rem .6rem; border-radius: 999px; background: rgba(150,170,255,.16); }
.note { margin-top: 1.5rem; color: var(--muted); text-align: center; }

.socials { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.social { flex-direction: row; align-items: center; gap: 1rem; }
.social img { width: 34px; height: 34px; filter: drop-shadow(0 0 8px rgba(170,190,255,.6)); }
.social b { display: block; font-size: 1.05rem; }
.social small { color: var(--muted); }

.footer {
  position: fixed; bottom: 10px; left: 0; right: 0; text-align: center; z-index: 5;
  font-size: .75rem; letter-spacing: .15em; color: rgba(255,255,255,.45); pointer-events: none;
}

/* ---------- Mobile ---------- */
@media (max-width: 820px) {
  .topbar { grid-template-columns: 1fr auto; height: auto; padding-top: 12px; padding-bottom: 12px; row-gap: 8px; }
  .nav { grid-column: 1 / -1; grid-row: 2; justify-content: space-between; gap: 1rem; }
  .nav a { font-size: .88rem; letter-spacing: .03em; }
  .logo { font-size: 1.5rem; margin-left: 0; }
  .mini small { display: none; }
  main.home { left: 50%; transform: translateX(-50%); top: 24vh; animation: fadeUpC 1s .2s both; }
  @keyframes fadeUpC { from { opacity: 0; transform: translate(-50%, 22px); } to { opacity: 1; transform: translateX(-50%); } }
  .page { padding-top: 150px; }
  .about { grid-template-columns: 1fr; text-align: center; padding: 1.6rem; }
  .avatar-wrap { margin: 0 auto; }
  .info { grid-template-columns: 1fr; text-align: left; }
  .chips { justify-content: center; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- Trình phát nhạc ---------- */
.music { transition: opacity .35s, transform .35s; }
.music.hidden { opacity: 0; transform: translateY(14px); pointer-events: none; }
.music {
  position: fixed; left: 18px; bottom: 18px; z-index: 10;
  display: flex; align-items: center; gap: .6rem;
  padding: .4rem .9rem .4rem .45rem; border-radius: 999px; font-size: .8rem;
}
.music .mbtn {
  width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--glass-line);
  background: rgba(150,170,255,.2); color: var(--text); cursor: pointer; font-size: .75rem;
  display: grid; place-items: center; transition: background .2s, transform .2s;
}
.music .mbtn:hover { background: rgba(150,170,255,.4); transform: scale(1.08); }
.music .mtitle { max-width: 140px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
.music .mvol { width: 80px; accent-color: var(--accent); cursor: pointer; }
.bars { display: flex; align-items: flex-end; gap: 2px; height: 14px; }
.bars span { width: 3px; height: 4px; border-radius: 2px; background: var(--accent); }
.music.playing .bars span { animation: eq 1s ease-in-out infinite; }
.music.playing .bars span:nth-child(2) { animation-delay: .25s; }
.music.playing .bars span:nth-child(3) { animation-delay: .5s; }
@keyframes eq { 0%,100% { height: 4px; } 50% { height: 14px; } }
@media (max-width: 820px) { .music .mtitle, .music .mvol { display: none; } .music { left: 12px; bottom: 12px; } }

/* ---------- Secret keypad ---------- */
.keybox { max-width: 360px; margin: 0 auto; padding: 2rem 1.8rem 2.2rem; text-align: center; transition: box-shadow .4s, border-color .4s; }
.kdisplay { display: flex; justify-content: center; gap: .9rem; height: 2.4rem; align-items: center; }
.dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--accent); transition: background .2s, box-shadow .2s, transform .2s; }
.dot.on { background: var(--accent); box-shadow: 0 0 14px var(--accent); transform: scale(1.15); }
.khint { margin: .6rem 0 1.4rem; font-size: .9rem; letter-spacing: .12em; color: var(--muted); min-height: 1.3em; }
.khint.good { color: #7dffb0; } .khint.bad { color: #ff8d8d; }
.pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; justify-items: center; }
.key {
  width: 76px; height: 76px; border-radius: 50%; cursor: pointer;
  font-family: var(--serif); font-size: 2rem; color: var(--text);
  background: rgba(150,170,255,.14); border: 1px solid var(--glass-line);
  transition: transform .15s, background .2s, box-shadow .2s;
}
.key.small { font-family: var(--sans); font-size: 1.1rem; color: var(--muted); }
.key:hover { background: rgba(150,170,255,.3); box-shadow: 0 0 22px rgba(150,170,255,.45); transform: translateY(-2px); }
.key:active { transform: scale(.92); }
.keybox.ok { border-color: #7dffb0; box-shadow: 0 0 50px rgba(125,255,176,.35); }
.keybox.ok .dot.on { background: #7dffb0; border-color: #7dffb0; box-shadow: 0 0 14px #7dffb0; }
.keybox.shake { animation: shake .5s; border-color: #ff8d8d; }
@keyframes shake { 0%,100% { transform: none; } 20% { transform: translateX(-10px); } 40% { transform: translateX(10px); } 60% { transform: translateX(-7px); } 80% { transform: translateX(7px); } }
@media (max-width: 400px) { .key { width: 64px; height: 64px; } }

/* ---------- Nút máy tính -> secret ---------- */
.calc-btn {
  position: fixed; right: 18px; bottom: 18px; z-index: 10;
  width: 46px; height: 46px; border-radius: 50%;
  display: grid; place-items: center; color: var(--text); opacity: .75;
  transition: opacity .25s, transform .25s, box-shadow .25s, border-color .25s;
}
.calc-btn:hover { opacity: 1; transform: translateY(-3px) rotate(-6deg); border-color: rgba(190,205,255,.65); box-shadow: 0 8px 30px rgba(90,110,255,.45); }
@media (max-width: 820px) { .calc-btn { right: 12px; bottom: 12px; } }
