:root {
  --bg: #080d20;
  --tx: #e9ecff;
  --mu: #9aa3d6;
  --ln: rgba(130, 149, 255, 0.18);
  --am: #ffb454;
  --pw: #8295ff;
  /* 3D Hero Scene Opacity & Visual Prominence Controls:
     Change these anytime to tune the 3D models and background canvas */
  --hero-3d-opacity: 0.74;     /* Opacity of 3D Chess & Piano models/pedestals (0.0 to 1.0) */
  --hero-canvas-opacity: 0.88; /* Master opacity of 3D WebGL background canvas */
  color-scheme: dark;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  position: relative;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 80px;
  scroll-padding-bottom: 120px;
}

body {
  background: var(--bg);
  color: var(--tx);
  font: 400 1.02rem/1.65 Figtree, system-ui, -apple-system, sans-serif;
}

h1, h2, h3, .logo, .stats b, .me-meta b {
  font-family: 'Bricolage Grotesque', Figtree, sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}

:focus-visible {
  outline: 2px solid var(--am);
  outline-offset: 3px;
}

#bg {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

#bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0;
  background: linear-gradient(90deg, var(--am), #ff6b8b, var(--pw));
  z-index: 50;
  box-shadow: 0 0 12px var(--am);
}

/* ---------- Top Header & Navigation ---------- */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 40;
  width: 100%;
  background: linear-gradient(180deg, rgba(11, 16, 38, 0.96) 0%, rgba(11, 16, 38, 0.82) 75%, transparent 100%);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(160, 170, 255, 0.12);
}

.top-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px clamp(16px, 4vw, 48px);
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

.top-nav .logo {
  font-weight: 800;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.nav-links {
  display: flex;
  gap: clamp(10px, 1.6vw, 24px);
  font-size: 0.92rem;
  color: var(--mu);
}

.nav-links a {
  transition: color 0.2s;
  padding: 4px 6px;
}

.nav-links a:hover, .nav-links a.on {
  color: var(--am);
}

.nav-resume {
  font-size: 0.85rem;
  padding: 6px 16px;
  min-height: 36px;
  flex-shrink: 0;
  background: rgba(124, 140, 255, 0.12);
  border-color: var(--pw);
  color: var(--tx);
}

.nav-resume:hover {
  background: var(--pw);
  color: var(--bg);
}

/* ---------- Floating Mobile & Tablet Bottom Dock ---------- */
.mobile-dock {
  display: none;
}

/* ---------- Common Container & Typography ---------- */
header, section, footer {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 100%;
}

.panel {
  background: rgba(8, 13, 32, 0.74);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid rgba(130, 149, 255, 0.1);
  border-bottom: 1px solid rgba(130, 149, 255, 0.05);
  padding: clamp(52px, 8vw, 110px) clamp(16px, 5vw, 84px);
  width: 100%;
  max-width: 100%;
}

.panel > * {
  max-width: 1080px;
  margin-inline: auto;
  width: 100%;
}

h2 {
  font-size: clamp(2rem, 4.5vw, 3.6rem);
  line-height: 1.08;
  font-weight: 800;
  letter-spacing: -0.025em;
  margin-bottom: 18px;
  text-align: center;
}

h2 + :not(.sub) {
  margin-top: 36px;
}

.sub {
  max-width: 44rem;
  color: var(--mu);
  margin: 0 auto 40px;
  font-size: clamp(0.96rem, 1.8vw, 1.05rem);
  text-align: center;
  line-height: 1.6;
}

/* ---------- Hero Section (Centered on Desktop) ---------- */
.hero {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  max-width: 900px;
  margin-inline: auto;
  padding: clamp(100px, 14vh, 145px) clamp(20px, 5vw, 60px) clamp(44px, 8vh, 80px);
  width: 100%;
  position: relative;
}

.hero::before {
  content: "";
  position: absolute;
  top: 42%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(880px, 92vw);
  height: min(540px, 65vh);
  background: radial-gradient(ellipse at center, rgba(130, 149, 255, 0.14) 0%, rgba(23, 31, 73, 0.4) 45%, transparent 72%);
  pointer-events: none;
  z-index: -1;
  filter: blur(35px);
}

.hero > * {
  animation: up 0.9s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
.hero > :nth-child(2) { animation-delay: 0.1s; }
.hero > :nth-child(3) { animation-delay: 0.2s; }
.hero > :nth-child(4) { animation-delay: 0.35s; }
.hero > :nth-child(5) { animation-delay: 0.5s; }

@keyframes up {
  from { opacity: 0; transform: translateY(24px); }
}

.hero-intro {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-bottom: 8px;
}

.hero-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 2px solid var(--am);
  background: linear-gradient(160deg, rgba(124, 140, 255, 0.35), rgba(255, 180, 84, 0.25));
  overflow: hidden;
  box-shadow: 0 4px 18px rgba(255, 180, 84, 0.3);
  flex-shrink: 0;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--am);
}

