/* In-game court HUD: callouts, toasts, crosshair and the thumb
   cluster. Court-only: every rule is scoped to #match-hud or .dodgeball-game,
   so Walk's phone controls are untouched. */
.dodgeball-game {
  --hud-team-gold: #9b5706;
  --hud-team-purple: #753db2;
  --hud-gold: #e8c578;
  --hud-ink: #0d1f22;
  --hud-text: #f5f0df;
}
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}
#match-hud {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  font-weight: 650;
}
#court-names {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}
.court-name {
  position: absolute;
  left: 0;
  top: 0;
  color: var(--club-ink, white);
  background: #211c29ed;
  border-radius: 4px;
  padding: 1px 5px;
  font:
    700 clamp(12px, 1.8vmin, 18px)/1.2 system-ui,
    sans-serif;
  white-space: nowrap;
}
.court-name::after {
  position: absolute;
  content: '';
  top: 100%;
  left: 50%;
  height: var(--name-stem, 0);
  width: 1px;
  background: currentColor;
  opacity: 0.75;
}
.court-name.below-head::after {
  top: auto;
  bottom: 100%;
}
#match-hud button {
  pointer-events: auto;
}

/* Top row: match controls, leave on the right (desktop). */
.match-top {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  left: max(12px, env(safe-area-inset-left));
  right: max(12px, env(safe-area-inset-right));
  display: flex;
  justify-content: center;
  align-items: flex-start;
}
.match-top #leave-match {
  position: absolute;
  top: 0;
  right: 0;
  min-height: 34px;
  padding: 0 14px;
  color: var(--hud-text);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: #0d1f22b3;
  border: 1px solid #ffffff3d;
  border-radius: 10px;
}
/* Centre-top stack: callout above short-lived toasts. Never reaches the
   crosshair at 50% height. */
