:root {
  --paper: #f3eee4;
  --ink: #2b2a27;
  --soft: #6f6a60;
  --hair: rgba(43, 42, 39, .16);
  --card: rgba(250, 247, 240, .92);
  --accent: #c8553d;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Songti SC", "Noto Serif CJK SC", Georgia, serif;
  --sans: -apple-system, "Helvetica Neue", "PingFang SC", "Segoe UI", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--paper); color: var(--ink); font-family: var(--sans); font-size: 12px; -webkit-font-smoothing: antialiased; }
#stage { position: fixed; inset: 0; touch-action: none; }
#stage canvas { display: block; width: 100%; height: 100%; }
#labels { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
#ui { position: fixed; inset: 0; pointer-events: none; }
#ui > * { pointer-events: auto; }
.hidden { display: none !important; }
body.photo #ui, body.photo #labels { display: none; }
#photoExit { position: fixed; right: 14px; top: 14px; opacity: .5; }
.dim { color: var(--soft); }
.num { font-variant-numeric: tabular-nums; }
.grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gap { height: 8px; }

/* title */
#title { position: absolute; left: 28px; top: 22px; max-width: 310px; pointer-events: none !important; }
.kicker { font-size: 10px; letter-spacing: .22em; text-transform: uppercase; color: var(--soft); margin-bottom: 6px; }
#title h1 { font-family: var(--serif); font-weight: 500; font-size: 27px; line-height: 1.08; margin: 0 0 6px; letter-spacing: -.01em; }
#title p { margin: 0; color: var(--soft); font-size: 12px; line-height: 1.45; border-top: 1px solid var(--hair); padding-top: 7px; }
body.night:not(.over) #title h1, body.night:not(.over) #ticker div:last-child { color: #f3eee4; }
body.night:not(.over) #title p, body.night:not(.over) #title .kicker, body.night:not(.over) #ticker div { color: #c9c3b6; border-color: rgba(243, 238, 228, .25); }
/* zoomed in, the scene runs under the title and the ticker: they get a paper backing */
#title, #ticker { border: 1px solid transparent; border-radius: 14px; padding: 10px 14px; margin: -11px -15px; transition: background .3s, border-color .3s; }
body.over #title, body.over #ticker { background: var(--card); border-color: var(--hair); backdrop-filter: blur(6px); }
body.over #title p { display: none; }

/* scorecard */
#score { position: absolute; right: 332px; top: 20px; background: var(--card); border: 1px solid var(--hair); border-radius: 14px; padding: 10px 14px; width: 270px; backdrop-filter: blur(6px); }
body.panel-closed #score, body.panel-closed #summary, body.panel-closed #curves { right: 64px; }
#score .kicker { letter-spacing: .14em; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#score .meta0 { display: flex; align-items: baseline; gap: 10px; border-bottom: 1px solid var(--hair); padding-bottom: 4px; margin-bottom: 4px; }
#score .clock { font-family: var(--serif); font-size: 26px; font-variant-numeric: tabular-nums; }
#score .phase { color: var(--soft); font-size: 11px; }
#score .row { display: flex; align-items: center; gap: 7px; padding: 2px 0; }
#score .pl { width: 10px; color: var(--soft); font-size: 11px; }
.sw { display: inline-block; width: 9px; height: 13px; border-radius: 2px; border: 1px solid var(--hair); flex: none; vertical-align: -2px; }
#score .nm { flex: 1; font-family: var(--serif); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#score .gl { font-variant-numeric: tabular-nums; font-size: 12px; min-width: 44px; text-align: right; }
#score .mini { font-size: 10px; color: var(--soft); }
#score .meta { display: flex; gap: 10px; flex-wrap: wrap; border-top: 1px solid var(--hair); margin-top: 5px; padding-top: 5px; color: var(--soft); font-size: 11px; font-variant-numeric: tabular-nums; }
#summary { position: absolute; right: 332px; top: 196px; width: 270px; background: var(--card); border: 1px solid var(--hair); border-radius: 14px; padding: 10px 12px; backdrop-filter: blur(6px); }
#summary .kicker { letter-spacing: .12em; }

