:root {
  --mint: #B8F2E6;
  --mint-strong: #23B5A5;
  --lavender: #D8BBFF;
  --lavender-strong: #8B68F6;
  --peach: #FFCFB3;
  --peach-strong: #EB7B59;
  --ice: #F6FAFF;
  --indigo: #222640;
  --indigo-soft: #4F5678;
  --glass-bg: rgba(246, 250, 255, 0.72);
  --glass-bg-strong: rgba(255, 255, 255, 0.84);
  --glass-border: rgba(255, 255, 255, 0.78);
  --glass-shadow: 0 18px 44px rgba(34, 38, 64, 0.09);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --font-sans: "Plus Jakarta Sans", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  color: var(--indigo);
  background: var(--ice);
  overflow-x: hidden;
  line-height: 1.58;
}

/* Soft Pastel Mesh Gradient Background */
.mesh-backdrop {
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(circle at 12% 14%, rgba(184, 242, 230, 0.72) 0%, transparent 42%),
    radial-gradient(circle at 86% 18%, rgba(216, 187, 255, 0.68) 0%, transparent 44%),
    radial-gradient(circle at 78% 82%, rgba(255, 207, 179, 0.65) 0%, transparent 46%),
    radial-gradient(circle at 18% 84%, rgba(160, 196, 255, 0.48) 0%, transparent 42%),
    linear-gradient(145deg, #F6FAFF 0%, #F1F6FF 50%, #FBF6FF 100%);
  pointer-events: none;
}

#pcb-traces-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
}

/* Floating Segmented Top Bar */
.glass-topbar-wrap {
  position: sticky;
  top: 0.85rem;
  z-index: 40;
  width: min(1220px, calc(100% - 1.5rem));
  margin: 0.85rem auto 0;
}

.glass-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
  padding: 0.55rem 0.75rem;
  border-radius: 999px;
  background: rgba(246, 250, 255, 0.76);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1.5px solid var(--glass-border);
  box-shadow: 0 12px 32px rgba(34, 38, 64, 0.08);
  animation: topbarDrop 0.65s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.topbar-brand-group {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.brand-badge {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
  padding-left: 0.25rem;
}

.brand-tag {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--lavender-strong);
}

.brand-title {
  font-size: 1rem;
  font-weight: 800;
  color: var(--indigo);
}

.segmented-nav {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(34, 38, 64, 0.07);
}

.seg-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.48rem 0.85rem;
  border-radius: 999px;
  border: 0;
  background: transparent;
  color: var(--indigo);
  text-decoration: none;
  font-family: var(--font-sans);
  font-size: 0.83rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s ease, transform 0.16s ease, box-shadow 0.2s ease;
}

.seg-link:hover {
  background: rgba(184, 242, 230, 0.65);
  transform: translateY(-1px);
}

