:root {
  --sand: #d4a874;
  --sand-deep: #b98a57;
  --ink: #2a1c10;
  --ink-soft: rgba(42, 28, 16, .72);
  --paper: rgba(236, 214, 182, .94);
  --focus: #fff4e2;
  --gutter: clamp(16px, 3vw, 32px);
  --ui-font: ui-sans-serif, system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

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

html, body { margin: 0; height: 100%; }

body {
  background: var(--sand);
  color: var(--ink);
  font-family: var(--ui-font);
  -webkit-font-smoothing: antialiased;
}

body.home {
  overflow: hidden;
  height: 100dvh;
  touch-action: none;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap;
}

button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 4px;
  border-radius: 4px;
  box-shadow: 0 0 0 5px rgba(42, 28, 16, .55);
}

/* ---------- Sand canvas ---------- */
#sand {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
}

#sand.is-shaking { animation: shake .55s cubic-bezier(.36, .07, .19, .97) both; }

@keyframes shake {
  10%, 90% { transform: translate3d(-3px, 1px, 0) rotate(-.3deg); }
  20%, 80% { transform: translate3d(6px, -2px, 0) rotate(.4deg); }
  30%, 50%, 70% { transform: translate3d(-9px, 2px, 0) rotate(-.5deg); }
  40%, 60% { transform: translate3d(9px, -1px, 0) rotate(.5deg); }
}

/* ---------- Corners ---------- */
.corner { position: fixed; z-index: 10; }
.corner--tl { top: calc(var(--gutter) + env(safe-area-inset-top)); left: calc(var(--gutter) + env(safe-area-inset-left)); }
.corner--tr { top: calc(var(--gutter) + env(safe-area-inset-top)); right: calc(var(--gutter) + env(safe-area-inset-right)); z-index: 30; }
.corner--br { bottom: calc(var(--gutter) + env(safe-area-inset-bottom)); right: calc(var(--gutter) + env(safe-area-inset-right)); }

.logo-btn {
  display: block;
  padding: 6px;
  margin: -6px;
  transition: transform .2s ease, opacity .2s ease;
}
.logo-btn img {
  display: block;
  width: clamp(116px, 14vw, 170px);
  height: auto;
  opacity: .88;
}
.logo-btn:hover img { opacity: 1; }
.logo-btn:active { transform: scale(.96) rotate(-2deg); }

/* Hamburger */
.menu-btn {
  width: 44px; height: 44px;
  margin: -8px -8px 0 0;
  display: grid;
  place-content: center;
  gap: 5px;
}
.menu-btn span {
  display: block;
  width: 24px; height: 2px;
  background: var(--ink);
  border-radius: 2px;
  transition: transform .25s ease, opacity .2s ease;
}
.menu-btn[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.menu-btn[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.menu-btn[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Menu overlay */
.menu {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: var(--paper);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: menu-in .25s ease both;
}
.menu[hidden] { display: none; }
.menu ul { list-style: none; margin: 0; padding: 0; text-align: center; }
.menu li + li { margin-top: clamp(14px, 3vh, 28px); }
.menu a {
  color: var(--ink);
  text-decoration: none;
  font-size: clamp(28px, 6vw, 52px);
  letter-spacing: .32em;
  text-transform: uppercase;
  padding: .1em 0 .1em .32em;
  border-bottom: 1px solid transparent;
  transition: border-color .2s ease;
}
.menu a:hover { border-bottom-color: var(--ink); }

@keyframes menu-in { from { opacity: 0; } to { opacity: 1; } }

/* Social */
.social { list-style: none; display: flex; gap: 6px; margin: 0; padding: 0; }
.social a {
  display: grid;
  place-items: center;
  width: 40px; height: 40px;
  color: var(--ink);
  opacity: .8;
  transition: opacity .2s ease, transform .2s ease;
}
.social a:hover { opacity: 1; transform: translateY(-2px); }
.social svg {
  width: 22px; height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.social svg .fill { fill: currentColor; stroke: none; }

/* Small print */
.hint, .copyright {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  font-size: 10.5px;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--ink-soft);
  white-space: nowrap;
  pointer-events: none;
  z-index: 5;
}
.hint {
  bottom: calc(var(--gutter) + 28px + env(safe-area-inset-bottom));
  transition: opacity .8s ease;
}
.hint.is-hidden { opacity: 0; }
.copyright { bottom: calc(var(--gutter) + 10px + env(safe-area-inset-bottom)); }

@media (max-width: 560px) {
  .hint { font-size: 9.5px; letter-spacing: .14em; bottom: calc(var(--gutter) + 64px + env(safe-area-inset-bottom)); }
  .copyright { left: calc(var(--gutter) + env(safe-area-inset-left)); transform: none; bottom: calc(var(--gutter) + 13px + env(safe-area-inset-bottom)); letter-spacing: .14em; }
}

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