:root {
  --font-main: "Comic Neue", "Comic Sans MS", "Comic Sans", cursive;
  --ui-scale: 1.46;
  --bg-primary: #9ed4ff;
  --bg-secondary: #b8e4ff;
  --text-color: #1f1a1a;
  --panel-bg: rgba(255, 249, 224, 0.94);
  --accent: #df2d2d;
  --border: #2d0e0e;
  --glow: #ffe37c;
  --nav-body-fill: #8b5a2b;
  --nav-body-width: 9rem;
  --duck-tab-width: 7.5rem;
  --duck-tab-height: 8.75rem;
  --duck-tree-overlap: 5.35rem;

  /* DUCK TAB CONTROLS: tweak these values to move/rotate the desktop duck tabs */
  --duck-tab-idle-offset: -1.35rem;
  --duck-tab-active-offset: -4.45rem;
  --duck-tab-hover-offset: -3.35rem;
  --duck-tab-hover-rotation: 33deg;
  --duck-tab-active-rotation: 60deg;
  --duck-tab-motion-duration: .34s;
  --duck-tab-motion-ease: cubic-bezier(.22, .7, .2, 1);
}

html[data-theme="night"] {
  --bg-primary: #111a3a;
  --bg-secondary: #273967;
  --text-color: #f1edff;
  --panel-bg: rgba(32, 24, 51, 0.92);
  --accent: #ff5673;
  --border: #e2dcff;
  --glow: #9fd3ff;
}

* { box-sizing: border-box; }

html {
  font-size: calc(100% * var(--ui-scale));
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-main);
  color: var(--text-color);
  background: linear-gradient(180deg, var(--bg-primary), var(--bg-secondary));
  background-attachment: fixed;
  overflow-x: hidden;
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

body::before {
  background-image: radial-gradient(circle at 20% 20%, rgba(255,255,255,.35) 0 2px, transparent 2px),
                    radial-gradient(circle at 80% 60%, rgba(255,255,255,.25) 0 1px, transparent 1px);
  background-size: 12px 12px, 9px 9px;
  mix-blend-mode: soft-light;
}

body::after {
  background-image: linear-gradient(transparent 48%, rgba(0,0,0,.12) 49%, transparent 50%);
  background-size: 100% 4px;
  opacity: .25;
}

.site-shell {
  position: fixed;
  inset: 0;
  padding: 1.5rem;
  overflow: auto;
  z-index: 20;
}

.retro-panel {
  border: 4px dashed var(--border);
  background: var(--panel-bg);
  box-shadow: 0 0 0 5px var(--glow), 10px 10px 0 rgba(0,0,0,.35);
}

.site-shell.is-intro .site-nav-panel {
  display: none;
}

.site-nav-panel {
  position: fixed;
  top: 170px;
  right: max(1.25rem, calc(50vw - 610px));
  z-index: 28;
  display: flex;
  align-items: stretch;
  width: fit-content;
  touch-action: none;
}

.site-nav-panel .drag-dither {
  inset: 0;
  width: 100%;
  height: 100%;
}

.nav-tabs-rail {
  display: flex;
  flex-direction: column;
  gap: .25rem;
}

.site-nav-tabs {
  position: relative;
  z-index: 1;
  margin-right: calc(-1 * var(--duck-tree-overlap));
  padding: .75rem 0;
}

.site-nav-body {
  position: relative;
  z-index: 3;
  width: var(--nav-body-width);
  min-height: 100%;
  border: 4px solid var(--border);
  border-radius: 0;
  background: var(--nav-body-fill);
  box-shadow: 0 0 0 5px var(--glow), 10px 10px 0 rgba(0,0,0,.35);
}

.site-nav-panel.is-draggable .site-nav-body {
  cursor: grab;
}

.site-nav-panel.is-dragging .site-nav-body {
  cursor: grabbing;
}

