/* NBA-owned port of basketaki_new/index.html corner geometry + src/mobile-hud.css.
   The existing native HUD supplies scores/fouls/corner state; no engine changes. */
#hud.corners #sb { left: max(18px, env(safe-area-inset-left)); right: max(18px, env(safe-area-inset-right));
  width: auto; transform: none; display: flex; align-items: stretch; justify-content: space-between;
  min-height: 0; background: none !important; border: 0 !important; box-shadow: none !important; border-radius: 0; }
#hud.corners #sb .tm, #hud.corners #sb .mid { background: #102c56ed; border: 1px solid #ffffff44; border-radius: 8px; }
#hud.corners #sb .mid { position: absolute; left: 0; top: calc(100% + 6px); flex-direction: row; align-items: baseline;
  gap: 8px; min-width: 0; padding: 4px 12px; }
#hud.corners #sb #sb-shot { left: auto; right: 0; transform: none; margin-top: 6px; border-radius: 6px; }
html[data-brand=telekom] #hud.corners #sb .tm, html[data-brand=telekom] #hud.corners #sb .mid {
  background: linear-gradient(180deg,#e20074f5,#a80058f5); border-color: #ffffffbb; }
/* Only one camera/pause pair on touch devices, including wide landscape phones/tablets. */
html.nba-touch #match-tools { display: flex; bottom: auto; top: max(8px, env(safe-area-inset-top)); left: max(10px, env(safe-area-inset-left)); right: auto; }
html.nba-touch #match-label, html.nba-touch body:not(.mp-page) #camera-button, html.nba-touch body:not(.mp-page) #pause-button { display: none; }
html.nba-touch #match-tools .nba-fullscreen { position: relative; min-width: 44px; width: 44px; min-height: 44px; padding: 0; font-size: 0; border-radius: 7px; }
html.nba-touch #match-tools .nba-fullscreen::before { content: '⛶'; font: 25px/1 Arial,sans-serif; }
/* Phones (2026-10-24, owner: the scoreboard covered the top of the court on a phone held sideways).
   On a touch screen that is short (landscape phone) or narrow (portrait phone) the scoreboard becomes one slim
   bar hanging from the very top edge: smaller type, long team names cut short, the team fouls a small «Φ3» pill
   beside the score instead of a second line. ΚΑΜΕΡΑ / ΠΑΥΣΗ move up beside the full-screen button and the
   commentator box shrinks under it. Desktop and tablets keep the full scoreboard (no rule here applies to them). */
@media (pointer: coarse) and (max-height: 540px), (pointer: coarse) and (max-width: 540px) {
  :root { --corner-tools-top: max(56px, calc(env(safe-area-inset-top) + 48px)); }

  /* only the team names give way when space is short (ellipsis); scores, fouls and the clock never shrink */
  #sb { top: env(safe-area-inset-top, 0px); width: max-content; max-width: calc(100vw - 400px); filter: drop-shadow(0 2px 6px rgba(0, 0, 0, .55)); }
  #sb .tm { min-width: 0; height: 28px; gap: 5px; padding: 0 7px !important; }
  #sb .tm.l { border-radius: 0 0 0 9px; border-left-width: 3px; }
  #sb .tm.r { border-radius: 0 0 9px 0; border-right-width: 3px; }
  #sb .nm { min-width: 0; max-width: 6.2em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    font-size: 12px; line-height: 1.25; letter-spacing: .4px; }
  #sb .sc { flex-shrink: 0; min-width: 20px; padding-top: 2px; font-size: 26px; line-height: 1; text-shadow: 0 0 8px rgba(255, 255, 255, .2); }
  #sb .mid { flex-shrink: 0; height: 28px; flex-direction: row; align-items: baseline; justify-content: center; gap: 4px;
    min-width: 0; padding: 4px 8px 0; border-top-width: 2px; }
  #sb-clock { font-size: 22px; line-height: .95; }
  #sb-period { font-size: 8px; letter-spacing: 1px; }
  #sb #sb-shot { margin-top: 0; min-width: 24px; padding: 1px 5px 0; border-radius: 0 0 5px 5px; font-size: 15px; line-height: 1.05; }
  #sb-poss { border-width: 5px; }
  #sb-poss[data-p="Y"] { left: -13px; }
  #sb-poss[data-p="B"] { left: calc(100% + 3px); }
  /* team fouls: «Φ» and the number in a pill next to the score (gold once the bonus applies) */
  #sb .sb-fouls { flex-shrink: 0; position: static !important; font-size: 0 !important; line-height: 0 !important; letter-spacing: 0 !important; }
  #sb .sb-fouls::after { content: 'Φ' attr(data-fouls); display: inline-block; padding: 2px 3px 1px; border-radius: 3px;
    background: rgba(255, 255, 255, .1); font: 700 9px/1 Arial, sans-serif; letter-spacing: .2px; }
  #sb .sb-fouls[data-bonus="true"]::after { background: rgba(255, 225, 134, .18); box-shadow: inset 0 0 0 1px rgba(255, 225, 134, .7); }

  /* baseline camera: the two teams stay in the top corners (the far basket keeps the top centre), the clock sits
     beside the right-hand team on the same slim row */
  #hud.corners #sb { right: max(18px, calc(env(safe-area-inset-right) + 12px)); width: auto; max-width: none; }
  #hud.corners #sb .tm.l, #hud.corners #sb .tm.r { border-radius: 0 0 9px 9px; }
  #hud.corners #sb .mid { position: static; order: 2; margin: 0 4px 0 auto; padding: 4px 8px 0; border-radius: 0 0 9px 9px; }
  #hud.corners #sb .tm.r { order: 3; }
  #hud.corners #sb #sb-shot { top: 100%; right: 0; left: auto; margin-top: 3px; border-radius: 5px; }

  /* ΚΑΜΕΡΑ / ΠΑΥΣΗ on the full-screen button's row; under it while the teams use the corners */
  #touch .touch-tools { top: max(8px, env(safe-area-inset-top)); left: calc(max(10px, env(safe-area-inset-left)) + 48px); gap: 6px; }
  html.fs-standalone #touch .touch-tools { left: max(10px, env(safe-area-inset-left)); }
  #hud.corners ~ #touch .touch-tools { left: max(10px, env(safe-area-inset-left)); }
  #touch .touch-tools button { min-width: 62px; padding: 6px 8px; background: #101b2ebf; font-size: 9.5px; }

  /* the commentator, smaller, under the full-screen button */
  #presenter { left: max(10px, env(safe-area-inset-left)); top: max(58px, calc(env(safe-area-inset-top) + 50px)); width: 50px; }
  #presenter span { padding: 4px 1px 3px; font-size: 5.5px; }
  #presenter b { top: 3px; right: 3px; padding: 2px 3px 1px; font-size: 5px; }
}

