:root {
  --cap: #D62839;
  --cap-soft: #F0626F;
  --petal: #F6B6CA;
  --petal-soft: #FDE9EF;
  --milk: #FFFAF8;
  --ink: #4A1520;
  --ink-soft: #7A3342;
  --primary-color: var(--cap);
  --secondary-color: var(--petal);
  --glass: rgba(255, 250, 248, 0.62);
  --line: rgba(214, 40, 57, 0.28);
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Nunito', 'Segoe UI', sans-serif; }

body {
  background: linear-gradient(180deg, #FFF9F7 0%, #FDEAF0 55%, #F9D3DF 100%);
  color: var(--ink);
  overflow: hidden;
}
body:not(.touch-device) { cursor: none; }
.hidden { display: none !important; }
.container { width: 100%; height: 100vh; position: relative; }

/* =====================================================================
   CON TRỎ CHUỘT TUỲ BIẾN
   ===================================================================== */
.custom-cursor {
  position: fixed;
  width: 40px;
  height: 40px;
  pointer-events: none;
  z-index: 10000;
  transform: translate(-50%, -50%);
  background-image: url('assets/custom_cursor.png');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  display: none;
  will-change: transform;
}

/* ---------- Nền rừng nấm của trang chính ---------- */
#background { position: fixed; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 1; pointer-events: none; opacity: 0.28; mix-blend-mode: multiply; }
.forest { position: fixed; inset: 0; z-index: 2; pointer-events: none; overflow: hidden; }
.forest::before {
  content: ''; position: absolute; inset: -10% 0 30% 0;
  background: repeating-linear-gradient(105deg, transparent 0 140px, rgba(255, 255, 255, 0.55) 140px 190px, transparent 190px 340px);
  filter: blur(26px); opacity: 0.55;
}
.forest svg.ground { position: absolute; left: 0; bottom: 0; width: 100%; height: 42vh; }
.spore {
  position: absolute; bottom: -10px; border-radius: 50%; background: #fff;
  box-shadow: 0 0 8px 2px rgba(246, 182, 202, 0.9); opacity: 0;
  animation: float-up linear infinite;
}
@keyframes float-up {
  0% { transform: translate(0, 0); opacity: 0; }
  15% { opacity: 0.9; }
  100% { transform: translate(var(--drift, 30px), -95vh); opacity: 0; }
}

.glitch-overlay { position: fixed; inset: 0; pointer-events: none; z-index: 3; opacity: 0; background: radial-gradient(circle, rgba(246,182,202,.5), transparent 70%); transition: opacity .5s; }
#hacker-overlay, #snow-overlay { position: fixed; inset: 0; pointer-events: none; z-index: 3; }

/* ---------- Thẻ hồ sơ ---------- */
#profile-block, #skills-block {
  position: fixed; inset: 0; margin: auto; height: fit-content;
  width: 820px; max-width: 92vw; min-height: 332px; padding: 24px;
  background: var(--glass); border: 1.5px solid var(--line); border-radius: 28px 28px 22px 22px;
  box-shadow: 0 18px 50px rgba(214, 40, 57, 0.14), inset 0 1px 0 rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); z-index: 20;
  display: flex; flex-direction: column; gap: 15px;
  transform-style: preserve-3d;
}
#profile-block { opacity: 0; pointer-events: auto; }

.profile-header { display: flex; align-items: flex-start; gap: 20px; }
.profile-container { position: relative; width: 150px; height: 150px; flex-shrink: 0; }
.profile-container::after {
  content: ''; position: absolute; inset: -3px; border-radius: 50%;
  background: radial-gradient(circle at 10px 10px, var(--cap) 10%, transparent 16%);
  animation: orbit 3s linear infinite; z-index: -1;
}
.profile-container.fast-orbit::after { animation: orbit 0.5s linear forwards; }
.profile-picture {
  width: 150px; height: 150px; border-radius: 50%; object-fit: cover; cursor: pointer;
  border: 4px solid var(--milk); box-shadow: 0 0 0 2px var(--petal), 0 8px 20px rgba(214, 40, 57, 0.2);
}
.profile-info { flex: 1; display: flex; flex-direction: column; min-width: 0; }

