:root {
  --bg: #060913;
  --bg-soft: #0b1020;
  --card: rgba(255, 255, 255, 0.04);
  --border: rgba(255, 255, 255, 0.09);
  --text: #e8ecf4;
  --muted: #8b93a7;
  --accent: #4ef0c0;
  --accent2: #6c8cff;
  --accent3: #c66cff;
  --mono: "JetBrains Mono", monospace;
  --sans: "Space Grotesk", sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  overflow-x: hidden;
  line-height: 1.6;
}

::selection { background: var(--accent); color: #04120c; }

/* ---- Canvas background ---- */
#particles {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.glow {
  position: fixed;
  width: 600px;
  height: 600px;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.14;
  z-index: 0;
  pointer-events: none;
}
.glow-1 { background: var(--accent2); top: -200px; left: -150px; }
.glow-2 { background: var(--accent3); bottom: -250px; right: -150px; }

main { position: relative; z-index: 1; }

/* ---- Nav ---- */
nav {
  position: fixed;
  top: 0;
  width: 100%;
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 6vw;
  backdrop-filter: blur(14px);
  background: rgba(6, 9, 19, 0.6);
  border-bottom: 1px solid transparent;
  transition: border-color 0.3s;
}
nav.scrolled { border-bottom-color: var(--border); }

.logo {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--accent);
  text-decoration: none;
  letter-spacing: 0.5px;
}
.logo span { color: var(--muted); }

.nav-links { display: flex; gap: 28px; }
.nav-links a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-family: var(--mono);
  transition: color 0.2s;
}
.nav-links a:hover { color: var(--accent); }
.nav-links a::before { content: "// "; color: var(--accent); opacity: 0; transition: opacity 0.2s; }
.nav-links a:hover::before { opacity: 1; }
.language-switch { display: flex; gap: 2px; border: 1px solid var(--border); border-radius: 6px; padding: 3px; flex-shrink: 0; }
.language-switch button { font: 500 0.8rem var(--mono); border: 0; border-radius: 3px; padding: 6px 8px; color: var(--muted); background: transparent; cursor: pointer; }
.language-switch button[aria-pressed="true"] { background: var(--accent); color: var(--bg); }
.language-switch button:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; }
html[lang="th"] { --sans: "IBM Plex Sans Thai", sans-serif; }
html[lang="th"] .section-title,
html[lang="th"] .nav-links a,
html[lang="th"] .btn,
html[lang="th"] .typed-line { font-family: var(--sans); }
html[lang="th"] .hero h1,
html[lang="th"] .contact h2 { line-height: 1.5; letter-spacing: 0; }
html[lang="th"] .section-title { line-height: 1.6; letter-spacing: 0; }
@media (min-width: 821px) and (max-width: 1100px) {
  .nav-links { gap: 12px; }
  nav { padding-left: 3vw; padding-right: 3vw; }
}

/* ---- Hero ---- */
.hero {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0 6vw;
  max-width: 1100px;
  margin: 0 auto;
}

.hero-tag {
  font-family: var(--mono);
  color: var(--accent);
  font-size: 0.95rem;
  margin-bottom: 18px;
  opacity: 0;
  animation: fadeUp 0.8s 0.2s forwards;
}

.hero h1 {
  font-size: clamp(2.6rem, 7vw, 5rem);
  font-weight: 700;
  line-height: 1.08;
  letter-spacing: -1.5px;
  opacity: 0;
  animation: fadeUp 0.8s 0.4s forwards;
}

.hero h1 .gradient {
  background: linear-gradient(120deg, var(--accent), var(--accent2), var(--accent3));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  background-size: 200% 200%;
  animation: gradientShift 6s ease infinite;
}

@keyframes gradientShift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

.hero .typed-line {
  font-family: var(--mono);
  font-size: clamp(1rem, 2.4vw, 1.35rem);
  color: var(--muted);
  margin-top: 22px;
  min-height: 1.8em;
  opacity: 0;
  animation: fadeUp 0.8s 0.6s forwards;
}
.typed-line .cursor {
  display: inline-block;
  width: 10px;
  background: var(--accent);
  animation: blink 1s step-end infinite;
  color: transparent;
}
@keyframes blink { 50% { opacity: 0; } }