/* tables */
.tbl { width: 100%; border-collapse: collapse; font-size: 11px; font-variant-numeric: tabular-nums; }
.tbl th { text-align: left; font-weight: 500; color: var(--soft); font-size: 9.5px; letter-spacing: .08em; text-transform: uppercase; padding: 2px 3px; }
.tbl td { border-top: 1px solid var(--hair); padding: 3px 3px; white-space: nowrap; }
.tbl td.nm { font-family: var(--serif); font-size: 12.5px; max-width: 118px; overflow: hidden; text-overflow: ellipsis; }
.tbl td.nat { font-size: 9.5px; letter-spacing: .04em; }
.tbl td.num { text-align: right; }
.tbl td.mk { color: var(--accent); font-size: 10px; font-weight: 600; }
.splits { font-size: 10.5px; color: var(--soft); line-height: 1.5; margin: 4px 0; font-variant-numeric: tabular-nums; }
.splits b { color: var(--ink); font-family: var(--serif); font-weight: 500; font-size: 12px; }
canvas.chart { width: 100%; height: auto; display: block; }

/* ticker */
#ticker { position: absolute; left: 28px; bottom: 66px; width: 310px; pointer-events: none !important; }
#ticker:empty { display: none; }
#ticker div { padding: 3px 0; border-top: 1px solid var(--hair); color: var(--soft); font-size: 11.5px; line-height: 1.35; }
#ticker div:last-child { color: var(--ink); font-family: var(--serif); font-size: 14px; }
#ticker b { font-weight: 600; font-variant-numeric: tabular-nums; margin-right: 6px; }

/* pills & controls */
.pill { font: inherit; font-size: 11px; color: var(--ink); background: var(--card); border: 1px solid var(--hair); border-radius: 999px; padding: 5px 11px; cursor: pointer; white-space: nowrap; transition: background .15s, color .15s, border-color .15s; }
.pill:hover { border-color: var(--ink); }
.pill.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.pill.warn { border-color: var(--accent); color: var(--accent); }
.pill.big { font-family: var(--serif); font-size: 14px; padding: 7px 16px; }
.pill:disabled { opacity: .4; cursor: default; }
#bar { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); display: flex; gap: 6px; align-items: center; background: var(--card); border: 1px solid var(--hair); border-radius: 999px; padding: 6px 10px; backdrop-filter: blur(6px); max-width: calc(100vw - 24px); overflow-x: auto; scrollbar-width: none; }
#bar .sep { width: 1px; height: 16px; background: var(--hair); flex: none; }
#bar .pill { border-color: transparent; background: transparent; padding: 5px 9px; }
#bar .pill:hover { border-color: var(--hair); }
#bar .pill.on { background: var(--ink); }
#bar .pill.warn { border-color: var(--accent); }
#bar .vol { width: 70px; accent-color: var(--ink); height: 14px; flex: none; }

