/* Compact play HUD. The course keeps the centre; controls occupy the corners. */
#game.compact-game {
  --hud-edge: 12px;
  --hud-stage-top: 76px;
  --stage-left: 12px;
  --stage-right: 12px;
  --stage-top: var(--hud-stage-top);
  --stage-bottom: 80px;
  --hud-surface: var(--paper);
  --hud-shadow: 0 3px 12px #142c2418;
  --hud-border: var(--line);
}

/* Override legacy online/mobile rail insets without changing the camera on a turn. */
#game.compact-game:has(.online-strip:not(.hidden)) {
  --stage-top: var(--hud-stage-top);
}

#game.compact-game #course-stage {
  position: absolute;
  inset: calc(var(--stage-top) + var(--top))
    calc(var(--stage-right) + var(--right))
    calc(var(--stage-bottom) + var(--bottom))
    calc(var(--stage-left) + var(--left));
  visibility: hidden;
  pointer-events: none;
}

#game.compact-game .hud-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

#game.compact-game .hud-score {
  position: absolute;
  top: calc(var(--hud-edge) + var(--top));
  left: calc(var(--hud-edge) + var(--left));
  display: grid;
  grid-template-columns: minmax(0, 1fr) 54px;
  align-items: center;
  gap: 8px;
  width: 280px;
  max-width: calc(100% - 184px - var(--left) - var(--right));
  height: 56px;
  padding: 5px 10px;
  border: 1px solid var(--hud-border);
  border-radius: 14px;
  background: var(--hud-surface);
  box-shadow: var(--hud-shadow);
  z-index: 5;
}

#game.compact-game .hud-hole {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  min-height: 44px;
  margin: 0;
  padding: 0;
  text-align: left;
  border-radius: 5px;
}

#game.compact-game #hole-name {
  display: block;
  max-width: 100%;
  overflow: hidden;
  margin: 0;
  font: 650 18px/21px Cormorant, Georgia, serif;
  letter-spacing: -.1px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#game.compact-game .hud-hole-meta {
  display: flex;
  align-items: baseline;
  gap: 7px;
  max-width: 100%;
  color: var(--muted);
  font-size: 12px;
  line-height: 17px;
}

#game.compact-game #hole-numbers {
  display: block;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  font: inherit;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#game.compact-game .round-progress { font-weight: 650; }
#game.compact-game .hole-best { color: var(--muted); }
#game.compact-game .hud-par { flex: 0 0 auto; white-space: nowrap; }
#game.compact-game .hud-par b { color: var(--ink); font-weight: 750; }

#game.compact-game .hud-strokes {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 36px;
  padding-left: 7px;
  border-left: 1px solid var(--hud-border);
  font-variant-numeric: tabular-nums;
}

#game.compact-game .hud-strokes b {
  font-size: 20px;
  font-weight: 750;
  line-height: 23px;
}

#game.compact-game .hud-strokes span {
  font-size: 10px;
  font-weight: 600;
  line-height: 13px;
  letter-spacing: -.2px;
  color: var(--muted);
  white-space: nowrap;
}

#game.compact-game .hud-tools {
  position: absolute;
  top: calc(var(--hud-edge) + var(--top));
  right: calc(var(--hud-edge) + var(--right));
  display: flex;
  gap: 6px;
  padding: 0;
  border: 0;
  background: none;
  box-shadow: none;
  z-index: 7;
}

#game.compact-game .hud-icon,
#game.compact-game .hud-aim {
  display: grid;
  place-items: center;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  margin: 0;
  padding: 0;
  border: 1px solid var(--hud-border);
  border-radius: 13px;
  background: var(--hud-surface);
  color: var(--ink);
  box-shadow: var(--hud-shadow);
}

#game.compact-game .hud-icon svg,
#game.compact-game .hud-aim svg { width: 20px; height: 20px; }

