:root {
  color-scheme: light;
  --ink: #f8f8f2;
  --muted: #bd93f9;
  --paper: #282a36;
  --panel: #343746;
  --line: #44475a;
  --line-strong: #6272a4;
  --up: #50fa7b;
  --down: #ff5555;
  --pink: #ff79c6;
  --cyan: #8be9fd;
  --orange: #ffb86c;
  --yellow: #f1fa8c;
  --purple: #bd93f9;
  --shadow: rgba(0, 0, 0, 0.34);
  --focus: #f1fa8c;
  --content-width: min(50vw, 620px, calc((100dvh - 222px) * 1.333));
  --main-width: var(--content-width);
  --page-pad: clamp(6px, 1.2dvh, 12px);
  --gap: clamp(8px, 1.35dvh, 13px);
  --button-h: clamp(58px, 8.2dvh, 76px);
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
  overflow: hidden;
  background: var(--paper);
}

body {
  height: 100%;
  overflow: hidden;
  margin: 0;
  color: var(--ink);
  font-family: "DM Sans", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
  text-transform: lowercase;
  background: var(--paper);
}

button {
  font: inherit;
}

.shell {
  width: 100%;
  height: 100dvh;
  margin: 0 auto;
  padding: var(--page-pad) 0;
  display: grid;
  align-content: start;
  justify-items: center;
}

.topbar {
  display: grid;
  place-items: center;
  min-height: 0;
  width: var(--content-width);
  padding: 4px 0 6px;
  overflow: visible;
}

h1,
h2,
p,
figure {
  margin: 0;
}

h1 {
  width: 100%;
  padding-inline: 18px;
  font-size: clamp(1.7rem, 3.85vw, 3.48rem);
  line-height: 0.88;
  font-weight: 900;
  text-align: center;
  color: var(--pink);
  -webkit-text-stroke: 1px #ff9fda;
  text-shadow:
    2px 2px 0 var(--purple),
    3px 3px 0 #d7b2ff,
    5px 5px 0 var(--orange),
    6px 6px 0 #ffd1a0,
    8px 8px 0 var(--yellow),
    9px 9px 0 #fbffb9,
    0 14px 34px rgba(0, 0, 0, 0.38);
}

.subject {
  display: grid;
  width: var(--content-width);
  gap: 10px;
  min-height: 0;
  padding-top: 4px;
}

.subject h2 {
  font-size: clamp(1.6rem, 3.3vw, 3.1rem);
  line-height: 1;
  font-weight: 900;
  text-align: center;
  color: var(--yellow);
  -webkit-text-stroke: 1px #fbffb9;
  text-shadow:
    2px 2px 0 var(--orange),
    3px 3px 0 #ffd1a0,
    5px 5px 0 var(--pink),
    6px 6px 0 #ff9fda,
    0 12px 28px rgba(0, 0, 0, 0.32);
  width: var(--content-width);
  justify-self: center;
}

.morph-lab {
  display: grid;
  place-items: center;
  min-height: 0;
}

.morph-stage {
  overflow: hidden;
  width: var(--content-width);
  position: relative;
  aspect-ratio: 4 / 3;
  max-height: 100%;
  min-height: 0;
  border: 2px solid var(--line-strong);
  border-radius: 8px;
  background: #2b2928;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  transition: border-color 180ms ease;
}

.morph-stage:hover {
  border-color: var(--pink);
}

.morph-stage canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

.vote-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  justify-content: center;
  gap: 12px;
  width: var(--content-width);
  justify-self: center;
  margin-top: 2px;
  visibility: hidden;
}

.vote-panel.ready {
  visibility: visible;
}

.copyright {
  width: var(--content-width);
  justify-self: center;
  color: #343746;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
  text-align: center;
}

.vote-button {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: 46px auto;
  justify-content: center;
  align-items: center;
  gap: 12px;
  min-height: var(--button-h);
  min-width: 0;
  padding: 12px 18px;
  border: 2px solid var(--line-strong);
  border-radius: 8px;
  color: var(--ink);
  background: var(--panel);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  overflow: hidden;
}

.vote-button::before {
  content: none;
}

.vote-button:hover {
  border-color: var(--cyan);
  background: var(--line);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.28);
  transition:
    background-color 80ms ease,
    border-color 80ms ease,
    box-shadow 80ms ease;
}

.vote-button:active {
  background: var(--line-strong);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.vote-button:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.vote-icon {
  display: block;
  width: 46px;
  height: 46px;
  background: var(--icon-color);
  mask-position: center;
  mask-repeat: no-repeat;
  mask-size: contain;
  -webkit-mask-position: center;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-size: contain;
}

.vote-icon-up {
  --icon-color: var(--up);
  mask-image: url("/icons/thumbs-up.svg");
  -webkit-mask-image: url("/icons/thumbs-up.svg");
}

.vote-icon-down {
  --icon-color: var(--down);
  mask-image: url("/icons/thumbs-down.svg");
  -webkit-mask-image: url("/icons/thumbs-down.svg");
}


.vote-button strong {
  min-width: 1.4em;
  font-size: 2.35rem;
  line-height: 1;
  text-align: left;
  color: #f8f8f2;
}

.vote-button[data-vote="up"].selected {
  --icon-color: var(--paper);
  border-color: #3ad466;
  background-color: var(--up);
  color: var(--paper);
}

.vote-button[data-vote="down"].selected {
  --icon-color: var(--paper);
  border-color: #d94444;
  background-color: var(--down);
  color: var(--paper);
}

.vote-button.selected .vote-icon {
  --icon-color: var(--paper);
}

.vote-button.selected strong {
  color: var(--paper);
}

@media (max-width: 900px) {
  :root {
    --content-width: min(88vw, 620px, calc((100dvh - 216px) * 1.333));
    --main-width: var(--content-width);
    --button-h: clamp(54px, 7.8dvh, 64px);
  }

  .morph-stage {
    width: var(--main-width);
  }
}

@media (max-width: 560px) {
  .shell {
    width: 100%;
    padding-top: 6px;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .topbar {
    min-height: 0;
    width: var(--content-width);
    padding: 10px 0 6px;
  }

  h1 {
    padding-inline: 0;
    font-size: clamp(2.06rem, 9.7vw, 2.48rem);
    text-shadow:
      1px 1px 0 var(--purple),
      2px 2px 0 #d7b2ff,
      3px 3px 0 var(--orange),
      4px 4px 0 #ffd1a0,
      5px 5px 0 var(--yellow),
      6px 6px 0 #fbffb9,
      0 10px 24px rgba(0, 0, 0, 0.38);
  }

  .subject {
    height: 100%;
    align-content: center;
    gap: 6px;
    padding-top: 0;
  }

  .subject h2 {
    font-size: clamp(2.35rem, 12.8vw, 3.1rem);
    text-shadow:
      1px 1px 0 var(--orange),
      2px 2px 0 #ffd1a0,
      3px 3px 0 var(--pink),
      4px 4px 0 #ff9fda,
      0 9px 20px rgba(0, 0, 0, 0.32);
  }

  .morph-stage {
    aspect-ratio: 4 / 3;
  }

  .vote-button {
    grid-template-columns: 34px auto;
    gap: 7px;
    min-height: var(--button-h);
    padding: 10px 12px;
  }

  .vote-icon {
    width: 34px;
    height: 34px;
  }

  .vote-button strong {
    min-width: 1em;
    font-size: 1.72rem;
  }

  .copyright {
    padding-bottom: 4px;
    font-size: 0.66rem;
    color: #2c2e3b;
  }
}
