:root {
  --paper: #f3eee4;
  --ink: #2b2a27;
  --soft: #6f6a60;
  --hair: rgba(43, 42, 39, .16);
  --card: rgba(250, 247, 240, .9);
  --accent: #c8553d;
  --water: #2f7fa8;
  --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; }
#flash { position: fixed; inset: 0; pointer-events: none; background: #fff; opacity: 0; }
#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; }

/* left column: title, then whatever card is open, so nothing overlaps a long headline */
#left { position: absolute; left: 28px; top: 22px; width: 300px; display: flex; flex-direction: column; gap: 14px; pointer-events: none !important; max-height: calc(100vh - 230px); }
#left > section { pointer-events: auto; }
#title { pointer-events: none; }
#title, #ticker { text-shadow: 0 0 5px var(--paper), 0 0 5px var(--paper), 0 0 10px var(--paper); }
body.dark #title, body.dark #ticker { text-shadow: 0 0 5px #242d39, 0 0 5px #242d39, 0 0 10px #242d39; }
.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: 28px; line-height: 1.06; 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.dark #title h1, body.dark #ticker div:last-child { color: #f3eee4; }
body.dark #title p, body.dark #title .kicker, body.dark #ticker div { color: #b9b4a8; border-color: rgba(255, 255, 255, .2); }