.hero-desc {
  max-width: 620px;
  color: var(--muted);
  margin-top: 26px;
  font-size: 1.05rem;
  opacity: 0;
  animation: fadeUp 0.8s 0.8s forwards;
}

.hero-cta {
  margin-top: 40px;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  opacity: 0;
  animation: fadeUp 0.8s 1s forwards;
}

.btn {
  font-family: var(--mono);
  font-size: 0.92rem;
  padding: 13px 26px;
  border-radius: 10px;
  text-decoration: none;
  transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
  border: 1px solid var(--border);
}
.btn-primary {
  background: var(--accent);
  color: #04120c;
  font-weight: 700;
  border-color: var(--accent);
}
.btn-primary:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 30px rgba(78, 240, 192, 0.35);
}
.btn-ghost { color: var(--text); }
.btn-ghost:hover {
  transform: translateY(-3px);
  background: var(--card);
  border-color: var(--accent2);
}

.scroll-hint {
  position: absolute;
  bottom: 34px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--muted);
  animation: bob 2s ease-in-out infinite;
}
@keyframes bob { 50% { transform: translate(-50%, 8px); } }

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

/* ---- Sections ---- */
section {
  max-width: 1100px;
  margin: 0 auto;
  padding: 110px 6vw 0;
}

.section-title {
  font-family: var(--mono);
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 46px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.section-title::before {
  content: attr(data-num);
  color: var(--accent);
  font-size: 1rem;
  font-weight: 400;
}
.section-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--border), transparent);
}

/* reveal on scroll */
.reveal {
  opacity: 0;
  transform: translateY(36px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}
.reveal.visible { opacity: 1; transform: translateY(0); }

.projects-intro { color: var(--muted); margin: -22px 0 32px; max-width: 620px; }
.projects-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 32px; }
.project { min-width: 0; display: flex; flex-direction: column; }
.project-preview {
  display: block;
  aspect-ratio: 8 / 5;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.project-preview img { display: block; width: 100%; height: 100%; object-fit: contain; }
.project-content { display: flex; flex-direction: column; align-items: flex-start; flex: 1; padding-top: 24px; }
.project h3 { font-size: 1.35rem; font-weight: 700; letter-spacing: 0; }
.project-content p { color: var(--muted); margin-top: 12px; }
.project-features { padding-left: 20px; margin: 20px 0 24px; color: var(--text); font-size: 0.95rem; }
.project-features li + li { margin-top: 6px; }
.project-demo { display: inline-flex; justify-content: center; margin-top: auto; }
.projects-note { color: var(--muted); font-size: 0.85rem; margin-top: 32px; }
#projects { scroll-margin-top: 80px; }
#projects a:focus-visible { outline: 2px solid var(--accent); outline-offset: 5px; }
@media (max-width: 700px) {
  .projects-grid { grid-template-columns: minmax(0, 1fr); gap: 40px; }
  #projects .section-title { font-size: 1.2rem; gap: 10px; }
}

/* ---- About ---- */
.about-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 44px;
  align-items: start;
}
.about-text p { color: var(--muted); margin-bottom: 18px; font-size: 1.02rem; }
.about-text strong { color: var(--text); }