.hero-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  display: block;
  background: transparent;
  padding: 0;
}

.hi {
  color: var(--am);
  font-weight: 600;
  font-size: 1.2rem;
}

h1 {
  font-size: clamp(2.8rem, 8.5vw, 6.5rem);
  line-height: 0.94;
  font-weight: 800;
  letter-spacing: -0.04em;
  margin: 6px 0 20px;
  word-break: break-word;
  max-width: 100%;
  text-align: center;
}

.lead {
  max-width: 36rem;
  margin-inline: auto;
  font-size: clamp(1.08rem, 2.2vw, 1.25rem);
  color: var(--tx);
  line-height: 1.6;
  text-align: center;
}

.hero .ctl {
  justify-content: center;
  margin-top: 24px;
}

.hint {
  max-width: 30rem;
  margin: 22px auto 0;
  color: var(--mu);
  font-size: 0.92rem;
  text-align: center;
}

/* ---------- Buttons & Controls ---------- */
.ctl {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-top: 20px;
  max-width: 100%;
}

button, .btn {
  font: 600 0.94rem Figtree, sans-serif;
  color: var(--tx);
  background: transparent;
  border: 1px solid var(--pw);
  border-radius: 999px;
  padding: 10px 20px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.2s, color 0.2s, transform 0.15s, box-shadow 0.2s, border-color 0.2s;
  max-width: 100%;
}

button:hover, .btn:hover {
  background: var(--pw);
  color: var(--bg);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(124, 140, 255, 0.25);
}

button:active, .btn:active {
  transform: scale(0.97);
}

button:first-child, .btn:first-child {
  background: var(--am);
  border-color: var(--am);
  color: var(--bg);
}

button:first-child:hover, .btn:first-child:hover {
  box-shadow: 0 4px 20px rgba(255, 180, 84, 0.35);
}

.btn.ghost {
  background: transparent;
  border-color: var(--pw);
  color: var(--tx);
}

.btn.ghost:hover {
  background: var(--pw);
  color: var(--bg);
}

output {
  color: var(--mu);
  margin-left: 4px;
}

/* ---------- Stats Section (Centered Floating Card) ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1px;
  background: var(--ln);
  border: 1px solid var(--ln);
  border-radius: 16px;
  overflow: hidden;
  max-width: 1080px;
  margin: 0 auto;
  width: calc(100% - 32px);
}

.stats div {
  background: rgba(11, 16, 38, 0.82);
  padding: clamp(24px, 3.5vw, 36px) clamp(16px, 2.5vw, 32px);
  transition: background 0.3s;
}

.stats div:hover {
  background: rgba(20, 28, 60, 0.9);
}

.stats b {
  display: block;
  font-size: clamp(2rem, 4vw, 3.4rem);
  line-height: 1;
  color: var(--am);
  margin-bottom: 6px;
}

.stats span {
  color: var(--mu);
  font-size: clamp(0.85rem, 1.5vw, 0.95rem);
}

/* ---------- Tech Stack Ticker ---------- */
.stack {
  position: relative;
  z-index: 1;
  overflow: hidden;
  background: rgba(11, 16, 38, 0.82);
  border-bottom: 1px solid var(--ln);
  padding: 20px 0;
  width: 100%;
  max-width: 100%;
}

