:root {
  color-scheme: dark;
  --ink: #15152a;
  --ink-deep: #16182d;
  --violet: #716a99;
  --glass: #58d6a9;
  --coral: #ff5d5d;
  --sun: #ffd166;
  --blue: #4f7cff;
  --lilac: #b695ff;
  --cream: #fff5df;
  --paper: #fff5df;
  --muted: #b9b6d2;
  --display-font: Impact, Haettenschweiler, "Arial Narrow Bold", "Franklin Gothic Condensed", sans-serif;
  --body-font: "Arial Rounded MT Bold", "Avenir Next Rounded", "Trebuchet MS", ui-rounded, system-ui, sans-serif;
  --utility-font: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 0;
  background: var(--ink-deep);
}

body {
  min-width: 0;
  min-height: 100vh;
  margin: 0;
  overflow-x: clip;
  overflow-y: auto;
  color: var(--cream);
  background:
    radial-gradient(circle at 15% 8%, rgba(113, 106, 153, 0.34), transparent 27rem),
    linear-gradient(145deg, #1e2038, #121426 75%);
  font-family: var(--body-font);
}

button,
svg {
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
}

.skip-link {
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 10;
  padding: 0.75rem 1rem;
  color: var(--ink);
  background: var(--sun);
  border-radius: 0.75rem;
  font-weight: 800;
  transform: translateY(-180%);
  transition: transform 160ms ease;
}

.skip-link:focus {
  transform: translateY(0);
}

.app-shell {
  width: min(100% - 2rem, 92rem);
  margin-inline: auto;
  padding: clamp(1.25rem, 3vw, 3rem) 0 2rem;
}

.site-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem;
  width: min(100% - 2rem, 92rem);
  margin: 0 auto;
  padding: 0 0 2rem;
  color: var(--muted);
  font-size: 0.78rem;
}

.site-footer p {
  margin: 0;
}

.tinychaos-credit {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.tinychaos-credit a {
  color: var(--cream);
  font-weight: 900;
}

.tinychaos-credit a:focus-visible {
  outline: 4px solid var(--blue);
  outline-offset: 3px;
  box-shadow: 0 0 0 4px var(--paper), 0 0 0 8px var(--ink);
}

.masthead {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 2rem;
  margin-bottom: clamp(1rem, 2.4vw, 2rem);
}

.eyebrow,
.panel-label {
  margin: 0 0 0.35rem;
  color: var(--sun);
  font-family: var(--utility-font);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-family: var(--display-font);
  font-size: clamp(2.55rem, 6vw, 5.7rem);
  font-weight: 900;
  line-height: 0.84;
  letter-spacing: -0.075em;
  text-wrap: balance;
}

h1 span {
  position: relative;
  color: var(--glass);
  text-shadow: 0.07em 0.07em 0 #44506d;
}

h1 span::after {
  position: absolute;
  right: 0.08em;
  bottom: -0.19em;
  width: 58%;
  height: 0.1em;
  background: var(--coral);
  border-radius: 99px;
  content: "";
  transform: rotate(-2deg);
}

.status-cluster {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  max-width: 26rem;
  padding: 0.75rem 1rem;
  border: 1px solid rgba(156, 235, 221, 0.25);
  border-radius: 99px;
  color: #e9e6f6;
  background: rgba(20, 22, 42, 0.6);
  box-shadow: 0 10px 32px rgba(10, 11, 25, 0.25);
  backdrop-filter: blur(12px);
}

.status-cluster p {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.25;
}

.status-light {
  width: 0.7rem;
  height: 0.7rem;
  flex: 0 0 auto;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-radius: 50%;
  background: var(--glass);
  box-shadow: 0 0 0.8rem var(--glass);
  animation: status-pulse 2.4s ease-in-out infinite;
}

.experience {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(18rem, 23rem);
  gap: clamp(1rem, 2vw, 1.5rem);
  align-items: stretch;
}

.stage-card,
.control-deck {
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(33, 35, 63, 0.8);
  box-shadow: 0 2rem 5rem rgba(9, 10, 23, 0.34);
}

.stage-card {
  position: relative;
  overflow: hidden;
  min-width: 0;
  border-radius: clamp(1.25rem, 3vw, 2.25rem);
  cursor: crosshair;
}

#mirror-scene {
  display: block;
  width: 100%;
  height: auto;
  min-height: 30rem;
  outline: none;
  touch-action: none;
}

