/* iOS-flavoured UI: system colours, grouped inset lists, segmented controls,
   a large navigation title, and a full-screen layer for dealing the cards. */

:root {
  color-scheme: light dark;

  --bg: #f2f2f7;
  --bg-elev: #ffffff;
  --label: #000000;
  --label-2: rgba(60, 60, 67, .6);
  --label-3: rgba(60, 60, 67, .3);
  --separator: rgba(60, 60, 67, .29);
  --fill: rgba(120, 120, 128, .12);
  /* Monochrome accent: the interface carries no colour of its own, only
     red for anything destructive or impostor-related. */
  --accent: #1c1c1e;
  --accent-ink: #ffffff;
  --accent-soft: rgba(28, 28, 30, .08);
  --red: #ff3b30;
  --green: #34c759;
  --card: #ffffff;
  --card-shadow: 0 1px 3px rgb(0 0 0 / .1);
  --bar: rgba(249, 249, 249, .82);
  --radius: 12px;
  --spring: cubic-bezier(.32, .72, 0, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --bg-elev: #1c1c1e;
    --label: #ffffff;
    --label-2: rgba(235, 235, 245, .6);
    --label-3: rgba(235, 235, 245, .3);
    --separator: rgba(84, 84, 88, .65);
    --fill: rgba(118, 118, 128, .24);
    --accent: #f2f2f7;
    --accent-ink: #000000;
    --accent-soft: rgba(242, 242, 247, .14);
    --red: #ff453a;
    --green: #30d158;
    --card: #1c1c1e;
    --card-shadow: 0 1px 3px rgb(0 0 0 / .5);
    --bar: rgba(30, 30, 32, .8);
  }
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html {
  -webkit-text-size-adjust: 100%;
  height: 100%;
  overscroll-behavior: none;
  /* no double-tap zoom, no 300ms delay: taps land like a native control */
  touch-action: manipulation;
}

body {
  margin: 0;
  min-height: 100vh;
  padding: 0 0 calc(48px + env(safe-area-inset-bottom));
  background: var(--bg);
  color: var(--label);
  font: 17px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, sans-serif;
  letter-spacing: -.01em;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  overscroll-behavior: none;
  text-rendering: optimizeLegibility;
}

/* Chrome is not selectable, the way native controls are not; the word on a
   card and the solution stay selectable. */
.nav, .page-title, .group__header, .btn, .segmented, .card__label, .switch, .stepper,
.sheet__header {
  -webkit-user-select: none;
  user-select: none;
}

main {
  max-width: 480px;
  margin: 0 auto;
  padding: 0 16px;
}

.stack {
  position: relative;
  overflow-x: clip;
}

/* Screens push and pop sideways, the way a navigation stack does on iOS. */

.screen--out {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
}

.screen--push-in { animation: push-in .38s var(--spring) both; }
.screen--push-out { animation: push-out .38s var(--spring) both; }
.screen--pop-in { animation: pop-in .38s var(--spring) both; }
.screen--pop-out { animation: pop-out .38s var(--spring) both; }

@keyframes push-in {
  from { transform: translateX(100%); }
  to { transform: none; }
}

@keyframes push-out {
  from { transform: none; opacity: 1; }
  to { transform: translateX(-28%); opacity: 0; }
}

@keyframes pop-in {
  from { transform: translateX(-28%); opacity: 0; }
  to { transform: none; opacity: 1; }
}

@keyframes pop-out {
  from { transform: none; }
  to { transform: translateX(100%); }
}

button { font: inherit; letter-spacing: inherit; }

/* ---------- navigation bar ---------- */

.nav {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bar);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: .5px solid transparent;
  transition: border-color .2s ease;
  padding-top: env(safe-area-inset-top);
}

/* The hairline only appears once content has scrolled under the bar. */
.nav.is-scrolled { border-bottom-color: var(--separator); }

.nav__bar {
  position: relative;
  max-width: 480px;
  margin: 0 auto;
  padding: 6px 16px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.nav__back {
  position: relative;
  appearance: none;
  border: 0;
  background: none;
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 0;
  margin-left: -2px;
  cursor: pointer;
}

.nav__back svg { width: 11px; height: 18px; }
.nav__back:active { opacity: .4; }

.nav__compact {
  position: absolute;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 17px;
  font-weight: 600;
  pointer-events: none;
  opacity: 0;
  transition: opacity .2s ease;
}

.nav.is-scrolled .nav__compact { opacity: 1; }

/* The large title scrolls away with the content, as it does on iOS; the bar
   keeps a compact copy that fades in behind it. */
.page-title {
  margin: 6px 16px 10px;
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -.022em;
}

/* ---------- segmented control ---------- */

.segmented {
  display: flex;
  gap: 2px;
  padding: 2px;
  background: var(--fill);
  border-radius: 9px;
}

.segmented__opt {
  flex: 1;
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--label);
  font-size: 15px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 7px;
  cursor: pointer;
  transition: background .2s var(--spring);
}