.seg-home {
  background: linear-gradient(135deg, var(--mint), #D6F8F0);
  border: 1px solid rgba(35, 181, 165, 0.28);
  font-weight: 700;
}

.seg-help {
  background: linear-gradient(135deg, var(--peach), #FFE3D1);
  font-weight: 700;
}

.mobile-menu-btn {
  display: none;
}

/* Main Container */
.lab-main {
  position: relative;
  z-index: 5;
  width: min(1220px, calc(100% - 1.5rem));
  margin: 1.5rem auto 3rem;
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

/* Frosted Translucent Glass Cards */
.glass-card {
  position: relative;
  background: var(--glass-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1.5px solid var(--glass-border);
  border-radius: var(--radius-xl);
  padding: clamp(1.35rem, 2.5vw, 2.2rem);
  box-shadow: var(--glass-shadow);
  overflow: hidden;
}

.glass-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.55) 0%, rgba(255, 255, 255, 0.05) 55%);
  pointer-events: none;
}

.glass-card > * {
  position: relative;
  z-index: 1;
}

/* Entrance & Scroll Reveal Animations */
.hero-entrance {
  animation: heroFloatIn 0.78s cubic-bezier(0.22, 1, 0.36, 1) both;
}

[data-reveal] {
  opacity: 0;
  transform: translateY(24px) scale(0.985);
  transition: opacity 0.65s cubic-bezier(0.22, 1, 0.36, 1), transform 0.65s cubic-bezier(0.22, 1, 0.36, 1);
}

[data-reveal].is-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

@keyframes topbarDrop {
  from { opacity: 0; transform: translateY(-16px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes heroFloatIn {
  from { opacity: 0; transform: translateY(22px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Pills & Headings */
.lab-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.73rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--indigo);
  margin-bottom: 0.75rem;
}

.pill-mint {
  background: linear-gradient(135deg, var(--mint), #DCFAF3);
  border: 1px solid rgba(35, 181, 165, 0.32);
}

.pill-lavender {
  background: linear-gradient(135deg, var(--lavender), #ECE0FF);
  border: 1px solid rgba(139, 104, 246, 0.3);
}

.pill-peach {
  background: linear-gradient(135deg, var(--peach), #FFE6D6);
  border: 1px solid rgba(235, 123, 89, 0.3);
}

h1 {
  margin: 0 0 0.8rem;
  font-size: clamp(1.85rem, 3.6vw, 2.8rem);
  line-height: 1.13;
  letter-spacing: -0.025em;
  color: var(--indigo);
}

h2 {
  margin: 0 0 0.65rem;
  font-size: clamp(1.4rem, 2.5vw, 2rem);
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: var(--indigo);
}

h3 {
  margin: 0 0 0.55rem;
  font-size: 1.18rem;
  line-height: 1.28;
  color: var(--indigo);
}

h4 {
  margin: 0 0 0.65rem;
  font-size: 1.02rem;
  color: var(--indigo);
}

/* Buttons */
.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
}

.glass-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.7rem 1.2rem;
  border-radius: 999px;
  border: 1.5px solid transparent;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  color: var(--indigo);
  transition: transform 0.18s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

.glass-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 22px rgba(34, 38, 64, 0.12);
}

.glass-btn:active {
  transform: translateY(0);
}

.btn-mint {
  background: linear-gradient(135deg, #A2EFE0, var(--mint));
  border-color: rgba(35, 181, 165, 0.35);
}

.btn-lavender {
  background: linear-gradient(135deg, #CFA9FF, var(--lavender));
  border-color: rgba(139, 104, 246, 0.35);
}

.btn-peach {
  background: linear-gradient(135deg, #FFC2A1, var(--peach));
  border-color: rgba(235, 123, 89, 0.35);
}

.btn-alert {
  background: linear-gradient(135deg, #FFB5B5, #FFD6A5);
  border-color: rgba(235, 91, 91, 0.45);
  color: #5C1624;
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.72);
  border-color: rgba(34, 38, 64, 0.14);
}

/* Hero Section */
.hero-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.95fr;
  gap: 1.8rem;
  align-items: center;
}

.hero-lead {
  margin: 0 0 1.25rem;
  font-size: 1.03rem;
  color: var(--indigo-soft);
}

.hero-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
  margin-bottom: 1.25rem;
}

.metric-tile {
  padding: 0.9rem 1.05rem;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(34, 38, 64, 0.08);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.metric-label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--indigo-soft);
  letter-spacing: 0.05em;
}

.metric-val {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  color: var(--indigo);
}

.metric-sub {
  font-size: 0.76rem;
  color: var(--indigo-soft);
}

.metric-bar {
  height: 7px;
  border-radius: 999px;
  background: rgba(34, 38, 64, 0.08);
  overflow: hidden;
  margin-top: 0.2rem;
}

.metric-bar > span {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--mint-strong), var(--lavender-strong));
  transition: width 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

.hero-figure {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.figure-frame {
  border-radius: var(--radius-lg);
  padding: 0.85rem;
  background: linear-gradient(145deg, rgba(34, 38, 64, 0.92), rgba(50, 56, 92, 0.9));
  border: 2px solid rgba(184, 242, 230, 0.65);
  box-shadow: 0 16px 34px rgba(34, 38, 64, 0.16);
}

.figure-frame img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 12px;
}

.hero-figure figcaption {
  font-size: 0.84rem;
  color: var(--indigo-soft);
  text-align: center;
}

/* Theory Section */
.sec-head {
  margin-bottom: 1.1rem;
}

.theory-highlight {
  padding: 1.15rem 1.3rem;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.78);
  border-left: 4px solid var(--lavender-strong);
  margin-bottom: 1.2rem;
}

.lean-exact-p {
  margin: 0;
  color: var(--indigo-soft);
  font-size: 0.98rem;
}

.two-col-bays {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.15rem;
  margin-bottom: 1.25rem;
}

.sub-glass-bay {
  padding: 1.15rem 1.25rem;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.72);
  border: 1.5px solid rgba(255, 255, 255, 0.9);
}

.bay-mint {
  box-shadow: inset 0 0 0 1px rgba(35, 181, 165, 0.18);
}

.bay-peach {
  box-shadow: inset 0 0 0 1px rgba(235, 123, 89, 0.18);
}

.lean-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  font-size: 0.93rem;
  color: var(--indigo-soft);
}

.confirm-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
  padding: 0.95rem 1.15rem;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, rgba(184, 242, 230, 0.42), rgba(216, 187, 255, 0.38));
  border: 1px solid rgba(255, 255, 255, 0.8);
  font-weight: 600;
  font-size: 0.92rem;
}

