:root {
  --bg: #07080d;
  --bg-soft: #10131d;
  --card: rgba(20, 24, 38, 0.7);
  --text: #e7eaf3;
  --muted: #a9b1c8;
  --line: rgba(255, 255, 255, 0.1);
  --primary: #8b5cf6;
  --secondary: #00e5ff;
  --success: #00ffa3;
  --shadow: 0 10px 35px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: Inter, Segoe UI, Roboto, Arial, sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 20% 10%, #11172a 0%, var(--bg) 35%)
    fixed;
  line-height: 1.6;
  overflow-x: hidden;
}

p {
  margin: 0 0 0.9rem;
}

img,
video {
  max-width: 100%;
  display: block;
}

.container {
  width: min(1120px, calc(100% - 2rem));
  margin-inline: auto;
}

.bg-effects {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: -2;
}

.blob {
  position: absolute;
  border-radius: 999px;
  filter: blur(50px);
  opacity: 0.35;
  animation: float 16s ease-in-out infinite;
}

.blob-1 {
  width: 280px;
  height: 280px;
  top: -60px;
  left: -40px;
  background: var(--primary);
}

.blob-2 {
  width: 250px;
  height: 250px;
  top: 30%;
  right: -80px;
  background: var(--secondary);
  animation-delay: -4s;
}

.blob-3 {
  width: 320px;
  height: 320px;
  bottom: -120px;
  left: 35%;
  background: var(--success);
  animation-delay: -8s;
}

#particles {
  position: absolute;
  inset: 0;
}

.particle {
  position: absolute;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.45);
  animation: drift linear infinite;
}

.navbar-wrap {
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(10px);
  background: rgba(7, 8, 13, 0.65);
  border-bottom: 1px solid var(--line);
}

.navbar {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  text-decoration: none;
  color: var(--text);
  font-weight: 800;
  letter-spacing: 0.08em;
}

.brand span {
  color: var(--secondary);
}

.nav-links {
  margin: 0;
  padding: 0;
  display: flex;
  list-style: none;
  gap: 0.45rem;
}

.nav-links a {
  display: inline-block;
  color: var(--muted);
  text-decoration: none;
  padding: 0.55rem 0.85rem;
  border-radius: 0.65rem;
  transition: all 0.3s ease;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--text);
  background: rgba(139, 92, 246, 0.22);
}

.menu-toggle {
  display: none;
  background: none;
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 1.25rem;
  border-radius: 0.5rem;
  padding: 0.3rem 0.6rem;
  min-width: 42px;
  min-height: 42px;
}

.hero {
  min-height: calc(100vh - 72px);
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  align-items: center;
  gap: 2.5rem;
  padding: 5.2rem 0 4.2rem;
}

.eyebrow {
  color: var(--secondary);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.78rem;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.2;
}

h1 {
  font-size: clamp(2rem, 4vw, 3.5rem);
  margin-top: 0.6rem;
  letter-spacing: -0.02em;
}

.hero p {
  color: var(--muted);
  max-width: 62ch;
}

.hero-content h1 {
  max-width: 18ch;
}

.hero-actions {
  display: flex;
  gap: 0.8rem;
  margin-top: 1.2rem;
}

.btn {
  text-decoration: none;
  border: 1px solid var(--line);
  color: var(--text);
  padding: 0.7rem 1rem;
  border-radius: 0.7rem;
  font-weight: 600;
  transition: transform 0.28s ease, box-shadow 0.28s ease, background 0.28s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

.btn-primary {
  background: linear-gradient(120deg, var(--primary), #5b8cff);
  border-color: transparent;
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.04);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1.5rem;
}

.chip {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: #d6def5;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  font-size: 0.85rem;
}

.hero-avatar {
  display: grid;
  place-items: center;
}

.avatar-ring {
  width: min(350px, 80vw);
  aspect-ratio: 1;
  border-radius: 50%;
  padding: 8px;
  background: linear-gradient(140deg, var(--primary), var(--secondary));
  box-shadow: var(--shadow);
}

.avatar-ring img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.section {
  padding: 4rem 0 1.2rem;
}

.section-head {
  margin-bottom: 1.25rem;
}

.section-subhead {
  margin: 2.1rem 0 1rem;
}

.section-subhead h3 {
  font-size: clamp(1.1rem, 2.5vw, 1.5rem);
  margin-top: 0.3rem;
}

.section h2 {
  font-size: clamp(1.6rem, 3vw, 2.4rem);
}

.about-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

#sobre-mi.section {
  padding-top: 2.8rem;
  padding-bottom: 0.8rem;
}