#mirror-scene:focus-visible {
  outline: 4px solid var(--blue);
  outline-offset: 4px;
  box-shadow: inset 0 0 0 5px var(--blue), 0 0 0 4px var(--paper), 0 0 0 8px var(--ink);
}

.stage-hint {
  position: absolute;
  bottom: 1rem;
  left: 1.1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  padding: 0.5rem 0.75rem;
  border-radius: 99px;
  color: var(--ink);
  background: rgba(255, 244, 216, 0.86);
  font-family: var(--utility-font);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: -0.02em;
  pointer-events: none;
  backdrop-filter: blur(8px);
}

.stage-hint span {
  color: var(--coral);
  font-size: 1rem;
}

.control-deck {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 1.2rem;
  padding: clamp(1rem, 2vw, 1.5rem);
  border-radius: clamp(1.25rem, 3vw, 2.25rem);
}

.instructions {
  padding: 0.3rem 0.25rem 0;
}

.instructions p:last-child {
  max-width: 31ch;
  margin: 0;
  color: #d7d3e9;
  font-size: 0.94rem;
  line-height: 1.55;
}

.button-row {
  display: grid;
  gap: 0.65rem;
}

.primary-button,
.icon-button {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.65rem;
  min-height: 3rem;
  padding: 0.72rem 0.85rem;
  border: 3px solid var(--ink);
  border-radius: 0.9rem;
  font-weight: 800;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.primary-button {
  color: var(--ink);
  background: var(--sun);
  box-shadow: 4px 4px 0 var(--ink);
}

.icon-button {
  color: var(--cream);
  background: #343653;
  box-shadow: 4px 4px 0 var(--ink);
}

.primary-button:hover,
.icon-button:hover {
  transform: translateY(-2px);
}

.primary-button:hover {
  box-shadow: 6px 6px 0 var(--ink);
}

.icon-button:hover {
  background: #414462;
}

.primary-button:active,
.icon-button:active {
  transform: translateY(2px);
}

.primary-button:focus-visible,
.icon-button:focus-visible {
  outline: 4px solid var(--blue);
  outline-offset: 3px;
  box-shadow: 0 0 0 4px var(--paper), 0 0 0 8px var(--ink);
}

.primary-button > span:first-child,
.icon-button > span:first-child {
  display: grid;
  width: 1.5rem;
  height: 1.5rem;
  place-items: center;
  font-size: 1.25rem;
}

kbd {
  min-width: 1.75rem;
  margin-left: auto;
  padding: 0.18rem 0.35rem;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-bottom-width: 2px;
  border-radius: 0.35rem;
  color: inherit;
  background: rgba(14, 16, 32, 0.16);
  font-family: var(--utility-font);
  font-size: 0.65rem;
  text-align: center;
}

.interaction-panel {
  display: flex;
  min-height: 0;
  flex: 1;
  flex-direction: column;
  padding: 1rem;
  border-radius: 1rem;
  color: var(--ink);
  background: var(--paper);
  box-shadow: inset 0 0 0 2px rgba(98, 68, 61, 0.12);
}

.interaction-panel .panel-label {
  color: #88544b;
}

.interaction-copy {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 0.8rem;
}

.interaction-copy p {
  margin: 0;
}

.interaction-copy strong {
  font-family: var(--display-font);
  font-size: 2.2rem;
  line-height: 1;
}

#sync-copy {
  max-width: 10ch;
  color: #775f62;
  font-family: var(--utility-font);
  font-size: 0.7rem;
  line-height: 1.25;
  text-align: right;
}

progress {
  width: 100%;
  height: 0.72rem;
  overflow: hidden;
  border: 0;
  border-radius: 99px;
  background: #d4c5ad;
  accent-color: var(--coral);
}

progress::-webkit-progress-bar {
  background: #d4c5ad;
  border-radius: 99px;
}

progress::-webkit-progress-value {
  border-radius: 99px;
  background: var(--coral);
  transition: width 220ms ease;
}

progress::-moz-progress-bar {
  border-radius: 99px;
  background: var(--coral);
}

.activity-log {
  display: flex;
  min-height: 0;
  flex-direction: column;
  gap: 0.7rem;
  margin: 1rem 0 0;
  padding: 0;
  list-style: none;
}

.activity-log li {
  display: grid;
  grid-template-columns: 3rem 1fr;
  gap: 0.55rem;
  padding-top: 0.7rem;
  border-top: 1px dashed rgba(74, 55, 62, 0.26);
  font-size: 0.76rem;
  line-height: 1.35;
}

