/* The screens before the story on a phone and in the iPhone app (owner 2026-10-20: "pre game ui, the new story tables
   screen needs mobile improvement, login screen as well"): the log in, your tables, the new race and the waiting room,
   in the phone chat's own look (public/ui-proto). html.phone-ui comes from public/phone-flag.js; body.pg marks one of
   these screens (app.js, login.html). Nothing here reaches a computer.

   The colors follow the phone (owner: "dark theme to match iphone so we dont blind people"): the night when the
   iPhone is in dark mode, the chat's paper only when it is in light mode. The main stylesheet's own tokens follow too,
   so a form, a sheet or a note inside these screens matches them. */

html:not(.phone-ui) .pg-only {
  display: none !important;
}

html.phone-ui body.pg {
  --pg-page: #0b0d14;
  --pg-text: #f6f1e4;
  --pg-text-2: #cfc6b0;
  --pg-accent: #b79cff;
  --pg-on-accent: #100f17;
  --pg-bad: #ff8a8a;
  --pg-sheet: #151824;
  --pg-dark: #2a1d24;
  --pg-rule: color-mix(in srgb, var(--pg-text) 15%, transparent);
  --pg-pad: max(22px, env(safe-area-inset-left));
  --bg: var(--pg-page);
  --bg-2: var(--pg-page);
  --surface: var(--pg-sheet);
  --surface-2: color-mix(in srgb, var(--pg-text) 8%, var(--pg-sheet));
  --line: var(--pg-rule);
  --line-2: color-mix(in srgb, var(--pg-text) 28%, transparent);
  --text: var(--pg-text);
  --muted: var(--pg-text-2);
  --faint: color-mix(in srgb, var(--pg-text-2) 80%, transparent);
  --accent: var(--pg-accent);
  --accent-ink: var(--pg-on-accent);
  --bad: var(--pg-bad);
  color-scheme: dark;
  background: var(--pg-page);
  background-image: none;
  color: var(--pg-text);
  font-family: var(--serif);
}

@media (prefers-color-scheme: light) {
  html.phone-ui body.pg {
    --pg-page: #f5efe3;
    --pg-text: #1b120d;
    --pg-text-2: #5a4a3a;
    --pg-accent: #9a5be0;
    --pg-on-accent: #fff;
    --pg-bad: #c4342b;
    --pg-sheet: #fbf7ee;
    color-scheme: light;
  }
}

/* the game's own top bar steps aside: each screen has its own */
html.phone-ui body.pg .topbar {
  display: none;
}

html.phone-ui body.pg .view {
  padding: 0;
  max-width: none;
}

/* ---------- the screen: a top line, the body, the main button at the bottom ---------- */