.terminal {
  background: #0a0f1e;
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  font-family: var(--mono);
  font-size: 0.82rem;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.terminal-bar {
  background: rgba(255, 255, 255, 0.05);
  padding: 10px 14px;
  display: flex;
  gap: 7px;
  align-items: center;
}
.terminal-bar i {
  width: 11px; height: 11px; border-radius: 50%;
}
.terminal-bar i:nth-child(1) { background: #ff5f57; }
.terminal-bar i:nth-child(2) { background: #febc2e; }
.terminal-bar i:nth-child(3) { background: #28c840; }
.terminal-bar span {
  margin-left: 8px;
  color: var(--muted);
  font-size: 0.72rem;
}
.terminal-body { padding: 18px; line-height: 1.9; }
.terminal-body .k { color: var(--accent3); }
.terminal-body .s { color: var(--accent); }
.terminal-body .p { color: var(--muted); }
.terminal-body .n { color: var(--accent2); }

/* ---- Experience timeline ---- */
.timeline { position: relative; padding-left: 34px; }
.timeline::before {
  content: "";
  position: absolute;
  left: 8px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  background: linear-gradient(180deg, var(--accent), var(--accent2), var(--accent3));
  opacity: 0.4;
}

.job {
  position: relative;
  margin-bottom: 44px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 26px 28px;
  transition: transform 0.25s, border-color 0.25s, box-shadow 0.25s;
}
.job:hover {
  transform: translateX(6px);
  border-color: rgba(78, 240, 192, 0.4);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
}
.job::before {
  content: "";
  position: absolute;
  left: -34px;
  top: 32px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--bg);
  border: 3px solid var(--accent);
  box-shadow: 0 0 14px rgba(78, 240, 192, 0.6);
}

.job-period {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--accent);
  letter-spacing: 0.5px;
}
.job h3 { font-size: 1.25rem; margin: 6px 0 2px; }
.job .company { color: var(--accent2); font-weight: 600; font-size: 0.95rem; }
.job .place { color: var(--muted); font-size: 0.85rem; font-family: var(--mono); }
.job ul { margin-top: 14px; padding-left: 18px; color: var(--muted); font-size: 0.95rem; }
.job ul li { margin-bottom: 7px; }
.job ul li::marker { color: var(--accent); }

.badge-current {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.68rem;
  background: rgba(78, 240, 192, 0.12);
  color: var(--accent);
  border: 1px solid rgba(78, 240, 192, 0.35);
  padding: 2px 10px;
  border-radius: 99px;
  margin-left: 10px;
  vertical-align: middle;
}

/* ---- Skills ---- */
.skills-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 14px;
}
.skill {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  font-family: var(--mono);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: transform 0.2s, border-color 0.2s, background 0.2s;
  cursor: default;
}
.skill:hover {
  transform: translateY(-5px) scale(1.03);
  border-color: var(--accent);
  background: rgba(78, 240, 192, 0.06);
}
.skill .dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  flex-shrink: 0;
}

/* ---- Education & Publications ---- */
.cards-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 26px;
  transition: transform 0.25s, border-color 0.25s;
}
.card:hover { transform: translateY(-5px); border-color: rgba(108, 140, 255, 0.45); }
.card .card-tag {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--accent2);
}
.card h3 { font-size: 1.1rem; margin: 8px 0 4px; }
.card p { color: var(--muted); font-size: 0.9rem; }
.card em { color: var(--text); font-style: italic; }
.card a { color: var(--accent); text-decoration: none; font-family: var(--mono); font-size: 0.82rem; }
.card a:hover { text-decoration: underline; }

.mentorship-card {
  max-width: 820px;
}
.mentorship-intro {
  max-width: 820px;
  margin-bottom: 18px;
  color: var(--muted);
  font-size: 1rem;
}
.mentorship-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}
.mentorship-card .company {
  color: var(--accent2);
  font-weight: 600;
  font-size: 0.95rem;
}
.mentorship-card .place {
  color: var(--muted);
  font-size: 0.85rem;
  font-family: var(--mono);
  margin-top: 2px;
}
.mentorship-card p {
  margin-top: 14px;
}
.mentorship-card ul {
  margin-top: 14px;
  padding-left: 18px;
  color: var(--muted);
  font-size: 0.95rem;
}
.mentorship-card li {
  margin-bottom: 7px;
}
.mentorship-card li::marker {
  color: var(--accent);
}