@font-face { font-family: 'Angel Wish'; src: url('assets/Angel_wish.ttf') format('truetype'); }
#profile-name {
  font-family: 'Angel Wish', 'Fraunces', Georgia, serif;
  font-size: 34px; font-weight: 600; letter-spacing: 2px; line-height: 1.2; min-height: 1.2em;
  white-space: nowrap; color: var(--cap); text-shadow: 0 2px 0 var(--petal-soft);
}
#profile-bio { font-family: 'Fraunces', Georgia, serif; font-style: italic; font-size: 17px; line-height: 1.5; min-height: 1.5em; margin-top: 10px; color: var(--ink-soft); overflow-wrap: anywhere; }

.badge-box { background: var(--petal-soft); padding: 2px; border-radius: 16px; width: fit-content; max-width: 100%; margin-top: 4px; }
.badge-box-inner { background: rgba(255, 255, 255, 0.8); padding: 6px 10px; border-radius: 14px; }
.badge-group { display: flex; flex-wrap: wrap; gap: 8px; }
#discordBadges { display: contents; }
.badge-container { position: relative; }
.badge { width: 22px; height: 22px; transition: transform 0.3s; }
.badge:hover { transform: scale(1.25); }
.tooltip {
  visibility: hidden; opacity: 0; position: absolute; z-index: 100; width: 120px; padding: 5px 0;
  background: var(--ink); color: var(--milk); font-size: 12px; text-align: center; border-radius: 8px; transition: opacity 0.3s;
}
.badge-container .tooltip { bottom: 125%; left: 50%; margin-left: -60px; }
.badge-container:hover .tooltip, .visitor-counter:hover .tooltip { visibility: visible; opacity: 1; }

.bio-separator { height: 2px; margin: 16px 0; border-radius: 2px; background: repeating-linear-gradient(90deg, var(--petal) 0 10px, transparent 10px 18px); }

.profile-footer { display: flex; flex-direction: column; gap: 12px; margin-top: auto; }
.social-links { display: flex; justify-content: center; gap: 14px; }
.social-icon {
  width: 38px; height: 38px; padding: 8px; border-radius: 50%; background: var(--cap);
  box-shadow: 0 4px 10px rgba(214, 40, 57, 0.3); transition: transform 0.3s, background 0.3s;
}
.social-icon:hover { transform: translateY(-4px) scale(1.15); background: var(--cap-soft); }

.visitor-counter {
  position: relative; align-self: flex-start; display: flex; align-items: center; gap: 8px;
  padding: 7px 16px; border-radius: 20px; font-size: 14px; font-weight: 700; color: var(--cap);
  background: var(--petal-soft); border: 1px solid var(--line);
}
.visitor-icon { width: 18px; height: 18px; }
.visitor-counter .tooltip { top: -36px; left: 50%; margin-left: -60px; }

.skills-title { text-align: center; font-family: 'Fraunces', Georgia, serif; font-size: 26px; color: var(--cap); margin-bottom: 12px; }
.skill { display: flex; flex-direction: column; gap: 6px; }
.skill-name { display: flex; align-items: center; font-weight: 700; }
.skill-name span:nth-of-type(1) { flex: 1; }
.skill-icon { width: 22px; height: 22px; margin-right: 8px; }
.skill-bar-container { height: 12px; background: rgba(214, 40, 57, 0.1); border-radius: 6px; overflow: hidden; }
.skill-bar { height: 100%; width: 0; border-radius: 6px; }
#python-bar { background: linear-gradient(90deg, var(--cap), var(--cap-soft)); }
#cpp-bar { background: linear-gradient(90deg, #E4577A, var(--petal)); }
#csharp-bar { background: linear-gradient(90deg, var(--petal), #FBD5E1); }

