/* Phone layout: portrait, one action per screen, no scrolling. Uses tokens.css only. */
html[data-role='player'] { font-size: 16px; }
html[data-role='player'] body { position: fixed; inset: 0; overscroll-behavior: none; touch-action: manipulation; }

#app {
  height: 100vh; height: 100dvh; height: var(--app-h, 100dvh);
  display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto;
  padding: max(0.6rem, env(safe-area-inset-top)) 1rem max(0.8rem, env(safe-area-inset-bottom));
  gap: 0.6rem;
  /* the player's own colour washes the top, the game's colour the bottom corner */
  background:
    radial-gradient(110% 48% at 50% -10%, color-mix(in srgb, var(--pc, var(--accent)) 42%, transparent), transparent 70%),
    radial-gradient(70% 36% at 100% 100%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 70%),
    linear-gradient(var(--sky-1), var(--sky-0));
  transition: background var(--d-slow);
}
#app::before { content: ''; position: absolute; inset-inline: 0; top: 0; height: 0.35rem; background: var(--pc, var(--accent)); opacity: 0.95; }
html[data-role='player'] body { position: fixed; }
#app { position: relative; }

#bar { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); min-height: 2.6rem; }
#bar:empty { min-height: 0; }
#bar .chip { font-size: 0.95rem; max-width: 55%; }
#bar .chip .avatar { --sz: 2rem; }
#bar .badge { font-size: 1rem; padding: 0.2rem 0.8rem; }
#time[hidden] { display: none; }
#time { height: 0.6rem; }

#bar { grid-row: 1; }
#time { grid-row: 2; }
#view { grid-row: 3; position: relative; min-height: 0; }
#view > .screen { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1rem; text-align: center; }

.p-title { font-size: 2.2rem; }
.p-label { font-size: 1.5rem; }
.p-sub { font-size: 1.15rem; color: var(--ink-2); font-weight: 700; }
.p-stack { width: 100%; display: grid; gap: 0.8rem; }
.p-error { min-height: 1.6rem; color: var(--bad); font-weight: 800; font-size: 1.05rem; }
.medal { --sz: 7rem; }

/* watching the TV */
.watch .medal { --sz: 8.5rem; position: relative; }
.watch .medal::after { content: ''; position: absolute; inset: -0.9rem; border-radius: 36%; border: 0.25rem solid var(--accent); opacity: 0.35; animation: watch-ring 1.8s var(--e-out) infinite; }
@keyframes watch-ring { 0% { transform: scale(0.85); opacity: 0.5; } 100% { transform: scale(1.15); opacity: 0; } }

/* join */
.join { justify-content: flex-start !important; gap: 0.7rem !important; }
.join__logo { font-family: var(--font-display); font-size: 2.3rem; line-height: 1.5; color: var(--ink); text-shadow: 0 0.06em 0 var(--c-whosaid), 0 0.12em 0 var(--c-draw); }
.join__logo b { font-weight: 400; color: var(--c-mostlikely); text-shadow: 0 0.06em 0 var(--c-brand), 0 0.12em 0 var(--c-whosaid); }
.join__for { display: inline-flex; align-items: center; gap: 0.35rem; margin-top: -0.6rem; font-family: var(--font-display); font-size: 1.15rem; color: var(--ink-2); }
.join__for i { color: var(--bad); font-size: 0.9em; }
.join__sadu { height: 0.7rem; max-width: 16rem; margin-top: -0.3rem; }
.lobby__actions { width: 100%; display: grid; gap: 0.6rem; margin-top: 0.6rem; }
.lobby__actions .btn { min-height: 3.2rem; font-size: 1.15rem; }
.lobby__leave { color: var(--ink-2); }
.lobby__leave.is-armed { background: var(--bad); color: var(--ink); }
.join .btn { flex: none; }
.join__back { margin-top: 0 !important; min-height: 2.8rem; font-size: 1.05rem; }
.join__note { margin-top: -0.4rem; font-size: 1rem; line-height: 1.35; font-weight: 700; color: var(--c-mostlikely); text-wrap: balance; }
.join__avatars { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.4rem; width: 100%; max-width: 21rem; }
.join__avatars button { display: grid; place-items: center; aspect-ratio: 1; border-radius: var(--r-m); background: var(--surface); transition: transform var(--d-fast) var(--e-pop), background var(--d-fast); }
.join__avatars .avatar { --sz: 78%; }
.join__avatars button.is-on { background: var(--surface-3); box-shadow: 0 0 0 0.2rem var(--pc), var(--shadow-pop); transform: scale(1.04); }
.join__colors { display: grid; grid-template-columns: repeat(8, 1fr); gap: 0.45rem; width: 100%; max-width: 21rem; }
.join__colors button { aspect-ratio: 1; border-radius: 50%; background: var(--pc); box-shadow: 0 0.16rem 0 var(--shade); display: grid; place-items: center; color: var(--ink-dark); font-size: 1rem; transition: transform var(--d-fast) var(--e-pop); }
.join__colors button.is-on { transform: scale(1.18); box-shadow: 0 0 0 0.18rem var(--ink), 0 0.16rem 0 var(--shade); }
.join__colors button.is-taken { opacity: 0.22; }
.join .btn { margin-top: auto; }
/* shorter screens (most phones once the browser bars are showing): avatars in two rows */
@media (max-height: 780px) { .join { gap: 0.55rem !important; } .join__logo { font-size: 1.9rem; } .join__avatars { grid-template-columns: repeat(8, 1fr); gap: 0.3rem; } .join__avatars button { border-radius: var(--r-s); } }
@media (max-height: 560px) { .join__logo { font-size: 1.5rem; } .join__for { display: none; } }