/* a small phone held sideways: the buttons go under the full-screen button so the bar keeps its width */
@media (pointer: coarse) and (max-height: 540px) and (max-width: 720px) and (orientation: landscape) {
  #sb { max-width: calc(100vw - 124px); }
  #touch .touch-tools, html.fs-standalone #touch .touch-tools { top: var(--corner-tools-top); left: max(10px, env(safe-area-inset-left)); }
  #presenter { top: calc(var(--corner-tools-top) + 52px); }
}

/* portrait phone: the centred bar keeps clear of the full-screen button; the buttons go under the bar */
@media (pointer: coarse) and (max-width: 540px) and (orientation: portrait) {
  #sb { left: calc(50% + 24px); max-width: calc(100vw - 84px); }
  html.fs-standalone #sb { left: 50%; max-width: calc(100vw - 32px); }
  #sb .nm { max-width: 4.6em; }
  #touch .touch-tools, html.fs-standalone #touch .touch-tools { top: max(52px, calc(env(safe-area-inset-top) + 44px)); left: max(10px, env(safe-area-inset-left)); }
  #presenter { top: max(104px, calc(env(safe-area-inset-top) + 96px)); }
}

/* NBA's inherited grid has a minimum height and a themed outer border; reset both on phones. */
@media (pointer: coarse) and (max-height: 540px), (pointer: coarse) and (max-width: 540px) {
  html.nba-touch #sb { display: flex; align-items: stretch; min-height: 0; grid-template-columns: none;
    border-width: 1px !important; border-radius: 0 0 9px 9px; }
  html.nba-touch #hud.corners #sb { border: 0 !important; }
  html.nba-touch #sb .tm { flex: 0 1 auto; }
  html.nba-touch #sb .mid { display: flex; flex-direction: row; }
  html.nba-touch #touch .touch-tools { right: auto; }
  html.nba-touch #hud.corners ~ #touch .touch-tools { top: var(--corner-tools-top); }
  html.nba-touch #p1 { left: max(10px, env(safe-area-inset-left)); bottom: max(12px, env(safe-area-inset-bottom));
    width: 144px; padding: 7px 9px 5px; }
  html.nba-touch #p1-name { margin-bottom: 5px; font-size: 9px; }
  html.nba-touch #p1 .bar2 { height: 4px; margin: 5px 0 12px; }
  html.nba-touch #p1 .bar2 em { font-size: 6px; }
  html.nba-touch[data-brand=telekom] #hud::after { left: max(10px, env(safe-area-inset-left)); right: auto;
    top: max(108px, calc(env(safe-area-inset-top) + 100px)); bottom: auto; width: 80px; height: 31px; }
}
@media (pointer: coarse) and (orientation: portrait) and (max-width: 540px) {
  html.nba-touch #hud.corners #sb { left: 10px; right: 10px; }
}

