/* ==========================================================================
   The phone: one screen at a time over a living world.
   The canvas fills the screen and never stops; every panel sits on top of it.
   Built for a phone held upright in a hall — big type, big targets, the
   thumb's half of the screen for anything you press.
   ========================================================================== */

html,
body {
  height: 100%;
}

body.play {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: var(--pink-900);
  color: var(--white);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
  overscroll-behavior: none;
}

.world {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  touch-action: none;
}

/* ── top bar: logo, sound, language ────────────────────────── */

.bar {
  position: fixed;
  z-index: 20;
  inset-inline: 0;
  top: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(10px + var(--safe-t)) 14px 10px;
  pointer-events: none;
}

.bar__logo {
  height: 30px;
  width: auto;
  filter: drop-shadow(0 1px 6px rgba(20, 8, 40, 0.35));
}

.bar__tools {
  margin-inline-start: auto;
  display: flex;
  gap: 6px;
  pointer-events: auto;
}

.tool {
  min-width: 44px;
  min-height: 40px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--radius);
  background: rgba(28, 25, 33, 0.42);
  color: var(--white);
  font-size: 0.95rem;
  font-weight: 700;
}

.tool[aria-pressed='false'] {
  opacity: 0.55;
}

body.is-running .bar {
  display: none;
}

/* ── join: a white sheet with the brand's diamond peak ─────── */

.sheet {
  position: fixed;
  z-index: 10;
  inset-inline: 0;
  bottom: 0;
  padding: 44px 22px calc(22px + var(--safe-b));
  background: var(--white);
  color: var(--ink);
  clip-path: polygon(0 26px, 50% 0, 100% 26px, 100% 100%, 0 100%);
  animation: rise 520ms var(--ease-out-expo) both;
}

.sheet__inner {
  max-width: 420px;
  margin-inline: auto;
}

.title {
  font-family: var(--font-display);
  font-size: clamp(2.1rem, 9vw, 2.8rem);
  font-weight: 700;
  line-height: 1.15;
  color: var(--grape);
  text-align: center;
}

:lang(en) .title {
  font-weight: 800;
  letter-spacing: -0.01em;
}

.tagline {
  margin-top: 6px;
  text-align: center;
  font-size: 1.05rem;
  color: var(--ink-700);
}

.join {
  margin-top: 22px;
  display: grid;
  gap: 10px;
}

.join label {
  font-weight: 700;
  font-size: 1rem;
}

.join input {
  width: 100%;
  min-height: 56px;
  padding: 0 16px;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--ink);
  font-size: 1.25rem;
  font-weight: 700;
  -webkit-user-select: text;
  user-select: text;
}

.join input::placeholder {
  color: var(--ink-600);
  font-weight: 400;
}

.join input:focus {
  outline: 3px solid var(--grape-300);
  outline-offset: 1px;
}

.join .btn {
  min-height: 58px;
  font-size: 1.25rem;
}

.join__msg {
  min-height: 1.4em;
  color: var(--sienna-700);
  font-weight: 700;
  font-size: 0.98rem;
}

.join__msg:empty {
  min-height: 0;
}

.hint {
  font-size: 0.92rem;
  color: var(--ink-600);
  text-align: center;
}

/* ── lobby ─────────────────────────────────────────────────── */

.lobby {
  position: fixed;
  z-index: 10;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: calc(64px + var(--safe-t)) 16px calc(16px + var(--safe-b));
  pointer-events: none;
}

.lobby__card {
  background: var(--white);
  color: var(--ink);
  padding: 18px 18px 16px;
  border-radius: var(--radius);
  text-align: center;
  animation: rise 520ms var(--ease-out-expo) both;
  max-width: 460px;
  width: 100%;
  margin-inline: auto;
  box-shadow: 0 18px 40px -18px rgba(20, 8, 40, 0.6);
}

.lobby__in {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--grape);
  line-height: 1.25;
}

.lobby__wait {
  margin-top: 6px;
  font-size: 1.02rem;
  color: var(--ink-700);
}

.lobby__count {
  margin-top: 10px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  color: var(--emerald-700);
}

.lobby__count .dia {
  color: var(--emerald);
}

.how {
  list-style: none;
  padding: 0;
  margin-top: auto;
  margin-inline: auto;
  max-width: 460px;
  width: 100%;
  display: grid;
  gap: 2px;
  animation: rise 620ms 120ms var(--ease-out-expo) both;
}