.hud-stack {
  position: absolute;
  top: calc(max(10px, env(safe-area-inset-top)) + 46px);
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
}
#round-message {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-height: 0;
  opacity: 0;
  visibility: hidden;
  text-align: center;
  transition:
    opacity 0.25s,
    visibility 0s 0.25s,
    max-height 0s 0.25s;
}
#round-message.is-on {
  max-height: 140px;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.12s;
}
.basket-call:not([hidden]) {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  left: max(12px, env(safe-area-inset-left));
  padding: 0.38em 1em 0.38em 0.65em;
  clip-path: polygon(0 0, 100% 0, calc(100% - 0.5em) 50%, 100% 100%, 0 100%);
  color: #261b2c;
  background: #ffda63;
  border-left: 4px solid #74eab6;
  font:
    900 clamp(12px, 1.8vw, 20px)/1.2 'Trebuchet MS',
    sans-serif;
  transform: rotate(-2deg);
  pointer-events: none;
}
.couch-view .basket-call {
  top: 2.6rem;
  text-shadow: none;
  font-size: clamp(11px, 1.3vw, 16px);
}
.round-scoreboard:not([hidden]) {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 18px;
  width: min(94vw, 960px);
  box-sizing: border-box;
  padding: 10px 14px;
  border: 1px solid #ffffff60;
  border-radius: 10px;
  color: #fff;
  background: #16141cf5;
  font:
    600 clamp(11px, 1.4vw, 15px)/1.35 system-ui,
    sans-serif;
}
.round-scoreboard table {
  width: 100%;
  border-collapse: collapse;
}
.round-scoreboard caption {
  font-weight: 800;
  text-align: left;
  color: #ffdf87;
  padding-bottom: 3px;
}
.round-scoreboard th,
.round-scoreboard td {
  padding: 2px;
  text-align: center;
}
.round-scoreboard thead {
  color: #d2d5de;
  font-size: 0.9em;
  border-bottom: 1px solid #ffffff55;
}
.round-scoreboard th:first-child {
  text-align: left;
  overflow-wrap: anywhere;
  max-width: 12ch;
}
.round-scoreboard td {
  font-variant-numeric: tabular-nums;
}
.round-scoreboard tr[data-local] {
  background: #ffffff16;
}
#couch-hud .round-scoreboard {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 1;
}
.couch-view .win-pennant {
  position: absolute;
  bottom: 10px;
  right: 10px;
}
@media (max-width: 700px) {
  .round-scoreboard:not([hidden]) {
    grid-template-columns: 1fr;
  }
}
@media (max-height: 450px) {
  .hud-stack:has(.round-scoreboard:not([hidden])) {
    top: 8px;
  }
  .hud-stack:has(.round-scoreboard:not([hidden])) .callout-main {
    font-size: 28px;
  }
}
#round-message .callout-main {
  font-size: clamp(40px, 13vw, 76px);
  line-height: 1.05;
  font-weight: 900;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  text-shadow: 0 3px 0 #0008;
}
#round-message.is-on .callout-main {
  animation: hud-pop 0.32s cubic-bezier(0.2, 1.4, 0.4, 1);
}
.win-pennant:empty {
  display: none;
}
.win-pennant {
  --silk: #f3bd52;
  --ink: #241a17;
  color: var(--ink);
  background: var(--silk);
  clip-path: polygon(0 0, 100% 0, calc(100% - 8px) 50%, 100% 100%, 0 100%, 8px 50%);
  padding: 3px 25px;
  line-height: 1.2;
  font-family: inherit;
  font-size: clamp(12px, 1.6vw, 17px);
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}
[data-club='purple'] .win-pennant {
  --silk: #7148ae;
  --ink: white;
}
[data-club='nomads'] .win-pennant {
  --silk: #26313b;
  --ink: #fff;
}
#round-message[data-prize='match'] .win-pennant {
  border-block: 2px solid #f9d888;
}
#round-message[data-prize='match'] .win-pennant::before,
#round-message[data-prize='match'] .win-pennant::after {
  content: '★';
  margin-inline: 0.55em;
  color: currentColor;
}
@media (prefers-reduced-motion: no-preference) {
  .couch-view .win-pennant:not(:empty),
  #round-message.is-on[data-prize='match'] .win-pennant {
    animation: raise-pennant 0.65s cubic-bezier(0.18, 0.85, 0.22, 1.18) both;
  }
}
@keyframes raise-pennant {
  from {
    opacity: 0;
    transform: translateY(-1em) scaleX(0.65);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
#round-message .callout-sub {
  font-size: 14px;
  letter-spacing: 0.08em;
  text-shadow: 0 1px 0 #000;
}
#round-message .callout-sub:empty {
  display: none;
}
#round-message[data-tone='win'] .callout-main,
#round-message[data-tone='go'] .callout-main {
  color: #ffe08a;
}
#round-message[data-tone='loss'] .callout-main {
  color: #ff8d83;
}
/* A callout owns the stack; prompts wait until it has gone. */
#round-message.is-on ~ #hud-toasts {
  display: none;
}
#hud-toasts {
  /* Keep short prompts below the reticle and out of the overhead scoreboard sightline. */
  position: fixed;
  top: calc(50% + 64px);
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: 88vw;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.hud-toast {
  max-width: min(88vw, 360px);
  padding: 7px 14px;
  color: var(--hud-text);
  font-size: 13px;
  line-height: 1.3;
  text-align: center;
  background: #0d1f22d9;
  border: 1px solid #ffffff2e;
  border-left: 3px solid var(--hud-gold);
  border-radius: 999px;
  box-shadow: 0 2px 0 #0007;
  animation: hud-toast-in 0.22s ease-out;
}
.hud-toast[data-key='possession'],
.hud-toast[data-key='out'] {
  border-left-color: #ff6a5c;
}