#sobre-mi .section-head {
  margin-bottom: 1rem;
}

#sobre-mi .about-grid {
  grid-template-columns: 1fr;
}

.glass {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 1rem;
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
}

.card {
  padding: 1.35rem;
}

#sobre-mi .card p {
  font-size: 1.03rem;
  color: #c8d1e8;
}

.specialty-list {
  margin: 0.7rem 0 0;
  padding-left: 1rem;
  color: var(--muted);
}

.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
}

.project-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 1rem;
  overflow: hidden;
  transition: transform 0.35s ease, border-color 0.35s ease;
}

.project-card:hover {
  transform: translateY(-7px);
  border-color: rgba(139, 92, 246, 0.65);
}

.project-preview {
  height: 160px;
  position: relative;
  overflow: hidden;
}

.animation-card .project-preview {
  height: 190px;
}

.project-preview img,
.project-preview video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.animation-video {
  background: #0a0f1d;
}

.project-preview .model-viewer {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 160px;
  background: radial-gradient(circle at 30% 20%, #1a2440 0%, #0b1020 60%);
}

.model-placeholder {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 1rem;
  color: #b8c2df;
  background: linear-gradient(145deg, #18243d, #111a2b);
}

.model-fallback-img {
  display: block;
  width: min(180px, 80%);
  margin: 0.8rem auto 0;
  border-radius: 0.5rem;
  border: 1px solid var(--line);
}

.fallback-viewer {
  display: grid;
  gap: 0.8rem;
}

.fallback-note {
  margin: 0;
  color: var(--muted);
}

.fallback-controls {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.fallback-stage {
  min-height: 340px;
  border: 1px solid var(--line);
  border-radius: 0.8rem;
  background: #0a0f1d;
  overflow: hidden;
  position: relative;
  touch-action: none;
  cursor: grab;
}

.fallback-stage:active {
  cursor: grabbing;
}

#fallbackImage {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  transform-origin: center center;
  max-width: 80%;
  max-height: 80%;
  user-select: none;
  pointer-events: none;
}


.project-body {
  padding: 1rem;
}

.project-body h3 {
  font-size: 1.1rem;
}

.project-body p {
  color: var(--muted);
  margin: 0.5rem 0 1rem;
  overflow-wrap: anywhere;
}

.project-actions {
  display: flex;
  gap: 0.55rem;
  flex-wrap: wrap;
  margin-top: 0.8rem;
}

#designGrid .project-card {
  display: flex;
  flex-direction: column;
}

#designGrid .project-body {
  display: flex;
  flex-direction: column;
  flex: 1;
}

#designGrid .project-actions {
  margin-top: auto;
}

.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  border-left: 1px solid var(--line);
}

.timeline-item {
  margin-left: 1rem;
  padding: 0 0 1.4rem 1rem;
  position: relative;
}

.timeline-item::before {
  content: "";
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--secondary);
  position: absolute;
  left: -1.35rem;
  top: 0.35rem;
  box-shadow: 0 0 0 4px rgba(0, 229, 255, 0.2);
}

.timeline-year {
  display: inline-block;
  color: var(--secondary);
  font-weight: 600;
  margin-bottom: 0.2rem;
}

.footer {
  padding: 3rem 0 2rem;
  color: var(--muted);
  text-align: center;
}