#results-button-container { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 25; }
#results-theme {
  padding: 8px 18px; border-radius: 20px; cursor: pointer; font-size: 14px; font-weight: 700;
  background: var(--milk); color: var(--cap); border: 1.5px solid var(--cap); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); transition: all 0.3s;
}
#results-theme:hover { background: var(--cap); color: var(--milk); }
#results-hint {
  position: absolute; top: 46px; left: 50%; transform: translateX(-50%); width: 190px; padding: 8px 12px;
  background: var(--ink); color: var(--milk); font-size: 12px; text-align: center; border-radius: 12px; pointer-events: none;
}

.top-controls {
  position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 25;
  display: flex; align-items: center; gap: 16px; padding: 8px 16px; border-radius: 22px;
  background: var(--glass); border: 1px solid var(--line); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.volume-control, .transparency-control { display: flex; align-items: center; gap: 8px; }
.volume-icon, .transparency-icon { width: 20px; height: 20px; color: var(--cap); cursor: pointer; }
.volume-icon:hover { color: var(--cap-soft); }
.slider { -webkit-appearance: none; appearance: none; width: 80px; height: 6px; border-radius: 3px; outline: none; cursor: pointer; background: linear-gradient(90deg, var(--petal), var(--cap)); }
.slider::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%; background: var(--milk); border: 2px solid var(--cap); cursor: pointer; }
.slider::-moz-range-thumb { width: 10px; height: 10px; border-radius: 50%; background: var(--milk); border: 2px solid var(--cap); cursor: pointer; }
:focus-visible { outline: 2px solid var(--cap); outline-offset: 3px; }

