:root {
  color-scheme: light;
  --fc-bg: hsl(210 40% 98%);
  --fc-surface: hsl(0 0% 100% / 0.78);
  --fc-surface-strong: hsl(0 0% 100% / 0.92);
  --fc-ink: hsl(222 47% 11%);
  --fc-muted: hsl(215 20% 40%);
  --fc-line: hsl(215 30% 88% / 0.85);
  --fc-brand: hsl(207 86% 48%);
  --fc-brand-dark: hsl(211 79% 36%);
  --fc-blossom: hsl(335 93% 60%);
  --fc-washi: hsl(38 90% 51%);
  --fc-emerald: hsl(151 70% 35%);
  --fc-indigo: hsl(244 64% 56%);
  --fc-ring: hsl(207 86% 48% / 0.28);
  --fc-shadow-sm: 0 8px 24px hsl(222 47% 11% / 0.08);
  --fc-shadow-md: 0 18px 50px hsl(222 47% 11% / 0.12);
  --fc-shadow-lg: 0 28px 90px hsl(222 47% 11% / 0.16);
  --fc-glow: 0 22px 80px hsl(207 86% 56% / 0.27), 0 8px 30px hsl(335 93% 60% / 0.13);
  --fc-radius-xl: 1.25rem;
  --fc-radius-2xl: 1.75rem;
  --fc-radius-3xl: 2.25rem;
  --fc-ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

.dark {
  color-scheme: dark;
  --fc-bg: hsl(222 47% 6%);
  --fc-surface: hsl(222 47% 13% / 0.72);
  --fc-surface-strong: hsl(222 47% 10% / 0.92);
  --fc-ink: hsl(210 40% 98%);
  --fc-muted: hsl(215 20% 78%);
  --fc-line: hsl(0 0% 100% / 0.12);
  --fc-brand: hsl(204 94% 63%);
  --fc-brand-dark: hsl(207 86% 50%);
  --fc-ring: hsl(204 94% 63% / 0.34);
  --fc-shadow-sm: 0 8px 24px hsl(0 0% 0% / 0.22);
  --fc-shadow-md: 0 18px 56px hsl(0 0% 0% / 0.32);
  --fc-shadow-lg: 0 32px 100px hsl(0 0% 0% / 0.42);
  --fc-glow: 0 22px 90px hsl(207 86% 50% / 0.2), 0 8px 34px hsl(335 93% 60% / 0.13);
}

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

html {
  min-width: 320px;
  scroll-behavior: smooth;
  text-rendering: geometricPrecision;
  -webkit-text-size-adjust: 100%;
}

body {
  min-width: 320px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 10% 10%, hsl(207 86% 56% / 0.16), transparent 32rem),
    radial-gradient(circle at 90% 8%, hsl(335 93% 60% / 0.13), transparent 30rem),
    radial-gradient(circle at 50% 90%, hsl(38 90% 51% / 0.09), transparent 28rem),
    var(--fc-bg);
  color: var(--fc-ink);
  overscroll-behavior-y: none;
}

p,
h1,
h2,
h3,
h4,
h5,
h6,
span,
div,
a,
button,
label,
input,
select,
textarea,
li,
dt,
dd {
  word-wrap: break-word;
  overflow-wrap: break-word;
  min-width: 0;
}

img,
svg,
video,
canvas,
iframe,
picture {
  max-width: 100%;
  height: auto;
}

button,
a,
input,
select,
textarea {
  touch-action: manipulation;
}

button,
select,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled,
[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.58;
  filter: saturate(0.7);
}

.hidden,
[hidden] {
  display: none !important;
}

::selection {
  background: hsl(207 86% 48% / 0.25);
  color: var(--fc-ink);
}

.dark ::selection {
  background: hsl(204 94% 63% / 0.34);
  color: hsl(0 0% 100%);
}

::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