#stack {
  display: flex;
  width: max-content;
  animation: mq 45s linear infinite;
}

.stack:hover #stack {
  animation-play-state: paused;
}

#stack figure {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-right: 42px;
  min-width: 52px;
  color: var(--mu);
  font-size: 0.8rem;
  transition: transform 0.2s;
}

#stack figure:hover {
  transform: scale(1.15);
}

#stack img {
  width: 28px;
  height: 28px;
}

@keyframes mq {
  to { transform: translateX(-50%); }
}

/* ---------- Pathfinding Search Lab ---------- */
#grid {
  display: block;
  width: 100%;
  max-width: 980px;
  margin-inline: auto;
  height: auto;
  border: 1px solid var(--ln);
  border-radius: 10px;
  background: #0e1533;
  cursor: crosshair;
  touch-action: none;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

#lab .ctl {
  max-width: 980px;
  margin: 20px auto 0;
}

/* ---------- Work Timeline ---------- */
.tl {
  position: relative;
  padding-left: 36px;
  --p: 0;
  width: 100%;
  max-width: 760px;
  margin-inline: auto;
}

.tl::before, .tl::after {
  content: "";
  position: absolute;
  left: 7px;
  top: 18px;
  width: 2px;
  height: var(--h, 100%);
  background: var(--ln);
}

.tl::after {
  height: calc(var(--h, 100%) * var(--p));
  background: var(--am);
  box-shadow: 0 0 8px var(--am);
}

.tl article {
  position: relative;
  padding-bottom: 38px;
}

.tl article:last-child {
  padding-bottom: 0;
}

.tl article::before {
  content: "";
  position: absolute;
  z-index: 2;
  left: -36px;
  top: 10px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--am);
  transition: box-shadow 0.3s;
}

.tl article:hover::before {
  box-shadow: 0 0 12px var(--am);
}

h3 {
  font-size: 1.35rem;
  font-weight: 500;
}

time {
  display: block;
  color: var(--am);
  font-size: 0.9rem;
  margin: 2px 0 8px;
}

.tl p {
  max-width: 100%;
  color: var(--mu);
  line-height: 1.6;
}

.tl p a {
  color: var(--am);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ---------- Cards (Education & Projects) ---------- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
  gap: clamp(14px, 2.5vw, 22px);
  width: 100%;
  max-width: 100%;
}

#projects .cards {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr));
}

.card {
  display: block;
  padding: clamp(20px, 3.5vw, 26px);
  border: 1px solid var(--ln);
  border-radius: 14px;
  background: rgba(124, 140, 255, 0.07);
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.3s;
  max-width: 100%;
}

.card:hover {
  border-color: var(--am);
  box-shadow: 0 8px 32px rgba(255, 180, 84, 0.12);
  transform: translateY(-2px);
}

.card p {
  color: var(--mu);
  margin: 10px 0 16px;
}

.card small {
  color: var(--pw);
  font-size: 0.85rem;
}

.card b {
  color: var(--tx);
  font-weight: 600;
}

.edu-h {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 10px;
}

.edu-h time {
  margin: 2px 0 0;
}

.edu-h h3 {
  font-size: 1.15rem;
  line-height: 1.3;
}

/* ---------- Research Papers ---------- */
.papers {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr));
  gap: clamp(16px, 2.5vw, 24px);
  width: 100%;
  max-width: 940px;
  margin-inline: auto;
}

.paper {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: clamp(20px, 3.5vw, 26px);
  border: 1px solid var(--ln);
  border-radius: 14px;
  background: rgba(124, 140, 255, 0.07);
  transition: border-color 0.2s, box-shadow 0.3s, transform 0.2s;
  max-width: 100%;
}

.paper:hover {
  border-color: var(--pw);
  box-shadow: 0 8px 32px rgba(124, 140, 255, 0.12);
  transform: translateY(-2px);
}

.paper h3 {
  font-size: 1.2rem;
  line-height: 1.35;
}

.paper p {
  color: var(--mu);
}

.paper .btn {
  align-self: flex-start;
  margin-top: auto;
}

.pm {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  color: var(--mu);
  font-size: 0.9rem;
}