.pg-screen {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

.pg-top {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: max(6px, env(safe-area-inset-top)) var(--pg-pad) 6px;
}

.pg-brand {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 9px;
  font: 10px var(--pixel);
  letter-spacing: 0.04em;
}

.pg-brand img {
  width: 20px;
  height: 20px;
  image-rendering: pixelated;
}

.pg-icon,
.pg-back {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  margin: 0 -8px;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}

.pg-icon .px-icon,
.pg-back .px-icon {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.pg-back {
  font: 28px/1 var(--serif);
}

.pg-crumb {
  flex: 1;
  font: 9px var(--pixel);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.pg-me {
  display: block;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid var(--pg-text);
  background: var(--pg-dark);
}

.pg-face {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}

.pg-body {
  flex: 1;
  padding: 0 var(--pg-pad) 18px;
}

.pg-body h1 {
  margin: 10px 0 6px;
  font: 600 32px/1.1 var(--serif);
  letter-spacing: -0.01em;
}

.pg-lead {
  margin: 0 0 18px;
  font: italic 16px/1.45 var(--serif);
  color: var(--pg-text-2);
}

.pg-label,
.pg-body label.pg-label {
  display: block;
  margin: 22px 0 6px;
  font: 8px var(--pixel);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--pg-text-2);
}

/* a field: the words on a line, the line turns violet while typing */
html.phone-ui body.pg .pg-field,
html.phone-ui body.pg .pg-more input:not([type="radio"]):not([type="checkbox"]),
html.phone-ui body.pg .pg-more textarea,
html.phone-ui body.pg .pg-more select {
  width: 100%;
  padding: 4px 0 9px;
  border: 0;
  border-bottom: 2px solid var(--pg-text);
  border-radius: 0;
  background: transparent;
  color: var(--pg-text);
  font: 21px/1.3 var(--serif);
  outline: none;
}

html.phone-ui body.pg .pg-more input:not([type="radio"]):not([type="checkbox"]),
html.phone-ui body.pg .pg-more textarea,
html.phone-ui body.pg .pg-more select {
  font-size: 17px;
}

html.phone-ui body.pg .pg-field:focus,
html.phone-ui body.pg .pg-more input:focus,
html.phone-ui body.pg .pg-more textarea:focus,
html.phone-ui body.pg .pg-more select:focus {
  border-color: var(--pg-accent);
}

html.phone-ui body.pg .pg-field::placeholder,
html.phone-ui body.pg .pg-more textarea::placeholder {
  color: color-mix(in srgb, var(--pg-text) 38%, transparent);
  font-style: italic;
}

.pg-foot {
  position: sticky;
  bottom: 0;
  z-index: 2;
  padding: 12px var(--pg-pad) max(14px, calc(env(safe-area-inset-bottom) + 6px));
  background: var(--pg-page);
}

.pg-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  height: 54px;
  border: 0;
  background: var(--pg-accent);
  color: var(--pg-on-accent);
  font: 11px var(--pixel);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
}

.pg-cta:active {
  filter: brightness(0.92);
}

.pg-cta:disabled {
  opacity: 0.5;
}

.pg-note {
  margin: 10px 0 0;
  text-align: center;
  font: italic 13.5px/1.45 var(--serif);
  color: var(--pg-text-2);
}

.pg-fine {
  font: italic 13.5px/1.45 var(--serif);
  color: var(--pg-text-2);
}

html.phone-ui body.pg .form-status {
  margin: 10px 0 0;
  font: italic 14px/1.4 var(--serif);
}

html.phone-ui body.pg .form-status.bad {
  color: var(--pg-bad);
}

/* ---------- your tables ---------- */

.pg-rows {
  border-top: 1px solid var(--pg-rule);
}

.pg-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 12px;
  padding: 16px 0 15px;
  border-bottom: 1px solid var(--pg-rule);
  color: inherit;
  text-decoration: none;
}

.pg-row b {
  font: 600 20px/1.2 var(--serif);
  overflow-wrap: anywhere;
}

.pg-tag {
  align-self: center;
  justify-self: end;
  max-width: 44vw;
  overflow: hidden;
  text-overflow: ellipsis;
  font: 8px var(--pixel);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--pg-text-2);
  white-space: nowrap;
}

.pg-tag.hot {
  color: var(--pg-accent);
}

.pg-who {
  grid-column: 1 / -1;
  font: italic 15px/1.4 var(--serif);
  color: var(--pg-text-2);
}

.pg-when {
  grid-column: 1 / -1;
  font: 12.5px var(--serif);
  color: var(--pg-text-2);
  opacity: 0.8;
}

.pg-section {
  margin: 30px 0 8px;
}

/* ---------- the new race ---------- */

.pg-more {
  margin-top: 26px;
  border-top: 1px solid var(--pg-rule);
  border-bottom: 1px solid var(--pg-rule);
}

.pg-more > summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 0;
  font: 600 16px var(--serif);
  list-style: none;
  cursor: pointer;
}

.pg-more > summary::-webkit-details-marker {
  display: none;
}

.pg-more > summary::after {
  content: "›";
  font: italic 20px/1 var(--serif);
  color: var(--pg-text-2);
  transition: transform 0.2s;
}