.how li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  background: rgba(28, 25, 33, 0.62);
  font-size: 1rem;
  line-height: 1.45;
}

.how li::before {
  content: '';
  width: 10px;
  height: 10px;
  flex: none;
  background: var(--emerald);
  transform: rotate(45deg);
}

.practice {
  margin: 14px auto 0;
  padding: 8px 14px;
  background: var(--emerald);
  color: var(--ink);
  font-weight: 700;
  border-radius: var(--radius);
  text-align: center;
  animation: nudge 1.6s ease-in-out infinite;
}

/* ── HUD ───────────────────────────────────────────────────── */

.hud {
  position: fixed;
  z-index: 12;
  inset-inline: 0;
  top: 0;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: start;
  gap: 8px 12px;
  padding: calc(10px + var(--safe-t)) 14px 0;
  pointer-events: none;
  text-shadow: 0 1px 8px rgba(20, 8, 40, 0.5);
}

.hud__q {
  display: grid;
  gap: 6px;
}

.hud__qlabel {
  font-weight: 700;
  font-size: 0.98rem;
}

.pips {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.pip {
  width: 13px;
  height: 13px;
  transform: rotate(45deg) scale(0.82);
  border: 2px solid rgba(255, 255, 255, 0.75);
  transition: background-color 300ms var(--ease-out), transform 300ms var(--ease-spring);
}

.pip.is-now {
  border-color: var(--white);
  transform: rotate(45deg) scale(1.05);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.25);
}

.pip.is-right {
  background: var(--emerald);
  border-color: var(--emerald);
}

.pip.is-wrong {
  background: rgba(255, 255, 255, 0.35);
  border-color: transparent;
}

.hud__score {
  text-align: end;
  line-height: 1.1;
}

.hud__score small {
  display: block;
  font-size: 0.8rem;
  opacity: 0.85;
}

.hud__score b {
  font-size: 1.7rem;
  font-weight: 700;
}

.hud__dots {
  grid-column: 2;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  font-weight: 700;
}

.hud__dots .dia {
  color: var(--emerald);
}

.pop {
  animation: pop 420ms var(--ease-spring);
}

/* ── countdown ─────────────────────────────────────────────── */

.count {
  position: fixed;
  z-index: 30;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 10px;
  background: rgba(94, 15, 58, 0.55);
  pointer-events: none;
}