::-webkit-scrollbar-track {
  background: hsl(210 40% 96% / 0.85);
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, hsl(207 86% 48%), hsl(335 82% 52%));
  border: 3px solid hsl(210 40% 96% / 0.9);
  border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, hsl(211 79% 36%), hsl(335 85% 42%));
}

.dark ::-webkit-scrollbar-track {
  background: hsl(222 47% 8%);
}

.dark ::-webkit-scrollbar-thumb {
  border-color: hsl(222 47% 8%);
}

:focus-visible {
  outline: 3px solid transparent;
  box-shadow: 0 0 0 4px var(--fc-ring), 0 0 0 1px hsl(207 86% 48%);
}

#appRoot {
  isolation: isolate;
}

#backgroundOrnaments::before,
#backgroundOrnaments::after {
  content: "";
  position: absolute;
  pointer-events: none;
  border-radius: 999px;
  filter: blur(10px);
  opacity: 0.78;
  animation: floatOrb 12s var(--fc-ease) infinite alternate;
}

#backgroundOrnaments::before {
  width: min(44vw, 34rem);
  height: min(44vw, 34rem);
  left: -12rem;
  top: 10rem;
  background: radial-gradient(circle, hsl(207 86% 56% / 0.16), transparent 68%);
}

#backgroundOrnaments::after {
  width: min(38vw, 30rem);
  height: min(38vw, 30rem);
  right: -10rem;
  bottom: 10rem;
  background: radial-gradient(circle, hsl(335 93% 60% / 0.14), transparent 68%);
  animation-delay: -4s;
}

#siteHeader {
  box-shadow: 0 1px 0 hsl(0 0% 100% / 0.6), 0 16px 44px hsl(222 47% 11% / 0.06);
}

.dark #siteHeader {
  box-shadow: 0 1px 0 hsl(0 0% 100% / 0.08), 0 16px 44px hsl(0 0% 0% / 0.24);
}

#brandMark {
  position: relative;
  overflow: hidden;
}

#brandMark::after {
  content: "";
  position: absolute;
  inset: -45%;
  background: linear-gradient(120deg, transparent 35%, hsl(0 0% 100% / 0.45), transparent 65%);
  transform: translateX(-80%) rotate(12deg);
  transition: transform 0.7s var(--fc-ease);
}

#brandHomeLink:hover #brandMark::after {
  transform: translateX(85%) rotate(12deg);
}

#desktopNavLinks a,
#mobileNavLinks a,
#footerLinks a,
button,
#startFoldingButton,
#watchPreviewButton {
  transition-property: transform, color, background-color, border-color, box-shadow, opacity, filter;
  transition-duration: 220ms;
  transition-timing-function: var(--fc-ease);
}

#desktopNavLinks a:hover,
#mobileNavLinks a:hover,
#footerLinks a:hover,
button:hover,
#startFoldingButton:hover,
#watchPreviewButton:hover {
  transform: translateY(-1px);
}

button:active,
#startFoldingButton:active,
#watchPreviewButton:active {
  transform: translateY(1px) scale(0.98);
}

#heroSection,
#tutorialWorkspace,
#projectLibrary,
#practiceTools,
#creasePatterns {
  animation: fadeUp 0.72s var(--fc-ease) both;
}

#tutorialWorkspace {
  animation-delay: 0.08s;
}

#projectLibrary {
  animation-delay: 0.12s;
}

#practiceTools {
  animation-delay: 0.16s;
}

#creasePatterns {
  animation-delay: 0.2s;
}

#heroBadge,
#heroStats > div,
#heroVisualCard,
#controlPanel,
#foldingStage,
#instructionPanel article,
#projectCardsGrid article,
#practiceTools article,
#patternsPanel {
  position: relative;
  overflow: hidden;
}

#heroBadge::before,
#heroStats > div::before,
#heroVisualCard::before,
#controlPanel::before,
#foldingStage::before,
#instructionPanel article::before,
#projectCardsGrid article::before,
#practiceTools article::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  background:
    linear-gradient(135deg, hsl(0 0% 100% / 0.34), transparent 42%),
    radial-gradient(circle at 20% 0%, hsl(207 86% 56% / 0.08), transparent 42%);
  opacity: 0.9;
}

