/* Player detail sheet: side panel on desktop, full screen on mobile. Plus chart styles. */
.detail {
  margin: 0 0 0 auto; padding: 0; border: 0; height: 100dvh; max-height: 100dvh;
  width: min(600px, 100vw); max-width: 100vw;
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow);
  overflow-y: auto; overscroll-behavior: contain;
}
.detail::backdrop { background: rgb(13 20 27 / 0.35); }
@media (prefers-color-scheme: dark) { .detail::backdrop { background: rgb(0 0 0 / 0.6); } }
.detail[open] { animation: sheet-in 180ms ease-out; }
@keyframes sheet-in { from { transform: translateX(24px); opacity: 0; } }
@media (max-width: 640px) { .detail { width: 100vw; } }

.detail-bar {
  position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: var(--s2);
  padding: var(--s3) var(--s4); background: var(--surface); border-bottom: 1px solid var(--line);
}
.detail-bar .crumb { margin-right: auto; font-size: 0.8125rem; color: var(--ink-3); }
.detail-body { padding: var(--s4) var(--s5) var(--s6); display: flex; flex-direction: column; gap: var(--s5); }
@media (max-width: 640px) { .detail-body { padding: var(--s4); } }

.detail-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--s2) var(--s4); }
.detail-head h2 { font-size: 1.6rem; flex: 1 1 100%; overflow-wrap: anywhere; }
.detail-rank { font-size: 0.8125rem; color: var(--ink-2); flex: 1 1 100%; }
.detail-rating { font: 700 2.6rem/1 var(--font-display); letter-spacing: -0.02em; }
.detail-rating-meta { font-size: 0.875rem; color: var(--ink-2); display: flex; flex-direction: column; gap: 2px; padding-bottom: 4px; }
.detail-actions { display: flex; flex-wrap: wrap; gap: var(--s2); }

.section-title { font-size: 0.8125rem; font-family: var(--font-body); font-weight: 600; color: var(--ink-2); margin-bottom: var(--s3); text-transform: none; }

/* Stats */
.stat-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--s3); }
.stat-group { background: var(--surface-2); border-radius: var(--radius-sm); padding: var(--s3) var(--s4); }
.stat-group dl { margin: 0; display: grid; grid-template-columns: 1fr auto; gap: 6px var(--s3); font-size: 0.875rem; }
.stat-group dt { color: var(--ink-2); }
.stat-group dd { margin: 0; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }

.words { display: flex; flex-direction: column; gap: var(--s3); }
.word-row { display: flex; flex-direction: column; gap: 6px; }
.word-row .label { font-size: 0.8125rem; color: var(--ink-2); }
.word-row .tiles { --t: 30px; flex-wrap: wrap; }
@media (max-width: 420px) { .word-row .tiles { --t: 22px; } }

/* Record: W/T/L 100% bar, 2px surface gap between segments */
.wtl { display: flex; gap: 2px; height: 10px; margin: var(--s2) 0 var(--s2); }
.wtl span { display: block; height: 100%; min-width: 2px; }
.wtl span:first-child { border-radius: 4px 0 0 4px; }
.wtl span:last-child { border-radius: 0 4px 4px 0; }
.wtl .w { background: var(--up); }
.wtl .t { background: var(--line-strong); }
.wtl .l { background: var(--down); }
.wtl-legend { display: flex; flex-wrap: wrap; gap: var(--s1) var(--s4); font-size: 0.8125rem; color: var(--ink-2); }
.wtl-legend b { color: var(--ink); font-weight: 600; }
.key { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; vertical-align: 1px; }
.key.w { background: var(--up); } .key.t { background: var(--line-strong); } .key.l { background: var(--down); }

/* Percentile in top 2000 */
.pctl-track { position: relative; height: 8px; border-radius: 4px; background: var(--accent-soft); margin: var(--s3) 0 var(--s2); }
.pctl-fill { position: absolute; inset: 0 auto 0 0; border-radius: 4px; background: var(--series-1); }
.pctl-dot { position: absolute; top: 50%; width: 14px; height: 14px; margin-left: -7px; transform: translateY(-50%); border-radius: 50%; background: var(--series-1); box-shadow: 0 0 0 2px var(--surface-2); }
.pctl-scale { display: flex; justify-content: space-between; font-size: 0.75rem; color: var(--ink-3); }

/* History chart */
.chart-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s3); margin-bottom: var(--s3); }
.chart-head .section-title { margin: 0 auto 0 0; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); overflow: hidden; }
.seg button { all: unset; padding: 4px 10px; font-size: 0.8125rem; cursor: pointer; color: var(--ink-2); }
.seg button + button { border-left: 1px solid var(--line-strong); }
.seg button[aria-pressed="true"] { background: var(--accent-soft); color: var(--ink); font-weight: 600; }
.seg button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.legend { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s4); font-size: 0.8125rem; margin-bottom: var(--s2); min-height: 1.5em; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); }
.legend-item b { color: var(--ink); font-weight: 600; }
.legend-date { color: var(--ink-3); }
.line-key { width: 22px; height: 0; border-top: 2px solid var(--series-1); }
.line-key.dashed { border-top: 2px dashed var(--series-2); }

.chart { position: relative; width: 100%; min-height: 220px; }
.chart .u-legend { display: none; }
.chart .u-select { background: color-mix(in srgb, var(--series-1) 12%, transparent); }
.chart-alt { font-size: 0.8125rem; color: var(--ink-2); margin-top: var(--s2); }
.chart-data { margin-top: var(--s2); font-size: 0.8125rem; }
.chart-data summary { cursor: pointer; color: var(--accent); }
.chart-data .table-scroll { max-height: 240px; overflow: auto; margin-top: var(--s2); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.chart-data table { width: 100%; border-collapse: collapse; }
.chart-data th, .chart-data td { padding: 4px var(--s3); border-bottom: 1px solid var(--line); text-align: right; }
.chart-data th:first-child, .chart-data td:first-child { text-align: left; }
.chart-data thead th { position: sticky; top: 0; background: var(--surface-2); }

/* Compare picker */
.compare { position: relative; display: flex; gap: var(--s2); align-items: center; flex-wrap: wrap; margin-top: var(--s3); }
.compare .input { flex: 1 1 200px; }
.compare-list {
  position: absolute; z-index: 3; top: 100%; left: 0; right: 0; margin: 4px 0 0; padding: 4px; list-style: none;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); box-shadow: var(--shadow);
  max-height: 260px; overflow: auto;
}
.compare-list li { display: flex; justify-content: space-between; gap: var(--s3); padding: 6px var(--s2); border-radius: 4px; cursor: pointer; font-size: 0.875rem; }
.compare-list li[aria-selected="true"], .compare-list li:hover { background: var(--accent-soft); }
.compare-list .muted { font-size: 0.8125rem; }

.panel-state { padding: var(--s6) 0; }

/* Small inline SVG charts (sparklines, histogram) */
.spark { display: block; width: 56px; height: 18px; }
.spark path { fill: none; stroke: var(--ink-3); stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
.spark circle { fill: var(--ink); }
.hist svg { display: block; width: 100%; height: auto; overflow: visible; }
.hist .bar { fill: var(--line-strong); }
.hist .bar.me { fill: var(--series-1); }
.hist .axis { fill: var(--ink-3); font: 500 10px var(--font-body); }
.hist .me-line { stroke: var(--ink); stroke-width: 1; }
.hist .me-label { fill: var(--ink); font: 600 11px var(--font-body); }
.hist-caption { font-size: 0.8125rem; color: var(--ink-2); margin-top: var(--s2); }