.tag {
  padding: 3px 12px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.8rem;
  border: 1px solid;
}

.tag.pub {
  color: #4ee0a0;
  border-color: #4ee0a0;
}

.tag.pres {
  color: var(--am);
  border-color: var(--am);
}

/* ---------- Skills Force Graph ---------- */
#sg {
  display: block;
  width: 100%;
  max-width: 980px;
  margin-inline: auto;
  height: 480px;
  border: 1px solid var(--ln);
  border-radius: 12px;
  background: radial-gradient(ellipse at center, rgba(20, 28, 60, 0.9), #0e1533);
  touch-action: pan-y;
  box-shadow: inset 0 0 60px rgba(124, 140, 255, 0.05);
}

.legend {
  color: var(--mu);
  font-size: 0.9rem;
  margin-top: 14px;
  text-align: center;
}

.legend .d {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin: 0 6px 0 0;
}

.legend .d + .d, .legend .d.b {
  margin-left: 18px;
}

.d.a { background: var(--am); }
.d.b { background: var(--pw); }

/* ---------- Certifications & Awards ---------- */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
  justify-content: center;
}

.chips button {
  background: transparent;
  border-color: var(--pw);
  color: var(--tx);
  padding: 8px 16px;
  min-height: 38px;
}

.chips button.on {
  background: var(--pw);
  color: var(--bg);
}

.certs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr));
  gap: 14px;
  width: 100%;
  max-width: 1040px;
  margin-inline: auto;
  justify-content: center;
}

#certs .ctl {
  justify-content: center;
  margin-top: 24px;
}

.cert {
  padding: 16px 18px;
  border: 1px solid var(--ln);
  border-left: 3px solid var(--pw);
  border-radius: 10px;
  background: rgba(124, 140, 255, 0.06);
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
  max-width: 100%;
}

.cert:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(124, 140, 255, 0.1);
}

.cert[data-t=comp] { border-left-color: var(--am); }
.cert[data-t=res] { border-left-color: #4ee0a0; }

.cert h4 {
  font: 600 1rem/1.35 Figtree, sans-serif;
  margin-bottom: 6px;
}

.cert span {
  color: var(--mu);
  font-size: 0.88rem;
}

a.cert {
  display: block;
}

a.cert:hover {
  border-color: var(--am);
}

.cert em {
  display: block;
  margin-top: 8px;
  color: var(--am);
  font-style: normal;
  font-size: 0.88rem;
  font-weight: 600;
}

/* ---------- Away from the Keyboard (About, Lifts, Chess, Piano) ---------- */
.about {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 52px;
  align-items: start;
  width: 100%;
  max-width: 980px;
  margin-inline: auto;
}

.me-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 90px;
}

.me {
  position: relative;
  aspect-ratio: 4 / 5;
  width: 100%;
  max-width: 260px;
  border-radius: 20px;
  border: 2px solid rgba(255, 180, 84, 0.35);
  background: linear-gradient(160deg, rgba(124, 140, 255, 0.25), rgba(255, 180, 84, 0.18));
  display: grid;
  place-items: center;
  font: 800 3.6rem 'Bricolage Grotesque', sans-serif;
  color: var(--am);
  overflow: hidden;
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.5), 0 0 28px rgba(124, 140, 255, 0.2);
  transition: transform 0.3s cubic-bezier(0.2, 0.7, 0.2, 1), box-shadow 0.3s ease, border-color 0.3s ease;
}

.me:hover {
  transform: translateY(-4px) scale(1.02);
  border-color: var(--am);
  box-shadow: 0 22px 52px rgba(0, 0, 0, 0.6), 0 0 36px rgba(255, 180, 84, 0.35);
}

.me img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  display: block;
  background: transparent;
  padding: 0;
  border-radius: 18px;
}

.me-meta {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.me-meta b {
  font-size: 1.12rem;
  color: var(--tx);
  letter-spacing: -0.01em;
}

.me-meta span {
  font-size: 0.85rem;
  color: var(--am);
  font-weight: 500;
}

.me-physique {
  display: inline-block;
  margin-top: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--am);
  background: rgba(255, 180, 84, 0.12);
  border: 1px solid rgba(255, 180, 84, 0.32);
  padding: 4px 12px;
  border-radius: 999px;
  letter-spacing: 0.02em;
}

