/* Volleyball — editorial interface over the diorama */
:root {
  --bg: #f3efe6;
  --paper: #fbf8f2;
  --ink: #23262b;
  --ink-2: #5b5f66;
  --ink-3: #8d9097;
  --line: rgba(35, 38, 43, 0.14);
  --accent: #c4473a;
  --accent-2: #2f6fb0;
  --glass: rgba(251, 248, 242, 0.86);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, "Songti SC", "Noto Serif CJK SC", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, "PingFang SC", "Hiragino Sans", "Noto Sans CJK SC", sans-serif;
  --r: 999px;
  --panel-w: 340px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--ink); font-family: var(--sans); font-size: 13px; -webkit-font-smoothing: antialiased; }
canvas#c { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; touch-action: none; cursor: grab; }
canvas#c:active { cursor: grabbing; }
button { font: inherit; color: inherit; }

/* ------------------------------------------------ title */
#title { position: fixed; top: 22px; left: 26px; max-width: 360px; pointer-events: none; z-index: 5; }
#title .kicker { font-size: 10.5px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--ink-2); }
#title h1 { font-family: var(--serif); font-weight: 400; font-size: 44px; line-height: 1; margin: 6px 0 6px; letter-spacing: -0.01em; }
#title .sub { font-family: var(--serif); font-style: italic; font-size: 15px; color: var(--ink-2); }
#title .facts { margin: 8px 0 0; padding-top: 8px; border-top: 1px solid var(--line); font-size: 11.5px; line-height: 1.5; color: var(--ink-2); }