/* Fixed timing display: readable between the two touch-control clusters. */
#meter {
  position: fixed;
  left: 50%;
  right: auto;
  top: auto;
  bottom: max(42px, calc(env(safe-area-inset-bottom) + 30px));
  width: min(260px, calc(100vw - 32px));
  height: auto;
  box-sizing: border-box;
  padding: 9px 12px 7px;
  transform: translateX(-50%);
  color: #f8faff;
  background: #0c1525ed;
  border: 1px solid #b4c8e578;
  border-radius: 9px;
  box-shadow: 0 3px 0 #0007;
  pointer-events: none;
  z-index: 15;
  opacity: 0;
  visibility: hidden;
  transition: opacity .1s, visibility .1s;
  font: 800 11px/1.2 Arial, sans-serif;
}
#meter.on { opacity: 1; visibility: visible; }
#meter .shot-meter-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 7px; }
#meter .shot-meter-head strong { color: #ffca50; font-size: 12px; }
#meter .shot-hint { color: #d9e4f5; font-size: 9px; white-space: nowrap; }
#meter .shot-meter-track { position: relative; height: 18px; border: 1px solid #6b8099; border-radius: 3px; background: #050b14; }
#meter i {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  height: 100%;
  max-width: 100%;
  background: linear-gradient(90deg, #d98d17, #ffe083);
  border-radius: 2px;
  z-index: 1;
}
#meter i.hot { background: linear-gradient(90deg, #40cc78, #9cffb6); box-shadow: none; }
#meter b {
  position: absolute;
  inset: -2px auto -2px 70%;
  width: 14%;
  height: auto;
  box-sizing: border-box;
  background: #39f47a5e;
  border: 2px solid #7dffa4;
  border-radius: 2px;
  z-index: 2;
}
#meter .shot-marker { position: absolute; top: -4px; bottom: -4px; left: 0; width: 3px; transform: translateX(-50%); background: #fff; box-shadow: 0 0 0 1px #071321; border-radius: 1px; z-index: 3; }
#meter .shot-feedback { display: block; min-height: 12px; margin-top: 5px; color: #fff; text-align: center; font-size: 10px; letter-spacing: .6px; }
#meter[data-state=pending] .shot-marker { background: #b9c7da; }
#meter[data-timing=perfect] { border-color: #7dffa4; }
#meter[data-timing=perfect] .shot-feedback { color: #7dffa4; }
#meter[data-timing=good] .shot-feedback { color: #d4ff82; }
#meter[data-timing=early] .shot-feedback, #meter[data-timing=late] .shot-feedback { color: #ffbb72; }
@media (pointer: coarse) and (orientation: portrait) {
  #meter { bottom: max(220px, calc(env(safe-area-inset-bottom) + 208px)); width: min(260px, calc(100vw - 40px)); }
}
@media (orientation: landscape) and (max-height: 540px) {
  #p1 { width: clamp(110px, calc((100vw - 330px) / 2), 240px); }
  #meter { bottom: max(25px, calc(env(safe-area-inset-bottom) + 16px)); width: min(240px, calc(100vw - 330px)); padding: 7px 10px 5px; }
  #meter .shot-meter-track { height: 15px; }
  #meter .shot-meter-head { margin-bottom: 5px; }
  #meter .shot-feedback { margin-top: 4px; }
}
@media (prefers-reduced-motion: reduce) { #meter { transition: none; } }

@media (pointer: coarse) and (orientation: landscape) and (max-height: 540px) {
  html.nba-touch #p1 { width: clamp(110px, calc((100vw - 380px) / 2), 200px); }
  #meter { width: min(240px, calc(100vw - 380px)); }
}

/* Keep full-screen beside the touch tools, clear of the corner team. MP owns its own action overlay. */
#hud.corners ~ #match-tools { top: 104px; bottom: auto; left: 22px; right: auto; max-width: calc(100vw - 44px); }
html.nba-touch #hud.corners ~ #match-tools { top: var(--corner-tools-top, 132px); left: calc(max(10px, env(safe-area-inset-left)) + 168px); }
html.nba-touch body.mp-page #hud ~ #match-tools { top: var(--corner-tools-top, 132px); left: max(10px, env(safe-area-inset-left)); }
@media (pointer: coarse) and (max-height: 540px), (pointer: coarse) and (max-width: 540px) {
  html.nba-touch #hud.corners ~ #match-tools { left: calc(max(10px, env(safe-area-inset-left)) + 136px); }
  html.nba-touch body.mp-page #hud ~ #match-tools { top: var(--corner-tools-top); left: max(10px, env(safe-area-inset-left)); }
}

html.nba-touch body.mp-page #match-tools button { min-height: 44px; }
html.nba-touch .mp-lobby:not(.mp-expanded) .mp-room-dock { top: var(--corner-tools-top, 132px); right: max(10px, env(safe-area-inset-right)); }
@media (pointer: coarse) and (orientation: portrait) and (max-width: 540px) {
  html.nba-touch .mp-lobby:not(.mp-expanded) .mp-room-dock { top: calc(var(--corner-tools-top) + 50px); }
}

/* Owner: no energy/power panel on touch screens. */
@media (pointer: coarse) { #p1 { display: none !important; } }