.dark #heroBadge::before,
.dark #heroStats > div::before,
.dark #heroVisualCard::before,
.dark #controlPanel::before,
.dark #foldingStage::before,
.dark #instructionPanel article::before,
.dark #projectCardsGrid article::before,
.dark #practiceTools article::before {
  background:
    linear-gradient(135deg, hsl(0 0% 100% / 0.08), transparent 42%),
    radial-gradient(circle at 20% 0%, hsl(204 94% 63% / 0.08), transparent 42%);
}

#heroTitle {
  letter-spacing: -0.055em;
  text-wrap: balance;
}

#heroDescription,
#patternsPanel p,
#instructionPanel p,
#projectCardsGrid p {
  text-wrap: pretty;
}

#startFoldingButton,
#saveProjectButton,
#filterAllButton,
#openCraneProjectButton,
#openLotusProjectButton,
#openFrogProjectButton,
#openStarProjectButton,
#calculatePaperButton {
  background-image: linear-gradient(135deg, hsl(222 47% 11%), hsl(215 40% 18%));
  box-shadow: 0 16px 34px hsl(222 47% 11% / 0.2);
  color: hsl(0 0% 100%);
}

#startFoldingButton:hover,
#saveProjectButton:hover,
#filterAllButton:hover,
#openCraneProjectButton:hover,
#openLotusProjectButton:hover,
#openFrogProjectButton:hover,
#openStarProjectButton:hover,
#calculatePaperButton:hover {
  background-image: linear-gradient(135deg, hsl(211 79% 36%), hsl(207 86% 48%));
  box-shadow: 0 18px 42px hsl(207 86% 48% / 0.25);
}

.dark #startFoldingButton,
.dark #saveProjectButton,
.dark #filterAllButton,
.dark #openCraneProjectButton,
.dark #openLotusProjectButton,
.dark #openFrogProjectButton,
.dark #openStarProjectButton,
.dark #calculatePaperButton {
  background-image: linear-gradient(135deg, hsl(0 0% 100%), hsl(210 40% 86%));
  color: hsl(222 47% 11%);
}

#playPauseButton,
#startCreaseTrainerButton,
#startTimerButton,
#downloadPatternButton {
  background-image: linear-gradient(135deg, hsl(211 79% 36%), hsl(207 86% 48%));
  color: hsl(0 0% 100%);
  box-shadow: 0 16px 34px hsl(207 86% 48% / 0.24);
}

#playPauseButton:hover,
#startCreaseTrainerButton:hover,
#startTimerButton:hover,
#downloadPatternButton:hover {
  background-image: linear-gradient(135deg, hsl(211 85% 30%), hsl(211 79% 36%));
  box-shadow: 0 18px 44px hsl(207 86% 48% / 0.3);
}

#themeToggleButton:hover,
#mobileMenuButton:hover,
#shareProjectButton:hover,
#watchPreviewButton:hover,
#filterBeginnerButton:hover,
#filterIntermediateButton:hover,
#filterAdvancedButton:hover,
#resetTimerButton:hover {
  box-shadow: 0 12px 28px hsl(222 47% 11% / 0.16);
}

#heroVisualCard {
  box-shadow: var(--fc-glow);
  transform-style: preserve-3d;
}

#heroVisualCard::after {
  content: "";
  position: absolute;
  inset: auto 8% -1.25rem 8%;
  height: 2.5rem;
  border-radius: 999px;
  background: hsl(222 47% 11% / 0.16);
  filter: blur(20px);
  z-index: -1;
}

#paperStagePreview,
#stageCanvas {
  background-size: 160% 160%;
  animation: gradientDrift 10s ease-in-out infinite alternate;
}

#origamiPreviewShape,
#paperModel {
  transition: transform 450ms var(--fc-ease), box-shadow 450ms var(--fc-ease);
}