.lifts {
  display: grid;
  gap: 14px;
  max-width: 580px;
  margin-bottom: 40px;
  width: 100%;
}

.lifts div {
  display: grid;
  grid-template-columns: minmax(130px, 170px) 1fr 76px;
  gap: 14px;
  align-items: center;
}

.lift-name {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
  font-weight: 600;
  color: var(--tx);
  font-size: 0.92rem;
}

.lift-name small {
  font-size: 0.76rem;
  font-weight: 500;
  color: var(--am);
  opacity: 0.95;
  margin-top: 2px;
}

.lifts i {
  display: block;
  height: 10px;
  border-radius: 5px;
  background: linear-gradient(90deg, var(--am), #ff6b8b);
  width: 0;
  transition: width 1.4s cubic-bezier(0.2, 0.7, 0.2, 1);
  box-shadow: 0 0 8px rgba(255, 180, 84, 0.3);
}

.lifts.in i {
  width: calc(var(--v) / 300 * 100%);
}

.lifts b {
  text-align: right;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--tx);
  white-space: nowrap;
}

/* Chess (Knight's Tour) */
.chess {
  display: grid;
  grid-template-columns: minmax(0, 340px) 1fr;
  gap: 36px;
  align-items: center;
  padding-top: 40px;
  border-top: 1px solid var(--ln);
  width: 100%;
  max-width: 100%;
}

#knight {
  display: block;
  width: 100%;
  max-width: 360px;
  aspect-ratio: 1;
  border-radius: 10px;
  border: 1px solid var(--ln);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

.chess .sub {
  margin: 10px 0 20px;
}

.chess .playme {
  margin: 28px 0 12px;
}

/* ---------- Piano (100% Responsive Concert Grand) ---------- */
.piano {
  padding-top: 40px;
  margin-top: 40px;
  border-top: 1px solid var(--ln);
  width: 100%;
  max-width: 100%;
}

.piano h3 {
  text-align: center;
}

.piano .sub {
  text-align: center;
  max-width: 44rem;
  margin: 10px auto 20px;
}

/* Octave Navigator - Fits 100% with ZERO Overflow */
.octave-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 0 auto 14px;
  max-width: 880px;
  width: 100%;
}

.nav-arrow {
  width: 36px;
  height: 36px;
  min-height: 36px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: 0.85rem;
  border: 1px solid var(--ln);
  background: rgba(124, 140, 255, 0.08);
  color: var(--tx);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s, border-color 0.2s, transform 0.15s;
}

.nav-arrow:hover {
  background: var(--am);
  border-color: var(--am);
  color: var(--bg);
  transform: scale(1.08);
}

.oct-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  width: 100%;
}

.oct-chips button {
  padding: 6px 14px;
  min-height: 36px;
  font-size: clamp(0.75rem, 1.6vw, 0.84rem);
  white-space: nowrap;
  border-radius: 999px;
  border: 1px solid var(--ln);
  background: rgba(124, 140, 255, 0.06);
  color: var(--tx);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s, box-shadow 0.2s;
}

