/* The player's phone. One screen at a time, thumb-sized, readable at arm's
   length in a half-lit room. */

html,
body {
  height: 100%;
}
body {
  overscroll-behavior: none;
  transition: background-color 0.25s;
}

.screen {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top);
  background: var(--bg);
  color: var(--fg);
  max-width: 34rem;
  margin-inline: auto;
}

/* Connection lost: a quiet strip, the game screen stays put underneath. */
body.offline::before {
  content: '';
  position: fixed;
  inset: 0 0 auto;
  height: 4px;
  z-index: 10;
  background: repeating-linear-gradient(90deg, var(--red) 0 16px, #fff 16px 32px);
  background-size: 64px 100%;
  animation: slide 0.8s linear infinite;
}
@keyframes slide {
  to {
    background-position: 64px 0;
  }
}

/* ---- PIN and name ---------------------------------------------------------- */

.entry {
  padding-inline: 1.5rem;
}
.entry .brand {
  margin-top: 1.5rem;
  align-self: flex-start;
  font-size: 1.125rem;
}
.entry form {
  margin-top: clamp(2.5rem, 12dvh, 6rem);
}
.entry-label {
  display: block;
  font-size: 2.5rem;
  font-weight: 750;
  line-height: 1.05;
  letter-spacing: -0.015em;
}
.entry-help {
  margin-top: 0.5rem;
  color: var(--fg-soft);
}
.entry .field {
  margin-top: 1.5rem;
  border-width: 2px;
  height: 4.75rem;
}
.name-row {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.5rem;
}
.name-row .field {
  margin-top: 0;
  min-width: 0;
}
.av-preview {
  width: 4.75rem;
  height: 4.75rem;
}
.av-label {
  margin-top: 1.25rem;
  font-weight: 650;
}
.av-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 0.4rem;
  margin-top: 0.6rem;
}
.av-option {
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  touch-action: manipulation;
  transition: transform 0.12s var(--ease);
}
.av-option[aria-checked='true'] {
  outline: 3px solid var(--ink);
  outline-offset: 2px;
  transform: scale(0.88);
}
.av-big {
  display: block;
  width: 5.5rem;
  height: 5.5rem;
  margin-bottom: 1.5rem;
  animation: hoist 0.6s var(--ease) both;
}
.pin-input {
  font-size: 3rem;
  letter-spacing: 0.14em;
  padding-inline: 1rem;
}
.pin-input::placeholder {
  color: #c3cbd9;
}
.name-input {
  font-size: 1.75rem;
  font-weight: 650;
  padding-inline: 1rem;
}
.error {
  margin-top: 0.75rem;
  color: #a8121c;
  font-weight: 600;
}
.btn.big {
  width: 100%;
  min-height: 3.75rem;
  margin-top: 1rem;
  font-size: 1.25rem;
}
.entry-foot {
  margin-top: auto;
  padding-block: 1.5rem calc(1.5rem + env(safe-area-inset-bottom));
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  color: var(--fg-soft);
}
.entry-foot .num {
  font-size: 1.125rem;
  color: var(--fg);
}

/* ---- in-game chrome -------------------------------------------------------- */