#heroVisualCard:hover #origamiPreviewShape,
#foldingStage:hover #paperModel {
  transform: translateY(-4px) rotateX(2deg) rotateY(-2deg);
  box-shadow: 0 34px 90px hsl(222 47% 11% / 0.22);
}

#origamiPreviewShape .grid > div,
#paperModelInner > div {
  transform-origin: center;
  animation: paperBreathe 4.5s var(--fc-ease) infinite;
}

#origamiPreviewShape .grid > div:nth-child(2),
#paperModelInner > div:nth-child(2) {
  animation-delay: -0.8s;
}

#origamiPreviewShape .grid > div:nth-child(3),
#paperModelInner > div:nth-child(3) {
  animation-delay: -1.4s;
}

#origamiPreviewShape .grid > div:nth-child(4),
#paperModelInner > div:nth-child(4) {
  animation-delay: -2s;
}

#heroProgressBar,
#stageProgressBar {
  position: relative;
  overflow: hidden;
  background-image: linear-gradient(90deg, hsl(211 79% 36%), hsl(207 86% 56%), hsl(335 93% 60%));
  background-size: 180% 100%;
  animation: progressShine 2.4s linear infinite;
}

#heroProgressBar::after,
#stageProgressBar::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, hsl(0 0% 100% / 0.38), transparent);
  transform: translateX(-100%);
  animation: shimmer 2.2s infinite;
}

#workspaceGrid {
  align-items: start;
}

#controlPanel,
#foldingStage,
#instructionPanel article,
#projectCardsGrid article,
#practiceTools article {
  box-shadow: var(--fc-shadow-md);
  transition: transform 260ms var(--fc-ease), box-shadow 260ms var(--fc-ease), border-color 260ms var(--fc-ease);
}

#controlPanel:hover,
#instructionPanel article:hover,
#projectCardsGrid article:hover,
#practiceTools article:hover {
  transform: translateY(-4px);
  box-shadow: var(--fc-shadow-lg);
  border-color: hsl(207 86% 48% / 0.34);
}

#controlPanel {
  position: sticky;
  top: 6.25rem;
}

select,
input[type="search"],
input[type="number"],
textarea {
  max-width: 100%;
  box-shadow: inset 0 1px 0 hsl(0 0% 100% / 0.7);
  transition: border-color 180ms var(--fc-ease), box-shadow 180ms var(--fc-ease), background-color 180ms var(--fc-ease);
}

select:hover,
input[type="search"]:hover,
input[type="number"]:hover,
textarea:hover {
  border-color: hsl(207 86% 48% / 0.65);
}

select:focus,
input[type="search"]:focus,
input[type="number"]:focus,
textarea:focus {
  box-shadow: 0 0 0 4px var(--fc-ring), inset 0 1px 0 hsl(0 0% 100% / 0.75);
}

input[type="range"] {
  min-width: 0;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  box-shadow: 0 0 0 5px hsl(207 86% 48% / 0.18), 0 8px 18px hsl(222 47% 11% / 0.18);
}

input[type="checkbox"] {
  flex: 0 0 auto;
  cursor: pointer;
}

#creaseOptionsPanel label {
  transition: background-color 180ms var(--fc-ease), transform 180ms var(--fc-ease);
}

#creaseOptionsPanel label:hover {
  background: hsl(0 0% 100% / 0.75);
  transform: translateX(2px);
}

.dark #creaseOptionsPanel label:hover {
  background: hsl(0 0% 100% / 0.08);
}

#stageCanvas {
  position: relative;
  overflow: hidden;
}

#stageCanvas::before {
  content: "";
  position: absolute;
  inset: 1rem;
  pointer-events: none;
  border-radius: 1.25rem;
  background-image:
    linear-gradient(hsl(207 86% 48% / 0.09) 1px, transparent 1px),
    linear-gradient(90deg, hsl(207 86% 48% / 0.09) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: radial-gradient(circle, black 35%, transparent 78%);
}