/* text + number input */
.entry { justify-content: flex-start !important; padding-top: 0.6rem; }
.entry textarea.field { min-height: 7.5rem; resize: none; line-height: 1.5; }
.entry__count { text-align: end; color: var(--ink-3); font-weight: 700; margin-top: -0.4rem; }
.entry__num { display: flex; align-items: center; gap: 0.6rem; }
.entry__num .field { text-align: center; font-family: var(--font-display); font-size: 2.6rem; min-height: 5rem; direction: ltr; }
.entry__unit { font-weight: 800; font-size: 1.3rem; color: var(--accent); white-space: nowrap; }

/* pick a player */
.pick { justify-content: flex-start !important; gap: 0.7rem !important; }
.pick__grid { flex: 1; min-height: 0; width: 100%; display: grid; gap: 0.5rem; grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr)); grid-auto-rows: minmax(0, 1fr); }
.pick__opt { display: flex; align-items: center; gap: 0.5rem; padding: 0.3rem 0.6rem; min-height: 0; border-radius: var(--r-m); background: var(--surface-2); box-shadow: inset 0 0.12rem 0 var(--line), var(--shadow-pop); font-weight: 800; font-size: 1.15rem; text-align: start; transition: transform var(--d-fast) var(--e-out), background var(--d-fast); }
.pick__opt .avatar { --sz: min(3rem, 100%); height: min(3rem, 100%); width: auto; aspect-ratio: 1; }
.pick__opt span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.pick__opt:active, .pick__opt.is-on { transform: translateY(0.15rem); background: var(--accent); color: var(--ink-dark); }
.pick__grid.is-dense .pick__opt { flex-direction: column; justify-content: center; gap: 0.1rem; padding: 0.25rem; font-size: 1rem; text-align: center; }
.pick__grid.is-dense .pick__opt .avatar { --sz: 2.6rem; height: 2.6rem; }
.pick__grid.is-dense .pick__opt span { max-width: 100%; }

/* word choice */
.words .btn { min-height: 4.6rem; font-family: var(--font-display); font-weight: 400; font-size: 2rem; }

/* drawing */
.sketch { justify-content: flex-start !important; gap: 0.55rem !important; }
.sketch__word { display: flex; align-items: baseline; justify-content: center; gap: 0.5rem; flex-wrap: wrap; }
.sketch__word b { font-family: var(--font-display); font-weight: 400; font-size: 1.9rem; color: var(--accent); }
.sketch__pad { width: min(100%, calc(var(--app-h, 100dvh) - 19.5rem)); aspect-ratio: 1; padding: 0; overflow: hidden; flex: none; }
.sketch__label { font-weight: 800; font-size: 1rem; color: var(--ink-2); }
.sketch__tools .sketch__cmd { display: flex; align-items: center; gap: 0.3rem; font-size: 1rem; font-weight: 800; padding: 0 0.6rem; white-space: nowrap; flex: none; }
.sketch__tools .sketch__cmd i { font-size: 1.25rem; }
.sketch__pad canvas { width: 100%; height: 100%; display: block; touch-action: none; }
.sketch__colors { display: grid; grid-template-columns: repeat(8, 1fr); gap: 0.4rem; width: 100%; }
.sketch__colors button { aspect-ratio: 1; border-radius: 50%; background: var(--dc); box-shadow: 0 0.16rem 0 var(--shade), inset 0 0 0 0.12rem var(--line); transition: transform var(--d-fast) var(--e-pop); }
.sketch__colors button.is-on { transform: scale(1.2); box-shadow: 0 0 0 0.18rem var(--ink), 0 0.16rem 0 var(--shade); }
.sketch__tools { display: flex; gap: 0.5rem; width: 100%; align-items: center; }
.sketch__tools button { height: 3rem; min-width: 2.7rem; padding: 0 0.5rem; border-radius: var(--r-m); background: var(--surface-2); box-shadow: inset 0 0.12rem 0 var(--line), var(--shadow-pop); display: grid; place-items: center; font-size: 1.4rem; }
.sketch__tools button.is-on { background: var(--accent); color: var(--ink-dark); }
.sketch__tools .sp { flex: 1; }
.sketch__dot { display: block; border-radius: 50%; background: currentColor; }
.sketch__note { font-size: 1rem; color: var(--ink-2); font-weight: 700; }