.count__sub {
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.count__num {
  position: relative;
  display: grid;
  place-items: center;
  width: 190px;
  height: 190px;
  font-family: var(--font-display);
  font-size: 6.5rem;
  font-weight: 700;
  line-height: 1;
}

.count__num::before {
  content: '';
  position: absolute;
  inset: 22px;
  border: 4px solid var(--white);
  transform: rotate(45deg);
}

.count__num.is-tick {
  animation: tick 900ms var(--ease-out-expo);
}

.count__num.is-go {
  font-size: 4rem;
  color: var(--emerald);
}

.count__num.is-go::before {
  border-color: var(--emerald);
  background: rgba(64, 205, 126, 0.12);
}

/* ── the question ──────────────────────────────────────────── */

.ask {
  position: fixed;
  z-index: 25;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: calc(14px + var(--safe-t)) 16px calc(14px + var(--safe-b));
  background: rgba(168, 34, 102, 0.96);
  animation: fade 260ms var(--ease-out) both;
  overflow-y: auto;
}

.ask__inner {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 620px;
  min-height: 100%;
  margin-inline: auto;
}

.ask__top {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
}

.ask__n {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.ask__worth {
  margin-inline-start: auto;
  /* Pale rose, not emerald: small text on the pink field needs the contrast (5.2:1). */
  color: var(--pink-200);
  font-size: 0.98rem;
}

.ask__time {
  min-width: 2.6em;
  text-align: end;
  font-size: 1.35rem;
}

.ask__time.is-low {
  color: #ffb79c;
}

.ask__bar {
  margin-top: 10px;
  height: 8px;
  background: rgba(255, 255, 255, 0.18);
  overflow: hidden;
}

.ask__bar i {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--emerald);
  transform-origin: var(--from, left) center;
}

:root[dir='rtl'] .ask__bar i {
  --from: right;
}

.ask__bar i.is-low {
  background: var(--sienna);
}

.ask__prompt {
  margin-top: 22px;
  font-size: clamp(1.3rem, 5.6vw, 1.75rem);
  font-weight: 700;
  line-height: 1.45;
  text-wrap: balance;
}

.ask__opts {
  margin-top: 20px;
  display: grid;
  gap: 10px;
}

.opt {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 60px;
  padding: 12px 16px;
  border: 0;
  border-radius: var(--radius);
  background: var(--white);
  color: var(--ink);
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.4;
  text-align: start;
  transition: transform 140ms var(--ease-out), background-color 200ms var(--ease-out), opacity 200ms var(--ease-out);
  animation: rise 360ms var(--ease-out-expo) both;
  touch-action: manipulation;
}

.opt:nth-child(2) { animation-delay: 40ms; }
.opt:nth-child(3) { animation-delay: 80ms; }
.opt:nth-child(4) { animation-delay: 120ms; }

.opt:active {
  transform: scale(0.98);
}

.opt__mark {
  width: 12px;
  height: 12px;
  flex: none;
  background: var(--grape);
  transform: rotate(45deg);
}

.opt__text {
  flex: 1;
}

.opt__icon {
  font-size: 1.3rem;
  line-height: 1;
}

.opt.is-right {
  background: var(--emerald);
  color: var(--ink);
}

.opt.is-right .opt__mark,
.opt.is-wrong .opt__mark {
  background: var(--ink);
}

.opt.is-wrong {
  background: var(--sienna);
  color: var(--ink);
  animation: shake 420ms var(--ease-out);
}

.opt.is-dim {
  opacity: 0.45;
}

.opt:disabled {
  cursor: default;
}

.ask__fb {
  margin-top: 20px;
  margin-bottom: 18px;
  display: grid;
  gap: 8px;
  animation: rise 420ms var(--ease-out-expo) both;
}

/* Continue sits in the thumb's reach, at the foot of the screen. */
.ask__next {
  margin-top: auto;
  position: sticky;
  bottom: 0;
  animation: rise 420ms 120ms var(--ease-out-expo) both;
}

/* Options take taps only once they have landed: a thumb still tapping to
   jump when the question appears must not answer it by accident. */
.ask__opts.is-arming {
  pointer-events: none;
}

.ask__verdict {
  display: flex;
  align-items: baseline;
  gap: 12px;
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 700;
}

.ask__pts {
  color: var(--emerald);
  font-size: 2rem;
}

.ask__explain {
  font-size: 1.02rem;
  line-height: 1.65;
  opacity: 0.92;
}


.btn__fill {
  position: absolute;
  inset-block: 0;
  inset-inline-start: 0;
  width: 0;
  background: rgba(28, 25, 33, 0.16);
  pointer-events: none;
}

.btn__label {
  position: relative;
}

/* Wide screens (a phone on its side, a tablet): options two by two. */
@media (min-width: 640px) and (min-aspect-ratio: 4/3) {
  .ask__opts {
    grid-template-columns: 1fr 1fr;
  }
}

/* ── the finale caption ────────────────────────────────────── */

.finale {
  position: fixed;
  z-index: 15;
  inset-inline: 0;
  top: calc(70px + var(--safe-t));
  padding: 0 20px;
  text-align: center;
  pointer-events: none;
  animation: rise 600ms var(--ease-out-expo) both;
  text-shadow: 0 2px 14px rgba(10, 4, 20, 0.6);
}

.finale__title {
  font-family: var(--font-display);
  font-size: clamp(2rem, 9vw, 2.8rem);
  font-weight: 700;
}

.finale__text {
  margin-top: 6px;
  font-size: 1.05rem;
  max-width: 30ch;
  margin-inline: auto;
  line-height: 1.6;
}

/* ── done ──────────────────────────────────────────────────── */

.done {
  position: fixed;
  z-index: 18;
  inset: 0;
  overflow-y: auto;
  padding: calc(64px + var(--safe-t)) 18px calc(20px + var(--safe-b));
  background: linear-gradient(to bottom, rgba(94, 15, 58, 0.2), rgba(94, 15, 58, 0.93) 30%, var(--pink-950));
  animation: fade 600ms var(--ease-out) both;
  -webkit-user-select: text;
  user-select: text;
}

.done__inner {
  max-width: 460px;
  margin-inline: auto;
  display: grid;
  gap: 4px;
  text-align: center;
}

.done__label {
  margin-top: 18vh;
  font-weight: 700;
  font-size: 1.1rem;
  opacity: 0.9;
}

.done__score {
  font-family: var(--font-display);
  font-size: clamp(3.6rem, 18vw, 5rem);
  font-weight: 700;
  line-height: 1.05;
}

.done__rank {
  display: inline-flex;
  margin: 8px auto 4px;
  padding: 6px 16px;
  background: var(--emerald);
  color: var(--ink);
  font-size: 1.3rem;
  font-weight: 700;
  border-radius: var(--radius);
}

.done__line {
  font-size: 1.05rem;
  opacity: 0.92;
}

.done__wait {
  margin-top: 10px;
  font-size: 0.95rem;
  opacity: 0.75;
  animation: breathe 2.4s ease-in-out infinite;
}

.winners {
  margin-top: 18px;
  text-align: start;
}

.winners h2 {
  font-size: 1.15rem;
  margin-bottom: 8px;
  text-align: center;
}

.winners ol {
  list-style: none;
  padding: 0;
  display: grid;
  gap: 2px;
}

.winners li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.1);
  font-weight: 700;
}