#game.compact-game .hud-popover {
  position: absolute;
  top: calc(64px + var(--top));
  right: calc(var(--hud-edge) + var(--right));
  display: grid;
  gap: 2px;
  width: 222px;
  max-width: calc(100% - 24px - var(--left) - var(--right));
  max-height: calc(100% - 144px - var(--top) - var(--bottom));
  overflow: auto;
  overscroll-behavior: contain;
  padding: 6px;
  border: 1px solid var(--hud-border);
  border-radius: 15px;
  background: var(--hud-surface);
  box-shadow: 0 8px 24px #142c2426;
  pointer-events: auto;
  scrollbar-width: thin;
  z-index: 8;
}

#game.compact-game .hud-menu-action,
#game.compact-game .hud-menu-sound {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  width: 100%;
  min-width: 0;
  min-height: 44px;
  height: auto;
  margin: 0;
  padding: 9px 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  box-shadow: none;
  font-size: 12px;
  font-weight: 650;
  line-height: 18px;
  text-align: left;
}

#game.compact-game .hud-menu-action svg,
#game.compact-game .hud-menu-sound svg { width: 18px; height: 18px; }

/* The existing sound button already receives its translated aria-label. */
#game.compact-game .hud-menu-sound::after { content: attr(aria-label); }

#game.compact-game .hud-shot {
  position: absolute;
  right: calc(var(--hud-edge) + var(--right));
  bottom: calc(var(--hud-edge) + var(--bottom));
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px 44px 80px;
  grid-template-rows: 46px;
  align-items: center;
  gap: 6px;
  width: 318px;
  max-width: calc(100% - 24px - var(--left) - var(--right));
  height: 60px;
  padding: 6px;
  border: 1px solid var(--hud-border);
  border-radius: 17px;
  background: var(--hud-surface);
  box-shadow: var(--hud-shadow);
  pointer-events: auto;
  z-index: 6;
}

#game.compact-game .hud-power {
  position: relative;
  grid-column: 1;
  grid-row: 1;
  min-width: 0;
  height: 46px;
}

#game.compact-game .hud-power label {
  position: absolute;
  top: 1px;
  left: 4px;
  right: 4px;
  display: flex;
  justify-content: space-between;
  gap: 4px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
  line-height: 12px;
  pointer-events: none;
}

#game.compact-game #power-value {
  color: var(--ink);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  font-weight: 750;
}

/* A 44px input target; only the rail and thumb are visually small. */
#game.compact-game #power {
  position: absolute;
  top: 2px;
  left: 0;
  display: block;
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 44px;
  min-height: 44px;
  margin: 0;
  padding: 12px 4px 0;
  border: 0;
  border-radius: 7px;
  background: transparent;
  cursor: pointer;
  touch-action: none;
}

#game.compact-game #power::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--green) var(--value, 40%), var(--line) var(--value, 40%));
}

#game.compact-game #power::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  margin-top: -8px;
  border: 3px solid var(--green);
  border-radius: 50%;
  background: var(--paper);
  box-shadow: 0 1px 3px #142c2428;
}

#game.compact-game #power::-moz-range-track {
  height: 4px;
  border-radius: 4px;
  background: var(--line);
}

#game.compact-game #power::-moz-range-progress {
  height: 4px;
  border-radius: 4px;
  background: var(--green);
}

#game.compact-game #power::-moz-range-thumb {
  box-sizing: border-box;
  width: 20px;
  height: 20px;
  border: 3px solid var(--green);
  border-radius: 50%;
  background: var(--paper);
  box-shadow: 0 1px 3px #142c2428;
}

#game.compact-game #power:disabled { opacity: .42; cursor: default; }
#game.compact-game #aim-left { grid-column: 2; grid-row: 1; }
#game.compact-game #aim-right { grid-column: 3; grid-row: 1; }
#game.compact-game .hud-aim { border-radius: 11px; box-shadow: none; background: var(--pale); }