/* ------------------------------------------------ scorecard */
#score { position: fixed; top: 18px; right: 18px; width: 318px; background: var(--glass); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); border: 1px solid var(--line); border-radius: 14px; padding: 8px 12px 8px; z-index: 6; }
#score .shead { display: flex; justify-content: space-between; font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-2); padding-bottom: 4px; border-bottom: 1px solid var(--line); }
#score .shead .status { color: var(--accent); font-weight: 600; }
.srow { display: grid; grid-template-columns: 14px 1fr 12px 22px 36px; align-items: center; gap: 6px; padding: 4px 0 0; }
.srow .tn { font-family: var(--serif); font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.srow .srv { color: #d9a321; font-size: 10px; text-align: center; }
.srow .sets { font-family: var(--serif); font-size: 16px; color: var(--ink-2); text-align: right; }
.srow .pts { font-family: var(--serif); font-size: 26px; text-align: right; line-height: 1; font-variant-numeric: tabular-nums; }
.srow .meta { grid-column: 2 / -1; display: flex; gap: 10px; font-size: 10.5px; color: var(--ink-3); margin-top: -2px; }
.srow .tos i { display: inline-block; width: 6px; height: 6px; border-radius: 50%; border: 1px solid var(--ink-3); margin-right: 3px; }
.srow .tos i.on { background: var(--ink-2); border-color: var(--ink-2); }
.srow.serving .tn { font-weight: 600; }
#score .hist { display: flex; gap: 8px; font-size: 11px; color: var(--ink-2); margin-top: 4px; min-height: 2px; font-variant-numeric: tabular-nums; }
.chip { display: inline-block; width: 12px; height: 12px; border-radius: 3px; background: linear-gradient(135deg, var(--c) 0 62%, var(--t) 62% 100%); box-shadow: inset 0 0 0 1px rgba(0,0,0,0.12); vertical-align: -1px; margin-right: 6px; flex: none; }

#badge { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: 5px 14px; border-radius: var(--r); font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; opacity: 0; transition: opacity 0.3s; pointer-events: none; z-index: 8; }
#badge.open { opacity: 1; }

/* ------------------------------------------------ ticker */
#ticker { position: fixed; left: 26px; bottom: 74px; max-width: 430px; z-index: 5; pointer-events: none; }
#ticker p { margin: 2px 0; font-family: var(--serif); font-size: 14px; line-height: 1.35; text-shadow: 0 1px 0 rgba(251,248,242,0.8); }
#ticker p:last-child { font-size: 15.5px; }

/* ------------------------------------------------ rule card */
#rulecard { position: fixed; left: 26px; top: 200px; width: 340px; max-height: calc(100vh - 300px); overflow: auto; background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px 12px; box-shadow: 0 10px 30px rgba(60,45,30,0.10); z-index: 9; opacity: 0; transform: translateY(8px); pointer-events: none; transition: opacity 0.25s, transform 0.25s; }
#rulecard.open { opacity: 1; transform: none; pointer-events: auto; }
.rc-kicker { font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--accent); }
#rulecard h3 { font-family: var(--serif); font-weight: 400; font-size: 22px; margin: 4px 0 8px; }
.rc-body { display: grid; grid-template-columns: 1fr 96px; gap: 12px; align-items: start; }
.rc-text p { margin: 0 0 8px; line-height: 1.45; }
.rc-text p span { display: block; font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 1px; }
.rc-text .spec { font-size: 12px; padding-left: 8px; border-left: 2px solid var(--line); }
.rc-text .spec.cur { border-left-color: var(--accent); }
.rc-text .spec.muted { color: var(--ink-3); }
.rc-text .spec b { font-weight: 600; margin-right: 4px; }
#rulecard figure { margin: 0; text-align: center; color: var(--ink); }
#rulecard figure svg { width: 96px; height: auto; }
#rulecard figcaption { font-size: 10px; color: var(--ink-3); letter-spacing: 0.08em; text-transform: uppercase; }
.rc-close { position: absolute; top: 8px; right: 10px; border: 0; background: none; font-size: 20px; line-height: 1; color: var(--ink-3); cursor: pointer; }
.rc-close:hover { color: var(--ink); }

/* ------------------------------------------------ side panel */
#panel { position: fixed; right: 18px; top: 170px; bottom: 74px; width: var(--panel-w); display: flex; flex-direction: column; background: var(--glass); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); border: 1px solid var(--line); border-radius: 14px; z-index: 6; transition: transform 0.3s ease, opacity 0.3s; }
body:not(.panel-open) #panel { transform: translateX(calc(100% + 30px)); opacity: 0; pointer-events: none; }
#tabs { display: flex; flex-wrap: wrap; gap: 4px; padding: 10px 10px 8px; border-bottom: 1px solid var(--line); }
#tabs button { border: 1px solid transparent; background: none; padding: 3px 9px; border-radius: var(--r); font-size: 11.5px; color: var(--ink-2); cursor: pointer; }
#tabs button:hover { color: var(--ink); }
#tabs button.on { border-color: var(--ink); color: var(--ink); }
#panel-body { overflow-y: auto; padding: 10px 14px 16px; flex: 1; }
#panel-body h4 { font-size: 10.5px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-2); font-weight: 600; margin: 16px 0 6px; padding-top: 10px; border-top: 1px solid var(--line); }
#panel-body h4:first-child { border-top: 0; margin-top: 4px; }
.hint, .note { color: var(--ink-2); line-height: 1.45; margin: 4px 0 8px; font-size: 12px; }
.note { font-size: 11.5px; }
.btns { display: flex; flex-wrap: wrap; gap: 5px; }
button.sit { border: 1px solid var(--line); background: var(--paper); border-radius: var(--r); padding: 5px 10px; cursor: pointer; font-size: 12px; display: inline-flex; align-items: center; gap: 6px; }
button.sit:hover { border-color: var(--ink); }
button.sit small { font-size: 9.5px; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.08em; }
button.sit.off { opacity: 0.4; cursor: not-allowed; }
.field { margin: 8px 0; }
.field > label { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--ink-2); margin-bottom: 4px; }
.field output, .kit output, .vol output { font-variant-numeric: tabular-nums; color: var(--ink); font-size: 11.5px; }
.field input[type=text], .field select, .scoregrid input { width: 100%; font: inherit; padding: 5px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); color: var(--ink); }
.field input[type=range] { width: 100%; }
input[type=range] { accent-color: var(--ink); }
input[type=color] { width: 34px; height: 22px; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: none; cursor: pointer; }
.kit { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px 10px; }
.kit label { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--ink-2); }
.kit label output { margin-left: auto; font-size: 10.5px; color: var(--ink-3); }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 8px 0; }
.warn { color: var(--accent); font-size: 11.5px; }
.roster { display: flex; flex-direction: column; }
.prow { display: grid; grid-template-columns: 26px 1fr 40px 70px; gap: 6px; align-items: center; border: 0; border-bottom: 1px solid var(--line); background: none; padding: 5px 2px; text-align: left; cursor: pointer; font-size: 12px; }
.prow:hover { background: rgba(35,38,43,0.04); }
.prow .num { font-family: var(--serif); font-size: 15px; }
.prow .pp, .prow .ps { color: var(--ink-3); font-size: 11px; }
.prow.court .ps { color: var(--accent-2); }
.scoregrid { display: grid; grid-template-columns: 1fr 60px 60px; gap: 6px; align-items: center; font-size: 11.5px; color: var(--ink-2); }
.scoregrid .tn { color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.checks { display: flex; flex-direction: column; gap: 4px; }
.checks label { display: flex; gap: 8px; align-items: center; cursor: pointer; font-size: 12.5px; }
.checks input { accent-color: var(--ink); }
ol.basics { padding-left: 18px; margin: 4px 0; }
ol.basics li { margin: 0 0 6px; line-height: 1.45; font-family: var(--serif); font-size: 13.5px; }
.gl { display: flex; flex-direction: column; }
.gl button { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; border: 0; border-bottom: 1px solid var(--line); background: none; padding: 6px 2px; cursor: pointer; text-align: left; }
.gl button span { font-family: var(--serif); font-size: 14px; }
.gl button small { color: var(--ink-3); font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; white-space: nowrap; }
.gl button:hover span { color: var(--accent); }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
table th, table td { padding: 3px 4px; border-bottom: 1px solid var(--line); text-align: right; font-size: 11.5px; }
table th:first-child, table td:first-child { text-align: left; }
table th { font-weight: 600; color: var(--ink-2); font-size: 10.5px; }
table.sets td.won { font-weight: 700; }
table.box { margin-bottom: 10px; }
table.box td:first-child { white-space: nowrap; max-width: 96px; overflow: hidden; text-overflow: ellipsis; }
table.box tr[data-pid] { cursor: pointer; }
table.box tr[data-pid]:hover td { background: rgba(35,38,43,0.04); }
.timeline { display: flex; flex-direction: column; }
.timeline button { border: 0; border-bottom: 1px solid var(--line); background: none; padding: 5px 2px; text-align: left; cursor: pointer; font-size: 11.5px; line-height: 1.4; display: block; }
.timeline button b { font-weight: 600; font-variant-numeric: tabular-nums; }
.timeline button span { color: var(--ink-2); }
.timeline button:hover:not(:disabled) { background: rgba(35,38,43,0.04); }
.timeline button.norec { cursor: default; opacity: 0.6; }

/* ------------------------------------------------ pills and segments */
.pill { border: 1px solid var(--line); background: var(--paper); border-radius: var(--r); padding: 5px 11px; cursor: pointer; font-size: 12px; white-space: nowrap; }
.pill:hover { border-color: var(--ink); }
.pill.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.pill.strong { font-weight: 600; }
.pill.icon { width: 30px; padding: 5px 0; text-align: center; }
.pill:disabled { opacity: 0.4; cursor: not-allowed; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--r); padding: 2px; background: var(--paper); }
.seg button { border: 0; background: none; border-radius: var(--r); padding: 3px 10px; cursor: pointer; font-size: 12px; white-space: nowrap; display: inline-flex; align-items: center; }
.seg button.on { background: var(--ink); color: var(--paper); }
.seg.wide { display: flex; width: 100%; }
.seg.wide button { flex: 1; justify-content: center; overflow: hidden; text-overflow: ellipsis; }
.seg.wrap { flex-wrap: wrap; border-radius: 14px; }