.game-dialog {
  width: min(860px, calc(100% - 1rem));
  max-height: min(92vh, 820px);
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: #0d111d;
  color: var(--text);
  padding: 1rem;
  overflow: auto;
}

.game-dialog::backdrop {
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(2px);
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.game-shell {
  border: 1px solid var(--line);
  border-radius: 0.8rem;
  padding: 0.8rem;
}

.app-shell {
  display: grid;
  gap: 0.8rem;
}

.app-panels {
  border: 1px solid var(--line);
  border-radius: 0.7rem;
  overflow: hidden;
  background: #090d18;
}

.app-panel {
  padding: 0;
}

.run-help {
  padding: 1rem;
  color: var(--muted);
}

.run-help p {
  margin: 0 0 0.6rem;
}

.run-help label {
  display: grid;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
}

.run-help input,
.run-help select {
  border: 1px solid var(--line);
  background: #10172a;
  color: var(--text);
  border-radius: 0.5rem;
  padding: 0.5rem 0.6rem;
}

.game-menu,
.game-content {
  padding: 1rem;
}

.menu-title {
  margin: 0 0 0.8rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.menu-msg {
  margin: 0 0 0.8rem;
  color: #a5d8ff;
}

.game-status {
  margin: 0 0 0.7rem;
  color: #d8e3ff;
  font-weight: 600;
}

.ms-grid {
  display: grid;
  gap: 4px;
  margin-bottom: 0.8rem;
}

.ms-cell {
  aspect-ratio: 1;
  border: 1px solid #344164;
  border-radius: 0.3rem;
  background: #1a2440;
  color: #f3f6ff;
  font-weight: 700;
  cursor: pointer;
}

.ms-cell.revealed {
  background: #10182d;
}

.lo-grid {
  display: grid;
  gap: 6px;
  margin-bottom: 0.8rem;
}

.lo-cell {
  aspect-ratio: 1;
  border-radius: 0.4rem;
  border: 1px solid #3a476d;
  cursor: pointer;
}

.lo-cell.on {
  background: var(--lo-on, #006a87);
}

.lo-cell.off {
  background: var(--lo-off, #85e4ff);
}

.mem-grid {
  display: grid;
  gap: 6px;
  margin-bottom: 0.8rem;
}

.mem-card {
  min-height: 52px;
  border-radius: 0.45rem;
  border: 1px solid #37456a;
  background: #16233f;
  color: #e7eaf3;
  font-weight: 600;
  cursor: pointer;
}

.mem-card.open {
  background: #0f172a;
  border-color: #5b8cff;
}

.mem-score {
  margin: 0 0 0.8rem;
}

.mem-pill {
  display: inline-block;
  margin-right: 0.5rem;
  margin-bottom: 0.4rem;
  padding: 0.3rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
}

.mem-pill.active {
  color: #e7eaf3;
  border-color: #5b8cff;
  background: rgba(91, 140, 255, 0.2);
}

.source-list {
  margin: 0;
  padding-left: 1rem;
}

.source-list a {
  color: var(--secondary);
  text-decoration: none;
}

.source-list a:hover {
  text-decoration: underline;
}

.command-block {
  margin-bottom: 0.9rem;
}

.code-block {
  margin: 0;
  padding: 1rem;
  max-height: 430px;
  overflow: auto;
  background: #090d18;
  color: #d9e2ff;
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.85rem;
  line-height: 1.5;
}

.btn.is-active {
  background: linear-gradient(120deg, var(--primary), #5b8cff);
  border-color: transparent;
}

.hf-wrap {
  padding: 1rem;
}

.hf-status {
  margin: 0 0 0.8rem;
  color: #d8e3ff;
  font-weight: 600;
}

.hf-feedback {
  margin: 0 0 0.8rem;
  color: #9bd7ff;
  font-weight: 500;
}

.hf-menu {
  padding: 1rem;
}

.hf-menu-title {
  margin: 0 0 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.hf-menu-line {
  margin: 0.2rem 0;
  color: var(--muted);
}

.hf-menu-controls {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin: 0.9rem 0;
}

.hf-select {
  border: 1px solid var(--line);
  background: #10172a;
  color: var(--text);
  border-radius: 0.5rem;
  padding: 0.45rem 0.6rem;
}

.hf-grid {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 5px;
  margin-bottom: 0.9rem;
}

.hf-cell {
  aspect-ratio: 1;
  border-radius: 0.35rem;
  border: 1px solid #2f3a58;
  background: linear-gradient(145deg, #18243d, #111a2b);
  color: #f1f5ff;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.hf-cell:hover {
  transform: translateY(-1px);
  border-color: #5b8cff;
}

.hf-cell.hit {
  background: linear-gradient(145deg, #10b981, #06b6d4);
  border-color: #67e8f9;
}

.hf-cell.miss {
  background: linear-gradient(145deg, #6b7280, #334155);
  border-color: #94a3b8;
}

@keyframes float {
  0%,
  100% {
    transform: translate3d(0, 0, 0);
  }
  50% {
    transform: translate3d(0, -20px, 0);
  }
}

@keyframes drift {
  from {
    transform: translateY(110vh) scale(1);
    opacity: 0;
  }
  20% {
    opacity: 0.8;
  }
  to {
    transform: translateY(-10vh) scale(0.6);
    opacity: 0;
  }
}

@media (max-width: 900px) {
  .navbar {
    position: relative;
  }

  .hero {
    grid-template-columns: 1fr;
    min-height: auto;
    padding-top: 3.2rem;
    padding-bottom: 2.4rem;
    gap: 1.8rem;
  }

  .hero-content h1 {
    max-width: 100%;
  }

  .hero-avatar {
    order: -1;
  }

  .avatar-ring {
    width: min(300px, 72vw);
  }

  .about-grid {
    grid-template-columns: 1fr;
  }

  .menu-toggle {
    display: block;
  }

  .nav-links {
    position: absolute;
    top: 72px;
    right: 1rem;
    left: 1rem;
    display: none;
    flex-direction: column;
    background: #0c1020;
    border: 1px solid var(--line);
    border-radius: 0.7rem;
    padding: 0.5rem;
    max-height: calc(100vh - 92px);
    overflow-y: auto;
  }

  .nav-links.open {
    display: flex;
  }

  .hf-grid {
    gap: 4px;
  }
}

@media (max-width: 640px) {
  .container {
    width: min(1120px, calc(100% - 1.25rem));
  }

  .section {
    padding: 3.2rem 0 0.8rem;
  }

  #sobre-mi.section {
    padding-top: 2.2rem;
    padding-bottom: 0.4rem;
  }

  .hero-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .hero-actions .btn {
    min-height: 44px;
  }

  .avatar-ring {
    width: min(250px, 74vw);
  }

  #sobre-mi .card p {
    font-size: 0.98rem;
  }

  .dialog-head {
    position: sticky;
    top: 0;
    background: #0d111d;
    z-index: 2;
    padding-bottom: 0.5rem;
  }

  .project-actions {
    gap: 0.45rem;
  }

  .project-actions .btn {
    flex: 1 1 100%;
    min-height: 42px;
  }

  .game-dialog {
    width: calc(100% - 0.6rem);
    padding: 0.7rem;
  }

  .fallback-stage {
    min-height: 240px;
  }

  .ms-cell,
  .lo-cell,
  .mem-card {
    min-height: 38px;
    font-size: 0.78rem;
  }

  .hf-wrap {
    padding: 0.7rem;
  }

  .hf-grid {
    gap: 3px;
  }

  .hf-cell {
    min-height: 0;
    font-size: 0.7rem;
  }

  .mem-pill {
    font-size: 0.8rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .reveal,
  .project-card,
  .btn,
  .blob,
  .particle {
    animation: none !important;
    transition: none !important;
    transform: none !important;
    opacity: 1 !important;
  }
}