.oct-chips button.on {
  background: linear-gradient(135deg, var(--am), #ff9f43);
  border-color: var(--am);
  color: #0a0e24;
  font-weight: 700;
  box-shadow: 0 0 12px rgba(255, 180, 84, 0.35);
}

/* Piano Stage - Fits 100% of Width with NO Horizontal Scrollbar */
.piano-viewport {
  position: relative;
  width: 100%;
  max-width: 880px;
  margin: 0 auto;
  overflow: hidden;
  border-radius: 12px;
  border: 1px solid var(--ln);
  background: #090e24;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6);
}

.piano-track {
  position: relative;
  width: 100%;
}

.piano-visualizer {
  position: relative;
  width: 100%;
  height: 130px;
  background: linear-gradient(180deg, rgba(14, 21, 51, 0.95) 0%, rgba(14, 21, 51, 0.6) 100%);
  border-bottom: 1px solid var(--ln);
  overflow: hidden;
}

#noteCanvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* Responsive Piano Keyboard - Keys Scale to Fill 100% Width */
.kbd {
  position: relative;
  display: flex;
  width: 100%;
  height: 165px;
  user-select: none;
  background: #0d1230;
}

.kbd .wk {
  flex: 1;
  min-width: 0;
  margin: 0;
  padding: 0 0 10px;
  border: 0;
  border-right: 1px solid rgba(20, 28, 60, 0.6);
  border-radius: 0 0 5px 5px;
  background: linear-gradient(180deg, #f0f2ff 0%, #d8deff 60%, #c0c8f4 100%);
  color: #3a4170;
  font: 600 clamp(0.55rem, 1.2vw, 0.68rem) Figtree, sans-serif;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  transform-origin: top;
  transition: transform 0.06s, background 0.06s, box-shadow 0.06s;
  cursor: pointer;
  min-height: unset;
}

.kbd .wk:last-of-type {
  border-right: 0;
}

.kbd .wk span {
  pointer-events: none;
  opacity: 0.85;
}

.kbd .wk b {
  color: inherit;
  font-weight: 700;
}

.kbd .bk {
  position: absolute;
  top: 0;
  height: 58%;
  padding: 0;
  border: 0;
  border-radius: 0 0 4px 4px;
  background: linear-gradient(180deg, #1c255c 0%, #0c102a 100%);
  z-index: 2;
  transform-origin: top;
  transition: transform 0.06s, background 0.06s, box-shadow 0.06s;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.6), inset 0 -2px 3px rgba(255, 255, 255, 0.06);
  cursor: pointer;
  min-height: unset;
}

.kbd .wk.on, .kbd .wk:active {
  transform: rotateX(-4deg);
  background: linear-gradient(180deg, #ffd9a1, var(--am));
  box-shadow: 0 0 20px rgba(255, 180, 84, 0.4);
}

.kbd .bk.on, .kbd .bk:active {
  transform: rotateX(-5deg);
  background: linear-gradient(180deg, #cc8a2a, #995e10);
  box-shadow: 0 0 16px rgba(255, 180, 84, 0.3);
}

/* Piece selector - Clean wrapping chips */
.piece-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 20px;
  width: 100%;
  justify-content: center;
}

.piece-selector button {
  font-size: clamp(0.76rem, 1.8vw, 0.85rem);
  padding: 8px 14px;
  min-height: 38px;
  border-color: var(--ln);
  background: rgba(124, 140, 255, 0.07);
  position: relative;
  overflow: hidden;
  max-width: 100%;
}

.piece-selector button:hover {
  border-color: var(--am);
  background: rgba(255, 180, 84, 0.1);
}

.piece-selector button.playing {
  border-color: var(--am);
  background: rgba(255, 180, 84, 0.15);
  box-shadow: 0 0 16px rgba(255, 180, 84, 0.2);
}

.piece-selector button.playing::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  background: var(--am);
  animation: piece-progress linear forwards;
}

@keyframes piece-progress {
  from { width: 0; }
  to { width: 100%; }
}

/* Piano controls */
.piano-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 16px;
  width: 100%;
  justify-content: center;
}

.piano-controls .btn, .piano-controls button {
  padding: 8px 16px;
  min-height: 40px;
  font-size: 0.88rem;
}

.piano-controls .speed-control {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  color: var(--mu);
  font-size: 0.88rem;
}

.piano-controls .speed-control input[type=range] {
  width: 100px;
  accent-color: var(--am);
}

/* Now playing badge */
.now-playing {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(255, 180, 84, 0.12);
  border: 1px solid rgba(255, 180, 84, 0.25);
  color: var(--am);
  font-size: 0.85rem;
  font-weight: 600;
  margin-top: 12px;
  opacity: 0;
  transition: opacity 0.3s;
}

.now-playing.show {
  display: flex;
  width: fit-content;
  margin: 14px auto 0;
  opacity: 1;
}

.now-playing .bars {
  display: flex;
  gap: 2px;
  height: 14px;
  align-items: flex-end;
}

.now-playing .bars span {
  display: block;
  width: 3px;
  background: var(--am);
  border-radius: 2px;
  animation: bar-bounce 0.8s ease-in-out infinite;
}

.now-playing .bars span:nth-child(2) { animation-delay: 0.15s; }
.now-playing .bars span:nth-child(3) { animation-delay: 0.3s; }

@keyframes bar-bounce {
  0%, 100% { height: 4px; }
  50% { height: 14px; }
}

/* ---------- Profiles Grid ---------- */
.prof {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 14px;
  width: 100%;
  max-width: 980px;
  margin-inline: auto;
  justify-content: center;
}

.prof a {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 18px 14px;
  border: 1px solid var(--ln);
  border-radius: 10px;
  transition: transform 0.2s, border-color 0.2s, background 0.2s, box-shadow 0.3s;
  max-width: 100%;
}

.prof a:hover {
  transform: translateY(-3px);
  border-color: var(--am);
  background: rgba(255, 180, 84, 0.08);
  box-shadow: 0 8px 24px rgba(255, 180, 84, 0.12);
}

.prof img {
  margin-bottom: 10px;
}

.prof span {
  color: var(--mu);
  font-size: 0.88rem;
}

/* ---------- Contact Section (Generous Bottom Clearance) ---------- */
#contact {
  padding-bottom: clamp(120px, 16vh, 180px);
  text-align: center;
}