/* ---- Contact ---- */
.contact {
  text-align: center;
  padding-bottom: 60px;
}
.contact h2 {
  font-size: clamp(1.8rem, 4.5vw, 3rem);
  letter-spacing: -1px;
  margin-bottom: 16px;
}
.contact p { color: var(--muted); max-width: 520px; margin: 0 auto 36px; }

.contact-links {
  display: flex;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
}

.side-quests {
  margin-top: 30px;
  padding: 16px 18px;
  border: 1px dashed rgba(139, 147, 167, 0.28);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.02);
  max-width: 520px;
}
.side-quests[open] {
  border-color: rgba(108, 140, 255, 0.35);
}
.side-quests summary {
  list-style: none;
  cursor: pointer;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.8rem;
  user-select: none;
}
.side-quests summary::-webkit-details-marker {
  display: none;
}
.side-quests summary::before {
  content: "> ";
  color: var(--accent2);
}
.side-quests[open] summary::before {
  content: "v ";
}
.side-quests p {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 12px 0 10px;
}
.side-quest-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.side-quest-btn {
  background: transparent;
  border: 1px dashed rgba(139, 147, 167, 0.45);
  color: var(--muted);
  border-radius: 99px;
  padding: 7px 12px;
  font-family: var(--mono);
  font-size: 0.72rem;
  opacity: 0.8;
  transition: color 0.2s, border-color 0.2s, opacity 0.2s, transform 0.2s;
}
.side-quest-btn:hover {
  color: var(--accent2);
  border-color: rgba(108, 140, 255, 0.55);
  opacity: 1;
  transform: translateY(-2px);
}

footer {
  text-align: center;
  padding: 34px 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.75rem;
  border-top: 1px solid var(--border);
  margin-top: 80px;
  position: relative;
  z-index: 1;
}
footer .heart { color: var(--accent); }

/* ---- Gimmicks ---- */
#progress {
  position: fixed;
  top: 0; left: 0;
  height: 3px;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent2), var(--accent3));
  z-index: 200;
  box-shadow: 0 0 12px rgba(78, 240, 192, 0.7);
}

.cursor-dot, .cursor-ring {
  position: fixed;
  top: 0; left: 0;
  border-radius: 50%;
  pointer-events: none;
  z-index: 999;
  display: none;
}
.cursor-dot {
  width: 7px; height: 7px;
  background: var(--accent);
  margin: -3.5px 0 0 -3.5px;
}
.cursor-ring {
  width: 34px; height: 34px;
  border: 1.5px solid rgba(78, 240, 192, 0.55);
  margin: -17px 0 0 -17px;
  transition: width 0.25s, height 0.25s, margin 0.25s, border-color 0.25s;
}
.cursor-ring.hovering {
  width: 56px; height: 56px;
  margin: -28px 0 0 -28px;
  border-color: var(--accent3);
}
@media (pointer: fine) {
  * { cursor: none !important; }
  .cursor-dot, .cursor-ring { display: block; }
}

