:root {
  --bg: #f4f3f0;
  --ink: #1a1a18;
  --muted: #7a776f;
  --line: #d8d5ce;
  --field: #fff;
  --ok: #2f6b45;
  --bad: #a52c22;
  --ease: cubic-bezier(0.23, 1, 0.32, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131312;
    --ink: #eceae5;
    --muted: #8d8a83;
    --line: #34332f;
    --field: #1c1c1a;
    --ok: #6fb98c;
    --bad: #e08278;
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  min-height: 100svh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(40px + env(safe-area-inset-top, 0px)) 20px calc(40px + env(safe-area-inset-bottom, 0px));
}

.screen {
  width: 100%;
  max-width: 480px;
}

.screen[hidden] { display: none; }

.screen > * {
  opacity: 0;
  transform: translateY(6px);
  animation: rise 420ms var(--ease) forwards;
}

.screen > *:nth-child(2) { animation-delay: 50ms; }
.screen > *:nth-child(3) { animation-delay: 100ms; }
.screen > *:nth-child(4) { animation-delay: 150ms; }

@keyframes rise {
  to { opacity: 1; transform: none; }
}

h1 {
  margin: 0 0 8px;
  font-size: 30px;
  line-height: 1.2;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.lead {
  margin: 0 0 32px;
  color: var(--muted);
  max-width: 34ch;
}

/* --- name screen --- */

form {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 24px;
}

#name-input {
  flex: 1 1 200px;
  min-width: 0;
  height: 46px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
  color: inherit;
  font: inherit;
  transition: border-color 160ms ease;
}

#name-input::placeholder { color: var(--muted); }

#name-input:focus {
  outline: none;
  border-color: var(--ink);
}

.btn {
  height: 46px;
  padding: 0 20px;
  border: 1px solid var(--ink);
  border-radius: 8px;
  background: var(--ink);
  color: var(--bg);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: transform 160ms var(--ease), opacity 160ms ease;
}

.btn:active { transform: scale(0.97); }

.btn[disabled] {
  opacity: 0.4;
  cursor: default;
}

.btn[disabled]:active { transform: none; }

/* --- code screen --- */

/* Sized off the viewport so the row survives however many digits
   the password happens to have. */
.code {
  display: flex;
  gap: clamp(5px, 1.6vw, 10px);
  margin-bottom: 22px;
}

.code.wrong { animation: shake 400ms var(--ease); }

@keyframes shake {
  20% { transform: translateX(-7px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(2px); }
  100% { transform: none; }
}

.slot {
  flex: 1 1 0;
  min-width: 0;
}

.digit {
  width: 100%;
  height: clamp(50px, 13vw, 66px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--field);
  color: inherit;
  font: 500 clamp(19px, 5vw, 26px)/1 inherit;
  font-variant-numeric: tabular-nums;
  text-align: center;
  transition: border-color 160ms ease, background-color 160ms ease;
}

.digit:focus {
  outline: none;
  border-color: var(--ink);
}

.digit[readonly] {
  background: transparent;
  border-style: dashed;
  border-color: var(--ok);
  color: var(--ok);
  cursor: default;
}

.cap {
  display: block;
  margin-top: 7px;
  height: 14px;
  font-size: clamp(9px, 2.3vw, 11px);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-align: center;
  color: var(--ok);
}

.note {
  margin: 0;
  min-height: 24px;
  font-size: 14px;
  color: var(--muted);
  transition: color 160ms ease;
}

.note.bad { color: var(--bad); }

/* --- gallery --- */

.stage {
  display: flex;
  justify-content: center;
}

.photo {
  display: block;
  max-width: 100%;
  max-height: 52svh;
  border-radius: 10px;
  opacity: 0;
  transition: opacity 420ms ease;
}

.photo.loaded { opacity: 1; }

.reset {
  margin-top: 28px;
  padding: 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: color 160ms ease, border-color 160ms ease;
}

@media (hover: hover) and (pointer: fine) {
  .reset:hover { color: var(--ink); border-color: var(--ink); }
}

@media (max-width: 400px) {
  h1 { font-size: 26px; }
}

@media (prefers-reduced-motion: reduce) {
  .screen > * { animation: none; opacity: 1; transform: none; }
  .code.wrong { animation: none; }
  .btn:active { transform: none; }
}
