:root {
  color-scheme: light;
  --paper: #ffffff;
  --gray-100: #f4f4f4;
  --gray-200: #e5e5e5;
  --gray-300: #c7c7c7;
  --gray-500: #767676;
  --gray-600: #606060;
  --black: #000000;
  --blue-100: #edeffd;
  --blue-500: #1634cc;
  --green-100: #e0fdce;
  --green-700: #0a3d14;
  --yellow-400: #ffef5f;
  --cyan-400: #7edcf2;
  --magenta-400: #f48cd9;
  --bezel: 12px;
}

@font-face {
  font-family: "Special Gothic Condensed";
  src: url("SpecialGothicCondensed-Bold.a85b442a.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--black);
  background-color: var(--paper);
  background-size: 32px 32px;
  background-image:
    linear-gradient(to right, var(--gray-200) 1px, transparent 1px),
    linear-gradient(to bottom, var(--gray-200) 1px, transparent 1px);
  font: 15px/1.45 system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  touch-action: manipulation;
}

::selection {
  background: var(--yellow-400);
  color: var(--black);
}

:focus-visible {
  outline: 2px solid var(--blue-500);
  outline-offset: 2px;
}

a {
  color: var(--blue-500);
}

button {
  font: inherit;
  color: var(--black);
  background: var(--paper);
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  padding: 10px 16px;
  min-height: 44px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

button:active,
button.held {
  background: var(--yellow-400);
  border-color: var(--black);
}

button.primary {
  background: var(--black);
  color: var(--paper);
  border-color: var(--black);
}

button.primary:active {
  background: var(--gray-600);
}

.frame {
  min-height: 100vh;
  min-height: 100dvh;
  padding: 8px;
  display: flex;
  background-image: linear-gradient(to right, var(--cyan-400), var(--magenta-400), var(--yellow-400));
}

.card {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--paper);
  padding: calc(12px + env(safe-area-inset-top)) 16px calc(12px + env(safe-area-inset-bottom));
}

.masthead {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 12px;
  align-items: center;
}

.mark {
  grid-row: 1 / 3;
  display: block;
  line-height: 0;
}

.mark svg {
  width: 32px;
  height: 32px;
}

h1 {
  margin: 0;
  font: 700 22px/1.1 Georgia, "Times New Roman", Times, serif;
  letter-spacing: -0.01em;
}

.lede {
  margin: 0;
  color: var(--gray-600);
  font-size: 14px;
}

.stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 180px;
  background: var(--black);
  border-radius: 12px;
}

canvas {
  position: absolute;
  inset: var(--bezel);
  margin: auto;
  width: 160px;
  height: 144px;
  image-rendering: pixelated;
  background: var(--paper);
  border-radius: 4px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.overlay {
  position: absolute;
  inset: var(--bezel);
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 10px;
  padding: 16px;
  text-align: center;
  background: rgba(255, 255, 255, 0.94);
  border-radius: 4px;
}

.overlay p {
  margin: 0;
}

.overlay[hidden] {
  display: none;
}

.hint {
  display: none;
  pointer-events: none;
  place-content: end center;
  background: transparent;
}

.hint p {
  background: var(--black);
  color: var(--paper);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 14px;
}

.sheet-title {
  font: 700 26px/1.1 Georgia, "Times New Roman", Times, serif;
}

.score {
  font: 700 64px/1 "Special Gothic Condensed", "Arial Narrow", Impact, sans-serif;
  letter-spacing: 0.01em;
}

.detail {
  color: var(--gray-600);
  font-size: 14px;
}

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

.back {
  font-size: 14px;
}

#fail {
  display: none;
}

.unsupported #fail {
  display: grid;
}

.unsupported canvas,
.unsupported .controls,
.unsupported .pad {
  display: none;
}

.controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

button.icon {
  width: 44px;
  height: 44px;
  padding: 0;
  display: grid;
  place-content: center;
}

button.icon svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

#mute-btn .slash {
  display: none;
}

#mute-btn.is-muted .wave {
  display: none;
}

#mute-btn.is-muted .slash {
  display: block;
}

.legend {
  display: none;
  margin: 0 0 0 auto;
  color: var(--gray-600);
  font-size: 13px;
  text-align: right;
}

.pad {
  --cell: 52px;
  display: none;
  grid-template-columns: auto 1fr auto;
  grid-template-areas:
    "dpad . ab"
    "pills pills pills";
  align-items: center;
  gap: 4px 16px;
  padding-top: 4px;
}

.pad button {
  min-height: 0;
  padding: 0;
}

.dpad {
  grid-area: dpad;
  display: grid;
  grid-template-columns: repeat(3, var(--cell));
  grid-template-rows: repeat(3, var(--cell));
}

.dpad button {
  display: grid;
  place-content: center;
  border-radius: 0;
}

.dpad svg {
  width: 26px;
  height: 26px;
  fill: currentColor;
}

.dpad-up {
  grid-area: 1 / 2;
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
}

.dpad-left {
  grid-area: 2 / 1;
  border-right: 0;
  border-radius: 8px 0 0 8px;
}

.dpad-center {
  grid-area: 2 / 2;
  display: grid;
  place-content: center;
  background: var(--paper);
}

.dpad-center::before {
  content: "";
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--gray-200);
}

.dpad-right {
  grid-area: 2 / 3;
  border-left: 0;
  border-radius: 0 8px 8px 0;
}

.dpad-down {
  grid-area: 3 / 2;
  border-top: 0;
  border-radius: 0 0 8px 8px;
}

