/* In-game HUD, feedback, touch controls, and gameplay display modes. */

.hud {
  position: fixed;
  pointer-events: none;
}

.card {
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 14px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.lb {
  font-size: 12px;
  color: var(--dim);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sub {
  font-size: 12px;
  color: var(--dim);
  display: block;
}

b {
  font-weight: 700;
}

/* Top-left: score, level, combo, power-up. */
#tl {
  top: calc(12px + env(safe-area-inset-top, 0px));
  left: calc(14px + env(safe-area-inset-left, 0px));
  min-width: 150px;
  overflow: hidden;
}

#score {
  font-size: 34px;
  line-height: 1.1;
  display: block;
  font-variant-numeric: tabular-nums;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#combo {
  color: var(--gold);
  font-size: 14px;
  font-weight: 700;
  min-height: 18px;
}

#lvname,
#combo,
#pw,
#clk,
#dist {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Top-center: timer, timer bar, and next-ring arrow. */
#tc {
  top: calc(12px + env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  min-width: 170px;
  z-index: 2;
}

#time {
  display: inline-block;
  min-width: 0;
  max-width: 100%;
  padding: 2px 14px;
  border-radius: 999px;
  background: rgba(5, 8, 20, 0.86);
  border: 2px solid rgba(255, 255, 255, 0.14);
  font-size: 46px;
  line-height: 1;
  font-weight: 700;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
}

#time.low {
  color: var(--red);
  background: rgba(28, 5, 12, 0.9);
  border-color: var(--red);
  animation: timeLow 0.9s ease-in-out infinite;
}

@keyframes timeLow {
  0%,
  100% {
    border-color: var(--red);
    box-shadow: 0 0 0 0 rgba(255, 84, 112, 0);
  }
  50% {
    border-color: rgba(255, 255, 255, 0.22);
    box-shadow: 0 0 16px 2px rgba(255, 84, 112, 0.55);
  }
}

#tbarw {
  height: 7px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.15);
  margin: 6px 0;
  overflow: hidden;
}

#tbar {
  display: block;
  height: 100%;
  background: var(--gold);
  width: 100%;
}

.nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 14px;
  color: var(--dim);
}

#arrow {
  width: 30px;
  height: 30px;
}

#arrow svg {
  width: 100%;
  height: 100%;
}

/* Top-right: ring progress. */
#tr {
  top: calc(12px + env(safe-area-inset-top, 0px));
  right: calc(14px + env(safe-area-inset-right, 0px));
  text-align: right;
  max-width: 190px;
  overflow: hidden;
}

#rg {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: flex-end;
  margin: 6px 0;
}

#rg i {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 2px solid var(--cyan);
  display: block;
}

#rg i.d {
  background: #55ff88;
  border-color: #55ff88;
}

#rg i.a {
  background: var(--gold);
  border-color: var(--gold);
  box-shadow: 0 0 8px var(--gold);
}

/* Bottom-left: speed and boost bars. */
#bl {
  bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  left: calc(14px + env(safe-area-inset-left, 0px));
  width: 220px;
}

#bl .row {
  display: flex;
  gap: 22px;
  margin-bottom: 6px;
}

#bl .row b {
  font-size: 28px;
  font-variant-numeric: tabular-nums;
}

#bl small {
  font-size: 11px;
  color: var(--dim);
  margin-left: 4px;
}

.bar {
  height: 6px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
  margin: 3px 0 6px;
  overflow: hidden;
}

.bar i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--cyan);
}

#bst {
  background: var(--gold);
}

/* Bottom-right: radar. */
#br {
  bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  right: calc(14px + env(safe-area-inset-right, 0px));
}

#radar {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  background: rgba(10, 14, 32, 0.6);
  border: 2px solid var(--line);
  display: block;
}

/* Center feedback: toast, countdown, damage flash. */
#toast {
  position: fixed;
  left: 50%;
  top: 30%;
  transform: translateX(-50%);
  font-size: 26px;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  text-shadow: 0 3px 14px #000;
  white-space: nowrap;
}

