* {
  box-sizing: border-box;
}

:root {
  --ink: #101010;
  --paper: #f4efdf;
  --acid: #dcff45;
  --shadow: 4px 5px 0 var(--ink);
}

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

body {
  overflow: hidden;
  background: #151515;
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

button,
a {
  font: inherit;
}

.stage {
  position: relative;
  width: 100vw;
  height: 100svh;
  min-height: 540px;
  overflow: hidden;
  isolation: isolate;
  background: #151515;
}

.scene-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  user-select: none;
  -webkit-user-drag: none;
}

/*
 * Foreground flipbook only.
 * Slightly larger and anchored lower so the table continues naturally
 * beyond the bottom viewport instead of looking like a pasted rectangle.
 */
.frame-stack {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  transform: translateY(5vh) scale(.88);
  transform-origin: center bottom;
}

.character-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center center;
  user-select: none;
  -webkit-user-drag: none;
  opacity: 0;
  visibility: hidden;
}

.character-frame.is-active {
  opacity: 1;
  visibility: visible;
}

.vignette {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background:
    linear-gradient(to bottom, rgba(0, 0, 0, .28) 0%, transparent 22%, transparent 72%, rgba(0, 0, 0, .38) 100%),
    linear-gradient(to right, rgba(0, 0, 0, .14), transparent 24%, transparent 76%, rgba(0, 0, 0, .14));
}

.grain {
  position: absolute;
  inset: -50%;
  z-index: 3;
  opacity: .055;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.8'/%3E%3C/svg%3E");
  animation: grain 240ms steps(2) infinite;
}

.topbar {
  position: absolute;
  z-index: 10;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: clamp(16px, 2.3vw, 30px);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 11px;
}

.meme-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 11px 20px 9px;
  border: 3px solid var(--ink);
  border-radius: 13px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--shadow);
  text-decoration: none;
  font-weight: 950;
  font-size: 14px;
  letter-spacing: .035em;
  line-height: 1;
  cursor: pointer;
  transition: transform 100ms ease, box-shadow 100ms ease, background-color 100ms ease;
}

.meme-button:hover {
  background: #fffaf0;
  transform: translate(-1px, -2px) rotate(0deg);
  box-shadow: 6px 7px 0 var(--ink);
}

.meme-button:active {
  transform: translate(3px, 4px) rotate(0deg);
  box-shadow: 1px 1px 0 var(--ink);
}

.brand-button {
  min-width: 92px;
  background: var(--acid);
  font-size: 18px;
  transform: rotate(-1.5deg);
}

.icon-button {
  min-width: 48px;
  padding-inline: 12px;
}

.tilt-left {
  transform: rotate(-1.15deg);
}

.tilt-right {
  transform: rotate(1.15deg);
}

.ca-pill {
  position: absolute;
  z-index: 10;
  left: 50%;
  bottom: clamp(18px, 3vw, 30px);
  width: min(620px, calc(100vw - 40px));
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border: 3px solid var(--ink);
  border-radius: 13px;
  background: rgba(244, 239, 223, .94);
  color: var(--ink);
  box-shadow: var(--shadow);
  transform: translateX(-50%) rotate(.25deg);
  cursor: pointer;
  backdrop-filter: blur(8px);
}

.ca-pill span,
.ca-pill em {
  font-size: 11px;
  font-style: normal;
  font-weight: 950;
  letter-spacing: .08em;
}

.ca-pill span {
  padding: 6px 7px 5px;
  border: 2px solid var(--ink);
  border-radius: 6px;
  background: var(--acid);
}

.ca-pill strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  letter-spacing: .035em;
}

.toast {
  position: absolute;
  z-index: 20;
  top: 92px;
  left: 50%;
  padding: 10px 14px 9px;
  border: 3px solid var(--ink);
  border-radius: 9px;
  background: var(--acid);
  color: var(--ink);
  box-shadow: 3px 4px 0 var(--ink);
  transform: translate(-50%, -14px) rotate(-1deg);
  opacity: 0;
  pointer-events: none;
  font-size: 12px;
  font-weight: 950;
  letter-spacing: .05em;
  transition: opacity 120ms ease, transform 120ms ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0) rotate(-1deg);
}

@keyframes grain {
  0% { transform: translate(0, 0); }
  25% { transform: translate(3%, -2%); }
  50% { transform: translate(-2%, 3%); }
  75% { transform: translate(2%, 2%); }
  100% { transform: translate(-3%, -2%); }
}

@media (max-width: 760px) {
  .stage {
    min-height: 600px;
  }

  .topbar {
    align-items: flex-start;
    padding: 15px;
  }

  .brand-button {
    min-width: 74px;
    min-height: 42px;
    padding: 9px 14px 8px;
    font-size: 15px;
  }

  .nav-actions {
    gap: 7px;
  }

  .nav-actions .meme-button {
    min-height: 42px;
    padding: 9px 11px 8px;
    font-size: 11px;
  }

  .nav-actions .icon-button {
    min-width: 42px;
  }

  .frame-stack {
    transform: translateY(4vh) scale(.82);
    transform-origin: center bottom;
  }

  .ca-pill {
    bottom: 16px;
    width: calc(100vw - 30px);
    gap: 8px;
    padding: 9px 10px;
  }

  .ca-pill strong {
    font-size: 10px;
  }
}

@media (max-width: 470px) {
  .nav-actions a:nth-child(2) {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .grain {
    animation: none;
  }

  .meme-button,
  .toast {
    transition: none;
  }
}