.segmented__opt.is-on {
  background: var(--bg-elev);
  font-weight: 600;
  box-shadow: 0 1px 3px rgb(0 0 0 / .12), 0 0 0 .5px rgb(0 0 0 / .04);
}

.segmented--sm { flex: 0 0 auto; margin-left: auto; position: relative; }
.segmented--sm .segmented__opt { padding: 4px 13px; font-size: 13px; letter-spacing: .02em; }

/* ---------- grouped lists ---------- */

.group__header {
  margin: 26px 16px 7px;
  font-size: 13px;
  font-weight: 400;
  letter-spacing: -.006em;
  text-transform: uppercase;
  color: var(--label-2);
}

.group__footer {
  margin: 7px 16px 0;
  font-size: 13px;
  line-height: 1.35;
  color: var(--label-2);
}

.lead + .group,
.lead + .segmented { margin-top: 20px; }

.group {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--bg-elev);
  border-radius: var(--radius);
  overflow: hidden;
}

.group--spaced { margin-top: 26px; }

.row {
  display: flex;
  align-items: center;
  min-height: 44px;
}

.row + .row { box-shadow: inset 0 .5px 0 var(--separator); }

.row--field { padding-left: 12px; }

.row__minus,
.row__add {
  appearance: none;
  border: 0;
  background: none;
  padding: 0;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--label);
  cursor: pointer;
}

.row__minus svg { width: 22px; height: 22px; display: block; }
.row__minus circle { fill: var(--red); }
.row__minus:disabled { opacity: .25; cursor: default; }

.row__input {
  flex: 1;
  min-width: 0;
  appearance: none;
  border: 0;
  background: none;
  color: var(--label);
  font: inherit;
  letter-spacing: inherit;
  padding: 12px 16px;
}

.row__input::placeholder { color: var(--label-3); }
.row__input:focus { outline: none; }

.switch {
  position: relative;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-right: 14px;
  cursor: pointer;
}

.switch__tag {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .08em;
  color: var(--label-3);
  transition: color .2s;
}

.switch__input {
  /* invisible but real: it stays the focusable, clickable control */
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 1;
}

.switch__track {
  position: relative;
  display: block;
  width: 51px;
  height: 31px;
  border-radius: 16px;
  background: var(--fill);
  transition: background .25s var(--spring);
}

.switch__track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 5px rgb(0 0 0 / .22);
  transition: transform .25s var(--spring);
}

.switch__input:checked + .switch__track { background: var(--accent); }
.switch__input:checked + .switch__track::after { transform: translateX(20px); }
.switch__input:checked ~ .switch__tag,
.switch:has(.switch__input:checked) .switch__tag { color: var(--label); }
.switch__input:focus-visible ~ .switch__track { outline: 3px solid var(--accent); outline-offset: 2px; }

/* value + stepper, as in a settings row */

.stepper {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin-right: 16px;
}

.stepper__value {
  min-width: 1ch;
  font-variant-numeric: tabular-nums;
  color: var(--label-2);
}

.stepper__btn {
  appearance: none;
  border: 0;
  width: 44px;
  height: 30px;
  background: var(--fill);
  color: var(--label);
  font-size: 19px;
  line-height: 1;
  cursor: pointer;
}

.stepper__btn:first-of-type { border-radius: 7px 0 0 7px; box-shadow: 1px 0 0 var(--separator); }
.stepper__btn:last-of-type { border-radius: 0 7px 7px 0; }
.stepper__btn:active:not(:disabled) { opacity: .5; }
.stepper__btn:disabled { color: var(--label-3); cursor: default; }

/* a row that leads somewhere */

.row__nav {
  appearance: none;
  border: 0;
  background: none;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  color: var(--label);
  text-align: left;
  cursor: pointer;
}

.row__nav-value {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--label-2);
}

.row__nav-value svg { width: 8px; height: 13px; color: var(--label-3); }
.row__nav:active { background: var(--fill); }

.row--action { padding: 0; }

.row__add {
  width: 100%;
  padding: 11px 16px 11px 12px;
}

.row__add svg { width: 22px; height: 22px; display: block; }
.row__add circle { fill: var(--green); }
.row__add:disabled { opacity: .3; cursor: default; }

