:root {
  --paper: #ffffff;
  --ink: #000000;
  --pink: #ff36b5;
  --yellow: #f7ff46;
  --lime: #b7ff2b;
  --cyan: #46c4e6;
  --grid-line: rgba(0, 0, 0, 0.075);
  --button-pad: 10px 13px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: "Courier New", monospace;
}

body {
  display: flex;
  justify-content: center;
}

.page {
  position: relative;
  width: min(760px, calc(100% - 24px));
  min-height: 100vh;
  padding: 28px 0 42px;
}

.social-link {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 20;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  background: var(--lime);
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  font-size: 1.08rem;
  text-decoration: none;
  line-height: 1;
}

.social-link:hover,
.social-link:focus-visible {
  background: var(--pink);
  outline: 2px solid var(--cyan);
  outline-offset: 3px;
}

.hero {
  display: grid;
  justify-items: center;
  gap: 16px;
  margin-bottom: 18px;
}

#titleCanvas {
  display: block;
  width: min(560px, 82vw);
  height: auto;
  image-rendering: pixelated;
}

.intro,
.status p,
.footer p,
.share-copy,
.submit-note,
.submit-title,
.share-meta {
  margin: 0;
  line-height: 1.45;
}

.intro {
  max-width: 640px;
  text-align: center;
  font-size: 0.92rem;
  line-height: 1.55;
}

.status {
  display: flex;
  gap: 14px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 0 auto 12px;
  font-size: 0.86rem;
  text-transform: uppercase;
}

.stage-shell {
  display: grid;
  justify-items: center;
  margin-bottom: 14px;
}

.stage {
  position: relative;
  width: min(78vw, 620px);
  background: var(--paper);
}

.stage canvas {
  display: block;
  width: 100%;
  height: auto;
  image-rendering: pixelated;
}

#gridCanvas {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(to right, var(--grid-line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid-line) 1px, transparent 1px);
  background-size: calc(100% / 50) calc(100% / 50);
  border: 1px solid var(--pink);
}

.meet-gate {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
}

.controls,
.footer,
.submit-panel {
  display: grid;
  gap: 12px;
  justify-items: center;
}

.controls {
  margin-bottom: 12px;
}

.row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.choice,
.action,
.swatch {
  appearance: none;
  border: 0;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  padding: var(--button-pad);
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0;
  border-radius: 0;
  box-shadow: none;
}

.choice:disabled,
.action:disabled {
  cursor: default;
  opacity: 0.45;
}

.choice[data-layer="body"] {
  background: var(--yellow);
}

.choice[data-layer="eyes"] {
  background: var(--cyan);
}

.choice[data-layer="mouth"] {
  background: var(--pink);
}

.choice:not(.active) {
  opacity: 0.62;
}

.choice.active {
  opacity: 1;
  box-shadow: inset 0 -4px 0 var(--paper), 0 0 0 2px var(--lime);
}

.action.primary,
.action.pink {
  background: var(--pink);
}

.action.primary {
  box-shadow: none;
}

.action.yellow {
  background: var(--yellow);
}

.action.lime {
  background: var(--lime);
}

.choice:focus-visible,
.action:focus-visible,
.swatch:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 3px;
}

.palette {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  width: min(100%, 620px);
}

.swatch {
  display: flex;
  align-items: center;
  gap: 10px;
}

.swatch-chip {
  width: 16px;
  height: 16px;
  border: 0;
  flex: none;
}

.swatch.active {
  background: var(--yellow);
}

.hidden {
  display: none !important;
}

.submit-panel {
  width: min(100%, 620px);
  margin: 18px auto 12px;
  padding-top: 14px;
  border-top: 1px solid var(--pink);
}

.submit-title {
  text-align: center;
  color: var(--ink);
  text-transform: uppercase;
  font-size: 0.92rem;
}

.submit-note {
  max-width: 520px;
  text-align: center;
  font-size: 0.86rem;
}

.identity-fields {
  display: grid;
  gap: 10px;
  width: min(100%, 420px);
}

.identity-field {
  display: grid;
  gap: 6px;
  width: 100%;
}

.identity-field span {
  font-size: 0.84rem;
  text-transform: uppercase;
  letter-spacing: 0;
}

.identity-field input {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--pink);
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  padding: 9px 0 8px;
  border-radius: 0;
  outline: 0;
}

.identity-field input:focus {
  border-bottom-color: var(--cyan);
}

.identity-field input.needs-identity {
  border-bottom-color: var(--lime);
  box-shadow: 0 1px 0 var(--lime);
}

.share-stage {
  width: 180px;
  background: var(--paper);
  border: 1px solid var(--lime);
}

.share-card-row,
.share-copy-row {
  display: grid;
  grid-template-columns: auto 34px;
  align-items: start;
  gap: 8px;
}

#shareCanvas {
  display: block;
  width: 100%;
  height: auto;
  image-rendering: pixelated;
}

.icon-button {
  appearance: none;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 0;
  background: var(--yellow);
  color: var(--ink);
  padding: 0;
  cursor: pointer;
}

.icon-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: square;
  stroke-linejoin: miter;
}

.icon-button:hover,
.icon-button:focus-visible {
  background: var(--cyan);
  outline: 2px solid var(--pink);
  outline-offset: 3px;
}

.share-copy,
.share-meta,
.footer {
  text-align: center;
  font-size: 0.86rem;
}

.share-copy {
  max-width: 430px;
}

.share-meta {
  max-width: min(100%, 520px);
  overflow-wrap: anywhere;
}

.share-meta a {
  color: var(--ink);
  text-decoration-color: var(--pink);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.final-share-button {
  min-width: 180px;
}

.share-result {
  width: min(100%, 520px);
  text-align: center;
  font-size: 0.86rem;
  line-height: 1.45;
  border-top: 1px solid var(--lime);
  padding-top: 12px;
}

@media (max-width: 760px) {
  .page {
    width: min(100%, calc(100% - 18px));
    padding-top: 22px;
  }

  .stage {
    width: 100%;
  }

  .status {
    gap: 8px;
    font-size: 0.78rem;
  }

  .choice,
  .action,
  .swatch {
    padding: 9px 10px;
    font-size: 0.84rem;
  }
}