.top {
  padding: 1rem 1.25rem 0;
  font-size: 1.125rem;
  color: var(--fg-soft);
}
.bar {
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.9rem 1.25rem calc(0.9rem + env(safe-area-inset-bottom));
  background: var(--ink);
  color: #fff;
  border-top: 1px solid rgb(255 255 255 / 0.22);
}
.bar-who {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
}
.bar-who .av {
  width: 1.75rem;
  height: 1.75rem;
}
/* Ink-field avatars would vanish into the ink bar without an edge. */
.bar .av {
  outline: 1px solid rgb(255 255 255 / 0.55);
}
.bar-name {
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bar-score {
  font-size: 1.25rem;
  flex: none;
}
.bar-score:not(.num) {
  font-size: 1rem;
  color: var(--on-ink-soft);
}

.note {
  align-self: flex-start;
  margin-top: 1rem;
  padding: 0.3em 0.65em;
  background: var(--yellow);
  color: var(--ink);
  font-weight: 700;
  font-stretch: 90%;
}

.qtext {
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.12;
}
.qtext.l {
  font-size: 2rem;
}
.qtext.m {
  font-size: 1.625rem;
}
.qtext.s {
  font-size: 1.3125rem;
}
.qtext.xs {
  font-size: 1.125rem;
  line-height: 1.2;
}

/* ---- waiting --------------------------------------------------------------- */

.wait-flags {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.75rem;
  padding: 2rem 1.5rem 0;
}
.wait-flags span {
  aspect-ratio: 4 / 3;
  transform-origin: 0 50%;
  animation: sway 3.2s ease-in-out infinite alternate;
}
.wait-flags span:nth-child(2) {
  animation-delay: -0.5s;
}
.wait-flags span:nth-child(3) {
  animation-delay: -1.1s;
}
.wait-flags span:nth-child(4) {
  animation-delay: -1.6s;
}
.wait-flags span:nth-child(5) {
  animation-delay: -2.2s;
}
@keyframes sway {
  from {
    transform: skewY(-3deg);
  }
  to {
    transform: skewY(3deg);
  }
}
.wait-copy {
  margin-block: auto;
  padding: 2rem 1.5rem;
}
.wait-copy h1 {
  font-size: clamp(2.25rem, 11vw, 3.25rem);
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}
.wait-copy p {
  margin-top: 1rem;
  font-size: 1.125rem;
  color: var(--fg-soft);
  max-width: 24ch;
}

/* ---- get ready ------------------------------------------------------------- */

.intro-copy {
  margin-block: auto;
  padding: 2rem 1.5rem;
  display: flex;
  flex-direction: column;
}
.intro-n {
  font-size: clamp(2.75rem, 14vw, 4rem);
  letter-spacing: -0.02em;
}
.intro-n span {
  color: var(--fg-soft);
  font-weight: 450;
  white-space: nowrap;
}
.ready {
  margin-top: 2.5rem;
  font-weight: 700;
  font-size: 1.125rem;
}
.meter {
  margin-top: 0.6rem;
  height: 6px;
  background: var(--line);
}
.meter i {
  display: block;
  height: 100%;
  background: var(--ink);
  transform-origin: 0 50%;
  animation: fill linear both;
}
@keyframes fill {
  from {
    transform: scaleX(0);
  }
}

/* ---- answering ------------------------------------------------------------- */

.answer {
  height: 100dvh;
}
.drain {
  height: 6px;
  flex: none;
  background: var(--line);
}
.drain i {
  display: block;
  height: 100%;
  background: var(--ink);
  transform-origin: 0 50%;
  animation: drain linear both;
}
@keyframes drain {
  to {
    transform: scaleX(0);
  }
}
.answer .qtext {
  padding: 1rem 1rem 0.25rem;
}
.picks {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-auto-rows: 1fr;
  gap: 0.75rem;
  padding: 0.75rem;
}
.picks.n2 {
  grid-template-columns: 1fr;
}
.picks.n3 .pick:last-child {
  grid-column: 1 / -1;
}
.pick {
  position: relative;
  min-height: 0;
  touch-action: manipulation;
  transition: transform 0.12s var(--ease);
  animation: unfurl 0.5s var(--ease) both;
}
.pick:nth-child(2) {
  animation-delay: 0.05s;
}
.pick:nth-child(3) {
  animation-delay: 0.1s;
}
.pick:nth-child(4) {
  animation-delay: 0.15s;
}
@keyframes unfurl {
  from {
    clip-path: inset(0 100% 0 0);
  }
  to {
    clip-path: inset(-4px);
  }
}
.pick:active {
  transform: scale(0.96);
}
.pick-flag {
  position: absolute;
  inset: 0;
}
.pick .chip {
  position: absolute;
  top: 0.6rem;
  left: 0.6rem;
  width: 2.75rem;
  height: 2.75rem;
  font-size: 1.625rem;
  border: 2px solid #fff;
}
.pick-text {
  position: absolute;
  left: 0.6rem;
  bottom: 0.6rem;
  max-width: calc(100% - 2.6rem);
  padding: 0.35em 0.6em;
  background: #fff;
  color: var(--ink);
  border: 1.5px solid var(--ink);
  font-weight: 650;
  font-size: 1.0625rem;
  line-height: 1.2;
  text-align: left;
  overflow-wrap: anywhere;
  /* Never grow over the letter chip above it. */
  max-height: calc(100% - 4.6rem);
  overflow: hidden;
}
.pick-text.long {
  font-size: 0.875rem;
  font-weight: 600;
}

/* ---- locked in ------------------------------------------------------------- */

.locked-copy {
  margin-block: auto;
  padding: 2rem 1.5rem;
}
.hoist {
  position: relative;
  width: min(62vw, 15rem);
  aspect-ratio: 4 / 3;
  animation: hoist 0.6s var(--ease) both;
}
@keyframes hoist {
  from {
    transform: translateY(3rem);
    opacity: 0;
  }
}
.hoist-flag {
  position: absolute;
  inset: 0;
}
.hoist .chip {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  width: 3rem;
  height: 3rem;
  font-size: 1.75rem;
  border: 2px solid #fff;
}
.locked-copy h1 {
  margin-top: 2rem;
  font-size: clamp(2.25rem, 11vw, 3rem);
  letter-spacing: -0.02em;
}
.locked-copy p {
  margin-top: 0.6rem;
  font-size: 1.125rem;
  color: var(--fg-soft);
}

/* ---- result ---------------------------------------------------------------- */

.result-copy {
  margin-block: auto;
  padding: 1.5rem;
}
.mark {
  display: grid;
  place-items: center;
  width: 4.5rem;
  height: 4.5rem;
  background: var(--ink);
  color: var(--yellow);
  animation: stamp 0.45s var(--ease) both;
}
.miss .mark {
  background: #fff;
  color: var(--red);
}
@keyframes stamp {
  from {
    transform: scale(0.4) rotate(-12deg);
    opacity: 0;
  }
}
.result-copy h1 {
  margin-top: 1.25rem;
  font-size: clamp(3rem, 16vw, 4.5rem);
  letter-spacing: -0.025em;
}
.gain {
  margin-top: 0.25rem;
  font-size: clamp(4rem, 22vw, 6rem);
  line-height: 1;
}
.line {
  margin-top: 0.75rem;
  font-size: 1.125rem;
  font-weight: 650;
}
.standing {
  padding: 1rem 1.5rem 1.25rem;
  border-top: 1.5px solid var(--rule);
}
.standing + .bar {
  margin-top: 0;
}
.standing-place {
  font-size: 1.5rem;
  font-weight: 750;
}
.standing-gap {
  color: var(--fg-soft);
  overflow-wrap: anywhere;
}

/* ---- final ----------------------------------------------------------------- */

.final {
  padding-inline: 1.5rem;
}
.final .brand {
  margin-top: 1.5rem;
  align-self: flex-start;
  font-size: 1.125rem;
}
.final-copy {
  margin-block: auto;
}
.final-copy h1 {
  font-size: clamp(3.5rem, 19vw, 5.5rem);
  letter-spacing: -0.03em;
}
.final-copy h1 span {
  display: block;
  margin-top: 0.5rem;
  font-size: 1.25rem;
  font-weight: 450;
  letter-spacing: 0;
  color: var(--fg-soft);
}
.final-score {
  margin-top: 2rem;
  font-size: 1.25rem;
}
.final-score .num {
  font-size: 3rem;
}
.final-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding-block: 1.25rem calc(1.25rem + env(safe-area-inset-bottom));
  border-top: 1.5px solid var(--rule);
  font-weight: 650;
}
[data-tone='yellow'] .final-foot .btn--quiet:hover {
  background: var(--ink);
  border-color: var(--ink);
}