/* 2-Column Lab Bays for 4 Games */
.lab-bays-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.4rem;
}

.lab-bay-card {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.bay-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.bay-code {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--lavender-strong);
}

.bay-status {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  background: rgba(34, 38, 64, 0.08);
  color: var(--indigo-soft);
}

.bay-status.done {
  background: var(--mint);
  color: #115E59;
}

.bay-desc {
  margin: 0;
  font-size: 0.92rem;
  color: var(--indigo-soft);
}

.sim-stage {
  border-radius: var(--radius-md);
  overflow: hidden;
  background: linear-gradient(150deg, #222640, #2E3458);
  border: 1.5px solid rgba(184, 242, 230, 0.45);
  box-shadow: inset 0 2px 12px rgba(0, 0, 0, 0.25);
}

.sim-stage canvas {
  display: block;
  width: 100%;
  height: auto;
}

.status-banner {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.7rem 0.95rem;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(34, 38, 64, 0.1);
  color: var(--indigo);
}

.lab-feedback {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--indigo-soft);
}

/* Game 1 Muda Grid */
.muda-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
}

.muda-item-btn {
  text-align: left;
  padding: 0.62rem 0.78rem;
  border-radius: 12px;
  border: 1.5px solid rgba(34, 38, 64, 0.12);
  background: rgba(255, 255, 255, 0.82);
  color: var(--indigo);
  font-family: var(--font-sans);
  font-size: 0.83rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.14s ease, background 0.18s ease, border-color 0.18s ease;
}

.muda-item-btn:hover {
  transform: translateY(-1px);
  border-color: var(--lavender-strong);
}

.muda-item-btn.marked {
  background: linear-gradient(135deg, #FFE2D6, #FFD0C2);
  border-color: var(--peach-strong);
  color: #7A2312;
  text-decoration: line-through;
}

/* Game 4 LEDs Strip */
.leds-strip {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 0.35rem;
  padding: 0.55rem;
  border-radius: 12px;
  background: rgba(34, 38, 64, 0.88);
}

.led-dot {
  height: 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

.led-dot.on {
  background: var(--mint);
  box-shadow: 0 0 10px var(--mint);
}

.led-dot.fault {
  background: #FF6B81;
  box-shadow: 0 0 12px #FF6B81;
  animation: faultBlink 0.45s ease infinite alternate;
}

@keyframes faultBlink {
  from { opacity: 0.45; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1.08); }
}

/* Illuminated Camera Circuit Stage */
.camera-stage-card {
  border-color: rgba(184, 242, 230, 0.9);
  box-shadow: 0 22px 54px rgba(34, 38, 64, 0.12), 0 0 0 1px rgba(216, 187, 255, 0.4);
}

.camera-desc {
  margin: 0 0 1rem;
  color: var(--indigo-soft);
}

.cam-metrics-bar {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
  margin: 1rem 0;
}

.cam-metric {
  padding: 0.72rem 0.9rem;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(34, 38, 64, 0.08);
  display: flex;
  flex-direction: column;
  gap: 0.18rem;
}

.cam-metric span {
  font-family: var(--font-mono);
  font-size: 0.67rem;
  font-weight: 700;
  color: var(--indigo-soft);
}

.cam-metric strong {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--indigo);
}