/* panel */
#panel { position: absolute; right: 16px; top: 20px; bottom: 66px; width: 300px; background: var(--card); border: 1px solid var(--hair); border-radius: 16px; display: flex; flex-direction: column; backdrop-filter: blur(6px); transition: transform .25s; }
body.panel-closed #panel { transform: translateX(calc(100% - 30px)); }
body.panel-closed #tabs, body.panel-closed #tabBody { visibility: hidden; }
#panelToggle { position: absolute; left: -13px; top: 14px; width: 26px; height: 26px; padding: 0; z-index: 2; }
#tabs { display: flex; flex-wrap: wrap; gap: 4px; padding: 12px 12px 10px 20px; border-bottom: 1px solid var(--hair); }
#tabs .pill { padding: 3px 8px; font-size: 10.5px; border-color: transparent; background: transparent; }
#tabs .pill.on { background: var(--ink); }
#tabBody { flex: 1; overflow-y: auto; padding: 12px 16px 18px; scrollbar-width: thin; }
#tabBody h3 { font-family: var(--serif); font-weight: 500; font-size: 17px; margin: 2px 0 2px; }
#tabBody h4 { font-size: 10px; letter-spacing: .16em; text-transform: uppercase; color: var(--soft); font-weight: 500; margin: 14px 0 6px; padding-top: 8px; border-top: 1px solid var(--hair); }
#tabBody h4:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.grid { display: flex; flex-wrap: wrap; gap: 5px; margin: 5px 0; }
.ctl { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
.ctl label { flex: 0 0 96px; color: var(--soft); font-size: 11px; }
.ctl input[type=range] { flex: 1; min-width: 0; accent-color: var(--ink); height: 14px; }
.ctl output { flex: 0 0 62px; text-align: right; font-variant-numeric: tabular-nums; font-size: 11px; }
.ctl input[type=text] { flex: 1; min-width: 0; font: inherit; border: 0; border-bottom: 1px solid var(--hair); background: transparent; padding: 3px 0; color: var(--ink); font-family: var(--serif); font-size: 14px; }
.ctl input[type=color] { width: 26px; height: 22px; padding: 0; border: 1px solid var(--hair); border-radius: 6px; background: none; }
.ctl select { flex: 1; min-width: 0; font: inherit; font-size: 11px; border: 1px solid var(--hair); border-radius: 999px; background: var(--card); padding: 4px 8px; color: var(--ink); }
.note { color: var(--soft); font-size: 11px; line-height: 1.45; margin: 6px 0; }
.tl { display: flex; gap: 7px; padding: 4px 0; border-top: 1px solid var(--hair); font-size: 11.5px; align-items: center; }
.tl b { flex: 0 0 14px; font-variant-numeric: tabular-nums; font-weight: 600; }
.tl .grow { font-family: var(--serif); font-size: 13px; }
.tl.click { cursor: pointer; }
.tl.click:hover, .tl.click.cur { color: var(--accent); }
.gloss { border-top: 1px solid var(--hair); padding: 7px 0; cursor: pointer; display: flex; justify-content: space-between; }
.gloss:hover { color: var(--accent); }
.gloss span:first-child { font-family: var(--serif); font-size: 14px; }

/* cards */
#rulecard { position: absolute; left: 28px; top: 168px; width: 300px; background: var(--card); border: 1px solid var(--hair); border-radius: 14px; padding: 14px 16px; backdrop-filter: blur(6px); z-index: 3; overflow-y: auto; scrollbar-width: thin; }
#rulecard .kicker { margin: 0; }
#rulecard h2 { font-family: var(--serif); font-weight: 500; font-size: 20px; margin: 2px 0 6px; }
#rulecard p { margin: 0 0 6px; line-height: 1.45; font-size: 12px; }
#rulecard p.what { color: var(--soft); }
#rulecard .sig { float: right; width: 62px; height: 92px; margin: 0 0 4px 10px; }
#rulecard .sig svg { width: 62px; height: 92px; }
.x { position: absolute; right: 8px; top: 6px; border: 0; background: none; font-size: 16px; cursor: pointer; color: var(--soft); }
#pcard { position: absolute; left: 28px; bottom: 176px; width: 270px; background: var(--card); border: 1px solid var(--hair); border-radius: 14px; padding: 12px 14px; backdrop-filter: blur(6px); z-index: 2; }
#pcard h2 { font-family: var(--serif); font-weight: 500; font-size: 18px; margin: 0 0 2px; }
#pcard > .num { font-family: var(--serif); font-size: 24px; float: right; margin-right: 18px; color: var(--soft); }
#pcard .stats { color: var(--soft); font-size: 11px; line-height: 1.5; margin: 6px 0 8px; border-top: 1px solid var(--hair); padding-top: 6px; font-variant-numeric: tabular-nums; }
#photofinish { position: absolute; left: 50%; bottom: 66px; transform: translateX(-50%); width: 440px; background: var(--card); border: 1px solid var(--hair); border-radius: 14px; padding: 12px 14px 8px; backdrop-filter: blur(6px); }
#photofinish canvas { width: 100%; height: auto; display: block; border-radius: 6px; }
#curves { position: absolute; right: 332px; bottom: 66px; width: 250px; background: var(--card); border: 1px solid var(--hair); border-radius: 14px; padding: 10px 12px; backdrop-filter: blur(6px); }
#curves canvas { width: 100%; height: auto; display: block; }
/* the photo finish and the speed curves share the bottom edge: on a narrow window the photo finish goes on top */
@media (max-width: 1500px) { #photofinish:not(.hidden) ~ #curves { display: none; } }
#langMenu { position: absolute; left: 50%; bottom: 66px; transform: translateX(-50%); display: grid; grid-template-columns: repeat(3, auto); gap: 2px; background: var(--card); border: 1px solid var(--hair); border-radius: 14px; padding: 8px; backdrop-filter: blur(6px); z-index: 6; }
#langMenu a { color: var(--ink); text-decoration: none; font-size: 12px; padding: 7px 12px; border-radius: 999px; white-space: nowrap; text-align: center; }
#langMenu a:hover { background: rgba(43, 42, 39, .07); }
#langMenu a.on { background: var(--ink); color: var(--paper); }
#help { position: absolute; left: 50%; bottom: 66px; transform: translateX(-50%); width: 340px; background: var(--card); border: 1px solid var(--hair); border-radius: 14px; padding: 14px 16px; backdrop-filter: blur(6px); z-index: 6; }
#help h2 { font-family: var(--serif); font-weight: 500; font-size: 17px; margin: 0 0 8px; }
#help dl { display: grid; grid-template-columns: 64px 1fr; gap: 4px 8px; margin: 0 0 8px; }
#help dt { font-family: ui-monospace, Menlo, monospace; font-size: 10.5px; color: var(--soft); }
#help dd { margin: 0; }

/* scene labels */
.lab3 { position: absolute; left: 0; top: 0; font-size: 10px; background: rgba(250, 247, 240, .88); border: 1px solid var(--hair); border-radius: 999px; padding: 1px 6px; white-space: nowrap; will-change: transform; font-variant-numeric: tabular-nums; }
.lab3.lead { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.lab3.tiny { background: none; border: 0; font-size: 9.5px; color: #fff; text-shadow: 0 0 3px rgba(0, 0, 0, .75); padding: 0; }
.lab3.zone { background: none; border: 0; font-size: 10px; letter-spacing: .16em; text-transform: uppercase; color: #fff; text-shadow: 0 0 4px rgba(0, 0, 0, .6); }
.lab3.wind { background: #2f4b6e; color: #fff; border-color: #2f4b6e; }

#panel { z-index: 5; }
@media (max-width: 820px) {
  #title h1 { font-size: 16px; } #title p { display: none; } #title { left: 14px; top: 12px; max-width: 132px; padding: 7px 9px; margin: -8px -10px; }
  #score { right: 44px !important; top: 12px; width: 190px; padding: 7px 10px; }
  #score .clock { font-size: 20px; } #score .mini { display: none; }
  #summary { display: none; }
  #panel { width: 290px; max-width: calc(100vw - 50px); right: 8px; top: 150px; }
  body.panel-closed #panel { background: none; border-color: transparent; backdrop-filter: none; pointer-events: none; transform: translateX(calc(100% - 22px)); }
  body.panel-closed #panelToggle { pointer-events: auto; }
  #ticker { left: 14px; width: 220px; padding: 7px 9px; margin: -8px -10px; }
  #rulecard { left: 14px; top: 150px; width: 262px; max-width: calc(100vw - 60px); }
  #pcard { left: 14px; bottom: auto; top: 150px; width: 250px; }
  #photofinish, #help { width: calc(100vw - 24px); max-width: 440px; }
  #help { max-height: calc(100vh - 150px); overflow-y: auto; }
  #curves { right: 44px !important; width: 200px; bottom: 110px; }
  #bar { justify-content: flex-start; }
}

/* field events: attempt series, height grids, the timeline, the attempt clock, combined-event points */
#score .cur { display: flex; align-items: center; gap: 7px; padding: 3px 0 4px; border-bottom: 1px solid var(--hair); margin-bottom: 3px; }
#score .cur .nm { font-size: 15px; }
#score .cur .bib { font-variant-numeric: tabular-nums; font-size: 10px; color: var(--soft); }
#score .clock.low { color: var(--accent); }
#score .last { font-variant-numeric: tabular-nums; font-size: 12px; margin-left: auto; }
.tbl td.ser { font-size: 10px; color: var(--soft); text-align: right; padding: 3px 2px; }
.tbl td.ser.best { color: var(--ink); font-weight: 600; }
.tbl td.ser.x { color: var(--accent); }
.tbl td.pts { text-align: right; font-weight: 600; }
.scroll { overflow-x: auto; scrollbar-width: thin; margin: 0 -4px; padding: 0 4px; }
.tl .mk { color: var(--accent); font-size: 10px; font-weight: 600; }
.tl .fx { color: var(--accent); }
.lab3.mark { background: #f6f2e8; border-color: var(--ink); font-weight: 600; font-size: 11px; }
.lab3.foul { background: var(--accent); color: #fff; border-color: var(--accent); }
.passrow { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0 8px; }
.passrow .pill { padding: 3px 7px; font-size: 10px; font-variant-numeric: tabular-nums; }