.pg-more[open] > summary::after {
  transform: rotate(90deg);
}

.pg-more-body {
  padding-bottom: 18px;
}

.pg-more-body h2 {
  margin: 22px 0 8px;
  font: 8px var(--pixel);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--pg-text-2);
}

.pg-more-body label:not(.model-option):not(.toggle-row) {
  margin: 14px 0;
  font: 600 15px var(--serif);
}

.pg-more-body .fine {
  font: italic 13.5px/1.45 var(--serif);
  color: var(--pg-text-2);
}

html.phone-ui body.pg .model-option {
  border-color: var(--pg-rule);
  background: transparent;
}

html.phone-ui body.pg .pg-more .testing {
  margin-top: 18px;
}

.pg-opts {
  margin: 12px 0 0;
  font: italic 14px/1.7 var(--serif);
  color: var(--pg-text-2);
}

.pg-opts b {
  font-style: normal;
  font-weight: 600;
  color: var(--pg-text);
}

.pg-more[open] + .pg-opts {
  display: none;
}

/* ---------- the waiting room ---------- */

.play.pg-play {
  display: block;
}

.pg-pic .stage-box {
  border: 0;
  border-radius: 0;
}

.pg-lobby .pg-body h1 {
  margin-top: 16px;
  font-size: 28px;
}

.pg-seats {
  display: flex;
  gap: 14px;
  margin: 16px 0 6px;
  overflow-x: auto;
}

.pg-seat {
  flex: none;
  width: 64px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--pg-text-2);
  font: italic 12.5px/1.3 var(--serif);
  text-align: center;
  overflow-wrap: anywhere;
}

.pg-seat .pg-ring {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin-bottom: 6px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid var(--pg-text);
  background: var(--pg-dark);
}

.pg-seat.mine {
  color: var(--pg-text);
  font-style: normal;
  font-weight: 600;
}

.pg-seat.open .pg-ring {
  border: 2px dashed color-mix(in srgb, var(--pg-text) 35%, transparent);
  background: transparent;
  font: 22px var(--serif);
  color: color-mix(in srgb, var(--pg-text) 45%, transparent);
}

button.pg-seat.open {
  cursor: pointer;
}

.pg-racer {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 14px;
  align-items: start;
  padding: 14px 0;
  margin-top: 14px;
  border-top: 1px solid var(--pg-rule);
  border-bottom: 1px solid var(--pg-rule);
}

.pg-racer + .pg-racer {
  margin-top: 0;
  border-top: 0;
}

.pg-racer .seat-face {
  grid-row: span 4;
  border-radius: 0;
  border: 2px solid var(--pg-text);
}

.pg-racer b {
  font: 600 19px/1.2 var(--serif);
}

.pg-pas {
  font: italic 14.5px/1.4 var(--serif);
  color: var(--pg-text-2);
}

.pg-pas-btn {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-decoration: underline dotted color-mix(in srgb, currentColor 50%, transparent);
  text-underline-offset: 3px;
  cursor: pointer;
}

.pg-links {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 18px;
  margin-top: 6px;
}

.pg-link {
  padding: 6px 0;
  border: 0;
  background: none;
  color: var(--pg-accent);
  font: 8px/1.4 var(--pixel);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-decoration: none;
  text-align: left;
  cursor: pointer;
}

.pg-link:disabled {
  color: var(--pg-text-2);
  opacity: 0.7;
  cursor: default;
}

.pg-racer .blood-pick {
  grid-column: 2;
  margin: 4px 0 0;
  font: italic 13.5px/1.45 var(--serif);
  color: var(--pg-text-2);
}

.pg-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 15px 0;
  border: 0;
  border-bottom: 1px solid var(--pg-rule);
  background: none;
  color: inherit;
  font: 600 16px var(--serif);
  text-align: left;
  cursor: pointer;
}

.pg-line i {
  font: normal 8px var(--pixel);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--pg-accent);
}