#game.compact-game #shoot {
  grid-column: 4;
  grid-row: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 80px;
  min-width: 0;
  height: 44px;
  min-height: 44px;
  padding: 0 7px;
  border: 1px solid var(--green);
  border-radius: 11px;
  background: var(--green);
  color: var(--paper);
  font-size: 12px;
  font-weight: 750;
  line-height: 16px;
  white-space: nowrap;
}

#game.compact-game #shoot svg { width: 15px; height: 15px; }

#game.compact-game .hud-status {
  position: absolute;
  left: calc(var(--hud-edge) + var(--left));
  bottom: calc(var(--hud-edge) + var(--bottom));
  display: none;
  align-items: center;
  gap: 8px;
  width: max-content;
  max-width: min(420px, calc(100% - 366px - var(--left) - var(--right)));
  padding: 6px 9px;
  border: 1px solid var(--hud-border);
  border-radius: 10px;
  background: var(--hud-surface);
  box-shadow: var(--hud-shadow);
  pointer-events: none;
  z-index: 4;
}

#game.compact-game[data-hud-status="event"] .hud-status { display: flex; }

#game.compact-game #status-line {
  display: block;
  min-width: 0;
  min-height: 0;
  margin: 0;
  font-size: 12px;
  font-weight: 650;
  line-height: 17px;
  text-align: left;
  color: var(--ink);
}

#game.compact-game #network-retry {
  position: static;
  flex: 0 0 auto;
  width: auto;
  min-height: 44px;
  margin: 0;
  padding: 6px 9px;
  border-radius: 8px;
  font-size: 12px;
}

#game.compact-game .hud-return {
  position: absolute;
  left: calc(var(--hud-edge) + var(--left));
  bottom: calc(var(--stage-bottom) + 8px + var(--bottom));
  display: flex;
  align-items: center;
  gap: 8px;
  width: max-content;
  max-width: calc(100% - 24px - var(--left) - var(--right));
  min-height: 44px;
  padding: 9px 12px;
  border: 1px solid var(--hud-border);
  border-radius: 13px;
  background: var(--hud-surface);
  box-shadow: var(--hud-shadow);
  font-size: 12px;
  font-weight: 700;
  line-height: 18px;
  z-index: 6;
}

#game.compact-game .hud-return svg { width: 19px; height: 19px; }

#game.compact-game .online-strip {
  top: calc(16px + var(--top));
  left: calc(308px + var(--left));
  right: calc(172px + var(--right));
  display: flex;
  width: auto;
  min-width: 0;
  max-width: 330px;
  min-height: 36px;
  gap: 14px;
  margin-inline: auto;
  padding: 8px 10px;
  border-radius: 11px;
  background: var(--hud-surface);
  box-shadow: var(--hud-shadow);
  transform: none;
  font-size: 11px;
  line-height: 18px;
}

#game.compact-game .online-strip > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#game.compact-game .hole-intro {
  top: calc(var(--stage-top) + var(--top) + 6px);
  max-width: min(280px, calc(100% - 32px - var(--left) - var(--right)));
  padding: 8px 12px;
  border: 1px solid var(--hud-border);
  border-radius: 11px;
  background: var(--hud-surface);
  box-shadow: var(--hud-shadow);
  backdrop-filter: none;
}

#game.compact-game .hole-intro small { font-size: 10px; line-height: 14px; letter-spacing: .8px; }
#game.compact-game .hole-intro strong { font-size: 21px; line-height: 23px; margin: 3px 0 0; }
#game.compact-game .cup-beacon { padding: 7px 9px; gap: 5px; font-size: 11px; box-shadow: var(--hud-shadow); }
#game.compact-game .cup-beacon svg { width: 16px; height: 16px; }

#game.compact-game .hud-icon[aria-pressed="true"],
#game.compact-game .hud-icon[aria-expanded="true"],
#game.compact-game .hud-menu-action[aria-pressed="true"] {
  background: var(--green);
  border-color: var(--green);
  color: var(--paper);
}