.nav-tab {
  position: relative;
  display: block;
  width: var(--duck-tab-width);
  height: var(--duck-tab-height);
  transform: translateX(var(--duck-tab-idle-offset));
  transition:
    transform var(--duck-tab-motion-duration) var(--duck-tab-motion-ease),
    filter var(--duck-tab-motion-duration) var(--duck-tab-motion-ease);
  text-decoration: none;
  color: #ffe18b;
  overflow: visible;
}

.nav-tab-duck {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  transform: scaleX(-1);
  transform-origin: 58% 68%;
  transition: transform var(--duck-tab-motion-duration) var(--duck-tab-motion-ease);
  filter: drop-shadow(0 6px 12px rgba(0, 0, 0, .28));
  pointer-events: none;
}

.nav-tab-label {
  position: absolute;
  left: .65rem;
  top: 1.2rem;
  z-index: 2;
  max-width: 3.8rem;
  font-size: .72rem;
  font-weight: 700;
  line-height: .86;
  letter-spacing: .03em;
  text-transform: lowercase;
  text-shadow:
    1px 1px 0 rgba(0,0,0,.85),
    -1px 1px 0 rgba(0,0,0,.85),
    1px -1px 0 rgba(0,0,0,.85),
    -1px -1px 0 rgba(0,0,0,.85);
  pointer-events: none;
}

.nav-tab:hover,
.nav-tab:focus-visible {
  transform: translateX(var(--duck-tab-hover-offset));
  filter: saturate(1.03);
}

.nav-tab:hover .nav-tab-duck,
.nav-tab:focus-visible .nav-tab-duck {
  transform: scaleX(-1) rotate(var(--duck-tab-hover-rotation));
}

.nav-tab.active-tab {
  transform: translateX(var(--duck-tab-active-offset));
}

.nav-tab.active-tab .nav-tab-duck {
  transform: scaleX(-1) rotate(var(--duck-tab-active-rotation));
}

.nav-tab.active-tab:hover,
.nav-tab.active-tab:focus-visible {
  transform: translateX(var(--duck-tab-active-offset));
}

.nav-tab:focus-visible {
  outline: none;
  filter: saturate(1.03) drop-shadow(0 0 0.35rem rgba(255, 227, 124, .5));
}