/* Crosshair (no text) and windup ring. */
.court-reticle {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  transform: translate(-50%, -50%);
}
.court-reticle::before,
.court-reticle::after {
  content: '';
  position: absolute;
  background: #fff;
  border-radius: 1px;
  box-shadow: 0 0 0 1px #0009;
}
.court-reticle::before {
  left: 0;
  right: 0;
  top: 9px;
  height: 2px;
}
.court-reticle::after {
  top: 0;
  bottom: 0;
  left: 9px;
  width: 2px;
}
:is(#defense-cue, .couch-defense) {
  position: absolute;
  top: 0;
  left: 0;
  box-sizing: border-box;
  width: var(--cue-size);
  height: var(--cue-size);
  border: 2px dashed #fff4ce;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 0 1px #382437;
  display: none;
}
:is(#defense-cue, .couch-defense)[data-phase='track'],
:is(#defense-cue, .couch-defense)[data-phase='press'] {
  display: block;
}
:is(#defense-cue, .couch-defense)[data-phase='press'] {
  border: 3px solid #89ffd2;
}
#windup-ring {
  --p: 0;
  position: absolute;
  top: 50%;
  left: 50%;
  width: 68px;
  height: 68px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: conic-gradient(var(--hud-gold) calc(var(--p) * 360deg), #ffffff2e 0);
  -webkit-mask: radial-gradient(circle, transparent 29px, #000 30px);
  mask: radial-gradient(circle, transparent 29px, #000 30px);
}

/* Action buttons: icon + short label (+ keycap on desktop). */
#match-actions:empty {
  display: none;
}
.dodgeball-game [data-action] {
  --p: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--hud-text);
  font-weight: 700;
  background: #0d1f22cc;
  border: 2px solid #ffffff55;
  box-shadow: 0 2px 0 #0007;
  transition: transform 0.08s;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.dodgeball-game .court-name.signature-windup {
  background: #31254c;
  color: #f4e5ff;
  box-shadow: inset 0 -2px #bc8bff;
}
.dodgeball-game [data-action='signature'][hidden] {
  display: none;
}
.dodgeball-game [data-action] svg,
.dodgeball-game .phone-actions [data-action] svg {
  width: 22px;
  height: 22px;
  margin: 0 !important;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.dodgeball-game [data-action] .action-label,
.dodgeball-game .phone-actions [data-action] .action-label {
  line-height: 1;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.dodgeball-game [data-action='pickup'] {
  border-color: #6fd3c0aa;
}
.dodgeball-game [data-action='defend'] {
  border-color: #7db7ffaa;
}
.dodgeball-game [data-action='jump'] {
  border-color: #f4d06fcc;
}
.dodgeball-game [data-action='duck'] {
  border-color: #c9a7ffaa;
}
.dodgeball-game [data-action='throwing'],
.dodgeball-game [data-action='ball'] {
  color: #112629;
  background: var(--hud-gold);
  border-color: #fff3cf;
}
.dodgeball-game [data-action]:active,
.dodgeball-game [data-action].is-winding {
  transform: scale(0.93);
  filter: brightness(1.2);
}
.dodgeball-game [data-action='throwing']::after,
.dodgeball-game [data-action='signature']::after,
.dodgeball-game [data-action='ball']::after {
  content: '';
  position: absolute;
  inset: -7px;
  border-radius: 50%;
  background: conic-gradient(#fff calc(var(--p) * 360deg), transparent 0);
  -webkit-mask: radial-gradient(circle, transparent calc(50% - 4px), #000 calc(50% - 3px));
  mask: radial-gradient(circle, transparent calc(50% - 4px), #000 calc(50% - 3px));
  pointer-events: none;
}

/* Desktop and other fine pointers: a compact keycap row, bottom right. */
@media (pointer: fine) {
  #match-actions {
    position: absolute;
    right: 20px;
    bottom: 20px;
    display: flex;
    gap: 10px;
  }
  #match-actions [data-action] {
    gap: 8px;
    min-height: 48px;
    padding: 0 14px;
    border-radius: 14px;
    flex-direction: row;
  }
  #match-actions kbd {
    display: inline-block;
    min-width: 20px;
    padding: 1px 5px;
    font:
      800 11px system-ui,
      sans-serif;
    text-align: center;
    color: inherit;
    background: #ffffff22;
    border: 1px solid currentColor;
    border-radius: 5px;
    opacity: 0.8;
  }
  #match-actions [data-action='throwing']::after {
    inset: -4px;
    border-radius: 17px;
    -webkit-mask: none;
    mask: none;
    background: none;
    border: 3px solid #fff;
    opacity: var(--p);
  }
}

/* Touch: the court's thumb cluster. Walk's controls are not selected here. */
.dodgeball-game:not(.in-match) .phone-controls,
.dodgeball-game:has(#match-hud:not([hidden]) #round-stats:not([hidden])) .phone-controls {
  display: none !important;
}
.dodgeball-game .phone-stick-label,
.dodgeball-game .phone-rotate-hint {
  display: none !important;
}
@media (pointer: coarse) {
  .dodgeball-game .phone-actions kbd {
    display: none;
  }
  .dodgeball-game .phone-actions {
    width: 172px !important;
    height: 170px !important;
    right: max(14px, env(safe-area-inset-right)) !important;
    top: auto !important;
    bottom: max(18px, env(safe-area-inset-bottom)) !important;
    transform: none !important;
  }
  .dodgeball-game .phone-actions [data-action] {
    position: absolute;
    flex-direction: column;
    gap: 2px;
    padding: 0 !important;
    width: 60px !important;
    height: 60px !important;
    border-radius: 50%;
  }
  /* Four smart buttons in a thumb arc: BALL big at the corner, DEFEND beside it, JUMP above
     and DUCK above DEFEND. Every target is at least 44px. */
  .dodgeball-game .phone-actions [data-action='jump'] {
    top: 0 !important;
    right: 18px !important;
    left: auto !important;
    bottom: auto !important;
  }
  .dodgeball-game .phone-actions [data-action='signature'] {
    top: -50px !important;
    right: 0 !important;
    left: auto !important;
    bottom: auto !important;
    width: auto !important;
    min-width: 96px;
    height: 44px !important;
    padding: 4px 8px !important;
    border-radius: 14px;
    background: #31254c;
    color: #f4e5ff;
  }
  .dodgeball-game .phone-actions [data-action='duck'] {
    top: 14px !important;
    left: 14px !important;
    right: auto !important;
    bottom: auto !important;
  }
  .dodgeball-game .phone-actions [data-action='defend'] {
    left: 0 !important;
    bottom: 10px !important;
    top: auto !important;
    right: auto !important;
  }
  .dodgeball-game .phone-actions [data-action='ball'] {
    right: 0 !important;
    bottom: 0 !important;
    top: auto !important;
    left: auto !important;
    width: 84px !important;
    height: 84px !important;
  }
  .dodgeball-game .phone-actions [data-action='ball'] {
    background: #31191b;
  }
  .dodgeball-game .phone-actions [data-action='ball'] img {
    width: 100%;
    height: 100%;
    pointer-events: none;
  }
  .dodgeball-game .phone-actions :is([data-action='duck'], [data-action='defend']) svg {
    display: none;
  }
  .dodgeball-game .phone-actions :is([data-action='duck'], [data-action='defend']) .action-label {
    width: calc(100% - 2px);
    font-size: 12px;
    line-height: 14px;
    text-transform: none;
    letter-spacing: 0;
    white-space: normal;
  }
  .hud-toast {
    font-size: 12px;
  }
}
@media (pointer: coarse) {
  /* Keep the score bug clear of the round menu button on the right. */
  .match-top {
    left: max(64px, calc(env(safe-area-inset-left) + 12px));
    right: max(64px, calc(env(safe-area-inset-right) + 12px));
  }
  .match-top #leave-match {
    display: none;
  }
}
@media (max-height: 500px) {
  #round-message .callout-main {
    font-size: 38px;
  }
  #round-message.is-on {
    max-height: 90px;
  }
}
@media (max-width: 359px) {
  .dodgeball-game .phone-actions {
    width: 150px !important;
    height: 150px !important;
  }
  .dodgeball-game .phone-actions [data-action='jump'],
  .dodgeball-game .phone-actions [data-action='duck'],
  .dodgeball-game .phone-actions [data-action='defend'] {
    width: 50px !important;
    height: 50px !important;
  }
  .dodgeball-game .phone-actions [data-action='jump'] {
    right: 14px !important;
  }
  .dodgeball-game .phone-actions [data-action='duck'] {
    left: 10px !important;
    top: 8px !important;
  }
  .dodgeball-game .phone-actions [data-action='ball'] {
    width: 72px !important;
    height: 72px !important;
  }
}
@keyframes hud-pop {
  from {
    transform: scale(0.5);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}
@keyframes hud-toast-in {
  from {
    transform: translateY(-6px);
    opacity: 0;
  }
  to {
    transform: none;
    opacity: 1;
  }
}
@media (prefers-reduced-motion: reduce) {
  #round-message,
  #round-message.is-on,
  .dodgeball-game [data-action] {
    transition: none;
  }
  #round-message.is-on .callout-main,
  .hud-toast {
    animation: none;
  }
}

/* Bots difficulty: host-only, desktop top-left; on phones it lives in the settings menu. */
.difficulty-setting {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--hud-text);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.match-top .difficulty-setting {
  position: absolute;
  top: 0;
  left: 0;
  min-height: 34px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgb(8 18 24 / 0.62);
  pointer-events: auto;
}
.difficulty-setting select {
  min-height: 30px;
  font: inherit;
  text-transform: none;
  letter-spacing: 0;
}
.difficulty-setting select:disabled {
  opacity: 0.6;
}
/* Narrow windows without the phone menu: drop below the score bug instead of hiding. */
@media (max-width: 760px) {
  .match-top .difficulty-setting {
    top: 46px;
  }
}

/* Sound: compact pill under the bots control on desktop; inside the settings menu on phones. */
.audio-setting {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--hud-text);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.audio-setting input {
  width: 84px;
}
.match-top .audio-setting {
  position: absolute;
  top: 42px;
  left: 0;
  min-height: 34px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgb(8 18 24 / 0.62);
  pointer-events: auto;
}
@media (max-width: 760px) {
  .match-top .audio-setting {
    top: 88px;
  }
}
.phone-settings-dialog .audio-setting {
  position: static;
  background: none;
  padding: 0;
}
