:root {
    --navy: #0a192f;
    --light-navy: #112240;
    --lightest-navy: #233554;
    --slate: #8892b0;
    --light-slate: #a8b2d1;
    --lightest-slate: #ccd6f6;
    --white: #e6f1ff;
    --green: #64ffda;
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
    --side-gutter: 60px;
    --hero-gutter: 380px;
  }

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

  body {
    background: var(--navy);
    color: var(--slate);
    font-family: var(--font-sans);
    line-height: 1.4;
    -webkit-font-smoothing: antialiased;
  }

  ::selection { background: var(--lightest-navy); color: var(--white); }
  a { color: inherit; text-decoration: none; }

  .skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--green);
    color: var(--navy);
    padding: 8px 16px;
    z-index: 200;
  }
  .skip-link:focus { top: 0; }

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

  /* Typing Effect Styles */
  #typing-cursor {
    display: inline-block;
    color: var(--green);
    font-weight: bold;
    font-size: 1.1em;
    animation: blink 0.8s infinite;
    margin-left: 2px;
  }

  #typing-cursor::after {
    content: '_';
  }

  #typing-cursor.typing {
    animation: blink 0.5s infinite;
  }

  @keyframes blink {
    0%, 49% { opacity: 1; }
    50%, 100% { opacity: 0; }
  }

  /* Top header */
  header.top-nav {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 80px;
    padding: 0 50px;
    background: rgba(10, 25, 47, 0.85);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid transparent;
  }

  .logo {
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .logo svg { width: 100%; height: 100%; }
  .logo text { font-family: var(--font-mono); font-weight: 700; }

  nav.main-nav {
    display: flex;
    align-items: center;
    gap: 36px;
  }
  nav.main-nav ul {
    list-style: none;
    display: flex;
    gap: 30px;
  }
  nav.main-nav a {
    font-family: var(--font-mono);
    font-size: 0.82rem;
    color: var(--lightest-slate);
    transition: color 0.2s ease;
  }
  nav.main-nav a span { color: var(--green); margin-right: 4px; }
  nav.main-nav a:hover, nav.main-nav a:focus-visible { color: var(--green); }

  .resume-btn {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--green) !important;
    border: 1px solid var(--green);
    border-radius: 4px;
    padding: 10px 16px;
    transition: background 0.2s ease, transform 0.2s ease;
  }
  .resume-btn:hover { background: rgba(100, 255, 218, 0.08); transform: translateY(-2px); }

  .nav-toggle { display: none; }

  /* Fixed side rails */
  .side-rail {
    position: fixed;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 50;
  }
  .side-rail.left { left: 40px; }
  .side-rail.right { right: 40px; }

  .side-rail ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 18px;
    margin-bottom: 20px;
  }
  .side-rail.left a {
    color: var(--light-slate);
    display: block;
    padding: 6px;
    transition: color 0.2s ease, transform 0.2s ease;
  }
  .side-rail.left a:hover { color: var(--green); transform: translateY(-3px); }
  .side-rail svg { width: 20px; height: 20px; }

  .side-rail .rail-line {
    width: 1px;
    height: 90px;
    background: var(--light-slate);
  }

  .side-rail.right .email-link {
    writing-mode: vertical-rl;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--light-slate);
    letter-spacing: 0.5px;
    margin-bottom: 20px;
    transition: color 0.2s ease, transform 0.2s ease;
  }
  .side-rail.right .email-link:hover { color: var(--green); transform: translateY(-3px); }

  /* Hero */
  .hero {
    min-height: calc(100vh - 80px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    max-width: 1100px;
    padding: 40px 40px 40px var(--hero-gutter);
  }
  .hero .eyebrow {
    font-family: var(--font-mono);
    color: var(--green);
    font-size: 1rem;
    margin-bottom: 18px;
  }
  .hero h1 {
    font-size: clamp(2.4rem, 7vw, 4.2rem);
    color: var(--lightest-slate);
    font-weight: 700;
    letter-spacing: -1px;
    line-height: 1.1;
  }
  .hero h2 {
    font-size: clamp(2rem, 6vw, 3.6rem);
    color: var(--slate);
    font-weight: 700;
    letter-spacing: -1px;
    line-height: 1.1;
    margin-top: 6px;
  }
  .hero p {
    margin-top: 24px;
    max-width: 540px;
    font-size: 1.1rem;
    text-align: justify;
  }
  .hero p b { color: var(--lightest-slate); font-weight: 600; }
  .hero .cta {
    display: inline-block;
    margin-top: 44px;
    padding: 16px 26px;
    border: 1px solid var(--green);
    border-radius: 4px;
    color: var(--green);
    font-family: var(--font-mono);
    font-size: 0.9rem;
    width: fit-content;
    transition: background 0.2s ease, transform 0.2s ease;
  }
  .hero .cta:hover { background: rgba(100, 255, 218, 0.08); transform: translateY(-3px); }

  /* Content sections below hero */
  main.content {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 var(--side-gutter) 100px;
  }
  section { margin-bottom: 140px; scroll-margin-top: 100px; }
  section:last-of-type { margin-bottom: 60px; }

  .section-heading {
    color: var(--lightest-slate);
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 40px;
    display: flex;
    align-items: baseline;
    gap: 14px;
  }
  .section-heading .num { font-family: var(--font-mono); color: var(--green); font-size: 1rem; font-weight: 400; }
  .section-heading .rule { height: 1px; background: var(--lightest-navy); flex: 1; margin-left: 6px; }

  #about .about-content {
    display: flex;
    gap: 40px;
    align-items: flex-start;
    margin-bottom: 40px;
  }
  #about .about-text {
    flex: 1;
    text-align: justify;
  }
  #about p { margin-bottom: 16px; font-size: 1rem; }
  .about-image {
    width: 280px;
    height: 280px;
    object-fit: cover;
    border-radius: 8px;
    flex-shrink: 0;
    border: 2px solid var(--green);
    opacity: 0.85;
    transition: opacity 0.3s ease;
  }
  .about-image:hover {
    opacity: 1;
  }
  .tech-intro {
    font-family: var(--font-mono);
    color: var(--light-slate);
    font-size: 0.85rem;
    margin: 24px 0 12px;
  }
  .stack-list {
    display: grid;
    grid-template-columns: repeat(3, auto);
    gap: 5px 50px;
    width: fit-content;
    list-style: none;
    font-family: var(--font-mono);
    font-size: 0.85rem;
  }
  .stack-list li { position: relative; padding-left: 20px; }
  .stack-list li::before { content: '▹'; position: absolute; left: 0; color: var(--green); }

  .job-list { display: flex; gap: 30px; }
  .job-tabs { display: flex; flex-direction: column; border-left: 2px solid var(--lightest-navy); min-width: 140px; }
  .job-tabs button {
    background: none; border: none; text-align: left; color: var(--slate);
    font-family: var(--font-mono); font-size: 0.82rem; padding: 12px 20px; cursor: pointer;
    border-left: 2px solid transparent; margin-left: -2px; transition: color 0.2s ease, background 0.2s ease;
    white-space: nowrap;
  }
  .job-tabs button:hover { background: var(--light-navy); color: var(--green); }
  .job-tabs button.active { color: var(--green); border-left: 2px solid var(--green); background: var(--light-navy); }
  .job-panel { display: none; }
  .job-panel.active { display: block; }
  .job-panel h3 { font-size: 1.15rem; color: var(--lightest-slate); font-weight: 600; }
  .job-panel h3 span { color: var(--green); }
  .job-panel .job-time { font-family: var(--font-mono); font-size: 0.78rem; color: var(--slate); margin: 4px 0 18px; }
  .job-panel ul { list-style: none; }
  .job-panel li { position: relative; padding-left: 24px; margin-bottom: 12px; font-size: 0.95rem; text-align: justify;}
  .job-panel li::before { content: '▹'; position: absolute; left: 0; color: var(--green); }

  .project {
    position: relative;
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 48px;
    padding: 44px 0;
    border-top: 1px solid var(--lightest-navy);
    transition: border-color 0.25s ease;
  }
  .project:hover { border-top-color: rgba(100, 255, 218, 0.4); }

  .project-rail { display: flex; flex-direction: column; gap: 28px; }

  .project-index {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--slate);
    letter-spacing: 0.5px;
    transition: color 0.25s ease;
  }
  .project:hover .project-index { color: var(--green); }

  .project-metric {
    padding-left: 14px;
    border-left: 2px solid var(--lightest-navy);
    transition: border-color 0.25s ease;
  }
  .project:hover .project-metric { border-left-color: var(--green); }
  .project-metric-value { color: var(--lightest-slate); font-size: 1.5rem; font-weight: 600; line-height: 1.1; }
  .project-metric-label { color: var(--slate); font-size: 0.82rem; margin-top: 4px; line-height: 1.4; }

  .project-tech { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 7px; }
  .project-tech li { font-family: var(--font-mono); font-size: 0.78rem; color: var(--slate); }

  .project-main { min-width: 0; }

  .project-title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 30px; }
  .project-title-row h3 { color: var(--lightest-slate); font-size: 1.3rem; font-weight: 700; margin: 0; }
  .project-title-row h4 {
    color: var(--slate);
    font-size: 0.85rem;
    font-weight: 500;
    font-family: var(--font-mono);
    margin: 0;
  }
  .project-title-row a { color: var(--slate); display: flex; align-items: center; transition: transform 0.25s ease, color 0.25s ease; }
  .project-title-group { display: flex; flex-direction: column; gap: 4px; }
  .project:hover .project-title-row a { color: var(--green); transform: translate(3px, -3px); }
  .project-title-row svg { width: 18px; height: 18px; }

  .thread { position: relative; padding-left: 26px; }
  .thread::before { content: ''; position: absolute; left: 4px; top: 6px; bottom: 6px; width: 1px; background: var(--lightest-navy); }

  .stage { position: relative; padding-bottom: 26px; }
  .stage:last-child { padding-bottom: 0; }
  .stage::before {
    content: ''; position: absolute; left: -26px; top: 5px;
    width: 9px; height: 9px; border-radius: 50%;
    background: var(--navy); border: 2px solid var(--slate);
    transition: border-color 0.25s ease, background 0.25s ease;
  }
  .project:hover .stage::before { border-color: var(--green); }

  .stage-label { color: var(--light-slate); font-size: 0.95rem; font-weight: 600; margin: 0 0 8px 0; }
  .stage p { color: var(--slate); font-size: 0.93rem; line-height: 1.65; margin: 0; }
  .stage ul { margin: 0; padding: 0; list-style: none; }
  .stage li { color: var(--slate); font-size: 0.93rem; line-height: 1.6; padding-left: 16px; position: relative; margin-bottom: 6px; }
  .stage li::before { content: '–'; position: absolute; left: 0; color: var(--slate); }
  .stage li:last-child { margin-bottom: 0; }

  .stage.impact .stage-label { color: var(--green); }
  .stage.impact::before { background: var(--green); border-color: var(--green); }

  #contact { text-align: center; max-width: 560px; margin: 0 auto 100px; }
  #contact .section-heading { justify-content: center; }
  #contact .num { }
  #contact .eyebrow { font-family: var(--font-mono); color: var(--green); font-size: 0.95rem; margin-bottom: 16px; }
  #contact h2.big { font-size: clamp(1.8rem, 5vw, 2.6rem); color: var(--lightest-slate); margin-bottom: 20px; }
  #contact > p { margin-bottom: 32px; }
  
  .contact-info { 
    margin-bottom: 48px;
    display: flex;
    flex-direction: column;
    gap: 16px;
  }
  
  .contact-info p {
    margin: 0;
    font-size: 1rem;
    color: var(--light-slate);
    line-height: 1.4;
  }
  
  .contact-info strong {
    color: var(--lightest-slate);
    font-weight: 600;
    margin-right: 8px;
  }
  
  .contact-info a {
    color: var(--green);
    text-decoration: none;
    transition: color 0.2s ease;
    word-break: break-all;
  }
  
  .contact-info a:hover {
    color: var(--white);
    text-decoration: underline;
  }
  
  #contact .cta { display: inline-block; padding: 16px 28px; border: 1px solid var(--green); color: var(--green); font-family: var(--font-mono); font-size: 0.85rem; border-radius: 4px; transition: background 0.2s ease, transform 0.2s ease; }
  #contact .cta:hover { background: rgba(100, 255, 218, 0.08); transform: translateY(-3px); }

  footer { text-align: center; padding: 0 0 60px; color: var(--slate); font-family: var(--font-mono); font-size: 0.78rem; }

  /* Game Section */
  #games { max-width: 700px; margin: 0 auto 100px; }
  .game-container { padding: 0; }
  
  .game-info-top {
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  .status-text {
    font-family: var(--font-mono);
    font-size: 1rem;
    color: var(--white);
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
  }
  
  .status-dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #e6f1ff;
    box-shadow: 0 0 6px rgba(230, 241, 255, 0.6);
  }
  
  .status-text.ai-turn .status-dot {
    background: #3b82f6;
    box-shadow: 0 0 6px rgba(59, 130, 246, 0.6);
  }
  
  .game-wrapper { margin-bottom: 24px; }
  
  #gameBoard {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    aspect-ratio: 1;
    gap: 1px;
    background: var(--lightest-navy);
    border: 2px solid var(--green);
    border-radius: 4px;
    padding: 1px;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
  }
  
  .game-cell {
    background: var(--light-navy);
    cursor: pointer;
    position: relative;
    border-radius: 2px;
    transition: background 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  .game-cell::after {
    content: '';
    width: 75%;
    height: 75%;
    border-radius: 50%;
    background: currentColor;
    display: none;
  }
  
  .game-cell.white::after {
    display: block;
    color: #e6f1ff;
    box-shadow: 0 0 8px rgba(230, 241, 255, 0.4);
  }
  
  .game-cell.blue::after {
    display: block;
    color: #3b82f6;
    box-shadow: 0 0 8px rgba(59, 130, 246, 0.4);
  }
  
  .game-cell.valid {
    background: var(--lightest-navy);
  }
  
  .game-cell.valid::before {
    content: '';
    width: 20%;
    height: 20%;
    border-radius: 50%;
    background: rgba(100, 255, 218, 0.6);
  }
  
  .game-cell:hover:not(.white):not(.blue) {
    background: #2a4a5a;
  }
  
  .game-footer {
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: center;
  }
  
  .score-display {
    display: flex;
    justify-content: center;
    gap: 40px;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--light-slate);
  }
  
  .score-display span {
    display: flex;
    align-items: center;
    gap: 8px;
  }
  
  .score-display span::before {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: currentColor;
  }
  
  .score-display span:first-child::before {
    background: #e6f1ff;
  }
  
  .score-display span:last-child::before {
    background: #3b82f6;
  }
  
  .game-controls {
    display: flex;
    gap: 20px;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
  }
  
  .reset-btn {
    background: var(--green);
    color: var(--navy);
    border: none;
    padding: 12px 24px;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
  }
  
  .reset-btn:hover {
    background: #4eddcc;
    transform: translateY(-2px);
  }
  
  .difficulty-control {
    display: flex;
    align-items: center;
    gap: 12px;
    font-family: var(--font-mono);
    font-size: 0.85rem;
  }
  
  .difficulty-control select {
    background: var(--light-navy);
    color: var(--lightest-slate);
    border: 1px solid var(--green);
    padding: 8px 12px;
    border-radius: 4px;
    font-family: var(--font-mono);
    cursor: pointer;
    transition: background 0.2s ease;
  }
  
  .difficulty-control select:hover {
    background: var(--lightest-navy);
  }
  
  .difficulty-control select option {
    background: var(--navy);
    color: var(--lightest-slate);
  }

  .reveal { opacity: 0; transform: translateY(12px); }
  .reveal.in { animation: revealIn 0.6s ease forwards; }
  @keyframes revealIn { to { opacity: 1; transform: translateY(0); } }

  @media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    .reveal { opacity: 1; transform: none; animation: none; }
    .project:hover { transform: none; }
  }

  @media (max-width: 1080px) {
    .side-rail { display: none; }
    :root { --hero-gutter: 60px; }
    .hero h1 { font-size: clamp(2rem, 5vw, 3.4rem); }
    .hero h2 { font-size: clamp(1.7rem, 5vw, 3rem); }
  }

  @media (max-width: 760px) {
    :root { --side-gutter: 24px; }
    header.top-nav { padding: 0 20px; }
    nav.main-nav ul { display: none; }
    .resume-btn { display: none; }
    .about-content { flex-direction: column; }
    .about-image { width: 240px; height: 240px; }
    .job-list { flex-direction: column; }
    .job-tabs {
      flex-direction: row; border-left: none; border-bottom: 2px solid var(--lightest-navy); overflow-x: auto;
    }
    .job-tabs button { border-left: none; border-bottom: 2px solid transparent; margin-left: 0; margin-bottom: -2px; }
    .job-tabs button.active { border-left: none; border-bottom: 2px solid var(--green); }
  }

  @media (max-width: 680px) {
    .project { grid-template-columns: 1fr; gap: 24px; padding: 32px 0; }
    .project-rail { flex-direction: row; flex-wrap: wrap; gap: 24px 32px; }
    .project-metric { padding-left: 0; border-left: none; padding-top: 10px; border-top: 2px solid var(--lightest-navy); }
    .project:hover .project-metric { border-top-color: var(--green); border-left-color: var(--lightest-navy); }
    .project-tech { flex-direction: row; flex-wrap: wrap; gap: 10px 16px; }
  }