#contact .sub {
  margin-inline: auto;
  text-align: center;
}

#contact .ctl {
  justify-content: center;
  margin: 24px auto 0;
  max-width: 760px;
}

/* ---------- Footer & Dialog ---------- */
footer {
  background: var(--bg);
  text-align: center;
  color: var(--mu);
  padding: 36px 20px calc(110px + env(safe-area-inset-bottom));
  font-size: 0.9rem;
  width: 100%;
  border-top: 1px solid var(--ln);
}

dialog {
  width: min(96vw, 1100px);
  max-height: 94vh;
  overflow: auto;
  border: 1px solid var(--ln);
  border-radius: 14px;
  background: var(--bg);
  color: var(--tx);
  padding: 14px;
}

dialog::backdrop {
  background: rgba(5, 8, 20, 0.82);
  backdrop-filter: blur(4px);
}

#lbi {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  cursor: zoom-in;
}

#lbi.full {
  max-width: none;
  width: 1600px;
  cursor: zoom-out;
}

#lbx {
  position: sticky;
  top: 0;
  float: right;
  margin: 0 0 8px 8px;
  padding: 6px 16px;
}

[hidden] {
  display: none !important;
}

/* ==========================================================================
   RESPONSIVE DESIGN: TABLETS & MOBILE PHONES
   ========================================================================== */

/* ---------- Tablet Breakpoint (<= 960px) ---------- */
@media (max-width: 960px) {
  body {
    padding-bottom: calc(76px + env(safe-area-inset-bottom));
  }

  /* Hide 9 desktop text links from top bar so they never overlap the logo */
  .nav-links {
    display: none !important;
  }

  .site-header {
    border-bottom: 1px solid var(--ln);
  }

  .top-nav {
    padding: 10px 18px;
  }

  /* Floating Bottom Glass Navigation Dock */
  .mobile-dock {
    display: flex;
    position: fixed;
    left: 14px;
    right: 14px;
    bottom: max(14px, env(safe-area-inset-bottom));
    margin: 0 auto;
    max-width: 440px;
    width: calc(100% - 28px);
    justify-content: space-around;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    border: 1px solid rgba(160, 170, 255, 0.28);
    border-radius: 999px;
    background: rgba(11, 16, 38, 0.95);
    backdrop-filter: blur(18px);
    box-shadow: 0 10px 36px rgba(0, 0, 0, 0.7), 0 0 20px rgba(124, 140, 255, 0.15);
    z-index: 99;
  }

  .mobile-dock a {
    display: block;
    padding: 8px 12px;
    font-size: 0.84rem;
    font-weight: 600;
    color: var(--mu);
    white-space: nowrap;
    border-radius: 999px;
    transition: color 0.2s, background 0.2s;
  }

  .mobile-dock a.on {
    background: var(--am);
    color: var(--bg);
    font-weight: 700;
    box-shadow: 0 0 12px rgba(255, 180, 84, 0.4);
  }

  /* Balanced 2-Row Stats on Tablet */
  .stats {
    grid-template-columns: repeat(6, 1fr);
  }
  .stats div:nth-child(1),
  .stats div:nth-child(2),
  .stats div:nth-child(3) {
    grid-column: span 2;
  }
  .stats div:nth-child(4),
  .stats div:nth-child(5) {
    grid-column: span 3;
  }

  /* About Section Stacked Layout */
  .about {
    grid-template-columns: 1fr;
    gap: 36px;
  }

  .me-wrap {
    position: static;
    margin: 0 auto 16px;
  }

  .me {
    max-width: 250px;
  }

  /* Chess Tour */
  .chess {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  #knight {
    margin: 0 auto;
    max-width: 330px;
  }

  #sg {
    height: 440px;
  }
}