html.phone-ui body.pg .planning {
  margin: 18px 0 0;
  border-color: var(--pg-rule);
  background: transparent;
}

html.phone-ui body.pg .play-side,
html.phone-ui body.pg .status-line:empty {
  display: none;
}

html.phone-ui body.pg .status-line {
  padding: 0 var(--pg-pad);
  font: italic 14px/1.4 var(--serif);
}

/* the table's sheet (sound, blood, table talk, delete) in the same colors */
html.phone-ui body.pg .chat-sheet-title {
  color: var(--pg-accent);
}

/* ---------- the look editor (#/look) ---------- */

/* the top line and the racer stay in view while the rows scroll under them (not on a phone held sideways) */
.pg-look-head {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--pg-page);
}

@media (max-height: 560px) {
  .pg-look-head {
    position: static;
  }
}

/* the picture: the portrait and the whole figure on the night, in either mode, like the waiting room's */
.pg-look-pic {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 18px;
  padding: 12px var(--pg-pad);
  background: #10131f;
}

.pg-look-pic canvas {
  display: block;
  image-rendering: pixelated;
}

.pg-look .pg-body h1 {
  margin-top: 18px;
  font-size: 28px;
  overflow-wrap: anywhere;
}

/* a friend's long name: the crumb ends in dots, Save takes two lines */
.pg-look .pg-crumb {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pg-look .pg-cta {
  padding: 0 14px;
  line-height: 1.6;
  text-align: center;
  overflow-wrap: anywhere;
}

/* a row: the name on the left, previous and next on the right (the colours and the hair styles under them) */
.pg-look .look-fields {
  display: block;
  border-top: 1px solid var(--pg-rule);
}

.pg-look .look-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border: 0;
  border-bottom: 1px solid var(--pg-rule);
  border-radius: 0;
  background: none;
}

.pg-look .look-field > :nth-child(n + 3) {
  grid-column: 1 / -1;
}

.pg-look .look-field > :nth-child(n + 3):last-child {
  margin-bottom: 8px;
}

.pg-look .look-label {
  font: 600 16px/1.25 var(--serif);
}

.pg-look .stepper {
  grid-template-columns: 44px 128px 44px;
  gap: 0;
}

.pg-look .step {
  height: 48px;
  padding: 0 0 4px;
  border: 0;
  border-radius: 0;
  background: none;
  color: var(--pg-accent);
  font: 30px/1 var(--serif);
}

.pg-look .step:active {
  opacity: 0.6;
}

.pg-look .look-value {
  display: flex;
  flex-direction: column;
  align-items: center;
  font: 16px/1.25 var(--serif);
  text-align: center;
}

.pg-look .look-count {
  margin: 2px 0 0;
  font: 7px var(--pixel);
  letter-spacing: 0.06em;
  color: var(--pg-text-2);
}

/* colours: squares in a grid, every one in sight */
.pg-look .swatches {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(36px, 1fr));
  gap: 8px;
}

.pg-look .swatch {
  width: auto;
  height: auto;
  aspect-ratio: 1;
  border: 0;
  border-radius: 0;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--pg-text) 25%, transparent);
}

.pg-look .swatch[aria-pressed="true"],
.pg-look .hair-tile[aria-pressed="true"] {
  outline: 2px solid var(--pg-accent);
  outline-offset: 2px;
}

/* hair: the groups as words in a line that scrolls sideways, the racer's own head in each style under it */
.pg-look .hair-chips {
  flex-wrap: nowrap;
  gap: 20px;
  margin: 0 calc(-1 * var(--pg-pad));
  padding: 0 var(--pg-pad);
  overflow-x: auto;
  scrollbar-width: none;
}

.pg-look .hair-chips::-webkit-scrollbar {
  display: none;
}

.pg-look .hair-chip {
  flex: none;
  min-height: 44px;
  padding: 0;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: none;
  color: var(--pg-text-2);
  font: 15px var(--serif);
  white-space: nowrap;
}