.winners li.is-me {
  background: var(--white);
  color: var(--grape-600);
}

.winners .rank {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: none;
  position: relative;
  color: var(--ink);
  font-size: 0.95rem;
}

.winners .rank::before {
  content: '';
  position: absolute;
  inset: 4px;
  background: var(--emerald);
  transform: rotate(45deg);
  z-index: -1;
}

.winners li:nth-child(2) .rank::before {
  background: var(--sienna);
}

.winners li:nth-child(3) .rank::before {
  background: var(--grape-300);
}

.winners li {
  position: relative;
  isolation: isolate;
}

.winners .who {
  flex: 1;
}

.cta {
  display: grid;
  gap: 4px;
  margin-top: 22px;
  padding: 18px 18px 16px;
  background: var(--white);
  color: var(--ink);
  text-decoration: none;
  text-align: start;
  border-radius: var(--radius);
  position: relative;
}

.cta strong {
  font-size: 1.2rem;
  color: var(--grape);
}

.cta span {
  font-size: 0.98rem;
  color: var(--ink-700);
  line-height: 1.5;
}

.cta em {
  margin-top: 8px;
  font-style: normal;
  font-weight: 700;
  color: var(--emerald-700);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.cta em::after {
  content: '←';
}

:lang(en) .cta em::after {
  content: '→';
}

/* ── notices: removed, a new game ──────────────────────────── */

.notice {
  position: fixed;
  z-index: 40;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 18px;
  padding: 24px;
  background: var(--pink-700);
  text-align: center;
}

.notice p {
  font-size: 1.4rem;
  font-weight: 700;
  max-width: 22ch;
}

/* ── the network line ──────────────────────────────────────── */

.netline {
  position: fixed;
  z-index: 50;
  top: calc(8px + var(--safe-t));
  left: 50%;
  translate: -50% 0;
  padding: 6px 14px;
  background: var(--ink);
  color: var(--white);
  font-size: 0.9rem;
  font-weight: 700;
  border-radius: var(--radius);
  white-space: nowrap;
  animation: fade 300ms var(--ease-out) both;
}

/* Landscape phones: less height, so panels get compact. */
@media (orientation: landscape) and (max-height: 500px) {
  .sheet {
    inset-inline: auto 0;
    width: min(420px, 52vw);
    top: 0;
    padding-top: calc(18px + var(--safe-t));
    clip-path: none;
    overflow-y: auto;
  }
  :root[dir='rtl'] .sheet {
    inset-inline: 0 auto;
  }
  .title { font-size: 1.8rem; }
  .how { display: none; }
  .lobby { padding-top: calc(56px + var(--safe-t)); }
  .done__label { margin-top: 0; }
  .ask__prompt { margin-top: 12px; }
  .ask__opts { margin-top: 12px; grid-template-columns: 1fr 1fr; }
  .opt { min-height: 50px; padding: 8px 12px; }
}

/* ── motion ────────────────────────────────────────────────── */

@keyframes rise {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: none; }
}

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

@keyframes pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.25); }
  100% { transform: scale(1); }
}

@keyframes tick {
  0% { opacity: 0; transform: scale(1.5); }
  25% { opacity: 1; transform: scale(1); }
  100% { opacity: 1; transform: scale(0.94); }
}

@keyframes nudge {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

@keyframes breathe {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 0.9; }
}

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