/* ------------------------------------------------ bottom bar */
#bar { position: fixed; left: 14px; right: 14px; bottom: 12px; display: flex; align-items: center; gap: 6px; padding: 6px 8px; background: var(--glass); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); border: 1px solid var(--line); border-radius: 18px; z-index: 7; overflow-x: auto; scrollbar-width: none; }
#bar::-webkit-scrollbar { display: none; }
#bar .grp { display: flex; align-items: center; gap: 5px; padding-right: 8px; margin-right: 2px; border-right: 1px solid var(--line); flex: none; }
#bar .grp:last-child { border-right: 0; }
#bar .grp.end { margin-left: auto; }
.vol { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; color: var(--ink-2); }
.vol input { width: 70px; }
.menu { display: none; position: fixed; bottom: 60px; background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 6px; box-shadow: 0 10px 30px rgba(60,45,30,0.12); z-index: 20; flex-direction: column; min-width: 200px; }
.menu.open { display: flex; }
.menu button { border: 0; background: none; text-align: left; padding: 6px 10px; border-radius: 8px; cursor: pointer; font-size: 12.5px; }
.menu button:hover, .menu button.on { background: rgba(35,38,43,0.07); }

/* ------------------------------------------------ floating labels */
#labels { position: fixed; inset: 0; pointer-events: none; z-index: 4; overflow: hidden; }
.plabel { position: absolute; left: 0; top: 0; z-index: 1; translate: -50% -100%; font-size: 10.5px; white-space: nowrap; background: rgba(251,248,242,0.9); border: 1px solid var(--line); border-left: 3px solid var(--c); padding: 1px 6px; border-radius: 4px; color: var(--ink); }
.plabel b { color: var(--accent); margin-right: 2px; }
.plabel.last { font-weight: 600; box-shadow: 0 2px 8px rgba(60,45,30,0.15); }
.touch-num { position: absolute; left: 0; top: 0; translate: -50% -50%; width: 17px; height: 17px; border-radius: 50%; background: var(--c); color: #fff; font-size: 10px; font-weight: 700; display: flex; align-items: center; justify-content: center; box-shadow: 0 0 0 2px rgba(251,248,242,0.9); }
#aimdot { position: fixed; left: 0; top: 0; width: 26px; height: 26px; translate: -50% -50%; border: 2px solid var(--accent); border-radius: 50%; display: none; pointer-events: none; z-index: 4; }
#aimdot::after { content: ""; position: absolute; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px 0 0 -3px; background: var(--accent); border-radius: 50%; }

/* ------------------------------------------------ popovers */
#playercard { position: fixed; width: 300px; background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 14px; box-shadow: 0 12px 34px rgba(60,45,30,0.14); z-index: 12; display: none; }
#playercard.open { display: block; }
.pc-head { display: flex; gap: 12px; align-items: center; }
.bignum { font-family: var(--serif); font-size: 30px; width: 50px; height: 50px; border-radius: 10px; background: var(--c); color: #fff; display: flex; align-items: center; justify-content: center; text-shadow: 0 1px 2px rgba(0,0,0,0.3); flex: none; }
.pc-head h3 { font-family: var(--serif); font-weight: 400; font-size: 19px; margin: 0; }
.pc-head .sub { font-size: 11.5px; color: var(--ink-2); }
.pc-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 12px 0; padding: 8px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.pc-stats div { text-align: center; }
.pc-stats b { display: block; font-family: var(--serif); font-size: 20px; font-weight: 400; }
.pc-stats span { font-size: 10px; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.06em; }
.pc-btns { display: flex; flex-wrap: wrap; gap: 5px; }
#help { position: fixed; right: 18px; bottom: 70px; width: 320px; background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; box-shadow: 0 12px 34px rgba(60,45,30,0.14); z-index: 15; display: none; }
#help.open { display: block; }
#help h3 { font-family: var(--serif); font-weight: 400; font-size: 18px; margin: 0 0 8px; }
#help ul { list-style: none; padding: 0; margin: 0 0 8px; }
#help li { padding: 3px 0; border-bottom: 1px solid var(--line); font-size: 12px; }
#help p { font-size: 11.5px; line-height: 1.45; color: var(--ink-2); margin: 0; }
#langmenu { position: fixed; right: 60px; bottom: 64px; background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 6px; box-shadow: 0 12px 34px rgba(60,45,30,0.14); z-index: 15; display: none; flex-direction: column; min-width: 150px; }
#langmenu.open { display: flex; }
#langmenu a { color: var(--ink); text-decoration: none; padding: 6px 10px; border-radius: 8px; font-size: 13px; }
#langmenu a:hover, #langmenu a.on { background: rgba(35,38,43,0.07); }
#summary { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; z-index: 30; background: rgba(243,239,230,0.55); }
#summary.open { display: flex; }
.sum-card { width: min(560px, calc(100vw - 32px)); background: var(--paper); border: 1px solid var(--line); border-radius: 18px; padding: 22px 24px; box-shadow: 0 20px 60px rgba(60,45,30,0.18); }
.sum-card .kicker { font-size: 10.5px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--accent); }
.sum-card h2 { font-family: var(--serif); font-weight: 400; font-size: 30px; margin: 6px 0 10px; }
.sum-sets { display: flex; gap: 12px; font-family: var(--serif); font-size: 17px; color: var(--ink-2); padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.sum-teams { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 12px 0; }
.sum-teams h4 { margin: 0 0 4px; font-family: var(--serif); font-weight: 400; font-size: 16px; }
.sum-teams p { margin: 0 0 6px; font-size: 11.5px; color: var(--ink-2); }
.sum-teams ol { margin: 0; padding-left: 18px; font-size: 12.5px; }
.sum-card .auto { font-size: 11.5px; color: var(--ink-3); margin-left: auto; }
#photo-hint { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); background: var(--glass); border: 1px solid var(--line); border-radius: var(--r); padding: 6px 14px; font-size: 11.5px; color: var(--ink-2); display: none; z-index: 20; cursor: pointer; }

/* photo mode hides the interface */
body.photo #title, body.photo #score, body.photo #panel, body.photo #bar, body.photo #ticker, body.photo #rulecard, body.photo #labels, body.photo #aimdot, body.photo #badge, body.photo #playercard, body.photo #help, body.photo #langmenu, body.photo #viewmenu { display: none !important; }
body.photo #photo-hint { display: block; animation: fadeHint 4s forwards; }
@keyframes fadeHint { 0%, 70% { opacity: 1; } 100% { opacity: 0; } }

/* ------------------------------------------------ narrow screens */
@media (max-width: 900px) {
  :root { --panel-w: 310px; }
  #rulecard { width: 300px; }
}
@media (max-width: 760px) {
  html, body { font-size: 12px; }
  #title { top: 12px; left: 16px; max-width: calc(100vw - 210px); }
  #title h1 { font-size: 28px; margin: 3px 0; }
  #title .sub { font-size: 12.5px; }
  #title .facts { display: none; }
  #score { top: 10px; right: 10px; width: 186px; padding: 6px 9px; border-radius: 12px; }
  .srow { grid-template-columns: 12px 1fr 10px 16px 28px; gap: 4px; }
  .srow .tn { font-size: 12.5px; }
  .srow .pts { font-size: 20px; }
  .srow .meta .rot { display: none; }
  #score .hist { display: none; }
  #ticker { left: 16px; right: 16px; bottom: 64px; max-width: none; }
  #ticker p:not(:last-child):not(:nth-last-child(2)) { display: none; }
  #ticker p { font-size: 12.5px; }
  #ticker p:last-child { font-size: 13.5px; }
  #panel { left: 8px; right: 8px; top: auto; bottom: 62px; width: auto; max-height: 52vh; }
  body:not(.panel-open) #panel { transform: translateY(calc(100% + 80px)); }
  #rulecard { left: 8px; right: 8px; width: auto; top: auto; bottom: 120px; max-height: 46vh; }
  .rc-body { grid-template-columns: 1fr 72px; }
  #rulecard figure svg { width: 72px; }
  #bar { left: 8px; right: 8px; bottom: 8px; border-radius: 14px; }
  #bar .grp.end { margin-left: 0; }
  #help { left: 8px; right: 8px; width: auto; bottom: 62px; }
  #langmenu { right: 8px; bottom: 62px; }
  .sum-teams { grid-template-columns: 1fr; }
}
