:root {
  color-scheme: dark;
  font-family: Helvetica, Arial, sans-serif;
  color: #ffffff;
  background: #000000;
  --page-inset: clamp(2rem, 6vw, 5rem);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  padding: var(--page-inset);
  display: flex;
  flex-direction: column;
}

main {
  text-align: left;
}

h1 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: -0.025em;
}

.intro {
  max-width: 34rem;
  margin: 0 0 1.5rem;
  color: #b8b8b2;
  line-height: 1.4;
}

.intro-flash {
  animation: intro-flash 0.6s steps(1) 3;
}

@keyframes intro-flash {
  50% {
    opacity: 0;
  }
}

nav {
  display: flex;
  justify-content: flex-start;
  gap: 1.25rem;
}

a {
  color: inherit;
  text-underline-offset: 0.25em;
}

a:hover,
a:focus-visible {
  text-decoration-thickness: 0.14em;
}

button {
  font: inherit;
}

.text-button {
  padding: 0;
  border: 0;
  color: inherit;
  background: transparent;
  text-decoration: underline;
  text-underline-offset: 0.25em;
  cursor: pointer;
}

.brush-area {
  position: relative;
  flex: 1;
  min-height: 12rem;
  margin-top: 1.5rem;
  border: 2px solid #ffffff;
  cursor: none;
  touch-action: none;
}

.drawing-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.canvas-countdown {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  z-index: 1;
  color: #ffffff;
  font-size: 0.75rem;
  line-height: 1;
  pointer-events: none;
}

.canvas-countdown[hidden] {
  display: none;
}

.restart-paint {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  z-index: 2;
  padding: 0.35rem 0.55rem;
  border: 0;
  color: #000000;
  background: #ffffff;
  font-size: 0.75rem;
  line-height: 1;
  cursor: pointer;
}

.restart-paint[hidden] {
  display: none;
}

.brush-cursor {
  position: fixed;
  top: 0;
  left: 0;
  display: none;
  width: 3rem;
  height: 3rem;
  object-fit: contain;
  image-rendering: pixelated;
  pointer-events: none;
  transform: translate(-50%, -50%);
  z-index: 2;
}

.brush-area:hover .brush-cursor {
  display: block;
}

.finish-drawing {
  position: absolute;
  right: 1rem;
  bottom: 1rem;
  z-index: 2;
  padding: 0;
  border: 0;
  color: #ffffff;
  background: transparent;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}

.finish-drawing[hidden] {
  display: none;
}

.encouragement {
  position: fixed;
  inset: 0;
  z-index: 3;
  display: grid;
  place-content: center;
  padding: 2rem;
  color: #ffffff;
  background: rgba(0, 0, 0, 0.9);
  text-align: center;
  font-family: Helvetica, Arial, sans-serif;
}

.encouragement-card {
  width: min(100%, 32rem);
  margin: auto;
  text-align: center;
}

.encouragement-prompt {
  display: grid;
  gap: 1.5rem;
}

.encouragement[hidden],
.gallery[hidden],
.gallery-detail[hidden] {
  display: none;
}

.encouragement p {
  margin: 0;
  font-size: clamp(0.8rem, 2.2vw, 1.25rem);
  line-height: 1.5;
  letter-spacing: 0;
}

.encouragement-actions {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  width: min(100%, 18rem);
  margin-inline: auto;
}

.encouragement-actions button {
  position: relative;
  width: 100%;
  overflow: hidden;
  padding: 0.6rem 0.75rem;
  border: 2px solid #ffffff;
  color: #ffffff;
  background: #000000;
  font-size: 0.65rem;
  line-height: 1.5;
  cursor: pointer;
}

#send-drawing::before {
  position: absolute;
  inset: 0;
  width: 0;
  z-index: 0;
  background: #737373;
  content: "";
  pointer-events: none;
}

#send-drawing span {
  position: relative;
  z-index: 1;
}

#send-drawing.is-loading::before {
  animation: send-countdown 8s linear forwards;
}

@keyframes send-countdown {
  to {
    width: 100%;
  }
}

.send-form {
  display: grid;
  gap: 1.25rem;
  text-align: left;
}

.send-form[hidden],
.encouragement-prompt[hidden] {
  display: none;
}

.send-form label {
  display: grid;
  gap: 0.5rem;
  font-size: 0.65rem;
  line-height: 1.5;
}

.send-form label span {
  font-size: 0.5rem;
}

.send-form input,
.send-form textarea {
  width: 100%;
  border: 2px solid #ffffff;
  border-radius: 0;
  padding: 0.75rem;
  color: #ffffff;
  background: #000000;
  font: 1rem Helvetica, Arial, sans-serif;
  outline: none;
}

.send-form input:focus,
.send-form textarea:focus {
  box-shadow: 4px 4px 0 #ffffff;
}

.gallery {
  position: fixed;
  inset: 0;
  z-index: 4;
  overflow-y: auto;
  padding: var(--page-inset);
  color: #ffffff;
  background: #000000;
}

.gallery header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 3rem;
}

.gallery h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 500;
}

.gallery-heading p {
  max-width: 32rem;
  margin: 0.5rem 0 0;
  color: #b8b8b2;
  line-height: 1.4;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, 7rem);
  gap: 1rem;
}

.gallery-grid img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  border: 2px solid #ffffff;
  object-fit: contain;
  image-rendering: pixelated;
}

.gallery-grid figure {
  margin: 0;
}

.gallery-tile {
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  color: inherit;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.gallery-grid figcaption {
  margin-top: 0.5rem;
  font-size: calc(1rem - 4pt);
  line-height: 1.3;
}

.gallery-detail {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  overflow-y: auto;
  padding: var(--page-inset);
  color: #ffffff;
  background: #000000;
}

.detail-close {
  position: fixed;
  top: var(--page-inset);
  right: var(--page-inset);
  z-index: 1;
  padding: 0;
  border: 0;
  color: #ffffff;
  background: transparent;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
}

.detail-content {
  width: min(70vw, 42rem);
}

.detail-image {
  display: block;
  width: 100%;
  max-height: 65vh;
  border: 2px solid #ffffff;
  object-fit: contain;
  image-rendering: pixelated;
}

.detail-content h3 {
  margin: 1rem 0 0;
  font-size: 1rem;
  font-weight: 500;
}

.detail-message {
  margin: 0.5rem 0 0;
  color: #b8b8b2;
  line-height: 1.4;
}

@media (max-width: 600px) {
  .gallery-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .detail-content {
    width: 100%;
  }
}