.discord-avatar-wrap { position: relative; width: 100%; height: 100%; }
.discord-avatar-wrap .profile-picture { width: 100%; height: 100%; }
.status-dot { display: inline-block; border-radius: 50%; }
#mainFrame { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 113%; height: 113%; pointer-events: none; z-index: 3; }
#mainStatusIndicator { position: absolute; bottom: 6%; right: 6%; width: 12%; height: 12%; min-width: 14px; min-height: 14px; border: 3px solid var(--milk); z-index: 4; }
.status-online { background: #23a55a; } .status-idle { background: #f0b232; }
.status-dnd { background: #f23f43; } .status-offline { background: #9a8a8e; }
#discordBadges img { cursor: default; }

.glitch { animation: wiggle 0.2s ease-in-out; }
@keyframes wiggle { 0%,100% { transform: translate(0); } 25% { transform: translate(-2px, 1px); } 75% { transform: translate(2px, -1px); } }
@keyframes orbit { to { transform: rotate(360deg); } }

@media (max-width: 430px) {
  #profile-block, #skills-block { width: 90vw; max-width: 350px; min-height: 280px; padding: 16px; }
  .profile-header { flex-direction: column; align-items: center; gap: 18px; margin-top: 8px; }
  .profile-container, .profile-picture { width: 120px; height: 120px; }
  .profile-info { align-items: center; text-align: center; }
  #profile-name { font-size: 24px; white-space: normal; }
  #profile-bio { font-size: 14px; }
  .badge { width: 18px; height: 18px; }
  .social-icon { width: 34px; height: 34px; }
  .visitor-counter { align-self: center; font-size: 12px; }
  .skills-title { font-size: 20px; }
  .forest svg.ground { height: 30vh; }
  .top-controls { gap: 10px; padding: 6px 12px; }
  .slider { width: 56px; }
}

.trunk { position: absolute; top: -5%; bottom: 0; width: 7vw; min-width: 46px; background: linear-gradient(90deg, rgba(196,120,130,.34), rgba(233,190,198,.18)); }
.trunk.l { left: 0; border-radius: 0 40px 0 0; }
.trunk.r { right: 0; transform: scaleX(-1); border-radius: 0 28px 0 0; }
.leaf-hang { position: absolute; background: #CFE3C8; opacity: .75; border-radius: 0 100% 0 100%; }
.leaf-hang.a { top: -6vh; left: 5vw; width: 22vw; height: 18vh; transform: rotate(8deg); }
.leaf-hang.b { top: -8vh; right: 4vw; width: 18vw; height: 15vh; transform: scaleX(-1) rotate(10deg); }
@media (max-width: 430px) { .trunk { width: 10vw; } }

/* =====================================================================
   MÀN HÌNH MỞ ĐẦU
   ===================================================================== */
#start-screen {
  position: fixed; inset: 0; z-index: 30;
  cursor: pointer;
  overflow: hidden;
  background-color: #FDE9EF;
  
  /* Thêm dòng này để màu nền mờ dần (fade-out) đồng bộ với animation GSAP */
  transition: background-color 0.9s ease 0.4s; 
}

.start-bg {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at 50% 30%, #FFFAF8 0%, #FDE9EF 55%, #F8C9D8 100%);
  transition: opacity 0.9s ease;
}
.start-bg::after {
  content: '';
  position: absolute; left: 50%; top: -20%;
  width: min(140vw, 1400px); height: 90%;
  transform: translateX(-50%);
  background: radial-gradient(closest-side, rgba(255,255,255,0.92), rgba(255,244,236,0.4) 55%, transparent);
  animation: sun-breathe 8s ease-in-out infinite alternate;
  will-change: transform, opacity;
}
@keyframes sun-breathe {
  from { opacity: 0.6; transform: translateX(-50%) scale(0.95); }
  to   { opacity: 1;   transform: translateX(-50%) scale(1.06); }
}

.start-scene {
  position: absolute; inset: 0;
  pointer-events: none;
  transition: opacity 0.9s ease;
}
.start-scene svg {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block;
  overflow: visible;
}

/* Nấm mọc lên */
.sc-piece {
  transform-box: fill-box;
  transform-origin: 50% 100%;
  animation: piece-grow 0.85s cubic-bezier(0.34, 1.56, 0.64, 1) var(--d, 0s) both;
  will-change: transform, opacity;
}
@keyframes piece-grow {
  from { transform: scaleY(0.05) scaleX(0.6); opacity: 0; }
  to   { transform: scaleY(1)    scaleX(1);   opacity: 1; }
}

/* Bào tử bay */
.start-spores { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 4; }
.start-spores i {
  position: absolute; bottom: -20px;
  width: var(--size, 6px); height: var(--size, 6px);
  border-radius: 50%;
  background: radial-gradient(circle, #fff 0 40%, var(--hue, #fff) 75%, transparent);
  box-shadow: 0 0 10px 2px rgba(246,182,202,0.55);
  opacity: 0;
  animation: spore-float var(--dur, 14s) linear var(--delay, 0s) infinite;
  will-change: transform, opacity;
}
@keyframes spore-float {
  0%   { transform: translate3d(0, 0, 0); opacity: 0; }
  10%  { opacity: 0.95; }
  85%  { opacity: 0.95; }
  100% { transform: translate3d(var(--dx, 20px), -105vh, 0); opacity: 0; }
}

/* Text giữa màn hình */
.start-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0 20px;
  pointer-events: none;
  z-index: 6;
  opacity: 0;
  animation: fade-in-center 1s 0.9s ease forwards;
}
@keyframes fade-in-center {
  from { opacity: 0; transform: translate(-50%, -50%) translateY(14px); }
  to   { opacity: 1; transform: translate(-50%, -50%) translateY(0); }
}

#start-text {
  font-family: 'Fraunces', Georgia, serif;
  font-style: italic;
  font-weight: 400;
  font-size: clamp(20px, 2.6vw, 30px);
  letter-spacing: 1.5px;
  color: var(--cap);
  white-space: nowrap;
  text-shadow:
    0 2px 0 #fff,
    0 0 18px rgba(255, 255, 255, 0.9),
    0 0 40px rgba(214, 40, 57, 0.15);
  line-height: 1.3;
}

/* Trạng thái khi click vào */
#start-screen.leaving { 
  pointer-events: none; 
  cursor: default; 
  background-color: transparent; /* Ra lệnh cho nền chuyển dần sang trong suốt */
}
#start-screen.leaving .start-bg { opacity: 0; }
#start-screen.leaving .start-spores { opacity: 0; transition: opacity 0.5s; }
#start-screen.leaving .start-center {
  animation: none;
  opacity: 0;
  transition: opacity 0.4s ease, transform 0.4s ease;
  transform: translate(-50%, -50%) translateY(-16px);
}