#toast.show {
  animation: pop 1.1s ease-out;
}

@keyframes pop {
  0% {
    opacity: 0;
    transform: translate(-50%, 10px) scale(0.7);
  }
  15% {
    opacity: 1;
    transform: translate(-50%, 0) scale(1.1);
  }
  70% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -26px) scale(1);
  }
}

#count {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 140px;
  font-weight: 700;
  color: var(--gold);
  text-shadow: 0 6px 30px #000;
  pointer-events: none;
}

#flash {
  position: fixed;
  inset: 0;
  background: var(--red);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s;
}

/* Touch controls. */
.joy,
#bb,
#pz {
  display: none;
  position: fixed;
  touch-action: none;
  z-index: 2;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

.joy {
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  width: 124px;
  height: 124px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid var(--line);
  transition:
    background 0.12s ease-out,
    border-color 0.12s ease-out;
}

.joy i {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 54px;
  height: 54px;
  margin: -27px 0 0 -27px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.35);
}

/* Pressed / dragging: more opaque so the stick stays readable over bright sky. */
.joy:active,
.joy.drag {
  background: rgba(255, 255, 255, 0.22);
  border-color: rgba(255, 255, 255, 0.45);
}

.joy:active i,
.joy.drag i {
  background: rgba(255, 255, 255, 0.6);
}

#jl {
  left: calc(22px + env(safe-area-inset-left, 0px));
}

#jr {
  right: calc(22px + env(safe-area-inset-right, 0px));
}

#bb {
  right: calc(34px + env(safe-area-inset-right, 0px));
  bottom: calc(172px + env(safe-area-inset-bottom, 0px));
  min-width: 74px;
  min-height: 48px;
  font-size: 14px;
  padding: 12px 16px;
  border-radius: 50%;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  transition:
    transform 0.1s ease-out,
    filter 0.1s ease-out;
}

#bb:active {
  transform: scale(0.94);
  filter: brightness(1.15);
}

#pz {
  left: calc(14px + env(safe-area-inset-left, 0px));
  top: calc(120px + env(safe-area-inset-top, 0px));
  min-width: 64px;
  min-height: 44px;
  font-size: 14px;
  padding: 8px 14px;
  background: var(--glass);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
}

#pz:active {
  background: rgba(255, 255, 255, 0.28);
}

/* Sound toggle keeps its desktop spot; it only grows on coarse pointers. */
#snd {
  max-width: calc(
    100% - 24px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px)
  );
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

@media (pointer: coarse) {
  #snd {
    min-height: 44px;
    padding: 10px 16px;
  }
}

.touch .joy,
.touch #bb,
.touch #pz {
  display: block;
}

.touch #bl {
  display: none;
}

.touch #br {
  bottom: auto;
  top: calc(110px + env(safe-area-inset-top, 0px));
}

.touch #radar {
  width: 104px;
  height: 104px;
}

.touch #snd {
  display: none;
}

/* Compact HUD modes: minimal (hm) and heads-up-only (ho). */
body.hm .card {
  background: none;
  border-color: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  padding: 4px 6px;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.8);
}

body.hm .lb,
body.hm #lvname,
body.hm #clk,
body.hm #bl .row,
body.hm #bl .sub,
body.hm #spbw,
body.hm #br,
body.hm #snd {
  display: none;
}

body.hm #bl {
  left: 50%;
  transform: translateX(-50%);
  width: 180px;
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
}

body.hm #score {
  font-size: 22px;
}

body.hm #time {
  font-size: 38px;
}

body.hm #tbarw {
  margin: 4px 0;
}

body.ho .hud:not(#tc),
body.ho #snd {
  display: none !important;
}

body.ho #tbarw {
  display: none;
}

@media (max-width: 700px) {
  #time {
    font-size: 34px;
  }
  #score {
    font-size: 24px;
  }
  #tl {
    min-width: 110px;
  }
  #tc {
    min-width: 120px;
  }
}

@media (prefers-reduced-motion: reduce) {
  #toast.show {
    animation-duration: 0.01s;
  }
}