.activity-log time {
  color: #8d5a55;
  font-family: var(--utility-font);
  font-size: 0.66rem;
  font-weight: 800;
  text-transform: uppercase;
}

.activity-log li:first-child span {
  font-weight: 800;
}

/* SVG animation surfaces */
.character,
.head,
.arm,
.replacement-character,
.glass-doodles,
.sparkles {
  transform-box: fill-box;
  transform-origin: center;
}

.character,
.replacement-character {
  will-change: transform, opacity;
}

.head,
.arm,
.mouth,
.brows,
.face-features,
.head-back,
.glass-doodles,
.sparkles {
  transition: transform 240ms ease, opacity 220ms ease;
}

.reflection-character {
  filter: saturate(0.88) hue-rotate(7deg);
}

.reflection-character .right-arm {
  transform-origin: 25% 20%;
}

.reflection-character.is-waving .right-arm {
  animation: wave-arm 520ms ease-in-out infinite alternate;
}

.reflection-character.is-drawing .right-arm {
  animation: scribble-arm 340ms ease-in-out infinite alternate;
}

.reflection-character.is-shrugging .left-arm {
  transform: rotate(27deg) translateY(-11px);
}

.reflection-character.is-shrugging .right-arm {
  transform: rotate(-27deg) translateY(-11px);
}

.reflection-character .head-back {
  opacity: 0;
}

.reflection-character.is-turned .face-features {
  opacity: 0;
}

.reflection-character.is-turned .head-back {
  opacity: 1;
}

.reflection-character.is-hiding {
  opacity: 0.38;
}

.replacement-character {
  opacity: 0;
}

.replacement-character.is-visible {
  opacity: 1;
}

.glass-doodles {
  fill: none;
  stroke: #ff527c;
  stroke-width: 8;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0;
}

.glass-doodles text {
  fill: #ff527c;
  stroke: none;
  font-family: var(--display-font);
  font-size: 31px;
  font-weight: 900;
  transform: rotate(-7deg);
  transform-origin: 985px 510px;
}

.glass-doodles.is-visible {
  opacity: 0.95;
}

.glass-doodles.is-visible path {
  animation: doodle-in 650ms ease both;
}

.mirror-plaque text {
  fill: #68443d;
  font-family: var(--utility-font);
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 1px;
}

.sparkles {
  fill: var(--cream);
  opacity: 0;
}

.sparkles.is-visible {
  opacity: 1;
  animation: sparkle-pop 700ms ease-in-out infinite alternate;
}

.noscript-message {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  left: 1rem;
  z-index: 4;
  margin: 0;
  padding: 1rem;
  border-radius: 0.75rem;
  color: var(--ink);
  background: var(--sun);
  text-align: center;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@keyframes status-pulse {
  50% { opacity: 0.55; transform: scale(0.86); }
}

@keyframes wave-arm {
  from { transform: rotate(-72deg) translate(-3px, -28px); }
  to { transform: rotate(-118deg) translate(-3px, -33px); }
}

@keyframes scribble-arm {
  from { transform: rotate(-56deg) translate(-3px, -14px); }
  to { transform: rotate(-78deg) translate(9px, -32px); }
}

@keyframes doodle-in {
  from { stroke-dasharray: 1 150; opacity: 0; }
  to { stroke-dasharray: 150 0; opacity: 1; }
}

@keyframes sparkle-pop {
  from { transform: scale(0.72) rotate(-8deg); }
  to { transform: scale(1.08) rotate(6deg); }
}

@media (max-width: 980px) {
  .experience {
    grid-template-columns: 1fr;
  }

  .control-deck {
    display: grid;
    grid-template-columns: minmax(12rem, 0.8fr) minmax(15rem, 1fr);
  }

  .instructions,
  .button-row {
    grid-column: 1;
  }

  .interaction-panel {
    grid-row: 1 / span 2;
    grid-column: 2;
  }
}

@media (max-width: 660px) {
  .app-shell {
    width: min(100% - 1rem, 92rem);
    padding-top: 1rem;
  }

  .masthead {
    display: block;
  }

  .status-cluster {
    margin-top: 1.35rem;
  }

  .experience,
  .control-deck {
    display: flex;
    flex-direction: column;
  }

  .interaction-panel {
    min-height: 14rem;
  }

  #mirror-scene {
    min-height: 0;
  }

  .stage-hint {
    bottom: 0.6rem;
    left: 0.6rem;
  }
}

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