.spark {
  position: fixed;
  width: 6px; height: 6px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 998;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 18px;
  padding-top: 80px;
}
.stat {
  text-align: center;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 26px 10px;
  transition: transform 0.25s, border-color 0.25s;
}
.stat:hover { transform: translateY(-5px); border-color: rgba(78, 240, 192, 0.4); }
.stat-clickable {
  cursor: pointer;
  position: relative;
}
.stat-clickable:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.stat-hint {
  position: absolute;
  top: 10px;
  right: 10px;
  color: var(--accent2);
  font-family: var(--mono);
  font-size: 0.9rem;
  letter-spacing: 0;
  opacity: 0.85;
  line-height: 1;
  pointer-events: none;
}
.stat-tooltip {
  position: absolute;
  top: calc(100% + 10px);
  left: 50%;
  right: auto;
  transform: translate(-50%, -6px);
  width: min(360px, 74vw);
  text-align: left;
  background: rgba(8, 12, 24, 0.97);
  border: 1px solid rgba(108, 140, 255, 0.35);
  border-radius: 12px;
  padding: 10px 12px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.42);
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 4;
}
.stat-tooltip p {
  font-family: var(--mono);
  color: var(--text);
  font-size: 0.75rem;
  margin-bottom: 6px;
}
.stat-tooltip ul {
  padding-left: 18px;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.45;
}
.stat-tooltip li::marker {
  color: var(--accent);
}
.stat-clickable:hover .stat-tooltip,
.stat-clickable:focus-visible .stat-tooltip,
.stat-clickable.open .stat-tooltip {
  opacity: 1;
  transform: translate(-50%, 0);
}
.stat-num {
  display: block;
  font-family: var(--mono);
  font-size: 2.4rem;
  font-weight: 700;
  background: linear-gradient(120deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.stat-label {
  color: var(--muted);
  font-size: 0.82rem;
  font-family: var(--mono);
}

#matrix {
  position: fixed;
  inset: 0;
  z-index: 500;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.6s;
}
#matrix.on { opacity: 1; }

.konami-hint { opacity: 0.45; font-size: 0.68rem; }

/* ---- Chat widget ---- */
#chat-fab {
  position: fixed;
  bottom: 26px;
  right: 26px;
  z-index: 300;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border: none;
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 30px rgba(78, 240, 192, 0.35);
  transition: transform 0.2s;
}
#chat-fab:hover { transform: scale(1.1); }
#chat-fab .ping {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--accent);
  animation: ping 2.2s ease-out infinite;
}
@keyframes ping {
  0% { transform: scale(1); opacity: 0.8; }
  100% { transform: scale(1.7); opacity: 0; }
}

#chat-panel {
  position: fixed;
  bottom: 100px;
  right: 26px;
  z-index: 300;
  width: min(370px, calc(100vw - 40px));
  height: min(540px, calc(100vh - 140px));
  background: #0a0f1e;
  border: 1px solid var(--border);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
  opacity: 0;
  transform: translateY(20px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.3s, transform 0.3s;
}
#chat-panel.open { opacity: 1; transform: none; pointer-events: auto; }

.chat-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.05);
  border-bottom: 1px solid var(--border);
  font-family: var(--mono);
}
.chat-header .status-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: #28c840;
  box-shadow: 0 0 8px #28c840;
  flex-shrink: 0;
}
.chat-header b { font-size: 0.9rem; }
.chat-header small { color: var(--muted); font-size: 0.66rem; display: block; }
#chat-close {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.05rem;
  padding: 4px;
}
#chat-close:hover { color: var(--text); }

#chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.msg {
  max-width: 86%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 0.85rem;
  line-height: 1.55;
  white-space: pre-line;
  overflow-wrap: break-word;
}
.msg.bot {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  align-self: flex-start;
}
.msg.user {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #04120c;
  font-weight: 500;
  border-bottom-right-radius: 4px;
  align-self: flex-end;
}
.msg a { color: var(--accent); }
.tdot {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--muted);
  margin-right: 4px;
  animation: tblink 1s infinite;
}
.tdot:nth-child(2) { animation-delay: 0.2s; }
.tdot:nth-child(3) { animation-delay: 0.4s; }
@keyframes tblink { 30% { opacity: 0.2; transform: translateY(-3px); } }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button {
  font-family: var(--mono);
  font-size: 0.72rem;
  background: transparent;
  color: var(--accent);
  border: 1px solid rgba(78, 240, 192, 0.4);
  border-radius: 99px;
  padding: 6px 12px;
  transition: background 0.2s;
}
.chips button:hover { background: rgba(78, 240, 192, 0.12); }

#chat-form {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--border);
}
#chat-input {
  flex: 1;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  color: var(--text);
  font-family: var(--sans);
  font-size: 0.88rem;
  outline: none;
}
#chat-input:focus { border-color: var(--accent); }
#chat-send {
  background: var(--accent);
  color: #04120c;
  border: none;
  border-radius: 10px;
  padding: 0 16px;
  font-weight: 700;
  font-family: var(--mono);
  font-size: 1rem;
}