/* guessing */
.guess { justify-content: flex-start !important; padding-top: 0.6rem; }
.guess__row { display: flex; gap: 0.5rem; width: 100%; }
.guess__row .field { flex: 1; min-width: 0; }
.guess__row .btn { padding: 0; width: 3.6rem; flex: none; font-size: 1.5rem; }
.guess__note { min-height: 2.4rem; font-size: 1.4rem; font-weight: 800; }
.guess__note.is-close { color: var(--c-mostlikely); }
.guess__note.is-wrong { color: var(--ink-3); }

/* result + rank */
.result .points { font-size: 2.2rem; padding: 0.1rem 1.2rem; }
.result__rank { display: inline-flex; align-items: baseline; gap: 0.4rem; }
.rank__num { font-size: 6.5rem; line-height: 1.1; color: var(--accent); }

/* the night's journey: games, current round, my points in each */
.result { gap: 0.7rem !important; }
.result > .medal { --sz: 5.5rem; }
.journey { width: 100%; margin-top: 0.4rem; padding: 0.7rem 0.5rem; display: grid; gap: 0.6rem; border-radius: var(--r-l); background: var(--surface); box-shadow: inset 0 0.12rem 0 var(--line), var(--shadow-pop); }
.journey__games { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 0.2rem; }
.journey__g { display: grid; justify-items: center; gap: 0.15rem; min-width: 0; }
.journey__g .medal { --sz: 2.7rem; }
.journey__name { font-size: 0.85rem; font-weight: 800; color: var(--ink-2); white-space: nowrap; }
.journey__pts { font-size: 1.05rem; color: var(--accent); min-height: 1.4rem; }
.journey__g.is-next { opacity: 0.4; }
.journey__g.is-next .medal { background: var(--surface-3); color: var(--ink); }
.journey__g.is-now .medal { box-shadow: 0 0 0 0.18rem var(--ink), var(--shadow-pop); }
.journey__round { display: grid; justify-items: center; gap: 0.35rem; font-size: 1rem; font-weight: 800; }
/* folded on result screens: one line, tap to open */
.journey__fold { width: 100%; display: flex; align-items: center; justify-content: center; gap: 0.4rem; min-height: 2.2rem; font-size: 0.95rem; font-weight: 800; color: var(--ink-2); }
.journey__fold i { font-size: 1.15rem; color: var(--accent); }
.journey__caret { transition: transform var(--d-med) var(--e-out); }
.journey.is-folded { padding-block: 0.3rem; }
.journey.is-folded:not(.is-open) .journey__games, .journey.is-folded:not(.is-open) .journey__round { display: none; }
.journey.is-folded.is-open .journey__caret { transform: rotate(180deg); }
.journey.is-folded.is-open .journey__games { margin-top: 0.4rem; }
.pick__sub { font-size: 1rem; margin-top: -0.3rem; }
.journey__dots { display: flex; gap: 0.25rem; }
.journey__dots i { width: 1rem; height: 0.45rem; border-radius: var(--r-pill); background: var(--surface-3); }
.journey__dots i.is-on { background: var(--accent); }
@media (max-height: 620px) { .result > .medal { --sz: 4rem; } .rank__num { font-size: 4.5rem; } }

