/* Phone layout (≤760px). Every rule below is scoped to phones except the tab
   bar's default hide, so desktop and tablet pages render exactly as before.
   Built for iOS Safari and Android Chrome: safe-area insets, dynamic viewport
   units, 44px touch targets and 16px inputs (no focus zoom). */
.m-tabbar {
  display: none;
}

@media (max-width: 760px) {
  :root {
    --m-gutter: max(16px, env(safe-area-inset-left, 0px));
    --m-gutter-end: max(16px, env(safe-area-inset-right, 0px));
    --m-tabbar: 64px;
    --m-radius: 12px;
    /* Spacing scale: tight within a group, generous between groups. */
    --m-tight: 8px;
    --m-group: 16px;
    --m-gap: 24px;
  }
  html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
  }
  html,
  body {
    overscroll-behavior-y: none;
  }
  body {
    -webkit-tap-highlight-color: transparent;
  }
  a,
  button,
  input,
  select,
  label {
    touch-action: manipulation;
  }

  /* Author display rules must never re-show hidden phone elements. */
  .tp-mobile [hidden] {
    display: none !important;
  }

  /* ---- Shell: no rail, no top bar; a bottom tab bar instead ---- */
  .rail,
  .topbar,
  .menu-toggle,
  body.nav-open::after {
    display: none !important;
  }
  .shell {
    margin-left: 0;
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--bg);
  }
  main,
  main:has(> .rd-page),
  main:has(> :not(.rd-page)) {
    padding: calc(env(safe-area-inset-top, 0px) + 20px) var(--m-gutter-end)
      calc(var(--m-tabbar) + env(safe-area-inset-bottom, 0px) + 24px) var(--m-gutter);
  }
  .engine-progress {
    padding-inline: var(--m-gutter) var(--m-gutter-end);
  }
  .engine-progress:empty {
    display: none;
  }

  .m-tabbar {
    position: fixed;
    inset: auto 0 0;
    z-index: 50;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    padding: 8px var(--m-gutter-end) calc(env(safe-area-inset-bottom, 0px) + 8px) var(--m-gutter);
    background: rgb(14 19 33 / 94%);
    border-top: 1px solid var(--divider);
    -webkit-backdrop-filter: saturate(140%) blur(16px);
    backdrop-filter: saturate(140%) blur(16px);
  }
  .m-tab {
    display: grid;
    justify-items: center;
    align-content: center;
    gap: 4px;
    min-height: 48px;
    color: var(--outline);
    font: 500 11px/1.1 var(--font);
    text-decoration: none;
    border-radius: 12px;
  }
  .m-tab-ic {
    display: grid;
    place-items: center;
    width: 52px;
    height: 30px;
    border-radius: 999px;
    transition: background-color 160ms ease-out;
  }
  .m-tab-ic svg {
    width: 20px;
    height: 20px;
  }
  .m-tab[aria-current="page"] {
    color: var(--accent-300);
  }
  .m-tab[aria-current="page"] .m-tab-ic {
    background: rgb(29 99 255 / 18%);
  }
  .m-tab:focus-visible {
    outline: 2px solid var(--accent-300);
    outline-offset: -2px;
  }

  /* ---- Page frame (Diagnostics Mobile design) ---- */
  main:has(> .ph-page) {
    padding-top: env(safe-area-inset-top, 0px);
  }
  .ph-page {
    display: grid;
    gap: 16px;
    min-width: 0;
    color: var(--text);
  }
  .ph-page [hidden] {
    display: none !important;
  }
  .ph-body,
  .ph-stack {
    display: grid;
    gap: 16px;
    min-width: 0;
  }
  svg.ph-ic {
    width: 16px;
    height: 16px;
    flex: none;
    display: block;
    stroke-width: 1.8;
  }
  .ph-chev {
    display: inline-grid;
    place-items: center;
    flex: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgb(29 99 255 / 16%);
    color: var(--accent-300);
  }
  svg.ph-chev {
    width: 24px;
    height: 24px;
    padding: 4px;
    box-sizing: border-box;
  }
  .ph-card.is-link:active,
  .ph-row.has-chev:active {
    background: var(--surface-high);
  }

  /* Headers: sticky, edge to edge, blurred */
  .ph-head {
    display: grid;
    margin-inline: calc(var(--m-gutter) * -1) calc(var(--m-gutter-end) * -1);
    padding-inline: var(--m-gutter) var(--m-gutter-end);
  }
  .ph-head.is-sticky {
    position: sticky;
    top: 0;
    z-index: 5;
    padding-top: calc(env(safe-area-inset-top, 0px) + 8px);
    background: rgb(14 19 33 / 94%);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
  }
  .ph-head.is-detail {
    gap: 4px;
    padding-top: calc(env(safe-area-inset-top, 0px) + 4px);
  }
  .ph-head-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 44px;
  }
  .ph-title {
    margin: 0;
    font: 700 26px/34px var(--headline);
    letter-spacing: -0.025em;
  }
  .ph-head-count {
    color: var(--text-muted-80);
    font: 500 13px/20px var(--font);
    font-variant-numeric: tabular-nums;
  }
  .ph-account {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 36px;
    max-width: 55%;
    padding: 0 12px 0 10px;
    border: 1px solid var(--divider-strong);
    border-radius: 999px;
    color: var(--text);
    font: 500 13px/1 var(--font);
    text-decoration: none;
  }
  .ph-account span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .ph-logo {
    width: 15px;
    height: 15px;
    flex: none;
  }
  /* Scrolls sideways only: no vertical drag, and a sideways fling never
     chains into the page. The rule is drawn inside so nothing overflows down. */
  .ph-sections {
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    margin: 6px calc(var(--m-gutter) * -1) 0 calc(var(--m-gutter) * -1);
    padding: 0 6px;
    box-shadow: inset 0 -1px 0 var(--divider);
  }
  .ph-sections::-webkit-scrollbar {
    display: none;
  }
  .ph-section,
  .ph-tab {
    position: relative;
    flex: none;
    display: grid;
    place-items: center;
    min-height: 44px;
    padding: 0 10px;
    color: var(--text-muted-80);
    font: 500 14px/20px var(--font);
    text-decoration: none;
    white-space: nowrap;
  }
  .ph-section[aria-current="page"],
  .ph-tab[aria-current="page"] {
    color: var(--text);
    font-weight: 600;
  }
  .ph-section[aria-current="page"]::after,
  .ph-tab[aria-current="page"]::after {
    content: "";
    position: absolute;
    inset: auto 10px -1px;
    height: 2px;
    border-radius: 999px;
    background: var(--accent);
  }
  .ph-tabs {
    display: grid;
    grid-template-columns: repeat(var(--n), minmax(0, 1fr));
    margin: 10px calc(var(--m-gutter) * -1) 0;
    padding: 0 6px;
    border-bottom: 1px solid var(--divider);
  }
  .ph-tab {
    padding: 0 4px;
  }
  .ph-tab[aria-current="page"]::after {
    inset: auto 8px -1px;
  }
  .ph-section[aria-current="page"]::after {
    bottom: 0;
  }
  .ph-back {
    justify-self: start;
    display: flex;
    align-items: center;
    gap: 6px;
    min-height: 40px;
    margin-left: -6px;
    padding: 0 6px;
    color: var(--accent-300);
    font: 600 15px/20px var(--font);
    text-decoration: none;
  }
  .ph-back svg.ph-ic {
    width: 22px;
    height: 22px;
  }
  .ph-detail-title {
    margin: 0;
    font: 700 24px/30px var(--headline);
    letter-spacing: -0.025em;
    text-wrap: pretty;
  }
  .ph-hero-name {
    display: flex;
    align-items: center;
    gap: 10px;
  }
  .ph-hero-name .ph-detail-title {
    font-size: 22px;
    line-height: 28px;
  }
  .ph-hero {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin-top: 8px;
  }
  .ph-hero b {
    font: 700 48px/1 var(--headline);
    letter-spacing: -0.03em;
    font-variant-numeric: tabular-nums;
  }
  .ph-hero > span:last-child {
    color: rgb(195 197 216 / 70%);
    font: 500 12px/16px var(--font);
  }

  /* Filter scope row and chips */
  .ph-filter-row {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    padding: 10px 0 12px;
  }
  .ph-filter-btn {
    flex: none;
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 36px;
    padding: 0 12px;
    border: 1px solid var(--divider-strong);
    border-radius: 999px;
    background: transparent;
    color: var(--text);
    font: 600 13px/1 var(--font);
    cursor: pointer;
  }
  .ph-chips {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
    overflow: hidden;
  }
  .ph-chip {
    flex: none;
    display: flex;
    align-items: center;
    gap: 5px;
    color: var(--text-muted);
    font: 500 12.5px/16px var(--font);
  }
  .ph-chip svg.ph-ic {
    width: 15px;
    height: 15px;
    color: var(--outline);
  }
  .ph-chip[data-tc="rapid"] svg { color: #497ef7; }
  .ph-chip[data-tc="blitz"] svg { color: #00a3ab; }
  .ph-chip[data-tc="bullet"] svg { color: #d1a22a; }
  .ph-dot {
    width: 12px;
    height: 12px;
    border-radius: 999px;
    box-shadow: inset 0 0 0 1.25px var(--outline);
  }
  .ph-dot.is-white { background: var(--text); }
  .ph-dot.is-black { background: #2a2f3e; }
  .ph-dot.is-both { background: linear-gradient(90deg, var(--text) 50%, #2a2f3e 50%); }

  /* Segmented controls */
  .ph-seg {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    gap: 2px;
    padding: 3px;
    border-radius: 12px;
    background: var(--t64-surface-lowest);
  }
  .ph-seg button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 36px;
    padding: 0 4px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--text-muted-80);
    font: 500 13.5px/1 var(--font);
    cursor: pointer;
  }
  .ph-seg.is-period button {
    min-height: 38px;
  }
  .ph-seg button.is-on {
    background: var(--surface-high);
    color: var(--text);
  }
  .ph-controls {
    display: grid;
    gap: 8px;
    margin-bottom: 12px;
  }
  .ph-seg.is-side button {
    flex: 1;
  }
  .ph-seg.is-sheet {
    background: var(--surface-low);
  }
  .ph-seg.is-sheet button {
    min-height: 40px;
  }
  .ph-seg.is-sheet button.is-on {
    background: var(--surface-highest);
    font-weight: 600;
  }
  .ph-tc-dot {
    width: 7px;
    height: 7px;
    border-radius: 999px;
  }
  .ph-tc-dot[data-tc="rapid"] { background: #497ef7; }
  .ph-tc-dot[data-tc="blitz"] { background: #00a3ab; }
  .ph-tc-dot[data-tc="bullet"] { background: #d1a22a; }

  /* Cards */
  .ph-card {
    display: grid;
    min-width: 0;
    padding: 0 16px;
    border: 1px solid var(--divider-soft);
    border-radius: 12px;
    background: var(--surface-low);
    color: var(--text);
    text-decoration: none;
  }
  .ph-card.is-link {
    position: relative;
    padding-bottom: 16px;
  }
  .ph-card-cover {
    color: inherit;
    text-decoration: none;
  }
  .ph-card-cover::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 12px;
  }
  .ph-page .ph-card-cover:focus-visible {
    outline: none;
  }
  .ph-card-cover:focus-visible::after {
    outline: 2px solid var(--accent-300);
    outline-offset: 2px;
  }
  .ph-card.is-chart {
    padding: 0 12px 10px;
  }
  .ph-card.is-chart .ph-card-head {
    padding: 0 4px;
  }
  .ph-card.is-map {
    padding-bottom: 12px;
    overflow: hidden;
  }
  .ph-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-height: 48px;
  }
  .ph-card-title {
    display: flex;
    align-items: center;
    gap: 4px;
    margin: 0;
    font: 600 15px/20px var(--headline);
  }
  .ph-card-label {
    flex: none;
    white-space: nowrap;
    color: rgb(195 197 216 / 70%);
    font: 500 12px/16px var(--font);
  }
  .ph-card-total {
    font: 700 18px/1 var(--headline);
    font-variant-numeric: tabular-nums;
  }
  .ph-card-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 48px;
    border-top: 1px solid var(--divider);
  }
  .ph-legend {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted-80);
    font: 500 11.5px/1 var(--font);
  }
  .ph-legend .ph-side {
    width: 3px;
    height: 12px;
  }
  .ph-legend .ph-side.is-black {
    margin-left: 6px;
  }
  .ph-chart-head {
    display: flex;
    justify-content: flex-end;
    min-height: 24px;
    padding: 12px 4px 6px;
  }
  .ph-readout {
    color: var(--text);
    font: 600 12px/16px var(--font);
    font-variant-numeric: tabular-nums;
  }

  /* List rows */
  .ph-row,
  .ph-rating-row,
  .ph-game {
    display: grid;
    align-items: center;
    gap: 12px;
    min-height: 60px;
    padding: 10px 0;
    border-top: 1px solid var(--divider);
    color: var(--text);
    text-decoration: none;
    font-variant-numeric: tabular-nums;
  }
  .ph-card-head + .ph-row,
  .ph-card-head + .ph-rating-row {
    border-top: 1px solid var(--divider);
  }
  .ph-card.is-games > .ph-game:first-child,
  .ph-card:not(:has(.ph-card-head)) > .ph-row:first-child {
    border-top: 0;
  }
  .ph-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }
  .ph-row.has-chev {
    grid-template-columns: minmax(0, 1fr) auto 24px;
    min-height: 64px;
  }
  .ph-row.has-side {
    grid-template-columns: 4px minmax(0, 1fr) auto;
  }
  .ph-row.has-side.has-chev {
    grid-template-columns: 4px minmax(0, 1fr) auto 24px;
  }
  .ph-row-text {
    display: grid;
    gap: 2px;
    min-width: 0;
  }
  .ph-row-name {
    font: 500 14.5px/20px var(--font);
    overflow-wrap: anywhere;
  }
  .ph-row-sub {
    color: var(--outline);
    font: 400 12px/16px var(--font);
  }
  .ph-row-value {
    font: 700 16px/1 var(--headline);
  }
  .ph-row-value.is-muted {
    color: rgb(195 197 216 / 60%);
  }
  .is-up { color: var(--t64-cyan); }
  .is-down { color: var(--t64-rose); }
  .ph-side {
    width: 4px;
    height: 28px;
    border-radius: 2px;
  }
  .ph-side.is-white {
    background: var(--text);
  }
  .ph-side.is-black {
    background: #2a2f3e;
    box-shadow: inset 0 0 0 1.25px var(--outline);
  }
  .ph-rating-row {
    grid-template-columns: 36px minmax(0, 1fr) auto auto 16px;
    min-height: 64px;
    padding: 12px 0;
  }
  .ph-class-ic {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 10px;
  }
  .ph-class-ic svg.ph-ic {
    width: 19px;
    height: 19px;
  }
  .ph-class-ic.is-small {
    width: 30px;
    height: 30px;
    border-radius: 9px;
  }
  .ph-class-ic.is-small svg.ph-ic {
    width: 16px;
    height: 16px;
  }
  .ph-class-ic[data-tc="rapid"] { color: #497ef7; background: rgb(73 126 247 / 15%); }
  .ph-class-ic[data-tc="blitz"] { color: #00a3ab; background: rgb(0 163 171 / 15%); }
  .ph-class-ic[data-tc="bullet"] { color: #d1a22a; background: rgb(209 162 42 / 15%); }
  .ph-rating-name {
    font: 600 15px/20px var(--headline);
  }
  .ph-rating-value {
    font: 700 18px/1 var(--headline);
  }
  .ph-delta {
    min-width: 40px;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--surface-high);
    color: var(--text-muted);
    font: 500 12px/16px var(--font);
    text-align: center;
  }
  .ph-delta.is-up { background: rgb(123 208 255 / 14%); color: var(--t64-cyan); }
  .ph-delta.is-down { background: rgb(255 180 171 / 14%); color: var(--t64-rose); }
  .ph-hero .ph-delta {
    font-size: 13px;
    line-height: 18px;
  }

  /* Tiles and stats */
  .ph-wdl,
  .ph-tiles {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    padding-bottom: 16px;
  }
  .ph-tiles.is-two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .ph-wdl-tile,
  .ph-tile {
    display: grid;
    justify-items: center;
    gap: 4px;
    padding: 12px 6px;
    border-radius: 10px;
    text-align: center;
    font-variant-numeric: tabular-nums;
  }
  .ph-wdl-tile b,
  .ph-tile b {
    font: 700 22px/26px var(--headline);
    letter-spacing: -0.02em;
  }
  .ph-wdl-tile span,
  .ph-tile span {
    color: var(--text-muted);
    font: 500 12.5px/16px var(--font);
  }
  .ph-wdl-tile.is-win { background: rgb(123 208 255 / 12%); color: var(--t64-cyan); }
  .ph-wdl-tile.is-draw { background: rgb(141 144 162 / 16%); color: var(--text); }
  .ph-wdl-tile.is-loss { background: rgb(255 180 171 / 12%); color: var(--t64-rose); }
  .ph-tile {
    background: rgb(29 99 255 / 14%);
  }
  .ph-tile b {
    color: var(--accent-300);
  }
  .ph-card > .ph-seg {
    margin: 12px 0;
  }
  .ph-card-head + .ph-seg {
    margin-top: 0;
  }
  .ph-stats {
    display: grid;
    grid-template-columns: repeat(var(--n), minmax(0, 1fr));
    padding: 16px 0;
  }
  .ph-stat {
    display: grid;
    justify-items: center;
    gap: 2px;
    min-width: 0;
    text-align: center;
    font-variant-numeric: tabular-nums;
  }
  .ph-stat b {
    white-space: nowrap;
    font: 700 20px/24px var(--headline);
    letter-spacing: -0.02em;
  }
  .ph-stats.is-big .ph-stat b {
    font-size: 24px;
    line-height: 28px;
  }
  .ph-stat span {
    white-space: nowrap;
    color: rgb(195 197 216 / 75%);
    font: 500 12px/16px var(--font);
  }
  
  
  
  
  
  .ph-share-tiles {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }
  .ph-share-tiles > div {
    display: grid;
    justify-items: center;
    gap: 4px;
    min-width: 0;
    padding: 12px 6px;
    border-radius: 10px;
    background: var(--surface-high);
    text-align: center;
  }
  .ph-share-tiles b {
    font: 700 20px/24px var(--headline);
    font-variant-numeric: tabular-nums;
  }
  .ph-share-tiles span {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-muted);
    font: 500 12.5px/16px var(--font);
  }

  /* Bars */
  .ph-bars {
    display: grid;
    grid-template-columns: repeat(var(--n), minmax(0, 1fr));
    gap: 8px;
    padding-bottom: 14px;
  }
  .ph-bar {
    display: grid;
    justify-items: center;
    gap: 6px;
    min-width: 0;
    color: var(--outline);
    font-variant-numeric: tabular-nums;
  }
  .ph-bar.is-top {
    color: var(--accent-300);
  }
  .ph-bar-value {
    font: 600 11.5px/14px var(--font);
  }
  .ph-bar-track {
    display: flex;
    align-items: flex-end;
    width: 100%;
    height: 96px;
  }
  .ph-bar-track i {
    display: block;
    width: 100%;
    border-radius: 4px;
    background: rgb(73 126 247 / 32%);
  }
  .ph-bar.is-top .ph-bar-track i {
    background: var(--accent);
  }
  .ph-bar-label {
    display: grid;
    justify-items: center;
    white-space: nowrap;
    font: 500 11.5px/14px var(--font);
  }
  .ph-bars[style*="--n:6"] .ph-bar-label,
  .ph-bars[style*="--n:7"] .ph-bar-label {
    font-size: 10.5px;
    line-height: 13px;
  }

  /* Bar charts: game counts and win / draw / loss stacks, with a tap readout */
  .ph-barchart {
    display: grid;
    gap: 10px;
    padding-bottom: 2px;
  }
  .ph-legend-row {
    display: flex;
    gap: 14px;
    color: var(--text-muted);
    font: 500 11.5px/14px var(--font);
  }
  .ph-legend-row span {
    display: flex;
    align-items: center;
    gap: 6px;
  }
  .ph-legend-row i {
    width: 8px;
    height: 8px;
    border-radius: 2px;
  }
  .ph-legend-row .is-win { background: #7bd0ff; }
  .ph-legend-row .is-draw { background: #8d90a2; }
  .ph-legend-row .is-loss { background: #ffb4ab; }
  .ph-chart-frame {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr);
    gap: 6px;
    padding-top: 4px;
  }
  .ph-yaxis {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    color: var(--outline);
    text-align: right;
    font: 400 10.5px/1 var(--font);
    font-variant-numeric: tabular-nums;
  }
  .ph-plot {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    gap: 10px;
    --r: 4px;
  }
  .ph-barchart:has(.ph-wdl-bar) .ph-plot {
    gap: 8px;
    --r: 6px;
  }
  /* Keep bar widths steady when fewer items than slots qualify. */
  .ph-barchart .ph-plot.is-slotted {
    grid-auto-columns: calc((100% - (var(--slots) - 1) * 8px) / var(--slots));
    justify-content: center;
  }
  .ph-barchart .ph-plot.is-dense {
    gap: 3px;
    --r: 2px;
  }
  .ph-bar-btn {
    position: relative;
    display: grid;
    justify-items: center;
    align-content: start;
    gap: 6px;
    min-width: 0;
    padding: 0;
    border: 0;
    background: none;
    color: var(--text);
    font-variant-numeric: tabular-nums;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  /* Fade the other bars and labels while one is chosen, never the readout. */
  .ph-bar-btn.is-dim > :not(.ph-tip) { opacity: 0.5; }
  .ph-bar-btn:focus-visible {
    outline: 2px solid var(--accent-300);
    outline-offset: 2px;
    border-radius: 4px;
  }
  .ph-bar-col {
    display: flex;
    align-items: flex-end;
    width: 100%;
    height: var(--h);
  }
  .ph-bar-col i {
    display: block;
    width: 100%;
    border-radius: var(--r);
    background: rgb(73 126 247 / 32%);
  }
  .ph-bar-col i.is-top { background: var(--accent); }
  .ph-wdl-bar {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: var(--h);
    overflow: hidden;
    border-radius: var(--r);
  }
  .ph-wdl-bar.is-on {
    outline: 1px solid rgb(181 196 255 / 60%);
    outline-offset: 2px;
  }
  .ph-wdl-bar i { display: block; }
  .ph-wdl-bar .is-loss { background: rgb(255 180 171 / 72%); }
  .ph-wdl-bar .is-draw { background: rgb(141 144 162 / 80%); }
  .ph-wdl-bar .is-win { flex: 1; background: rgb(123 208 255 / 72%); }
  .ph-wdl-bar.is-empty .is-win { opacity: 0; }
  .ph-plot.is-track .ph-wdl-bar {
    background: #1e2333;
    box-shadow: inset 0 0 0 1px rgb(141 144 162 / 18%);
  }
  .ph-bar-btn .ph-bar-label {
    min-height: 14px;
    color: var(--outline);
  }
  .ph-bar-btn.is-peak .ph-bar-label { color: var(--accent-300); }
  /* The bar's own column sizes to its widest child, so a date wider than the bar would widen it. */
  .ph-plot.is-dated > .ph-bar-btn { grid-template-columns: minmax(0, 1fr); }
  /* Date labels wider than their bar stay inside the chart at both ends. */
  .ph-plot.is-dated > .ph-bar-btn:first-child .ph-bar-label { justify-self: start; }
  .ph-plot.is-dated > .ph-bar-btn:last-child .ph-bar-label { justify-self: end; }
  .ph-barchart:has(.ph-wdl-bar) .ph-bar-btn.is-on .ph-bar-label { color: var(--text); }
  .ph-bar-flag {
    display: block;
    width: 22px;
    height: 15px;
    border-radius: 3px;
    background: var(--surface-high);
    box-shadow: 0 0 0 1px rgb(141 144 162 / 25%);
    object-fit: cover;
  }
  .ph-tip {
    position: absolute;
    z-index: 3;
    top: 0;
    left: 0;
    display: grid;
    gap: 1px;
    padding: 8px 10px;
    border: 1px solid rgb(141 144 162 / 30%);
    border-radius: 10px;
    background: var(--surface-high);
    box-shadow: 0 8px 24px rgb(0 0 0 / 40%);
    text-align: left;
    white-space: nowrap;
    pointer-events: none;
  }
  .ph-tip.is-end {
    right: 0;
    left: auto;
  }
  .ph-tip b {
    color: var(--text);
    font: 600 13px/16px var(--font);
  }
  .ph-tip > span {
    color: var(--text-muted);
    font: 400 11.5px/14px var(--font);
  }
  .ph-tip.is-wide {
    top: 6px;
    gap: 6px;
    width: 168px;
    padding: 10px 12px;
  }
  .ph-tip-head {
    display: grid;
    gap: 1px;
  }
  .ph-tip-head span {
    color: var(--outline);
    font: 400 11px/14px var(--font);
  }
  .ph-tip-row {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    color: var(--text-muted);
    font: 500 12px/16px var(--font);
  }
  .ph-tip .ph-tip-row b {
    font: 700 12px/16px var(--font);
  }
  .ph-tip-row b.is-win { color: #7bd0ff; }
  .ph-tip-row b.is-loss { color: #ffb4ab; }
  .ph-xaxis {
    display: grid;
    grid-template-columns: repeat(var(--n), minmax(0, 1fr));
    margin-top: -20px;
    color: var(--outline);
    font: 500 11.5px/14px var(--font);
    font-variant-numeric: tabular-nums;
    pointer-events: none;
  }
  .ph-xaxis.is-ends {
    display: flex;
    justify-content: space-between;
  }
  .ph-mini-seg {
    flex: none;
    display: grid;
    grid-template-columns: repeat(2, auto);
    gap: 2px;
    padding: 2px;
    border-radius: 9px;
    background: #090e1c;
  }
  .ph-mini-seg button {
    min-height: 28px;
    padding: 0 10px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: rgb(195 197 216 / 80%);
    font: 500 12px/1 var(--font);
    cursor: pointer;
  }
  .ph-mini-seg button.is-on {
    background: var(--surface-highest);
    color: var(--text);
  }
  .ph-row.has-flag {
    grid-template-columns: 28px minmax(0, 1fr) auto;
  }
  .ph-flag {
    display: grid;
    place-items: center;
    width: 28px;
    height: 20px;
    overflow: hidden;
    border-radius: 4px;
    background: var(--surface-high);
    box-shadow: 0 0 0 1px rgb(141 144 162 / 25%);
  }
  .ph-flag img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
  }
  .ph-flag svg.ph-globe {
    width: 14px;
    height: 14px;
    fill: none;
    stroke: var(--outline);
    stroke-width: 1.8;
    stroke-linecap: round;
  }

  /* Line chart */
  .ph-page svg.ph-chart {
    display: block;
    width: 100%;
    height: auto;
    overflow: visible;
    touch-action: pan-y;
    user-select: none;
    cursor: crosshair;
  }
  .ph-grid { stroke: var(--divider); stroke-dasharray: 2 3; }
  .ph-axis { fill: var(--outline); font: 500 10px var(--font); }
  .ph-area { fill: rgb(29 99 255 / 14%); }
  .ph-line { fill: none; stroke: #497ef7; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
  .ph-ref { stroke: var(--text-muted); stroke-opacity: 0.7; stroke-dasharray: 4 3; }
  .ph-ref-label { fill: var(--text-muted); font: 500 10px var(--font); }
  .ph-end { fill: #497ef7; stroke: var(--surface-low); stroke-width: 2; }
  .ph-guide { stroke: var(--accent-300); stroke-dasharray: 3 3; }
  .ph-hover { fill: var(--surface-low); stroke: var(--accent-300); stroke-width: 2; }

  /* Region map */
  .ph-map {
    position: relative;
    aspect-ratio: 1.95;
    max-height: 184px;
    margin: 0 -8px 4px;
  }
  .ph-map-canvas {
    position: absolute;
    inset: 0;
  }
  .ph-map-labels {
    position: absolute;
    inset: 0;
    pointer-events: none;
  }
  .ph-map-label {
    position: absolute;
    display: flex;
    align-items: baseline;
    gap: 4px;
    padding: 2px 6px 3px;
    transform: translate(-50%, -50%);
    border: 1px solid rgb(67 70 86 / 90%);
    border-radius: 6px;
    background: rgb(37 42 57 / 88%);
    color: var(--text);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
  }
  .ph-map-label span {
    color: var(--text-muted);
    font: 600 10px/13px var(--font);
    letter-spacing: 0.04em;
  }
  .ph-map-label b {
    font: 700 12px/15px var(--headline);
  }
  .ph-map-label.is-top {
    border-color: rgb(181 196 255 / 60%);
    background: rgb(48 52 68 / 92%);
  }
  .ph-map-label.is-top b {
    color: var(--accent-300);
  }

  /* Positions */
  
  .ph-board {
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    grid-template-rows: repeat(8, minmax(0, 1fr));
    aspect-ratio: 1;
    border: 1px solid var(--divider);
    border-radius: 4px;
    overflow: hidden;
  }
  .ph-sq {
    position: relative;
    display: grid;
    place-items: center;
    aspect-ratio: 1;
    min-height: 0;
    min-width: 0;
    background: var(--t64-outline-variant);
  }
  .ph-sq.is-dark {
    background: var(--surface-high);
  }
  .ph-sq.is-hl::before {
    content: "";
    position: absolute;
    inset: 0;
    background: rgb(29 99 255 / 32%);
  }
  .ph-sq img {
    position: absolute;
    inset: 6%;
    width: 88%;
    height: 88%;
    object-fit: contain;
  }
  
  
  
  
  
  
  

  /* Games */
  .ph-game {
    grid-template-columns: 4px 28px minmax(0, 1fr) auto;
    min-height: 64px;
  }
  .ph-result {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 7px;
    font: 700 12px/1 var(--font);
  }
  .ph-result.is-w { background: rgb(123 208 255 / 14%); color: var(--t64-cyan); }
  .ph-result.is-l { background: rgb(255 180 171 / 14%); color: var(--t64-rose); }
  .ph-result.is-d,
  .ph-result.is-unknown { background: rgb(141 144 162 / 20%); color: var(--text-muted); }
  .ph-game-text {
    display: grid;
    gap: 3px;
    min-width: 0;
  }
  .ph-game-opp {
    display: flex;
    align-items: baseline;
    gap: 6px;
    min-width: 0;
  }
  .ph-game-opp span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font: 500 14.5px/20px var(--font);
  }
  .ph-game-opp small {
    flex: none;
    color: var(--outline);
    font-size: 12.5px;
  }
  .ph-game-date {
    color: var(--outline);
    font: 500 12.5px/16px var(--font);
  }
  .ph-more {
    display: grid;
    justify-items: center;
  }

  /* Buttons, text, states */
  .ph-btn {
    min-height: 48px;
    padding: 0 16px;
    border: 0;
    border-radius: 8px;
    background: var(--accent);
    color: var(--t64-on-cobalt);
    font: 600 15px/20px var(--font);
    cursor: pointer;
  }
  .ph-btn:active {
    background: var(--t64-cobalt-active);
  }
  .ph-btn.is-quiet {
    background: var(--surface-low);
    color: var(--text);
  }
  .ph-link-btn {
    min-height: 44px;
    padding: 0;
    border: 0;
    background: none;
    color: var(--accent-300);
    font: 600 14px/20px var(--font);
    text-decoration: none;
    cursor: pointer;
  }
  .ph-link-btn.is-center {
    justify-self: center;
    display: grid;
    place-items: center;
    padding: 0 16px;
  }
  .ph-caption {
    margin: 0;
    padding: 0 2px;
    color: rgb(195 197 216 / 70%);
    font: 500 12px/16px var(--font);
  }
  .ph-caption.has-side {
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .ph-caption .ph-side {
    height: 14px;
    width: 3px;
  }
  .ph-empty,
  .ph-status {
    margin: 0;
    padding: 16px 0;
    color: var(--text-muted-80);
    font: 400 14px/22px var(--font);
  }
  .ph-pending {
    display: grid;
    gap: 8px;
    padding: 4px 0 8px;
  }
  .ph-pending .ph-skel-row {
    margin: 0;
    height: 20px;
  }
  .ph-skel-row.is-short {
    width: 60%;
  }
  .ph-empty-block {
    display: grid;
    justify-items: center;
    gap: 10px;
    padding: 40px 16px;
    text-align: center;
  }
  .ph-empty-block p {
    margin: 0;
    color: var(--text-muted-80);
  }
  .ph-eyebrow {
    color: rgb(195 197 216 / 70%);
    font: 600 11px/14px var(--font);
    letter-spacing: 0.14em;
    text-transform: uppercase;
  }

  /* Bottom sheet */
  .ph-sheet-root {
    position: fixed;
    inset: 0;
    z-index: 60;
    pointer-events: none;
  }
  .ph-scrim {
    position: absolute;
    inset: 0;
    background: rgb(9 14 28 / 60%);
    opacity: 0;
    transition: opacity 180ms ease-out;
  }
  .ph-sheet {
    position: absolute;
    inset: auto 0 0;
    display: grid;
    gap: 16px;
    max-height: 86%;
    overflow-y: auto;
    padding: 8px 20px calc(env(safe-area-inset-bottom, 0px) + 28px);
    border-top: 1px solid var(--divider-strong);
    border-radius: 20px 20px 0 0;
    background: var(--surface-high);
    transform: translateY(100%);
    transition: transform 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
    outline: none;
  }
  .ph-sheet-root.is-open {
    pointer-events: auto;
  }
  .ph-sheet-root.is-open .ph-scrim {
    opacity: 1;
  }
  .ph-sheet-root.is-open .ph-sheet {
    transform: none;
  }
  .ph-grip {
    width: 36px;
    height: 4px;
    margin: 0 auto 4px;
    border-radius: 999px;
    background: var(--t64-outline-variant);
  }
  .ph-sheet-title {
    margin: 0;
    font: 600 20px/28px var(--headline);
    letter-spacing: -0.025em;
  }
  .ph-filter-group {
    display: grid;
    gap: 8px;
  }

  /* Loading */
  .ph-skeleton {
    padding-block: 8px;
  }
  .ph-skel-row {
    display: block;
    height: 44px;
    margin: 8px 0;
    border-radius: 8px;
    background: linear-gradient(90deg, var(--surface-container), var(--surface-high), var(--surface-container));
    background-size: 200% 100%;
    animation: m-shimmer 1.4s ease-in-out infinite;
  }
  @keyframes m-shimmer {
    from { background-position: 100% 0; }
    to { background-position: -100% 0; }
  }

  /* Settings */
  .ph-settings .ph-head {
    padding-top: calc(env(safe-area-inset-top, 0px) + 8px);
  }
  .ph-add {
    display: flex;
    align-items: center;
    gap: 6px;
    min-height: 40px;
    padding: 0 14px;
    font-size: 14px;
  }
  .ph-add:disabled {
    opacity: 0.6;
  }
  .ph-account-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
    min-height: 68px;
    border-top: 1px solid var(--divider);
  }
  .ph-account-pick {
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr) 20px;
    align-items: center;
    gap: 12px;
    min-height: 64px;
    padding: 0;
    border: 0;
    background: none;
    color: var(--text);
    text-align: left;
    cursor: pointer;
  }
  .ph-account-logo {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--surface-high);
  }
  .ph-account-logo .ph-logo {
    width: 18px;
    height: 18px;
  }
  .ph-row-name.is-active {
    font-weight: 600;
  }
  .ph-row-sub.is-importing {
    color: var(--accent-300);
  }
  svg.ph-account-check {
    width: 18px;
    height: 18px;
    color: var(--accent-300);
    stroke-width: 2;
  }
  .ph-account-delete {
    min-height: 40px;
    padding: 0 10px;
    border: 0;
    border-radius: 8px;
    background: none;
    color: var(--t64-rose);
    font: 600 13px/20px var(--font);
    cursor: pointer;
  }
  .ph-note {
    margin: 0 2px;
    color: rgb(195 197 216 / 60%);
    font: 400 12px/18px var(--font);
    text-wrap: pretty;
  }
  .ph-note.is-center {
    margin-top: -8px;
    color: var(--outline);
    text-align: center;
  }
  .ph-input {
    width: 100%;
    min-height: 48px;
    padding: 10px 0;
    border: 0;
    border-bottom: 2px solid var(--t64-outline-variant);
    border-radius: 0;
    background: transparent;
    color: var(--text);
    font: 400 16px/26px var(--font);
    caret-color: var(--accent);
    outline: none;
  }
  .ph-input:focus,
  .ph-input:focus-visible {
    border-bottom-color: var(--accent);
    outline: none;
    box-shadow: none;
  }
  .ph-input.is-error {
    border-bottom-color: var(--t64-rose);
  }
  .ph-error {
    margin: -8px 0 0;
    color: var(--t64-rose);
    font: 500 12.5px/18px var(--font);
  }
  .ph-seg .ph-logo {
    width: 16px;
    height: 16px;
  }

  /* Focus and motion */
  .ph-page a:focus-visible,
  .ph-page button:focus-visible,
  .ph-sheet button:focus-visible {
    outline: 2px solid var(--accent-300);
    outline-offset: 2px;
    border-radius: 8px;
  }
  @media (hover: hover) {
    .ph-card.is-link:hover {
      border-color: rgb(141 144 162 / 50%);
    }
    .ph-row[href]:hover,
    .ph-game:hover,
    .ph-rating-row:hover {
      background: linear-gradient(var(--surface-container), var(--surface-container)) padding-box;
    }
  }

  @media (prefers-reduced-motion: reduce) {
    .ph-skel-row {
      animation: none;
    }
    .m-tab-ic,
    .ph-scrim,
    .ph-sheet {
      transition: none;
    }
  }
}

/* ---- Game review and Learning Hub (phones) ---- */
@media (max-width: 760px) {
  main:has(> .review-page) {
    height: 100vh;
    height: 100dvh;
    padding: calc(env(safe-area-inset-top, 0px) + 12px) var(--m-gutter-end)
      calc(var(--m-tabbar) + env(safe-area-inset-bottom, 0px) + 12px) var(--m-gutter);
  }
  .review-page.is-mobile > .review-head-mobile {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0 0 10px;
  }
  .review-head-mobile .btn {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    min-height: 44px;
    padding: 0;
    flex: none;
  }
  .review-back {
    margin-left: -10px;
    border: 0;
    background: none;
    color: var(--accent-300);
  }
  .review-back svg,
  .review-flip-icon svg {
    width: 22px;
    height: 22px;
  }
  .review-flip-icon {
    border-radius: 12px;
    background: var(--surface-low);
    color: var(--text);
  }
  .review-flip-icon[aria-pressed="true"] {
    color: var(--accent-300);
  }
  .review-title {
    flex: 1;
    min-width: 0;
  }
  .review-page.is-mobile > .page-head h1 {
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font: 700 18px/1.25 var(--headline);
  }
  .review-page.is-mobile > .page-head p {
    margin: 2px 0 0;
    color: var(--text-muted);
    font-size: 12.5px;
  }
  .review-page.is-mobile .review-panel {
    padding: 0;
    border: 0;
    background: none;
    gap: 10px;
  }
  .review-page.is-mobile .review-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .review-page.is-mobile .review-controls .btn {
    display: grid;
    place-items: center;
    background: var(--surface-low);
    color: var(--text);
    border: 0;
    min-height: 48px;
    border-radius: 12px;
    font-size: 18px;
  }
  .review-page.is-mobile .review-moves {
    display: flex;
    flex: none;
    gap: 4px;
    min-height: 0;
    height: auto;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
  }
  .review-page.is-mobile .review-moves::-webkit-scrollbar {
    display: none;
  }
  .review-page.is-mobile .review-moves button {
    flex: none;
    min-height: 40px;
    padding: 0 10px;
    white-space: nowrap;
  }

  /* Learning Hub */
  .tp-mobile {
    display: grid;
    gap: var(--m-gap);
  }
  .tp-m-title {
    margin: 0;
    font: 700 22px/1.2 var(--headline);
    letter-spacing: -0.02em;
  }
  .tp-intro[hidden],
  .tp-m-status[hidden] {
    display: none;
  }
  .tp-intro {
    display: grid;
    gap: var(--m-group);
  }
  .tp-promise {
    margin: 0;
    font: 600 18px/1.4 var(--headline);
    letter-spacing: -0.02em;
    color: var(--text);
  }
  .tp-promise em {
    font-style: normal;
    white-space: nowrap;
    text-decoration: underline;
    text-decoration-color: var(--accent);
    text-decoration-thickness: 3px;
    text-underline-offset: 5px;
    text-decoration-skip-ink: none;
  }
  .tp-promise b {
    color: var(--accent-300);
    font-weight: 800;
    white-space: nowrap;
  }
  .tp-nw {
    white-space: nowrap;
  }
  .tp-promise.is-small {
    font: 500 16px/1.5 var(--headline);
    letter-spacing: 0;
    color: var(--text-muted);
  }
  .tp-promise.is-small em {
    color: var(--text);
    text-decoration-thickness: 2px;
    text-underline-offset: 4px;
  }
  .tp-promise.is-small .tp-nw {
    white-space: normal;
  }
  .tp-features {
    display: grid;
    margin: 0;
    padding: 4px 14px;
    list-style: none;
    border-radius: var(--m-radius);
    background: var(--surface-low);
  }
  .tp-feature {
    display: grid;
    grid-template-columns: 32px 1fr;
    align-items: center;
    gap: 14px;
    min-height: 52px;
    border-top: 1px solid var(--divider);
    font: 600 14.5px var(--headline);
  }
  .tp-feature:first-child {
    border-top: 0;
  }
  .tp-f-ic {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 9px;
    background: rgb(29 99 255 / 14%);
    color: var(--accent-300);
  }
  .tp-f-svg {
    width: 18px;
    height: 18px;
  }
  .tp-feature.is-more {
    color: var(--text-muted);
    font-weight: 500;
  }
  .tp-feature.is-more .tp-f-ic {
    background: none;
    box-shadow: inset 0 0 0 1px var(--divider-strong);
    color: var(--text-muted);
  }
  .tp-feature.is-more .tp-f-svg {
    stroke-width: 3;
  }
  .tp-features.is-dense {
    grid-template-columns: 1fr 1fr;
    gap: 0 12px;
    padding: 8px 12px;
  }
  .tp-features.is-dense .tp-feature {
    grid-template-columns: 26px 1fr;
    gap: 9px;
    min-height: 44px;
    border-top: 0;
    font-size: 12.5px;
    line-height: 1.25;
  }
  .tp-features.is-dense .tp-f-ic {
    width: 26px;
    height: 26px;
    border-radius: 7px;
  }
  .tp-features.is-dense .tp-f-svg {
    width: 14px;
    height: 14px;
  }
  .tp-m-actions {
    display: grid;
    gap: 12px;
  }
  .tp-mobile .tp-actions {
    display: grid;
    gap: var(--m-gap);
  }
  .tp-mobile .tp-cta,
  .tp-mobile .tp-copy {
    width: 100%;
    min-height: 50px;
    border-radius: 12px;
    font-size: 15px;
  }
  .tp-m-status {
    margin: 0;
    color: var(--outline);
    font-size: 13px;
    text-align: center;
  }
  .tp-m-card {
    display: grid;
    gap: 10px;
    padding: 18px 16px;
    border-radius: var(--m-radius);
    background: var(--surface-low);
  }
  .tp-m-card .tp-joined-title {
    margin: 0;
    font: 700 19px/1.3 var(--headline);
  }
  .tp-m-invite {
    margin: 0 0 4px;
    color: var(--text-muted);
    font-size: 14px;
    line-height: 1.45;
  }
  .tp-m-count {
    margin: 2px 0 0;
    color: var(--outline);
    font-size: 13px;
    text-align: center;
  }
  .tp-m-coming {
    display: grid;
    gap: var(--m-group);
  }
}

/* ---- Revised phone design: Games played, position cards, breakdown bars ---- */
@media (max-width: 760px) {
  .ph-pair {
    display: contents;
  }
  .ph-card-right {
    display: flex;
    align-items: center;
    gap: 6px;
  }
  .ph-section-title {
    display: flex;
    align-items: center;
    gap: 4px;
    margin: 0;
    padding: 0 2px;
    font: 600 15px/20px var(--headline);
  }
  .ph-stats.is-gp {
    gap: 8px;
  }
  .ph-stats.is-gp .ph-stat {
    gap: 4px;
    padding: 12px 4px;
    border-radius: 10px;
    background: var(--surface-high);
  }
  .ph-stats.is-gp .ph-stat:first-child { background: rgb(123 208 255 / 12%); }
  .ph-stats.is-gp .ph-stat b {
    font-size: 19px;
    line-height: 24px;
  }
  .ph-stats.is-gp .ph-stat span { color: var(--text-muted); }
  .ph-stats.is-gp:has(.is-draw) .ph-stat:first-child { background: rgb(141 144 162 / 16%); }
  .ph-stats.is-gp:has(.is-loss) .ph-stat:first-child { background: rgb(255 180 171 / 12%); }
  .ph-stat b.is-win,
  .ph-row-value.is-win { color: var(--t64-cyan); }
  .ph-stat b.is-loss,
  .ph-row-value.is-loss { color: var(--t64-rose); }
  .ph-row.has-icon {
    grid-template-columns: 32px minmax(0, 1fr) auto;
  }
  .ph-row.has-icon .ph-class-ic {
    width: 32px;
    height: 32px;
    border-radius: 9px;
  }
  .ph-row.has-icon .ph-class-ic svg.ph-ic {
    width: 17px;
    height: 17px;
  }
  /* Count bars coloured by result. */
  .ph-barchart[data-tone="win"] .ph-bar-col i { background: rgb(123 208 255 / 38%); }
  .ph-barchart[data-tone="win"] .ph-bar-col i.is-top { background: #7bd0ff; }
  .ph-barchart[data-tone="draw"] .ph-bar-col i { background: rgb(141 144 162 / 38%); }
  .ph-barchart[data-tone="draw"] .ph-bar-col i.is-top { background: #dee2f6; }
  .ph-barchart[data-tone="loss"] .ph-bar-col i { background: rgb(255 180 171 / 38%); }
  .ph-barchart[data-tone="loss"] .ph-bar-col i.is-top { background: #ffb4ab; }

  /* Where your clock goes: two labelled rows of phase tiles. */
  .ph-clock-row {
    display: grid;
    gap: 8px;
  }
  .ph-clock-label {
    color: rgb(195 197 216 / 70%);
    font: 600 11px/14px var(--font);
    letter-spacing: 0.14em;
    text-transform: uppercase;
  }
  /* Pressure tiles: value over name, as the design draws them. */
  .ph-tile .ph-tile-name {
    order: 2;
  }
  .ph-tile .ph-tile-note {
    display: none;
  }

  /* Common positions: one card per position, board with the last move drawn. */
  .ph-positions {
    display: grid;
    gap: 16px;
  }
  .ph-poscard {
    display: grid;
    gap: 14px;
    align-content: start;
    min-width: 0;
    padding: 14px;
    border: 1px solid var(--divider-soft);
    border-radius: 12px;
    background: var(--surface-low);
  }
  .ph-board-wrap {
    position: relative;
  }
  .ph-poscard .ph-board {
    border: 0;
    border-radius: 6px;
    box-shadow: 0 0 0 1px rgb(67 70 86 / 60%);
  }
  .ph-arrow {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
  }
  .ph-poscard-name {
    display: grid;
    gap: 2px;
  }
  .ph-poscard-name b {
    font: 600 15px/20px var(--headline);
  }
  .ph-poscard-share {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--divider);
    color: var(--text-muted);
    font: 500 14px/20px var(--font);
    font-variant-numeric: tabular-nums;
  }
  .ph-poscard-share b {
    padding: 3px 10px;
    border-radius: 6px;
    background: var(--surface-high);
    color: var(--text);
    font: 700 15px/20px var(--headline);
  }
  .ph-poscard-wdl {
    display: grid;
    gap: 10px;
  }
  .ph-wdl-line {
    display: flex;
    gap: 2px;
    height: 8px;
    overflow: hidden;
    border-radius: 999px;
  }
  .ph-wdl-line i { display: block; }
  .ph-wdl-line .is-win { background: #7bd0ff; }
  .ph-wdl-line .is-draw { background: #8d90a2; }
  .ph-wdl-line .is-loss { flex: 1; background: #ffb4ab; }
  .ph-poscard-nums {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
    font-variant-numeric: tabular-nums;
  }
  .ph-poscard-nums span {
    display: grid;
    gap: 1px;
    color: var(--outline);
    font: 500 12.5px/16px var(--font);
  }
  .ph-poscard-nums span:nth-child(2) { justify-items: center; }
  .ph-poscard-nums span:nth-child(3) { justify-items: end; }
  .ph-poscard-nums b {
    font: 700 18px/22px var(--headline);
  }
  .ph-poscard-nums .is-win b { color: #7bd0ff; }
  .ph-poscard-nums .is-draw b { color: var(--text); }
  .ph-poscard-nums .is-loss b { color: #ffb4ab; }

  /* Breakdowns: each row's rate as a bar, against this type's average. */
  .ph-breakdowns {
    display: grid;
    gap: 16px;
  }
  .ph-breakdown .ph-card-label {
    color: rgb(195 197 216 / 60%);
    font: 600 10.5px/14px var(--font);
    letter-spacing: 0.12em;
    text-transform: uppercase;
  }
  .ph-brow {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    gap: 10px 12px;
    padding: 14px 0;
    border-top: 1px solid var(--divider);
    font-variant-numeric: tabular-nums;
  }
  .ph-brow .ph-row-value {
    white-space: nowrap;
    font: 700 20px/24px var(--headline);
    letter-spacing: -0.01em;
  }
  .ph-brow-track {
    grid-column: 1 / -1;
    position: relative;
    display: block;
    height: 6px;
    border-radius: 999px;
    background: var(--surface-high);
  }
  .ph-brow-track i {
    display: block;
    height: 100%;
    border-radius: 999px;
  }
  .ph-brow-track i.is-up { background: #7bd0ff; }
  .ph-brow-track i.is-down { background: #ffb4ab; }
  .ph-brow-track i.is-even { background: #8d90a2; }
  .ph-brow-track i.is-share { background: var(--accent-300); }
  .ph-brow-track b {
    position: absolute;
    top: -3px;
    bottom: -3px;
    width: 2px;
    border-radius: 1px;
    background: var(--text);
  }
  .ph-brow-legend {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 14px;
    padding: 12px 0 8px;
    border-top: 1px solid var(--divider);
    color: var(--outline);
    font: 500 12px/16px var(--font);
  }
  .ph-brow-legend span {
    display: flex;
    align-items: center;
    gap: 6px;
  }
  .ph-brow-legend .is-push { margin-left: auto; }
  .ph-brow-legend i {
    width: 12px;
    height: 6px;
    border-radius: 999px;
  }
  .ph-brow-legend i.is-avg {
    width: 2px;
    height: 12px;
    border-radius: 1px;
    background: var(--text);
  }
  .ph-brow-legend i.is-up { background: #7bd0ff; }
  .ph-brow-legend i.is-down { background: #ffb4ab; }
}

@media (min-width: 480px) and (max-width: 760px) {
  .ph-controls {
    grid-template-columns: 1fr auto;
    align-items: center;
  }
}