/* ---- Responsive ---- */
@media (max-width: 820px) {
  nav {
    padding: 14px 5vw;
  }
  .nav-links { display: none; }
  .hero {
    min-height: auto;
    padding-top: 120px;
    padding-bottom: 64px;
  }
  .hero-desc {
    font-size: 0.98rem;
  }
  .hero-cta {
    gap: 10px;
  }
  .hero-cta .btn {
    width: 100%;
    text-align: center;
    justify-content: center;
  }
  .scroll-hint {
    display: none;
  }
  section {
    padding: 84px 5vw 0;
  }
  .section-title {
    margin-bottom: 30px;
  }
  .about-grid { grid-template-columns: 1fr; }
  .timeline {
    padding-left: 22px;
  }
  .job {
    padding: 20px;
    margin-bottom: 24px;
  }
  .job::before {
    left: -22px;
  }
  .stats {
    padding-top: 58px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .stat {
    padding: 18px 8px;
  }
  .stat-tooltip {
    position: static;
    width: 100%;
    margin-top: 8px;
    transform: none;
    max-height: 0;
    padding: 0 10px;
    border-width: 0;
    box-shadow: none;
    overflow: hidden;
  }
  .stat-clickable:hover .stat-tooltip,
  .stat-clickable:focus-visible .stat-tooltip {
    opacity: 0;
    max-height: 0;
  }
  .stat-clickable.open .stat-tooltip {
    opacity: 1;
    max-height: 260px;
    padding: 10px;
    border-width: 1px;
    transform: none;
  }
  .stat-num {
    font-size: 1.9rem;
  }
  .skills-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .mentorship-grid {
    grid-template-columns: 1fr;
  }
  .cards-2 { grid-template-columns: 1fr; }
  #chat-fab {
    bottom: 18px;
    right: 18px;
    width: 54px;
    height: 54px;
  }
  #chat-panel {
    right: 10px;
    left: 10px;
    width: auto;
    bottom: 84px;
    height: min(70vh, 560px);
  }
  #game-hud, #cop-hud, #shoot-hud {
    top: 10px;
    max-width: calc(100vw - 18px);
    padding: 8px 12px;
    gap: 10px;
    font-size: 0.72rem;
    overflow-x: auto;
    scrollbar-width: none;
  }
  #game-hud::-webkit-scrollbar,
  #cop-hud::-webkit-scrollbar,
  #shoot-hud::-webkit-scrollbar {
    display: none;
  }
  #game-hint, #cop-hint, #shoot-hint {
    display: none;
  }
  #game-touch {
    padding: 0 16px;
    bottom: 14px;
  }
  .dpad {
    grid-template-columns: repeat(3, 42px);
    grid-template-rows: repeat(3, 42px);
  }
  #fire-btn {
    width: 60px;
    height: 60px;
  }
  #game-msg, #cop-msg {
    width: min(92vw, 420px);
    padding: 24px;
  }
  #fact-toast {
    bottom: 88px;
    font-size: 0.74rem;
    padding: 10px 14px;
  }
}

@media (max-width: 520px) {
  .hero h1 {
    letter-spacing: -0.8px;
  }
  .section-title {
    font-size: 1.28rem;
    gap: 10px;
  }
  .section-title::before {
    font-size: 0.86rem;
  }
  .skills-grid,
  .stats {
    grid-template-columns: 1fr;
  }
  .side-quest-links {
    flex-direction: column;
    align-items: stretch;
  }
  .side-quests {
    max-width: 100%;
    padding: 14px;
  }
  .side-quest-btn {
    width: 100%;
  }
}

/* ---- Battle City: profile siege ---- */
#game-overlay {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: none;
  pointer-events: none;
}
#game-overlay.open { display: block; }

#game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#game-hud, #cop-hud, #shoot-hud {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 18px;
  background: rgba(6, 9, 19, 0.88);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 10px 20px;
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--muted);
  pointer-events: auto;
  backdrop-filter: blur(8px);
  white-space: nowrap;
}
#game-hud b, #cop-hud b, #shoot-hud b { color: var(--accent); }
#game-hint, #cop-hint, #shoot-hint { font-size: 0.68rem; opacity: 0.7; }

