*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.5;
  color: var(--text);
  background: var(--background);
  padding-bottom: env(safe-area-inset-bottom);
}

h1,
h2,
h3 {
  line-height: 1.2;
  margin: 0 0 0.5em;
}

h1 {
  font-size: 1.6rem;
}

h2 {
  font-size: 1.3rem;
  margin-top: 1.5em;
}

h3 {
  font-size: 1.1rem;
}

p {
  margin: 0 0 0.75em;
}

a {
  color: var(--primary);
}

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

[tabindex="-1"]:focus {
  outline: none;
}

[hidden] {
  display: none !important;
}

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

.skip-link {
  position: absolute;
  left: 0.5rem;
  top: -100%;
  z-index: 10;
  padding: 0.75rem 1rem;
  background: var(--surface);
  color: var(--primary);
}

.skip-link:focus {
  top: 0.5rem;
}

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  padding: calc(0.75rem + env(safe-area-inset-top)) 1rem 0.75rem;
  background: var(--primary);
  color: #fff;
}

.site-title {
  margin: 0;
  font-weight: 700;
  font-size: 1.15rem;
  flex: 1;
}

.logo {
  height: 2.5rem;
  width: auto;
}

.connection {
  margin: 0;
  font-size: 0.9rem;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  background: rgb(255 255 255 / 0.2);
}

main {
  padding: 1rem;
  max-width: 60rem;
  margin: 0 auto;
}

main.narrow {
  max-width: 28rem;
}

.stack > * + * {
  margin-top: 1rem;
}

.field label,
.field legend {
  display: block;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.hint {
  font-size: 0.95rem;
  opacity: 0.85;
  margin-bottom: 0.4rem;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="file"] {
  display: block;
  width: 100%;
  min-height: 2.75rem;
  padding: 0.5rem 0.75rem;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 2px solid currentColor;
  border-radius: 0.5rem;
}

input[type="color"] {
  width: 4rem;
  height: 2.75rem;
  padding: 0.15rem;
  border: 2px solid currentColor;
  border-radius: 0.5rem;
  background: var(--surface);
}

input[aria-invalid="true"] {
  border-color: #b91c1c;
}

.checkbox {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
}

.checkbox input,
.choice input {
  width: 1.5rem;
  height: 1.5rem;
  margin: 0.1rem 0 0;
  flex: none;
  accent-color: var(--primary);
}

fieldset {
  border: 0;
  padding: 0;
  margin: 0;
}

legend {
  padding: 0;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.choices {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.5rem;
}

.choice {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 3rem;
  padding: 0.5rem 0.75rem;
  background: var(--surface);
  border: 2px solid rgb(0 0 0 / 0.15);
  border-radius: 0.75rem;
  cursor: pointer;
}

.choice:has(input:checked) {
  border-color: var(--primary);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  min-width: 2.75rem;
  padding: 0.5rem 1rem;
  font: inherit;
  font-weight: 600;
  color: var(--primary);
  background: var(--surface);
  border: 2px solid var(--primary);
  border-radius: 0.6rem;
  cursor: pointer;
  text-decoration: none;
  touch-action: manipulation;
}

.button.primary {
  color: #fff;
  background: var(--primary);
}

.button.danger {
  color: #fff;
  background: #b91c1c;
  border-color: #b91c1c;
}

.button.wide {
  width: 100%;
}

.button:disabled {
  opacity: 0.6;
  cursor: default;
}

.error {
  color: #991b1b;
  background: #fee2e2;
  border-left: 4px solid #b91c1c;
  padding: 0.5rem 0.75rem;
}

.notice {
  background: #dcfce7;
  color: #14532d;
  border-left: 4px solid #15803d;
  padding: 0.5rem 0.75rem;
}

.swatch {
  display: inline-block;
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 50%;
  border: 2px solid rgb(0 0 0 / 0.35);
  flex: none;
  vertical-align: -0.15rem;
}

.list {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem;
}

.list > li {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 3rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid rgb(0 0 0 / 0.1);
}

.list > li > :nth-child(2) {
  flex: 1;
}

.turn {
  display: grid;
  gap: 0.75rem;
  padding: 1rem;
  margin-bottom: 1rem;
  background: var(--surface);
  border-radius: 0.75rem;
  border-left: 0.5rem solid var(--player, var(--primary));
}

.turn h1 {
  margin: 0;
}

.identity {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
}

.identity p {
  margin: 0;
  flex: 1;
}

.cards {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 1rem;
}

.card {
  position: relative;
  padding: 1rem;
  background: var(--surface);
  border-radius: 0.75rem;
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.2);
}

.card h3 {
  margin-bottom: 0.25rem;
}

.card .points {
  font-weight: 700;
  color: var(--accent);
}

.card .description {
  white-space: pre-line;
}

.card .pending {
  font-style: italic;
}

.completed .meta {
  font-size: 0.95rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
}

caption {
  text-align: left;
  font-weight: 600;
  padding-bottom: 0.4rem;
}

th,
td {
  text-align: left;
  padding: 0.6rem 0.5rem;
  border-bottom: 1px solid rgb(0 0 0 / 0.1);
}

td.number,
th.number {
  text-align: right;
}

section + section {
  margin-top: 1.5rem;
}

@media (min-width: 40rem) {
  .cards {
    grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr));
  }
}

.envelope {
  position: relative;
}

.envelope-art {
  position: absolute;
  inset: 0;
  pointer-events: none;
  perspective: 40rem;
  z-index: 2;
}

.envelope-art .pocket,
.envelope-art .flap {
  position: absolute;
  left: 0;
  right: 0;
}

.envelope-art .pocket {
  bottom: 0;
  height: 60%;
  background: var(--accent);
  clip-path: polygon(0 0, 50% 45%, 100% 0, 100% 100%, 0 100%);
  border-radius: 0 0 0.75rem 0.75rem;
  animation: envelope-away 400ms 1000ms ease-in both;
}

.envelope-art .flap {
  top: 40%;
  height: 35%;
  background: var(--primary);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: top;
  animation:
    flap-open 450ms ease-out both,
    fade-out 300ms 1000ms ease-in both;
}

.envelope.opening .card {
  animation: card-rise 650ms 400ms cubic-bezier(0.2, 0.8, 0.3, 1.2) both;
}

@keyframes flap-open {
  from {
    transform: rotateX(0deg);
  }
  to {
    transform: rotateX(180deg);
  }
}

@keyframes card-rise {
  from {
    transform: translateY(35%) scale(0.92);
    opacity: 0.2;
  }
  to {
    transform: none;
    opacity: 1;
  }
}

@keyframes envelope-away {
  to {
    opacity: 0;
    transform: translateY(30%);
  }
}

@keyframes fade-out {
  to {
    opacity: 0;
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .envelope-art {
    display: none;
  }

  .envelope.opening .card {
    animation: fade-in 300ms ease-out both;
  }
}