.ab {
  grid-area: ab;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.ab button {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  font: 700 32px/1 "Special Gothic Condensed", "Arial Narrow", Impact, sans-serif;
}

.ab-b {
  margin-top: 32px;
}

.pills {
  grid-area: pills;
  display: flex;
  justify-content: center;
  gap: 24px;
}

.pills button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 72px;
  height: 44px;
  border: 0;
  background: none;
  color: var(--gray-600);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.pills button:active {
  background: none;
}

.pill {
  display: block;
  width: 48px;
  height: 16px;
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  background: var(--paper);
  transform: rotate(-25deg);
}

.pills button.held .pill {
  background: var(--yellow-400);
  border-color: var(--black);
}

footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 16px;
  color: var(--gray-600);
  font-size: 13px;
}

@media (pointer: coarse) {
  .pad {
    display: grid;
  }

  .hint {
    display: grid;
  }

  .hint[hidden] {
    display: none;
  }
}

@media (pointer: fine), (pointer: none) {
  .legend {
    display: block;
  }
}

@media (orientation: landscape) and (max-height: 540px) {
  .card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto minmax(0, 1fr) auto;
    grid-template-areas:
      "head head"
      "stage pad"
      "controls foot";
    column-gap: 16px;
  }

  .card {
    gap: 8px;
  }

  .masthead {
    grid-area: head;
  }

  .mark svg {
    width: 24px;
    height: 24px;
  }

  h1 {
    font-size: 18px;
  }

  .lede {
    display: none;
  }

  .stage {
    grid-area: stage;
    min-height: 0;
  }

  .controls {
    grid-area: controls;
  }

  .pad {
    --cell: 40px;
    grid-area: pad;
    grid-template-columns: auto;
    grid-template-areas:
      "dpad"
      "ab"
      "pills";
    align-content: center;
    justify-items: center;
    gap: 8px;
    padding-top: 0;
  }

  .dpad svg {
    width: 20px;
    height: 20px;
  }

  .ab button {
    width: 56px;
    height: 56px;
    font-size: 26px;
  }

  .ab-b {
    margin-top: 24px;
  }

  footer {
    grid-area: foot;
    justify-content: end;
  }
}

@media (min-width: 720px) and (pointer: fine), (min-width: 720px) and (pointer: none) {
  body {
    padding: 32px 16px;
  }

  .frame {
    min-height: 0;
    max-width: 568px;
    margin: 0 auto;
  }

  .card {
    padding: 20px 24px;
    gap: 16px;
  }

  h1 {
    font-size: 26px;
  }

  .stage {
    flex: none;
    height: 456px;
  }
}

.share {
  width: 600px;
  max-width: calc(100% - 24px);
  max-height: calc(100% - 64px);
  padding: 0;
  border: 0;
  border-radius: 12px;
  color: var(--black);
  background: var(--paper);
}

.share::backdrop {
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(4px);
}

.share-body {
  display: flex;
  flex-direction: column;
  gap: 32px;
  padding: 20px;
}

.share-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  min-height: 0;
  padding: 0;
  display: grid;
  place-content: center;
  border-color: var(--gray-600);
  border-radius: 50%;
}

.share-close:hover,
.share-close:active {
  background: var(--gray-100);
  border-color: var(--gray-600);
}

.share-close svg {
  width: 12px;
  height: 12px;
  fill: currentColor;
}

.share-head {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.share-head h2 {
  margin: 0;
  font-size: 24px;
  font-weight: 600;
  line-height: 1.25;
}

.share-subtitle {
  margin: 0;
  font-size: 16px;
  line-height: 1.375;
  color: var(--gray-500);
}

.share-providers {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px 24px;
}

.share-provider {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 100%;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  color: var(--gray-500);
  font-size: 14px;
  line-height: 1.375;
  text-decoration: none;
}

.share-provider:hover,
.share-provider:active {
  background: none;
  color: var(--black);
}

.share-bubble {
  width: 40px;
  height: 40px;
  display: grid;
  place-content: center;
  border-radius: 50%;
  background: var(--gray-100);
  transition: background-color 0.15s;
}

.share-provider:hover .share-bubble {
  background: var(--blue-100);
}

.share-bubble svg {
  width: 20px;
  height: 20px;
  fill: var(--black);
}

.share-copy {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.share-copy[hidden] {
  display: none;
}

.share-copy-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.share-copy input {
  flex: 1 1 auto;
  min-width: 0;
  height: 44px;
  padding: 0 12px;
  font: inherit;
  font-size: 18px;
  color: var(--gray-500);
  background: var(--paper);
  border: 1px solid var(--gray-300);
  border-radius: 4px;
}

.share-copy input:focus {
  outline: none;
  box-shadow: 0 0 0 3px var(--cyan-400);
}

.share-copy button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-shrink: 0;
  height: 44px;
  padding: 0 16px;
  font-size: 18px;
  border-color: transparent;
  border-radius: 4px;
  background: var(--gray-100);
}

.share-copy button:hover,
.share-copy button:active {
  background: var(--gray-200);
  border-color: transparent;
}

.share-copy button:disabled {
  cursor: default;
}

.share-copy button svg {
  width: 1em;
  height: 1em;
  fill: currentColor;
}

.share-copied {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  border-radius: inherit;
  background: var(--green-100);
  color: var(--green-700);
}

.share-copied[hidden] {
  display: none;
}

@media (min-width: 640px) {
  .share-providers {
    grid-template-columns: repeat(5, 1fr);
  }

  .share.has-native .share-providers {
    grid-template-columns: repeat(6, 1fr);
  }
}

@media (min-width: 768px) {
  .share-body {
    padding: 48px;
  }

  .share-providers {
    gap: 16px 32px;
  }

  .share-bubble {
    width: 60px;
    height: 60px;
  }

  .share-bubble svg {
    width: 28px;
    height: 28px;
  }

  .share-copy-row {
    flex-direction: row;
    gap: 12px;
  }
}
