:root {
  --ink: #2b2838;
  --soft: #4b4660;
  --gold: #b0802f;
  --paper: #fbf6ea;
  --serif: 'Fraunces', 'Iowan Old Style', Georgia, serif;
  --gx: clamp(16px, 3.6vw, 52px);
  --gy: clamp(16px, 7vh, 64px);
  /* kawung batik, gold on dark brown, for the scoreboard frame */
  --kawung: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Crect width='16' height='16' fill='%233b2a1b'/%3E%3Cg fill='%23c99a45'%3E%3Cellipse cx='5' cy='5' rx='3.2' ry='1.9' transform='rotate(45 5 5)'/%3E%3Cellipse cx='11' cy='5' rx='3.2' ry='1.9' transform='rotate(-45 11 5)'/%3E%3Cellipse cx='5' cy='11' rx='3.2' ry='1.9' transform='rotate(-45 5 11)'/%3E%3Cellipse cx='11' cy='11' rx='3.2' ry='1.9' transform='rotate(45 11 11)'/%3E%3C/g%3E%3Ccircle cx='8' cy='8' r='1' fill='%233b2a1b'/%3E%3C/svg%3E");
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: #e6d4c6;
}

body {
  font-family: var(--serif);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  font-optical-sizing: auto;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#court {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
}

/* ---------- Bio ---------- */
.bio {
  position: fixed;
  /* the text lines up with the page edge; the frosted panel reaches past it */
  left: calc(var(--gx) - 18px);
  top: calc(var(--gy) - 16px);
  max-width: min(416px, calc(100vw - 2 * var(--gx) + 36px));
  padding: 16px 22px 18px 18px;
  border-radius: 16px;
  background: rgba(251, 246, 234, 0.74);
  -webkit-backdrop-filter: blur(10px) saturate(1.15);
  backdrop-filter: blur(10px) saturate(1.15);
  box-shadow: 0 10px 30px rgba(60, 40, 30, 0.1);
  pointer-events: none;
}

.bio h1 {
  margin: 0 0 5px;
  font-size: clamp(24px, 2.1vw, 30px);
  font-weight: 400;
  line-height: 1.1;
  letter-spacing: -0.012em;
}

.role {
  margin: 0 0 2px;
  font-size: 14.5px;
  color: var(--soft);
}

.clock {
  margin: 0 0 20px;
  font-size: 13.5px;
  color: var(--soft);
  font-variant-numeric: tabular-nums;
}

.work {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 26px;
  row-gap: 12px;
  font-size: 16px;
}

.work li {
  display: contents;
}

.work .k {
  padding-top: 2px;
  font-size: 13.5px;
  color: var(--soft);
}

.work a {
  color: var(--ink);
  text-decoration: none;
  pointer-events: auto;
  border-bottom: 1px solid transparent;
}

.work a:hover,
.work a:focus-visible {
  border-bottom-color: currentColor;
  outline: none;
}

.work small {
  display: block;
  margin-top: 2px;
  font-size: 13.5px;
  color: var(--soft);
}

/* ---------- GAINS and social ---------- */
.gains {
  position: relative;
  margin-top: 20px;
  pointer-events: auto;
}

.gains-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.gains-letters {
  display: flex;
  gap: 8px;
}

.gains-letters button {
  width: 27px;
  height: 27px;
  padding: 0;
  border: 1px solid rgba(43, 40, 56, 0.35);
  border-radius: 5px;
  background: rgba(251, 246, 234, 0.55);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  text-shadow: none;
}

.gains-letters button:hover,
.gains-letters button:focus-visible {
  border-color: var(--ink);
  outline: none;
}

.gains-letters button.on {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--paper);
}

.social {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.social a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px 5px 8px;
  border: 1px solid rgba(43, 40, 56, 0.3);
  border-radius: 999px;
  background: rgba(251, 246, 234, 0.85);
  color: var(--ink);
  font-size: 13.5px;
  text-decoration: none;
  text-shadow: none;
  box-shadow: 0 2px 8px rgba(60, 40, 30, 0.12);
}

.social a:hover,
.social a:focus-visible {
  border-color: var(--ink);
  background: var(--paper);
  outline: none;
}