/* حقيقتين وكذبة */
.truths__row { display: flex; align-items: center; gap: 0.5rem; }
.truths__row .field { flex: 1; min-width: 0; min-height: 3.2rem; }
.truths__mark { flex: none; width: 5.4rem; min-height: 3.2rem; display: flex; align-items: center; justify-content: center; gap: 0.3rem; border-radius: var(--r-m); background: var(--surface-2); color: var(--good); font-weight: 800; font-size: 1rem; box-shadow: inset 0 0.12rem 0 var(--line); } /* a label, not a button */
.truths__row.is-lie .truths__mark { background: var(--bad); color: var(--ink); }
.truths__row.is-lie .field { border-color: var(--bad); }
.choice { flex: 1; min-height: 0; width: 100%; display: grid; gap: 0.6rem; grid-auto-rows: minmax(0, 1fr); }
.choice__opt { display: flex; align-items: center; gap: 0.7rem; padding: 0.5rem 0.8rem; border-radius: var(--r-m); background: var(--surface-2); box-shadow: inset 0 0.12rem 0 var(--line), var(--shadow-pop); text-align: start; transition: transform var(--d-fast) var(--e-out), background var(--d-fast); }
.choice__n { flex: none; width: 2.8rem; height: 2.8rem; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: var(--ink-dark); font-size: 1.7rem; }
.choice__text { font-weight: 800; font-size: 1.15rem; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.choice__opt.is-on, .choice__opt:active { background: var(--accent); color: var(--ink-dark); transform: translateY(0.15rem); }
.choice__opt.is-on .choice__n { background: var(--ink-dark); color: var(--accent); }

/* صورة مين؟ */
.photo__preview { max-width: 100%; max-height: 34vh; border-radius: var(--r-m); box-shadow: var(--shadow-pop); }
.photo__preview[hidden] { display: none; }
.photo label.btn { cursor: pointer; }
.photo__ask { font-family: var(--font-display); font-size: 1.5rem; line-height: 1.35; color: var(--accent); text-wrap: balance; }

/* reaction buttons under the screen */
#reacts { grid-row: 4; display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.5rem; }
#reacts[hidden] { display: none; }
#reacts.is-off button { opacity: 0.22; box-shadow: inset 0 0.12rem 0 var(--line); }
#reacts button { height: 3.4rem; border-radius: var(--r-m); background: var(--surface-2); box-shadow: inset 0 0.12rem 0 var(--line), var(--shadow-pop); font-size: 2rem; display: grid; place-items: center; transition: transform var(--d-fast) var(--e-out); }
#reacts button:active { transform: translateY(0.15rem) scale(0.94); }
.keepslot { width: 100%; }
.keepslot:empty { display: none; }
.keepsheet { position: absolute; inset: 0; z-index: 20; display: flex; flex-direction: column; gap: 0.6rem; padding: max(0.8rem, env(safe-area-inset-top)) 1rem max(0.8rem, env(safe-area-inset-bottom)); background: var(--sky-0); animation: m-fade var(--d-med) var(--e-out) both; }
.keepsheet img { flex: 1; min-height: 0; width: 100%; object-fit: contain; -webkit-touch-callout: default; user-select: auto; -webkit-user-select: auto; }
.keepsheet__hint { display: flex; align-items: center; justify-content: center; gap: 0.4rem; font-weight: 700; font-size: 1rem; color: var(--ink-2); }
.keepsheet a.btn { text-decoration: none; flex: none; }
@media (max-height: 700px) { .result > .medal { --sz: 4rem; } .result { gap: 0.5rem !important; } .journey { padding: 0.5rem; gap: 0.4rem; } .journey__g .medal { --sz: 2.3rem; } }

#offline {
  position: absolute; inset-inline: 1rem; bottom: max(5rem, env(safe-area-inset-bottom)); z-index: 10;
  display: flex; align-items: center; justify-content: center; gap: 0.5rem;
  padding: 0.7rem 1rem; border-radius: var(--r-m);
  background: var(--bad); color: var(--ink); font-weight: 800; box-shadow: var(--shadow-pop);
  animation: m-rise var(--d-med) var(--e-out) both;
}
#offline[hidden] { display: none; }

@media (prefers-reduced-motion: reduce) {
  html[data-role='player'] *, html[data-role='player'] *::before, html[data-role='player'] *::after {
    animation-duration: 1ms !important; animation-delay: 0ms !important; animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
}

/* room code entry (online) */
.code__input { width: 100%; max-width: 16rem; direction: ltr; text-align: center; font: inherit; font-size: 2rem; font-weight: 800; letter-spacing: 0.18em; padding: 0.5rem 0.8rem; border-radius: 0.9rem; border: 2px solid color-mix(in srgb, var(--ink) 25%, transparent); background: color-mix(in srgb, var(--ink) 8%, transparent); color: var(--ink); }
.code__input:focus { outline: none; border-color: var(--c-mostlikely); }
.join__for[hidden] { display: none; }

/* seconds left, next to the game badge in the header */
#bar .badge--time { margin-inline-start: auto; min-width: 2.8rem; justify-content: center; font-size: 1.05rem; }
#bar .badge--time.is-urgent { background: var(--bad); color: #fff; animation: m-pulse 700ms var(--e-out) infinite; }
#bar .badge--time[hidden] { display: none; }
/* the photo screen can be taller than the phone: it scrolls, and the message sits above the buttons */
.photo { overflow-y: auto; }
.photo .p-error { min-height: 0; }
.sketch__tools .sketch__cmd.is-on { background: var(--accent); color: var(--ink-dark); }