.cam-bezel {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: #1D2138;
  border: 3px solid rgba(184, 242, 230, 0.75);
  box-shadow: 0 18px 40px rgba(34, 38, 64, 0.22);
  position: relative;
}

.cam-bezel.portrait-cam {
  max-width: 460px;
  margin: 0 auto;
  aspect-ratio: 3 / 4;
}

.cam-bezel canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

/* Lean Master Certificate */
.certificate-card {
  text-align: center;
  background: linear-gradient(145deg, rgba(246, 250, 255, 0.86), rgba(216, 187, 255, 0.34), rgba(184, 242, 230, 0.38));
  border: 2px solid rgba(255, 255, 255, 0.9);
}

.cert-ribbon {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
}

.cert-serial {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--indigo-soft);
}

.cert-desc {
  max-width: 680px;
  margin: 0 auto 1.15rem;
  color: var(--indigo-soft);
}

.lean-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.6rem;
  margin-bottom: 1.35rem;
}

.lean-chip {
  padding: 0.45rem 0.95rem;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.76);
  border: 1.5px solid rgba(34, 38, 64, 0.12);
  color: var(--indigo-soft);
  transition: transform 0.2s ease, background 0.25s ease, border-color 0.25s ease;
}

.lean-chip.done {
  background: linear-gradient(135deg, var(--mint), #D9FBF4);
  border-color: var(--mint-strong);
  color: #115E59;
  transform: translateY(-2px);
  box-shadow: 0 8px 18px rgba(35, 181, 165, 0.2);
}

.cert-actions {
  justify-content: center;
}

/* Footer */
.lab-footer {
  position: relative;
  z-index: 5;
  text-align: center;
  padding: 1rem 1.2rem 2.2rem;
  font-size: 0.88rem;
  color: var(--indigo-soft);
}

/* Dialog */
.glass-dialog {
  width: min(560px, 92vw);
  border: 2px solid var(--glass-border);
  border-radius: var(--radius-xl);
  padding: 1.6rem;
  background: rgba(246, 250, 255, 0.95);
  backdrop-filter: blur(16px);
  color: var(--indigo);
  box-shadow: 0 24px 60px rgba(34, 38, 64, 0.22);
}

.glass-dialog::backdrop {
  background: rgba(34, 38, 64, 0.42);
  backdrop-filter: blur(6px);
}

.glass-dialog .lean-list {
  margin: 0.9rem 0 1.25rem;
}

/* Responsive */
@media (max-width: 980px) {
  .hero-grid,
  .two-col-bays,
  .lab-bays-grid {
    grid-template-columns: 1fr;
  }

  .cam-metrics-bar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  .glass-topbar {
    border-radius: 24px;
    flex-wrap: wrap;
  }

  .mobile-menu-btn {
    display: inline-flex;
    padding: 0.5rem 0.9rem;
    font-size: 0.84rem;
  }

  .segmented-nav {
    display: none;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    border-radius: 18px;
  }

  .segmented-nav.open {
    display: flex;
  }
}

@media (max-width: 560px) {
  .hero-metrics,
  .muda-grid {
    grid-template-columns: 1fr;
  }

  .leds-strip {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