@media (max-width: 430px) {
  #start-text {
    font-size: clamp(16px, 5vw, 20px);
    white-space: normal;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sc-piece { animation: none; }
  .start-spores i { animation: none; display: none; }
  .start-bg::after { animation: none; }
  .start-center { animation: none; opacity: 1; }
}

/* Ẩn triệt để nút View Results và thanh điều khiển khi màn hình start đang bật */
#start-screen:not(.hidden) ~ .container #results-button-container,
#start-screen:not(.hidden) ~ .container .top-controls {
    display: none !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* Nút View Results chỉ hiện ra khi màn hình start đã bị tắt */
#start-screen.hidden ~ .container #results-button-container.hidden {
    display: block !important;
}

/* =====================================================================
   VỊ TRÍ NẤM Ở CẠNH MÀN HÌNH (DESKTOP & MOBILE)
   ===================================================================== */
/* Mặc định cho Desktop (Màn hình ngang) */
.m-bot-center { transform: translate(600px, 850px) scale(4.5) translate(-70px, -90px); }
.m-bot-left   { transform: translate(150px, 820px) scale(3.5) rotate(20deg) translate(-70px, -90px); }
.m-bot-right  { transform: translate(1050px, 820px) scale(3.5) rotate(-20deg) translate(-70px, -90px); }
.m-mid-left   { transform: translate(-20px, 380px) scale(2.8) rotate(75deg) translate(-70px, -90px); }
.m-mid-right  { transform: translate(1220px, 380px) scale(2.8) rotate(-75deg) translate(-70px, -90px); }
.m-top-left   { transform: translate(60px, -20px) scale(2.2) rotate(135deg) translate(-70px, -90px); }
.m-top-right  { transform: translate(1140px, -20px) scale(2.2) rotate(-135deg) translate(-70px, -90px); }

/* Điều chỉnh lại cho Mobile (Màn hình dọc) - Giấu cuống, chỉ lộ mũ nấm */
@media (max-width: 768px) {
    /* Đẩy cụm nấm dưới cùng xuống sâu hơn */
    .m-bot-center { transform: translate(600px, 830px) scale(3.5) translate(-70px, -90px); }
    .m-bot-left   { transform: translate(320px, 800px) scale(2.5) rotate(30deg) translate(-70px, -90px); }
    .m-bot-right  { transform: translate(880px, 800px) scale(2.5) rotate(-30deg) translate(-70px, -90px); }

    /* Đẩy nấm 2 bên dạt hẳn ra ngoài lề (toạ độ 290 và 910) */
    .m-mid-left   { transform: translate(290px, 350px) scale(2.4) rotate(90deg) translate(-70px, -90px); }
    .m-mid-right  { transform: translate(910px, 350px) scale(2.4) rotate(-90deg) translate(-70px, -90px); }

    /* Thu hẹp toạ độ nấm góc trên để nó bám sát góc màn hình dọc */
    .m-top-left   { transform: translate(320px, -50px) scale(2.2) rotate(135deg) translate(-70px, -90px); }
    .m-top-right  { transform: translate(880px, -50px) scale(2.2) rotate(-135deg) translate(-70px, -90px); }
}