.dark #stageCanvas::before {
  background-image:
    linear-gradient(hsl(204 94% 63% / 0.1) 1px, transparent 1px),
    linear-gradient(90deg, hsl(204 94% 63% / 0.1) 1px, transparent 1px);
}

#paperModel::before,
#paperModel::after {
  content: "";
  position: absolute;
  pointer-events: none;
  z-index: 2;
}

#paperModel::before {
  inset: 18%;
  border-top: 3px dashed hsl(335 82% 52% / 0.72);
  transform: rotate(45deg);
  transform-origin: center;
  animation: pulseLine 1.8s ease-in-out infinite;
}

#paperModel::after {
  width: 4.5rem;
  height: 4.5rem;
  right: 16%;
  top: 22%;
  border-right: 5px solid hsl(211 79% 36%);
  border-top: 5px solid hsl(211 79% 36%);
  border-radius: 0 1.1rem 0 0;
  transform: rotate(45deg);
  opacity: 0.78;
  animation: nudgeArrow 1.7s var(--fc-ease) infinite;
}

.dark #paperModel::after {
  border-color: hsl(204 94% 63%);
}

#stageTimerBadge {
  box-shadow: 0 12px 30px hsl(222 47% 11% / 0.18);
  animation: softPulse 2.6s ease-in-out infinite;
}

#difficultyFilterBar {
  scrollbar-width: thin;
  scrollbar-color: hsl(207 86% 48%) transparent;
}

#projectCardsGrid article > div:first-child {
  position: relative;
  overflow: hidden;
}

#projectCardsGrid article > div:first-child::before {
  content: "";
  position: absolute;
  inset: 22%;
  border-radius: 35% 65% 65% 35% / 35% 35% 65% 65%;
  background: hsl(0 0% 100% / 0.28);
  box-shadow:
    0 0 0 22px hsl(0 0% 100% / 0.08),
    0 20px 40px hsl(222 47% 11% / 0.18);
  transform: rotate(45deg);
  transition: transform 420ms var(--fc-ease), border-radius 420ms var(--fc-ease);
}

#projectCardsGrid article:hover > div:first-child::before {
  transform: rotate(58deg) scale(1.08);
  border-radius: 58% 42% 45% 55% / 55% 45% 55% 45%;
}

#projectCardsGrid article > div:first-child::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent 30%, hsl(0 0% 100% / 0.28), transparent 62%);
  transform: translateX(-120%);
  transition: transform 620ms var(--fc-ease);
}

#projectCardsGrid article:hover > div:first-child::after {
  transform: translateX(120%);
}

#practiceTools article:nth-child(1) {
  background-image: radial-gradient(circle at 90% 10%, hsl(207 86% 56% / 0.16), transparent 38%), linear-gradient(var(--fc-surface), var(--fc-surface));
}

#practiceTools article:nth-child(2) {
  background-image: radial-gradient(circle at 90% 10%, hsl(151 70% 35% / 0.14), transparent 38%), linear-gradient(var(--fc-surface), var(--fc-surface));
}

#practiceTools article:nth-child(3) {
  background-image: radial-gradient(circle at 90% 10%, hsl(335 93% 60% / 0.14), transparent 38%), linear-gradient(var(--fc-surface), var(--fc-surface));
}

#focusTimerDisplay {
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.055em;
}

#patternsPanel {
  box-shadow: 0 28px 90px hsl(222 47% 11% / 0.28);
}

#patternsPanel::before {
  content: "";
  position: absolute;
  width: 22rem;
  height: 22rem;
  right: -7rem;
  top: -9rem;
  border-radius: 999px;
  background: radial-gradient(circle, hsl(207 86% 56% / 0.36), transparent 70%);
  pointer-events: none;
}

#patternsPanel::after {
  content: "";
  position: absolute;
  width: 18rem;
  height: 18rem;
  left: 18%;
  bottom: -10rem;
  border-radius: 999px;
  background: radial-gradient(circle, hsl(335 93% 60% / 0.22), transparent 70%);
  pointer-events: none;
}