#game-quit, #cop-quit, #shoot-quit {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 99px;
  padding: 4px 12px;
  font-family: var(--mono);
  font-size: 0.75rem;
}
#game-quit:hover, #cop-quit:hover, #shoot-quit:hover { color: var(--accent); border-color: var(--accent); }

#game-msg, #cop-msg {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  background: rgba(6, 9, 19, 0.92);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 34px 44px;
  font-family: var(--mono);
  text-align: center;
  pointer-events: auto;
}
#game-msg.show, #cop-msg.show { display: flex; }
#game-msg h3, #cop-msg h3 { color: var(--accent); font-size: 1.5rem; letter-spacing: 2px; }
#game-msg p, #cop-msg p { color: var(--muted); font-size: 0.85rem; white-space: pre-line; max-width: min(440px, 80vw); }

#play-game { cursor: pointer; }
#game-again { cursor: pointer; }

#game-touch {
  position: absolute;
  bottom: 26px;
  left: 0;
  right: 0;
  display: none;
  justify-content: space-between;
  align-items: center;
  padding: 0 30px;
  pointer-events: auto;
}
@media (pointer: coarse) { #game-overlay.open #game-touch { display: flex; } }
.dpad {
  display: grid;
  grid-template-columns: repeat(3, 48px);
  grid-template-rows: repeat(3, 48px);
  gap: 4px;
}
.dpad button, #fire-btn {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 1.05rem;
  border-radius: 10px;
}
.dpad button:active, #fire-btn:active { background: rgba(78, 240, 192, 0.25); }
.dpad .u { grid-area: 1 / 2; }
.dpad .l { grid-area: 2 / 1; }
.dpad .r { grid-area: 2 / 3; }
.dpad .d { grid-area: 3 / 2; }
#fire-btn { width: 68px; height: 68px; border-radius: 50%; }

/* ---- Virtua Cop: bug patrol ---- */
#cop-overlay {
  position: fixed;
  inset: 0;
  z-index: 910;
  display: none;
}
#cop-overlay.open { display: block; }

#cop-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
body.cop-playing .cursor-dot, body.cop-playing .cursor-ring,
body.shoot-playing .cursor-dot, body.shoot-playing .cursor-ring { display: none !important; }

#play-cop { cursor: pointer; }
#cop-again { cursor: pointer; }

#cop-banner {
  position: absolute;
  top: 36%;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--mono);
  font-size: clamp(1.8rem, 6vw, 3.2rem);
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 6px;
  text-shadow: 0 0 30px rgba(78, 240, 192, 0.6);
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
}
#cop-banner.show { animation: bannerPop 1.4s ease forwards; }
@keyframes bannerPop {
  0% { opacity: 0; transform: translateX(-50%) scale(1.6); }
  20% { opacity: 1; transform: translateX(-50%) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; }
}

/* ---- Profile intel toast ---- */
#fact-toast {
  position: fixed;
  bottom: 110px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(6, 9, 19, 0.94);
  border: 1px solid rgba(78, 240, 192, 0.5);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.8rem;
  padding: 12px 20px;
  border-radius: 12px;
  max-width: min(520px, 86vw);
  text-align: center;
  z-index: 950;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, transform 0.3s;
}
#fact-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#fact-toast b { color: var(--accent); }

/* ---- Destruction mode ---- */
#shoot-overlay {
  position: fixed;
  inset: 0;
  z-index: 920;
  display: none;
}
#shoot-overlay.open { display: block; }

#shoot-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#play-shoot { cursor: pointer; }

#shoot-fix {
  background: rgba(78, 240, 192, 0.08);
  border: 1px solid rgba(78, 240, 192, 0.5);
  color: var(--accent);
  border-radius: 99px;
  padding: 4px 12px;
  font-family: var(--mono);
  font-size: 0.75rem;
}
#shoot-fix:hover { background: rgba(78, 240, 192, 0.2); }