.row__pick {
  appearance: none;
  border: 0;
  background: none;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  color: var(--label);
  text-align: left;
  cursor: pointer;
}

.row__pick .check {
  width: 16px;
  height: 12px;
  color: var(--accent);
  opacity: 0;
  transition: opacity .15s;
}

.row__pick.is-on .check { opacity: 1; }
.row__pick:active { background: var(--fill); }

.row--value { justify-content: space-between; gap: 16px; padding: 12px 16px; }
.row__label { color: var(--label); }
.row__value { color: var(--label-2); text-align: right; }

/* ---------- text ---------- */

.lead {
  margin: 2px 16px 0;
  color: var(--label-2);
  font-size: 15px;
  line-height: 1.4;
}

.progress {
  margin: 2px 16px 14px;
  font-size: 13px;
  color: var(--label-2);
  font-variant-numeric: tabular-nums;
}

.error {
  margin: 14px 16px 0;
  font-size: 13px;
  color: var(--red);
}

.order { counter-reset: none; }

.order__number {
  flex: 0 0 22px;
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--label-3);
}

.order .row--value { justify-content: flex-start; gap: 10px; }
.order .row:first-child .row__label { font-weight: 600; }

.starter {
  margin: 14px 16px 18px;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -.02em;
}

/* ---------- buttons ---------- */

.actions { margin-top: 26px; display: grid; gap: 10px; }

.btn {
  appearance: none;
  border: 0;
  border-radius: 14px;
  width: 100%;
  min-height: 50px;
  padding: 14px 20px;
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s, transform .15s var(--spring);
}

.btn:active { opacity: .85; transform: scale(.98); }

.btn--filled { background: var(--accent); color: var(--accent-ink); }
.btn--tinted { background: var(--accent-soft); color: var(--accent); }
.btn--plain { background: none; color: var(--accent); font-weight: 400; min-height: 44px; }

/* ---------- dealing: a screen of its own ---------- */

.screen--full {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  padding: calc(env(safe-area-inset-top) + 8px) 16px calc(env(safe-area-inset-bottom) + 16px);
}

body.is-dealing { overflow: hidden; }

/* nothing floats over a card that fills the screen */
body.is-dealing .banner { display: none; }

.deal__bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 40px;
}

.deal__close {
  appearance: none;
  border: 0;
  background: var(--fill);
  color: var(--label-2);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.deal__close svg { width: 12px; height: 12px; }
.deal__close:active { opacity: .5; }

.deal__progress {
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--label-2);
}

.deal__foot { flex: 0 0 auto; min-height: 50px; }

/* ---------- the card, filling what is left ---------- */

.card {
  flex: 1 1 auto;
  appearance: none;
  background: none;
  border: 0;
  padding: 12px 0;
  margin: 0;
  width: 100%;
  min-height: 0;
  cursor: pointer;
  perspective: 1600px;
}

.card__inner {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 26px;
  transform-style: preserve-3d;
  transition: transform .6s var(--spring), box-shadow .6s var(--spring);
  box-shadow: 0 10px 30px rgb(0 0 0 / .14);
}

.card:active:not(.is-revealed) .card__inner { transform: scale(.99); }
.card:not([data-ready="true"]) { pointer-events: none; }

.card.is-revealed .card__inner {
  transform: rotateY(180deg);
  box-shadow: 0 18px 44px rgb(0 0 0 / .2);
}

.card__face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 28px;
  border-radius: 26px;
  background: var(--card);
  backface-visibility: hidden;
  text-align: center;
}

.card__face--front { transform: rotateY(180deg); }

.card__pattern {
  position: absolute;
  inset: 18px;
  border-radius: 16px;
  border: 1px solid var(--separator);
  background-image:
    repeating-linear-gradient(45deg, var(--fill) 0 2px, transparent 2px 11px),
    repeating-linear-gradient(-45deg, var(--fill) 0 2px, transparent 2px 11px);
}

/* whose turn it is */

.pass {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 20px 22px;
  border-radius: 18px;
  background: var(--card);
}

.pass__label,
.pass__hint {
  font-size: 13px;
  font-weight: 500;
  color: var(--label-3);
}

.pass__label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.pass__name {
  font-size: 40px;
  font-weight: 700;
  letter-spacing: -.03em;
  line-height: 1.05;
  overflow-wrap: anywhere;
}

/* the secret, as large as it fits */

.card__label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--label-3);
}

