/* Player, spectator and editor phone preview. */
.pl-app {
  position: relative;
  min-height: 100vh; min-height: 100dvh;
  background: var(--qf-bg);
  color: var(--qf-text);
  font-family: var(--qf-font-body);
  --pl-line: color-mix(in srgb, var(--qf-text) 12%, transparent);
  --pl-accent-text: color-mix(in srgb, var(--qf-accent) 65%, var(--qf-text));
}
.pl-app > .qf-bg { position: fixed; overflow: clip; }
.pl-content {
  position: relative; z-index: 1;
  width: 100%; max-width: 600px; margin-inline: auto;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
    calc(24px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  display: flex; flex-direction: column; gap: 16px;
  min-height: 100vh; min-height: 100dvh;
}
.pl-content > *, .pl-center > *, .pl-answer > * { min-width: 0; }
.pl-top {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding-block: 8px 12px; border-bottom: 1px solid var(--pl-line);
  font-size: .875rem;
}
.pl-code, .pl-score { font-family: var(--qf-font-mono); font-weight: 500; }
.pl-code { color: var(--pl-accent-text); letter-spacing: .08em; }
.pl-score { margin-left: auto; }
.pl-name { flex: 1 1 72px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl-card { padding: 16px; }
.pl-title { font-family: var(--qf-font-display); font-size: clamp(1.5rem, 1.25rem + 2vw, 2rem); font-weight: 500; line-height: 1.15; margin: 0; }
.pl-sub { color: var(--qf-text-muted); }
.pl-center { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 16px; }
.pl-wordmark { font-weight: 600; }
.pl-entry.qf-card { display: grid; gap: 12px; padding: 20px; border-top: 4px solid var(--qf-accent); }
.pl-entry .pl-sub { margin: 0; }
.pl-entry .pl-code-input { margin-block: 4px; }
.pl-studio-link { align-self: flex-start; }
.pl-content a:not(.btn) { color: var(--pl-accent-text); text-underline-offset: .2em; }
.pl-app .input { background: var(--qf-surface); color: var(--qf-text); border-color: var(--pl-line); }
.pl-app .input:focus, .pl-app :focus-visible { outline-color: var(--qf-accent); }
.pl-app .btn {
  background: var(--qf-surface); color: var(--qf-text); border-color: var(--pl-line);
}
.pl-app .btn:hover, .pl-avatar-tabs button:hover { background: color-mix(in srgb, var(--qf-surface) 90%, var(--qf-text)); }
.pl-app .btn-ghost { background: transparent; }
.pl-app .btn-primary { background: var(--qf-text); border-color: var(--qf-text); color: var(--qf-bg); }
.pl-app .btn-primary:hover { background: color-mix(in srgb, var(--qf-text) 90%, var(--qf-bg)); }
.pl-app .btn-success { border-color: var(--qf-correct); }
.pl-app .error-text { color: var(--qf-wrong); }
.pl-app .lang-switch { border-color: var(--pl-line); }
.pl-app .lang-switch button { color: var(--qf-text-muted); }
.pl-app .lang-switch button.active { color: var(--qf-text); background: var(--qf-surface); }
.input.pl-code-input {
  font-size: 2rem; text-align: center; letter-spacing: .24em;
  font-family: var(--qf-font-mono); font-weight: 500; text-transform: uppercase;
  min-height: 64px;
}
.pl-code-input::placeholder { color: var(--qf-text-muted); opacity: 1; }

/* The selected avatar and team are player content. */
.pl-avatar-preview { display: flex; justify-content: center; }
.pl-avatar-tabs { display: grid; gap: 4px; }
.pl-avatar-tabs button, .pl-team {
  min-height: 44px; padding: 8px 4px; border-radius: 8px;
  border: 1px solid var(--pl-line); background: var(--qf-surface);
  color: var(--qf-text); font-weight: 500; cursor: pointer;
}
.pl-avatar-tabs button.active, .pl-team.on { border-color: var(--qf-accent); }
.pl-emoji-grid, .pl-reactions { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 44px), 1fr)); gap: 4px; }
.pl-emoji-grid button, .pl-reactions button {
  min-height: 44px; padding: 4px; font-size: 1.375rem; border-radius: 8px;
  border: 1px solid var(--pl-line); background: var(--qf-surface); cursor: pointer;
}
.pl-emoji-grid button.on { border-color: var(--qf-accent); background: color-mix(in srgb, var(--qf-surface) 86%, var(--qf-accent)); }
.pl-reactions button:disabled { opacity: .5; }
.pl-color-row, .pl-tools { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; align-items: center; }
.pl-color { width: 36px; height: 36px; border-radius: 50%; border: 3px solid transparent; cursor: pointer; }
.pl-color.on { border-color: var(--qf-bg); outline: 2px solid var(--qf-accent); }
.pl-draw-wrap { display: flex; flex-direction: column; align-items: center; gap: 8px; min-width: 0; }
.pl-draw-canvas, .pl-crop-canvas { width: min(256px, 100%); height: auto; aspect-ratio: 1; border-radius: 50%; touch-action: none; }
.pl-draw-canvas { background: #fff; }
.pl-crop-canvas { background: #111; }
.pl-teams { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.pl-team { box-shadow: inset 0 4px var(--team); }
.pl-waiting { display: grid; gap: 8px; justify-items: center; text-align: center; }
.pl-waiting .qf-avatar, .pl-top .qf-avatar { box-shadow: none; }
.pl-waiting > .qf-avatar { animation: pl-bob 3s ease-in-out infinite; }
@keyframes pl-bob { 50% { transform: translateY(-6px); } }
.pl-lobby-others { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px; margin-top: 8px; max-width: 360px; }
.pl-lobby-face { display: inline-flex; }
.pl-lobby-face.offline { opacity: .4; }
.pl-lobby-face .qf-avatar { box-shadow: 0 0 0 2px var(--qf-bg); }
.pl-lobby-more { color: var(--qf-text-muted); padding-inline: 4px; }
@keyframes pl-pop { from { transform: scale(.6); opacity: 0; } to { transform: none; opacity: 1; } }
.pl-spectator-badge { font-size: .8125rem; color: var(--qf-text-muted); }

/* The prompt and answer shapes are the focus of a live question. */
.pl-q-meta { display: flex; gap: 4px 12px; flex-wrap: wrap; font-size: .875rem; color: var(--qf-text-muted); }
.pl-q-meta > * { min-width: 0; }
.pl-prompt { font-family: var(--qf-font-display); font-size: clamp(1.25rem, 1.125rem + 1vw, 1.5rem); font-weight: 500; line-height: 1.25; }
.pl-media { border-radius: 8px; overflow: hidden; display: grid; place-items: center; background: var(--qf-surface); }
.pl-media img { max-height: 34vh; width: 100%; object-fit: contain; }
.pl-timer-row { display: flex; align-items: center; gap: 8px; }
.pl-timer-row .qf-timer { min-width: 0; flex: 1; }
.pl-timer-row .qf-timer-top_bar { flex-direction: row; gap: 8px; align-items: center; }
.pl-timer-row .bar-track { flex: 1; height: 4px; }
.pl-timer-row .bar-fill { background: var(--qf-accent); }
.pl-timer-row .bar-label { color: var(--qf-text-muted); font-weight: 500; min-width: 3ch; text-align: right; }
.pl-status { padding: 8px 12px; border-radius: 8px; background: var(--qf-surface); color: var(--qf-text-muted); }
.pl-status.prep { border-left: 4px solid var(--qf-accent); color: var(--qf-text); }

.pl-answer, .pl-estimation, .pl-open { display: flex; flex-direction: column; gap: 8px; }
.pl-answer.locked { opacity: .65; }
.pl-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.pl-grid.n-3 > :last-child, .pl-grid.n-5 > :last-child { grid-column: 1 / -1; }
.pl-opt {
  position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 8px;
  min-width: 0; min-height: 88px; padding: 12px;
  border: 1px solid var(--pl-line); border-top: 4px solid var(--btn); border-radius: 8px;
  color: var(--qf-text); background: color-mix(in srgb, var(--qf-card) 88%, var(--btn));
  cursor: pointer; font-weight: 500; text-align: left;
  transition: background-color .15s var(--ui-ease), opacity .15s var(--ui-ease);
}
.pl-opt:hover:not(:disabled) { background: color-mix(in srgb, var(--qf-card) 78%, var(--btn)); }
.pl-opt:active:not(:disabled) { transform: scale(.98); }
.pl-opt.mine { background: color-mix(in srgb, var(--qf-card) 62%, var(--btn)); }
.pl-opt:disabled { cursor: default; }
.pl-answer.submitted .pl-opt:not(.mine):not(.on) { opacity: .58; }
.pl-opt.mine, .pl-opt.on { outline: 1px solid var(--qf-text); outline-offset: -2px; }
.pl-shape { font-size: 1.25rem; line-height: 1; }
.pl-opt-text { max-width: 100%; }
.pl-opt-img { max-height: 72px; border-radius: 4px; object-fit: contain; }
.pl-toggle .pl-check {
  position: absolute; top: 8px; right: 8px; width: 20px; height: 20px;
  border: 1px solid currentColor; border-radius: 4px; display: grid; place-items: center;
  color: var(--qf-text-muted);
}
.pl-toggle .pl-check .icon { visibility: hidden; }
.pl-toggle.on .pl-check { background: var(--qf-text); color: var(--qf-bg); }
.pl-toggle.on .pl-check .icon { visibility: visible; }
.pl-hint { margin-bottom: 8px; font-size: .875rem; color: var(--qf-text-muted); }
.pl-send { margin-top: 8px; }
.pl-est-value { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; }
.input.pl-num { flex: 0 1 180px; font-size: 2rem; font-weight: 600; text-align: center; font-family: var(--qf-font-mono); min-height: 64px; }
.pl-est-value .pl-unit { font-size: 1.25rem; font-weight: 600; }
.pl-unit { min-width: 0; flex: 1 1 72px; color: var(--qf-text-muted); }
.pl-range { width: 100%; height: 40px; margin: 0; accent-color: var(--qf-accent); }
.pl-est-scale { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 8px; color: var(--qf-text-muted); font-size: .875rem; }
.pl-order { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.pl-order-item { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px; border-radius: 8px; background: var(--qf-card); user-select: none; }
.pl-order-item .grow { flex-basis: 72px; }
.pl-order-item.dragging { z-index: 5; position: relative; outline: 1px solid var(--qf-accent); }
.pl-order-item img { width: 48px; height: 40px; object-fit: cover; border-radius: 4px; }
.pl-drag { display: grid; place-items: center; min-height: 44px; cursor: grab; touch-action: none; color: var(--qf-text-muted); }
.pl-order-btns { display: flex; gap: 4px; margin-left: auto; }
.pl-order-btns .btn { width: 44px; min-height: 44px; padding: 0; }
.pl-sent { color: var(--qf-correct); padding-block: 4px; font-weight: 500; animation: pl-pop .25s var(--ui-ease) both; }
.pl-sent::before { content: '✓ '; }
@media (prefers-reduced-motion: reduce) { .pl-waiting > .qf-avatar { animation: none; } }

/* Wager and scorecard. */
.pl-wager { display: flex; flex-direction: column; gap: 12px; }
.pl-wager-presets { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.pl-wager-presets .btn { padding-inline: 4px; }
.pl-wager-value, .pl-result .big { font-size: clamp(2rem, 1.5rem + 4vw, 3rem); font-weight: 500; font-family: var(--qf-font-mono); line-height: 1.1; }
.pl-result { display: grid; gap: 8px; padding: 20px 16px; animation: pl-pop .35s var(--ui-ease) both; border-left: 4px solid var(--pl-verdict, transparent); }
.pl-result > * { min-width: 0; }
.pl-result.correct { --pl-verdict: var(--qf-correct); }
.pl-result.wrong { --pl-verdict: var(--qf-wrong); }
.pl-result.partial { --pl-verdict: var(--qf-accent); }
.pl-result .verdict { color: var(--pl-verdict, var(--qf-text)); font-weight: 500; }
.pl-streak, .pl-correct-answer { color: var(--qf-text-muted); }
.pl-correct-answer strong { color: var(--qf-text); }
.pl-expl { line-height: 1.5; }
.pl-lb, .pl-noms { display: grid; gap: 4px; }
.pl-lb-row, .pl-nom { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 8px; border-radius: 8px; background: var(--qf-card); }
.pl-lb-row.me { outline: 1px solid var(--qf-accent); outline-offset: -1px; }
.pl-lb-row .rank { flex: 0 0 24px; text-align: center; color: var(--qf-text-muted); }
.pl-lb-row .name { flex: 1 1 72px; min-width: 0; }
.pl-lb-row .score { flex: 0 1 auto; min-width: 0; max-width: 40%; margin-left: auto; text-align: right; font-family: var(--qf-font-mono); }

/* In flow so wrapped controls always have space beneath the game. */
.pl-host-panel {
  position: sticky; bottom: max(8px, env(safe-area-inset-bottom)); z-index: 100; align-self: flex-end;
  display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 4px; max-width: 100%;
  padding: 4px; border: 1px solid var(--pl-line); border-radius: 12px; background: var(--qf-card);
}
.pl-host-panel .btn { min-height: 44px; font-size: .875rem; padding: 4px 8px; }
.pl-host-panel .btn-icon { min-width: 44px; }

/* The preview is scaled inside its own frame, independent of the editor viewport. */
.preview-phone .pl-app { min-height: 100%; height: 100%; overflow: auto; }
.preview-phone .pl-content { min-height: 100%; }
.preview-phone .pl-app > .qf-bg { position: absolute; }