.gains-card {
  position: absolute;
  left: 0;
  top: calc(100% + 8px);
  width: min(330px, calc(100vw - 2 * var(--gx)));
  padding: 14px 16px 12px;
  border-radius: 10px;
  background: rgba(251, 246, 234, 0.96);
  box-shadow: 0 10px 28px rgba(60, 40, 30, 0.2);
  text-shadow: none;
  font-size: 15px;
  line-height: 1.4;
  z-index: 2;
}

.gains-card[hidden] {
  display: none;
}

.gains-card h2 {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
}

.gains-card ol,
.gains-card ul,
.gains-card dl {
  margin: 0;
  padding: 0;
}

.goals {
  list-style: none;
  counter-reset: g;
}

.goals li {
  position: relative;
  margin-bottom: 8px;
  padding-left: 28px;
  counter-increment: g;
}

.goals li::before {
  content: '0' counter(g);
  position: absolute;
  left: 0;
  top: 1px;
  font-size: 13px;
  color: var(--soft);
  font-variant-numeric: tabular-nums;
}

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 14px;
}

.stats dt {
  font-size: 22px;
  line-height: 1.1;
}

.stats dd {
  margin: 0;
  font-size: 12px;
  color: var(--soft);
}

.pairs {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 14px;
}

.pairs dt {
  font-size: 13.5px;
  color: var(--soft);
  padding-top: 1px;
}

.pairs dd {
  margin: 0;
}

.wins {
  gap: 9px 14px;
}

.wins dt {
  padding-top: 0;
  font-size: 17px;
  line-height: 1.2;
  color: var(--ink);
}

.plain {
  list-style: none;
}

.plain li {
  margin-bottom: 6px;
}

/* ---------- Scoreboard ---------- */
.board {
  position: fixed;
  right: var(--gx);
  top: var(--gy);
  padding: 5px;
  border-radius: 7px;
  background: var(--kawung);
  box-shadow: 0 6px 18px rgba(60, 40, 30, 0.18);
  pointer-events: none;
}

.board-in {
  display: grid;
  row-gap: 3px;
  padding: 7px 11px 7px 9px;
  border-radius: 3px;
  background: var(--paper);
}

.row {
  display: grid;
  grid-template-columns: 9px auto 22px 28px;
  column-gap: 8px;
  align-items: center;
  font-size: 14px;
}

.row .nm {
  max-width: 96px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* the visitor's own name: tap to change it */
#me {
  padding: 0;
  border: 0;
  border-bottom: 1px dotted rgba(43, 40, 56, 0.45);
  background: none;
  color: inherit;
  font: inherit;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-align: left;
  text-transform: uppercase;
  cursor: pointer;
  pointer-events: auto;
}

.row .g,
.row .p {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.row .p {
  color: var(--gold);
  font-weight: 600;
}

.row .srv {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.row.serving .srv {
  background: #c9d83a;
  box-shadow: 0 0 0 1px rgba(80, 90, 20, 0.35);
}

/* ---------- Umpire call and end card ---------- */
#call {
  position: fixed;
  left: 0;
  right: 0;
  transform: translateY(-100%);
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
  text-shadow: 0 1px 14px rgba(255, 248, 240, 0.95), 0 0 2px rgba(255, 248, 240, 0.9);
}

#call.show {
  opacity: 1;
}

#call .reason {
  display: block;
  font-size: 13px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--soft);
}

#call .score {
  display: block;
  font-size: clamp(24px, 3.2vw, 42px);
  line-height: 1.15;
}

#box-card {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 5;
  transform: translate(-50%, -50%);
  width: min(380px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow: auto;
  padding: 20px 22px 18px;
  border-radius: 12px;
  background: rgba(251, 246, 234, 0.97);
  box-shadow: 0 14px 40px rgba(40, 30, 25, 0.28);
  user-select: text;
  -webkit-user-select: text;
}

#box-card[hidden] {
  display: none;
}

#box-card .close {
  position: absolute;
  top: 8px;
  right: 10px;
  width: 32px;
  height: 32px;
  border: 0;
  background: none;
  color: var(--soft);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

#box-card .eyebrow {
  margin: 0 0 4px;
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
}

#box-card h2 {
  margin: 0 0 8px;
  font-size: 24px;
  font-weight: 400;
  line-height: 1.15;
}

#box-card .lede {
  margin: 0 0 14px;
  font-size: 15px;
  line-height: 1.45;
  color: var(--soft);
}

.people {
  list-style: none;
  margin: 0;
  padding: 0;
}