.card__word {
  font-size: clamp(34px, 11vw, 56px);
  font-weight: 700;
  letter-spacing: -.03em;
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.card__hint {
  font-size: 15px;
  font-weight: 500;
  color: var(--label-3);
}

.card__face--impostor { background: var(--accent); }
.card__face--impostor .card__label { color: var(--accent-ink); opacity: .5; }
.card__face--impostor .card__hint { color: var(--accent-ink); opacity: .7; }
.card__face--impostor .card__word {
  color: var(--accent-ink);
  letter-spacing: .04em;
  text-transform: uppercase;
  font-size: clamp(30px, 9vw, 46px);
}

/* ---------- admin sheet ---------- */

.backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgb(0 0 0 / .4);
  opacity: 0;
  visibility: hidden;
  /* while fading out it must not swallow taps meant for the page below */
  pointer-events: none;
  transition: opacity .3s ease, visibility .3s;
}

.backdrop.is-in { opacity: 1; visibility: visible; pointer-events: auto; }

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 41;
  max-width: 480px;
  margin: 0 auto;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border-radius: 14px 14px 0 0;
  box-shadow: 0 -6px 40px rgb(0 0 0 / .28);
  transform: translateY(100%);
  visibility: hidden;
  pointer-events: none;
  transition: transform .42s var(--spring), visibility .42s;
}

.sheet.is-in { transform: none; visibility: visible; pointer-events: auto; }

.sheet__grabber {
  width: 36px;
  height: 5px;
  margin: 6px auto 0;
  border-radius: 3px;
  background: var(--label-3);
}

.sheet__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px 6px;
}

.sheet__title { margin: 0; font-size: 17px; font-weight: 600; }

.sheet__done {
  appearance: none;
  border: 0;
  background: none;
  color: var(--accent);
  font-size: 17px;
  font-weight: 600;
  padding: 4px 0;
  cursor: pointer;
}

.sheet__body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 0 16px calc(20px + env(safe-area-inset-bottom));
}

.sheet__body .group__header:first-child { margin-top: 14px; }

.row__input--end { text-align: right; padding-right: 0; }

.row__pick--danger { color: var(--red); }
.row__pick:disabled { opacity: .35; cursor: default; }

body.has-sheet { overflow: hidden; }

body.has-banner { padding-bottom: calc(116px + env(safe-area-inset-bottom)); }

.page-title { transition: transform .2s var(--spring); }
.page-title:active { transform: scale(.985); }

/* ---------- PIN pad ---------- */

.pin { padding: 18px 0 8px; }

.pin__dots {
  display: flex;
  justify-content: center;
  gap: 18px;
  margin-bottom: 30px;
}

.pin__dot {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 1.5px solid var(--label-2);
  transition: background .15s;
}

.pin__dot.is-filled { background: var(--label); border-color: var(--label); }

.pin__pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  justify-items: center;
  gap: 16px;
  max-width: 300px;
  margin: 0 auto;
}

.pin__key {
  appearance: none;
  border: 0;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--fill);
  color: var(--label);
  font-size: 26px;
  font-weight: 400;
  cursor: pointer;
}

.pin__key:active { opacity: .5; }
.pin__key--del { background: none; }
.pin__key--del svg { width: 26px; height: 18px; }

.pin.is-wrong .pin__dots { animation: shake .42s ease; }

@keyframes shake {
  10%, 90% { transform: translateX(-6px); }
  30%, 70% { transform: translateX(8px); }
  50% { transform: translateX(-4px); }
}

/* ---------- banner (update / install tip) ---------- */

.banner {
  position: fixed;
  left: 8px;
  right: 8px;
  bottom: calc(8px + env(safe-area-inset-bottom));
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 464px;
  margin: 0 auto;
  padding: 12px 12px 12px 16px;
  background: var(--bar);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border: .5px solid var(--separator);
  border-radius: 16px;
  box-shadow: 0 8px 30px rgb(0 0 0 / .18);
  transform: translateY(calc(100% + 24px));
  transition: transform .4s var(--spring), bottom .35s var(--spring);
}

.banner.is-in { transform: none; }

.banner__text {
  flex: 1;
  margin: 0;
  font-size: 15px;
  line-height: 1.3;
}

.banner__action {
  appearance: none;
  border: 0;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 15px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 10px;
  cursor: pointer;
}

.banner__close {
  appearance: none;
  border: 0;
  background: var(--fill);
  color: var(--label-2);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.banner__close svg { width: 11px; height: 11px; }

/* ---------- focus & motion ---------- */

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

@media (prefers-reduced-motion: reduce) {
  .card__inner, .btn, .nav__compact, .banner, .sheet, .backdrop, .page-title { transition-duration: .01ms; }
  .pin.is-wrong .pin__dots { animation: none; }
  .screen--push-in, .screen--push-out, .screen--pop-in, .screen--pop-out { animation-duration: .01ms; }
}