#downloadPanel {
  position: relative;
  z-index: 1;
  box-shadow: inset 0 1px 0 hsl(0 0% 100% / 0.18);
}

#siteFooter {
  position: relative;
}

#siteFooter::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 0;
  width: min(42rem, 85vw);
  height: 1px;
  transform: translateX(-50%);
  background: linear-gradient(90deg, transparent, hsl(207 86% 48% / 0.38), hsl(335 93% 60% / 0.28), transparent);
}

.modal,
[role="dialog"],
[aria-modal="true"] {
  z-index: 9999;
  max-width: min(100vw - 2rem, 42rem);
  max-height: calc(100dvh - 2rem);
  overflow: auto;
}

.loading,
[aria-busy="true"] {
  position: relative;
  pointer-events: none;
}

.loading::after,
[aria-busy="true"]::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 1rem;
  width: 1rem;
  height: 1rem;
  margin-top: -0.5rem;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 999px;
  animation: spin 0.8s linear infinite;
}

@media (max-width: 1023px) {
  #controlPanel {
    position: relative;
    top: auto;
  }

  #heroTitle {
    letter-spacing: -0.045em;
  }
}

@media (max-width: 767px) {
  #heroStats {
    grid-template-columns: 1fr;
  }

  #stageCanvas {
    min-height: 330px;
    padding: 1rem;
  }

  #paperModel::after {
    width: 3.25rem;
    height: 3.25rem;
  }

  #playerControls {
    grid-template-columns: 1fr;
  }

  #patternsPanel {
    padding: 1.25rem;
  }
}

@media (max-width: 480px) {
  #mainNavigation {
    gap: 0.5rem;
  }

  #brandText {
    max-width: 9.5rem;
  }

  #themeToggleButton,
  #mobileMenuButton {
    padding-inline: 0.85rem;
  }

  #heroTitle {
    font-size: clamp(2.5rem, 15vw, 3.5rem);
    line-height: 1.02;
  }

  #workspaceQuickActions,
  #heroActions,
  #focusTimerTool .flex {
    flex-direction: column;
  }

  #workspaceQuickActions > *,
  #heroActions > *,
  #focusTimerTool .flex > * {
    width: 100%;
  }
}

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

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

@keyframes floatOrb {
  from {
    transform: translate3d(0, 0, 0) scale(1);
  }
  to {
    transform: translate3d(2rem, -1.5rem, 0) scale(1.06);
  }
}

@keyframes gradientDrift {
  from {
    background-position: 0% 50%;
  }
  to {
    background-position: 100% 50%;
  }
}

@keyframes paperBreathe {
  0%,
  100% {
    transform: translateY(0) rotate(0deg);
    filter: brightness(1);
  }
  50% {
    transform: translateY(-3px) rotate(0.6deg);
    filter: brightness(1.04);
  }
}

@keyframes progressShine {
  from {
    background-position: 0% 50%;
  }
  to {
    background-position: 180% 50%;
  }
}

@keyframes shimmer {
  0% {
    transform: translateX(-110%);
  }
  58%,
  100% {
    transform: translateX(120%);
  }
}

@keyframes softPulse {
  0%,
  100% {
    transform: scale(1);
    box-shadow: 0 12px 30px hsl(222 47% 11% / 0.18);
  }
  50% {
    transform: scale(1.025);
    box-shadow: 0 16px 38px hsl(207 86% 48% / 0.2);
  }
}

@keyframes pulseLine {
  0%,
  100% {
    opacity: 0.42;
  }
  50% {
    opacity: 0.96;
  }
}

@keyframes nudgeArrow {
  0%,
  100% {
    transform: translateX(0) rotate(45deg);
    opacity: 0.62;
  }
  50% {
    transform: translateX(10px) rotate(45deg);
    opacity: 0.96;
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}