.pg-look .hair-chip[aria-pressed="true"] {
  border-bottom-color: var(--pg-accent);
  background: none;
  color: var(--pg-accent);
  font-weight: 600;
}

.pg-look .hair-chip-n {
  color: inherit;
  opacity: 0.7;
  font-size: 12px;
}

.pg-look .hair-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.pg-look .hair-tile {
  border: 0;
  border-radius: 0;
  background: #10131f;
}

.pg-look .hair-caption {
  font: italic 14px var(--serif);
  color: var(--pg-text-2);
}

/* what the narrator is told, the outfit to try, the notes */
.pg-look .look-desc {
  margin: 0;
  font: 16px/1.55 var(--serif);
}

.pg-look .pg-links {
  margin: 8px 0 4px;
}

.pg-look .pg-link {
  min-height: 44px;
}

.pg-look .pg-fine {
  margin: 10px 0 0;
}

.pg-look .pg-foot .form-status:empty {
  display: none;
}

.pg-skip {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  margin-top: 4px;
  text-align: center;
}

/* ---------- a box on a phone: a sheet from the bottom ---------- */

html.phone-ui .modal-backdrop {
  place-items: end stretch;
  padding: 0;
}

html.phone-ui .modal {
  width: 100%;
  max-height: 88vh;
  padding: 20px max(20px, env(safe-area-inset-right)) max(20px, calc(env(safe-area-inset-bottom) + 8px)) max(20px, env(safe-area-inset-left));
  border-width: 1px 0 0;
  border-radius: 16px 16px 0 0;
}

html.phone-ui .modal.wide {
  width: 100%;
}

html.phone-ui .modal-actions {
  flex-direction: column-reverse;
  align-items: stretch;
}

html.phone-ui .modal-actions .btn {
  min-height: 48px;
  white-space: normal;
}

html.phone-ui body.pg .modal-actions .btn.primary {
  border: 0;
  border-radius: 0;
  background: var(--pg-accent);
  color: var(--pg-on-accent);
  font: 10px var(--pixel);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

html.phone-ui body.pg .modal h2 {
  font: 600 22px/1.2 var(--serif);
}

/* a note pops up at the top, over no button (the main buttons and the sheets' are at the bottom) */
html.phone-ui .toast {
  top: max(12px, calc(env(safe-area-inset-top) + 6px));
  bottom: auto;
}

/* the menu of your tables: a list of plain lines */
.pg-menu {
  display: grid;
}

.pg-menu > * {
  display: block;
  padding: 15px 0;
  border: 0;
  border-bottom: 1px solid var(--pg-rule);
  background: none;
  color: inherit;
  font: 600 17px var(--serif);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.pg-menu > :first-child {
  border-top: 1px solid var(--pg-rule);
}

/* ---------- log in (login.html) ---------- */

html.phone-ui body.pg.login-page .view {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

html.phone-ui body.pg #login-form {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: max(28px, calc(env(safe-area-inset-top) + 16px)) var(--pg-pad) 0;
}

html.phone-ui body.pg #login-form > h1,
html.phone-ui body.pg #login-form > .muted,
html.phone-ui body.pg #login-form .inline-form > .btn {
  display: none;
}

html.phone-ui body.pg #login-form .inline-form {
  display: block;
  margin: 0;
}

html.phone-ui body.pg #login-form .pg-foot {
  margin: auto calc(-1 * var(--pg-pad)) 0;
  padding-top: 24px;
}

.pg-logo {
  display: grid;
  justify-items: center;
  margin: 6vh 0 7vh;
}

.pg-logo img {
  width: 104px;
  height: 104px;
  image-rendering: pixelated;
}

.pg-logo-name {
  margin-top: 22px;
  font: 24px var(--pixel);
  letter-spacing: 0.06em;
}

.pg-logo-sub {
  margin-top: 12px;
  font: italic 16px var(--serif);
  color: var(--pg-text-2);
}