#game.compact-game button:focus-visible,
#game.compact-game input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#game.compact-game button:active:not(:disabled) { transform: none; }

@media (hover: hover) {
  #game.compact-game .hud-icon:hover:not(:disabled):not([aria-pressed="true"]):not([aria-expanded="true"]),
  #game.compact-game .hud-menu-action:hover:not(:disabled):not([aria-pressed="true"]),
  #game.compact-game .hud-menu-sound:hover:not(:disabled),
  #game.compact-game .hud-return:hover:not(:disabled) { background: var(--pale); }
  #game.compact-game .hud-aim:hover:not(:disabled) { border-color: var(--green); }
  #game.compact-game #shoot:hover:not(:disabled) { background: var(--green-hover); border-color: var(--green-hover); }
}

/* Toasts are temporary and sit above the shot bar, never over its controls. */
#game.compact-game:not(.hidden) ~ #toast {
  top: auto;
  bottom: calc(88px + var(--bottom));
  max-width: calc(100% - 32px - var(--left) - var(--right));
  padding: 9px 12px;
  font-size: 12px;
  line-height: 17px;
  pointer-events: none;
}

@media (max-width: 699px) {
  #game.compact-game {
    --hud-edge: 8px;
    --hud-stage-top: 74px;
    --stage-left: 8px;
    --stage-right: 8px;
    --stage-bottom: 84px;
  }

  #game.compact-game .hud-score {
    max-width: calc(100% - 72px - var(--left) - var(--right));
  }

  #game.compact-game .hud-tools { flex-direction: column; }

  #game.compact-game .hud-popover {
    top: calc(108px + var(--top));
    right: calc(60px + var(--right));
    max-width: calc(100% - 68px - var(--left) - var(--right));
    max-height: calc(100% - 192px - var(--top) - var(--bottom));
  }

  #game.compact-game .hud-shot {
    max-width: calc(100% - 16px - var(--left) - var(--right));
  }

  #game.compact-game .hud-status {
    bottom: calc(var(--stage-bottom) + var(--bottom));
    max-width: calc(100% - 16px - var(--left) - var(--right));
  }

  #game.compact-game:has(.hud-return:not(.hidden)) .hud-status {
    bottom: calc(var(--stage-bottom) + 60px + var(--bottom));
  }

  #game.compact-game .online-strip {
    top: calc(74px + var(--top));
    left: calc(8px + var(--left));
    right: calc(64px + var(--right));
    min-height: 28px;
    max-width: none;
    padding: 4px 8px;
    gap: 10px;
  }

  #game.compact-game .hole-intro {
    max-width: calc(100% - 120px - var(--left) - var(--right));
    padding: 7px 10px;
  }

  #game.compact-game .hole-intro strong { font-size: 19px; line-height: 21px; }
  #game.compact-game:not(.hidden) ~ #toast { bottom: calc(92px + var(--bottom)); }
}

/* Tiny embedded previews retain every control, in two rows totalling 110px. */
@media (max-width: 299px) {
  #game.compact-game { --stage-bottom: 124px; }
  #game.compact-game .hud-score { gap: 6px; padding-inline: 7px; }
  #game.compact-game .hud-hole-meta { gap: 4px; font-size: 11px; }

  #game.compact-game .hud-shot {
    grid-template-columns: minmax(0, 1fr) 44px 44px;
    grid-template-rows: 46px 44px;
    height: 110px;
    border-radius: 15px;
  }

  #game.compact-game #shoot { grid-column: 1 / -1; grid-row: 2; width: 100%; }
  #game.compact-game .hud-popover { max-height: calc(100% - 232px - var(--top) - var(--bottom)); }
  #game.compact-game:not(.hidden) ~ #toast { bottom: calc(132px + var(--bottom)); }
}