.theme-fab {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 25;
  width: 68px;
  height: 68px;
  border-radius: 999px;
  border: 4px solid var(--border);
  background: linear-gradient(135deg, #8fd3ff, #4f88ff);
  box-shadow: 0 0 0 4px var(--glow), 0 8px 20px rgba(0,0,0,.3);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.theme-gif-single {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 999px;
  pointer-events: none;
}

html[data-theme="night"] .theme-fab {
  background: linear-gradient(135deg, #24335f, #0e1328);
}

main.page {
  position: relative;
  overflow: visible;
  max-width: 980px;
  margin: 0 auto;
  touch-action: none;
}

main.page.is-draggable {
  position: fixed;
  left: 50%;
  top: 52%;
  transform: translate(-50%, -50%);
  margin: 0;
  z-index: 30;
  cursor: grab;
}

main.page.is-dragging {
  cursor: grabbing;
  opacity: 1;
}

.drag-dither {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0;
}

.site-section { display: none; }
.site-section.active-section { display: block; }

main.page.is-intro .site-controls,
main.page.is-intro .site-section {
  display: none !important;
}

main.page.is-intro .site-subtitle--ready {
  display: none;
}

main.page:not(.is-intro) .site-subtitle--intro,
main.page:not(.is-intro) .site-intro {
  display: none;
}

.site-intro {
  text-align: center;
  padding-top: .75rem;
}

.rainbow-hr { border: 0; height: 8px; background: linear-gradient(90deg, red, orange, yellow, lime, cyan, blue, violet); }
.farm-scene-note { border: 3px dotted var(--border); padding: .75rem; background: #ffffff8e; margin-bottom: .8rem; }
.hidden-honeypot { position: absolute !important; left: -5000px !important; top: -5000px !important; }

.retro-panel,
.retro-panel .title,
.retro-panel .subtitle,
.retro-panel .content,
.retro-panel p,
.retro-panel li,
.retro-panel label { color: var(--text-color) !important; }

.retro-panel a { color: #0c4fb3; text-decoration: underline; font-weight: 700; }
html[data-theme="night"] .retro-panel a { color: #8cc8ff; }

.duck-enter-button {
  border: none;
  background: transparent;
  padding: 0;
  margin: 0 auto;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
}

.duck-enter-button:focus-visible {
  outline: 3px dashed var(--accent);
  outline-offset: 6px;
}

.duck-art {
  width: min(260px, 60vw);
  height: auto;
  image-rendering: auto;
  filter: drop-shadow(0 8px 18px rgba(0, 0, 0, .35));
}

.duck-enter-idle,
.duck-enter-animation {
  width: min(300px, 68vw);
}

.duck-enter-animation {
  opacity: 1;
  transition: opacity .55s ease, transform .55s ease;
}

.duck-enter-animation.is-fading-out {
  opacity: 0;
  transform: scale(.96);
}

.is-hidden {
  display: none !important;
}

.gallery-uploader {
  border: 3px dotted var(--border);
  background: #ffffff9e;
  padding: 1rem;
  border-radius: 12px;
  transition: transform .2s ease, box-shadow .2s ease, background-color .2s ease;
}

.gallery-uploader.drag-over {
  transform: scale(1.01);
  box-shadow: 0 0 0 5px var(--glow);
  background: #fff7cf;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: .9rem;
}

.gallery-item {
  margin: 0;
  border: 3px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: #00000011;
}

.gallery-item img {
  display: block;
  width: 100%;
  height: 170px;
  object-fit: cover;
  cursor: zoom-in;
}

.gallery-item figcaption {
  padding: .45rem .6rem;
  font-size: .8rem;
  line-height: 1.2;
  word-break: break-word;
}

.gallery-lightbox {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  background: rgba(8, 10, 20, .86);
  padding: 1rem;
}

.gallery-lightbox img {
  max-width: min(1100px, 96vw);
  max-height: 86vh;
  width: auto;
  height: auto;
  border: 4px solid var(--glow);
  box-shadow: 0 16px 38px rgba(0, 0, 0, .55);
  border-radius: 14px;
}

.gallery-lightbox-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  border: 3px solid var(--border);
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  padding: .45rem .75rem;
  border-radius: 10px;
  cursor: pointer;
}

.glitch-text { text-transform: lowercase; text-shadow: -2px 0 #f0f, 2px 0 #0ff; }

@media (max-width: 1023px) {
  .site-shell { position: static; overflow: visible; }
  .site-nav-panel {
    position: static;
    display: block;
    width: 100%;
    margin-bottom: 1rem;
    touch-action: auto;
  }
  .site-nav-tabs {
    margin-right: 0;
    padding: 0;
  }
  .site-nav-body,
  .site-nav-panel .drag-dither {
    display: none !important;
  }
  .nav-tabs-rail { flex-direction: row; flex-wrap: wrap; gap: .5rem; }
  .nav-tab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: auto;
    height: auto;
    min-height: 2.3rem;
    transform: none !important;
    border: 3px solid var(--border);
    border-radius: 12px;
    padding: .45rem .7rem;
    background: #fff9;
    color: var(--text-color);
  }
  .nav-tab-duck {
    display: none;
  }
  .nav-tab-label {
    position: static;
    max-width: none;
    font-size: .9rem;
    line-height: 1;
    color: inherit;
    text-shadow: none;
  }
  .nav-tab.active-tab {
    background: var(--accent);
    color: #fff;
  }
  .theme-fab { width: 56px; height: 56px; top: .75rem; right: .75rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

.duck-fallback {
  border: 3px solid var(--border);
  background: var(--accent);
  color: #fff;
  padding: .6rem 1rem;
  font-weight: 700;
}

main.page.is-dither-masked {
  will-change: mask-image, -webkit-mask-image;
}