/* scorecard */
/* right column: scorecard, then the card of the diver that was clicked */
#right { position: absolute; right: 332px; top: 20px; width: 262px; display: flex; flex-direction: column; gap: 10px; pointer-events: none !important; max-height: calc(100vh - 96px); }
#right > section { pointer-events: auto; }
body.panel-closed #right { right: 64px; }
#score { background: var(--card); border: 1px solid var(--hair); border-radius: 14px; padding: 10px 14px; backdrop-filter: blur(6px); }
#score .kicker { margin-bottom: 2px; letter-spacing: .14em; }
#score .mini, .mini { font-size: 10px; color: var(--soft); }
#score .who { display: flex; align-items: center; gap: 7px; margin-top: 7px; padding-top: 7px; border-top: 1px solid var(--hair); }
#score .nm { flex: 1; font-family: var(--serif); font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#score .dive { margin-top: 3px; line-height: 1.4; color: var(--soft); display: flex; gap: 8px; align-items: baseline; }
#score .dive .dn { flex: 1; min-width: 0; }
#score .dive b { color: var(--ink); font-family: var(--serif); font-size: 14px; font-weight: 600; }
#score .ddv { flex: none; color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; }
#score .judges { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 8px; }
.js { min-width: 27px; text-align: center; padding: 2px 3px; border: 1px solid var(--hair); border-radius: 5px; font-variant-numeric: tabular-nums; font-size: 11px; background: rgba(255, 255, 255, .5); }
.js.cut { text-decoration: line-through; color: #a9a398; background: none; }
.js.sy { border-color: var(--water); }
.js.gap { margin-left: 5px; }
#score .calc { margin-top: 6px; font-size: 11px; color: var(--soft); font-variant-numeric: tabular-nums; }
#score .tot { display: flex; justify-content: flex-end; align-items: baseline; gap: 8px; margin-top: 2px; }
#score .tot b { font-family: var(--serif); font-size: 26px; font-weight: 500; font-variant-numeric: tabular-nums; }
.bad { color: var(--accent); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
#score .top { margin-top: 8px; padding-top: 7px; border-top: 1px solid var(--hair); }
.row { display: flex; align-items: center; gap: 7px; padding: 2px 0; }
.row .rk { flex: 0 0 14px; color: var(--soft); font-variant-numeric: tabular-nums; }
.row .nm { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .gl { font-variant-numeric: tabular-nums; }
.flag { display: inline-block; width: 15px; height: 10px; border-radius: 2px; border: 1px solid var(--hair); flex: none; vertical-align: -1px; }

/* ticker */
#ticker { position: absolute; left: 28px; bottom: 66px; width: 320px; pointer-events: none !important; }
#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; }

/* 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: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; }
#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 input[type=range] { 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: 16px; margin: 14px 0 6px; }
#tabBody h3:first-child { margin-top: 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); min-height: 9px; }
.grid { display: flex; flex-wrap: wrap; gap: 5px; }
.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 48px; 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; }
.clash { color: var(--accent); font-size: 11px; margin: 6px 0; }
.tl { display: flex; gap: 8px; padding: 4px 0; border-top: 1px solid var(--hair); font-size: 11px; align-items: baseline; font-variant-numeric: tabular-nums; }
.tl b { flex: 0 0 16px; }
.tl .gr { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl.goal { cursor: pointer; }
.tl.goal:hover, .tl.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; }
.rtable { font-size: 10.5px; font-variant-numeric: tabular-nums; }
.rrow { display: grid; grid-template-columns: 14px minmax(0, 1fr) repeat(var(--n), 27px) 38px; gap: 2px; align-items: center; padding: 3px 0; border-top: 1px solid var(--hair); }
.rrow.head { color: var(--soft); border-top: 0; }
.rrow .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rrow .c { text-align: right; }
.rrow .b { font-weight: 600; }

/* cards */
#rulecard, #summary { background: var(--card); border: 1px solid var(--hair); border-radius: 14px; padding: 14px 16px; backdrop-filter: blur(6px); position: relative; }
#rulecard { display: grid; grid-template-columns: 1fr 62px; gap: 4px 10px; }
#rulecard .kicker { grid-column: 1 / 3; margin: 0; }
#rulecard h2 { font-family: var(--serif); font-weight: 500; font-size: 20px; margin: 2px 0 4px; grid-column: 1; }
#rulecard p { margin: 0 0 5px; line-height: 1.45; font-size: 12px; grid-column: 1; }
#rulecard p.what { color: var(--soft); }
#rulecard .sig { grid-row: 2 / 5; grid-column: 2; }
#rulecard .sig svg { width: 62px; height: 94px; display: block; }
#rulecard .x, #pcard .x, #help .x { position: absolute; right: 8px; top: 6px; border: 0; background: none; font-size: 16px; cursor: pointer; color: var(--soft); }
#summary { overflow-y: auto; }
#summary h2 { font-family: var(--serif); font-weight: 500; font-size: 20px; margin: 0 0 8px; }
#summary .row { border-top: 1px solid var(--hair); padding: 4px 0; }
#summary .row.in .nm { font-weight: 600; }
#summary .pill { margin-top: 10px; }
#summary .medals .nm { font-family: var(--serif); font-size: 15px; }
.medal { width: 12px; height: 12px; border-radius: 50%; flex: none; border: 1px solid var(--hair); }
.medal.m1 { background: #e3b23c; } .medal.m2 { background: #b9bcc0; } .medal.m3 { background: #b98d5e; }
#pcard { position: relative; background: var(--card); border: 1px solid var(--hair); border-radius: 14px; padding: 12px 14px; backdrop-filter: blur(6px); overflow-y: auto; min-height: 0; }
#pcard h2 { font-family: var(--serif); font-weight: 500; font-size: 18px; margin: 0 18px 2px 0; }
#pcard .stats { color: var(--soft); font-size: 11px; margin: 6px 0 4px; }
#pcard .list { margin-bottom: 6px; }
#pcard .ctl label { flex: 0 0 62px; }
#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); }
#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); }
#help h2 { font-family: var(--serif); font-weight: 500; font-size: 17px; margin: 0 0 8px; }
#help dl { display: grid; grid-template-columns: 84px 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; }
.lab3.chip { background: var(--ink); color: var(--paper); border-color: var(--ink); font-size: 10.5px; font-variant-numeric: tabular-nums; }
.lab3.tiny2 { background: none; border: 0; color: #fff; text-shadow: 0 0 3px rgba(0, 0, 0, .7); padding: 0; }
.lab3.score { background: #fff; border-color: var(--ink); border-radius: 4px; font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; padding: 2px 5px; }
.lab3.score.cut { text-decoration: line-through; color: #a9a398; border-color: var(--hair); font-weight: 400; }
.lab3.score.sync { border-color: var(--water); }
.lab3.jrow { display: flex; gap: 2px; background: none; border: 0; padding: 0; }
.lab3.jrow span { background: #fff; border: 1px solid var(--ink); border-radius: 4px; font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; padding: 2px 4px; }
.lab3.jrow span.cut { text-decoration: line-through; color: #a9a398; border-color: var(--hair); font-weight: 400; }
.lab3.jrow span.sync { border-color: var(--water); }
.lab3.digits { display: flex; gap: 4px; background: none; border: 0; padding: 0; }
.lab3.digits span { display: flex; flex-direction: column; align-items: center; background: var(--card); border: 1px solid var(--hair); border-radius: 8px; padding: 3px 7px; }
.lab3.digits b { font-family: var(--serif); font-size: 20px; font-weight: 500; line-height: 1.1; }
.lab3.digits i { font-style: normal; font-size: 9.5px; color: var(--soft); }
.lab3.digits span:last-child b { color: var(--accent); }

@media (max-width: 820px) {
  #left { left: 14px; top: 12px; width: 134px; max-height: none; }
  #title h1 { font-size: 19px; } #title p { display: none; }
  #right { right: 44px !important; top: 12px; width: 190px; max-height: none; }
  #score { padding: 7px 10px; }
  #score .top, #score .calc { display: none; }
  #score .nm { font-size: 13px; } #score .tot b { font-size: 20px; }
  #rulecard, #summary { position: fixed; left: 10px; right: 46px; bottom: 58px; max-height: 46vh; overflow-y: auto; z-index: 3; }
  #pcard { position: fixed; left: 10px; right: 46px; bottom: 58px; max-height: 52vh; z-index: 3; }
  #panel { width: 280px; right: 8px; top: 150px; z-index: 4; }
  #ticker { left: 14px; width: 220px; }
  #bar { justify-content: flex-start; }
  #help { width: auto; left: 10px; right: 10px; transform: none; max-height: 70vh; overflow-y: auto; z-index: 5; }
  #langMenu { z-index: 5; }
}

/* buttons start with a capital whatever the language of the label */
#panel button::first-letter { text-transform: uppercase; }