/* ---------- Mobile Phone Breakpoint (<= 640px) ---------- */
@media (max-width: 640px) {
  .hero {
    padding-inline: 18px;
  }

  h1 {
    font-size: clamp(2.6rem, 11vw, 4.2rem);
  }

  .hero-intro {
    gap: 10px;
  }

  .hero-avatar {
    width: 46px;
    height: 46px;
  }

  .mobile-dock {
    left: 10px;
    right: 10px;
    width: calc(100% - 20px);
    padding: 6px 8px;
  }

  .mobile-dock a {
    padding: 7px 10px;
    font-size: 0.8rem;
  }

  /* Stats on Mobile: 2 on row 1, 2 on row 2, 1 full-width on row 3 */
  .stats {
    grid-template-columns: 1fr 1fr;
    width: calc(100% - 24px);
    border-radius: 12px;
  }

  .stats div {
    padding: 20px 14px;
  }

  .stats div:last-child {
    grid-column: 1 / -1;
  }

  .panel {
    padding: 56px 18px;
  }

  /* Timeline on Phone */
  .tl {
    padding-left: 26px;
  }

  .tl::before, .tl::after {
    left: 5px;
  }

  .tl article::before {
    left: -26px;
    top: 8px;
    width: 14px;
    height: 14px;
  }

  /* Pathfinding Grid Controls */
  #stat {
    display: block;
    width: 100%;
    margin-left: 0;
    margin-top: 8px;
  }

  /* Gym Lifts */
  .lifts div {
    grid-template-columns: 125px 1fr 68px;
    gap: 10px;
    font-size: 0.88rem;
  }
  .lift-name {
    font-size: 0.84rem;
  }
  .lift-name small {
    font-size: 0.72rem;
  }
  .lifts b {
    font-size: 0.86rem;
  }

  /* Force Graph */
  #sg {
    height: 380px;
  }

  /* Piano on Mobile: zero scroll, compact keys */
  .kbd {
    height: 150px;
  }

  .piano-visualizer {
    height: 105px;
  }

  .piano-controls .speed-control {
    width: 100%;
    margin-left: 0;
    justify-content: space-between;
    padding: 6px 0;
  }

  .piano-controls .speed-control input[type=range] {
    flex: 1;
    max-width: 170px;
  }

  /* Profiles Grid on Mobile: 2 Neat Columns */
  .prof {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .prof a {
    padding: 14px;
  }

  .prof b {
    font-size: 0.95rem;
  }
}

/* ---------- Desktop Refinements (> 960px) ---------- */
@media (min-width: 961px) {
  footer {
    padding: 40px 20px 50px;
  }
  #contact {
    padding-bottom: clamp(90px, 12vh, 130px);
  }
}

/* ---------- Reduced Motion Mode ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
  .lifts i { transition: none !important; }
}

/* ---------- Immersive 3D concert universe ---------- */
body {
  background: radial-gradient(110% 85% at 50% 34%, #171f49 0%, #0d1330 48%, #080d20 100%) fixed;
}

html.no-webgl #bg {
  display: none;
}