.people li {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 9px 0;
  border-top: 1px solid rgba(43, 40, 56, 0.1);
  font-size: 15.5px;
}

.people i {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--c);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
}

.people small {
  font-size: 13px;
  color: var(--soft);
  font-variant-numeric: tabular-nums;
}

.people a {
  color: inherit;
  text-underline-offset: 3px;
}

.box-link {
  margin-top: 10px;
  padding: 0;
  border: 0;
  border-bottom: 1px solid currentColor;
  background: none;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}

#intro {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(320px, calc(100vw - 32px));
  padding: 20px 20px 18px;
  border-radius: 10px;
  background: rgba(251, 246, 234, 0.96);
  box-shadow: 0 10px 30px rgba(60, 40, 30, 0.22);
  text-align: center;
  user-select: text;
  -webkit-user-select: text;
}

#intro[hidden] {
  display: none;
}

#intro label {
  display: block;
  margin-bottom: 12px;
  font-size: 16px;
}

#intro input {
  display: block;
  width: 100%;
  margin-bottom: 12px;
  padding: 10px 12px;
  border: 1px solid rgba(43, 40, 56, 0.3);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 16px; /* 16px stops iPhone from zooming in */
  text-align: center;
}

#intro input:focus {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
}

#intro button,
#again {
  padding: 10px 26px;
  border: 1px solid var(--ink);
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  font: inherit;
  font-size: 15px;
  cursor: pointer;
}

#end {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  width: min(360px, calc(100vw - 32px));
  padding: 18px 20px 20px;
  border-radius: 10px;
  background: rgba(251, 246, 234, 0.94);
  box-shadow: 0 10px 30px rgba(60, 40, 30, 0.22);
  text-align: center;
}

#end[hidden] {
  display: none;
}

#end p {
  margin: 0 0 6px;
  font-size: 16px;
}

#end #record {
  margin-bottom: 14px;
  font-size: 12.5px;
  color: var(--soft);
}

#intro button:hover,
#again:hover {
  background: #403b52;
}

/* ---------- Hint and sound ---------- */
#hint {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(12px + env(safe-area-inset-bottom));
  margin: 0;
  text-align: center;
  font-size: 14.5px;
  font-style: italic;
  color: rgba(255, 255, 255, 0.95);
  text-shadow: 0 1px 4px rgba(20, 30, 10, 0.45);
  pointer-events: none;
}

#sound {
  position: fixed;
  right: calc(10px + env(safe-area-inset-right));
  bottom: calc(10px + env(safe-area-inset-bottom));
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgba(251, 246, 234, 0.7);
  color: var(--ink);
  cursor: pointer;
}

#sound .waves {
  display: none;
}

#sound.on .waves {
  display: inline;
}

#sound.on .mute {
  display: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- Phones ---------- */
@media (max-width: 560px) {
  :root {
    --gy: 40px;
  }
  /* on phones the panel becomes a frosted sheet across the top */
  .bio {
    left: 0;
    right: 0;
    top: 0;
    max-width: none;
    padding: var(--gy) var(--gx) 14px;
    border-radius: 0 0 18px 18px;
    /* lighter here so Bromo still shows through behind the text */
    background: rgba(251, 246, 234, 0.58);
    -webkit-backdrop-filter: blur(5px) saturate(1.1);
    backdrop-filter: blur(5px) saturate(1.1);
  }
  .bio h1 {
    font-size: 21px;
  }
  /* keep the top lines clear of the scoreboard */
  .bio h1,
  .role {
    max-width: calc(100vw - 2 * var(--gx) - 160px);
  }
  .role {
    font-size: 13.5px;
    line-height: 1.3;
  }
  #intro {
    top: 60%;
  }
  .clock {
    margin-bottom: 12px;
    font-size: 12.5px;
  }
  .work {
    font-size: 14px;
    row-gap: 5px;
  }
  .work .k,
  .work small {
    font-size: 12.5px;
  }
  .work small {
    margin-top: 0;
  }
  .work .short small {
    display: none;
  }
  .gains {
    margin-top: 12px;
  }
  .board {
    padding: 4px;
  }
  .board-in {
    padding: 5px 8px 5px 7px;
  }
  .row {
    grid-template-columns: 7px auto 16px 24px;
    column-gap: 6px;
    font-size: 13px;
  }
  .row .nm {
    font-size: 10.5px;
  }
}
