/* HUD: a header glued to the top of the board.
   Two kinds of things, and they must never look alike:
   - buttons (profile, records, sound, effects): raised, with a dark "3D" bottom edge, lift on hover, sink on press
   - read-outs (score, snacks, best, speed, effect): just an icon and a number on the header, no frame at all
   Rule: only things you can click get a border.
   Sizes are em off a font size that follows the board width (cqw), so it fits from phone to desktop. */
#hud {
  font-size: clamp(var(--min-font), 2.5cqw, 16px);
  background: linear-gradient(#fffaf3, #ffeaf2);
  border: 5px solid var(--ink); border-bottom: 0; border-radius: 22px 22px 0 0;
  padding: .5em .6em .45em;
}
.hud-row { display: flex; align-items: center; gap: .5em; }

/* ---------- buttons ---------- */
#hud button {
  font: 600 1em var(--font); color: var(--ink); cursor: pointer;
  background: #fff; border: 3px solid var(--ink); box-shadow: 0 .22em 0 var(--ink);
  transition: transform .08s, box-shadow .08s, background .15s;
}
#hud button:hover { transform: translateY(-2px); box-shadow: 0 calc(.22em + 2px) 0 var(--ink); background: #fff6fa; }
#hud button:active { transform: translateY(.18em); box-shadow: 0 .04em 0 var(--ink); }
#hud button:focus-visible { outline: 3px solid #ff7aa2; outline-offset: 2px; }

.hud-profile {
  display: flex; align-items: center; gap: .4em; min-width: 0; flex: 0 1 auto;
  padding: .15em .8em .15em .15em; border-radius: 999px;
}
.hud-profile .who { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.05; min-width: 0; }
.hud-profile small { font-size: max(var(--min-font), .62em); font-weight: 600; letter-spacing: .08em; text-transform: uppercase; opacity: .6; }
.hud-profile b { max-width: 8.5em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: max(var(--min-font), .95em); }

.hud-btns { display: flex; gap: .4em; flex: none; }
.round {
  position: relative; width: 2.5em; height: 2.5em; padding: 0; border-radius: 50%;
  display: grid; place-items: center;
}
.round .ico { width: 1.45em; height: 1.45em; vertical-align: 0; }
#trophies { background: #fff3c4; }
.num-badge {
  position: absolute; top: -.45em; right: -.55em; min-width: 1.5em; padding: 0 .3em;
  font-size: max(var(--min-font), .68em); font-weight: 600; line-height: 1.45em; color: #fff; text-align: center;
  background: #e0457b; border-radius: 999px; box-shadow: 0 0 0 2px #fff;
}

/* ---------- avatars (HUD, dialogs, ranking) ---------- */
.avatar {
  display: inline-grid; place-items: center; flex: none; width: 2.3em; height: 2.3em; border-radius: 50%;
  /* no frame: the art is already a round face */
}
.avatar img { width: 100%; height: 100%; }

/* ---------- read-outs ---------- */
.counters { flex: 1; display: flex; justify-content: center; gap: .9em; min-width: 0; }
.counter { display: flex; align-items: center; gap: .25em; min-width: 0; }
.counter .ico { width: 1.5em; height: 1.5em; vertical-align: 0; flex: none; }
.counter b { font-size: 1.15em; font-weight: 600; font-variant-numeric: tabular-nums; }
.counter.best b { font-size: max(var(--min-font), .95em); opacity: .75; }
/* a number went up */
.counter.bump { animation: bump .34s cubic-bezier(.3, 1.8, .5, 1); }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.25) rotate(-4deg); } 100% { transform: scale(1); } }

.hud-status {
  display: flex; align-items: center; gap: .6em; margin-top: .8em; padding: .2em .6em;
  font-size: max(var(--min-font), .82em); font-weight: 600; border-radius: .7em;
  background: rgba(91, 42, 78, .07);
}
/* speed meter: the bar is the base speed (what a night's sleep resets), the number is the current speed */
#spd { display: flex; align-items: center; gap: .4em; flex: none; }
#spd .meter { width: 5.5em; height: .7em; border-radius: 999px; background: #fff; overflow: hidden; }
#spd .meter i { display: block; height: 100%; width: 0; border-radius: 999px; transition: width .35s, background-color .35s; }
#spdx { min-width: 2.4em; text-align: right; font-variant-numeric: tabular-nums; }
#fx { flex: 1; min-width: 0; text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* small boards: drop the "Player" label and shorten the name (it is always shown) */
@container (max-width: 520px) {
  .hud-profile small { display: none; }
  .hud-profile b { max-width: 6.2em; }
}
@container (max-width: 420px) {
  .hud-profile b { max-width: 5.6em; }
  .counters { gap: .45em; }
}
@container (max-width: 370px) {
  .hud-profile b { max-width: 4em; }
  .hud-row { gap: .35em; }
  .counter .ico { width: 1.3em; height: 1.3em; }
  .counter b { font-size: 1em; }
  .counter.best { display: none; }   /* best is on the title card and in Records; the live numbers matter more here */
}
@container (max-width: 300px) {
  .hud-profile { padding: .15em; }
  .hud-profile .who { display: none; }   /* tiny boards: the avatar alone stands for the profile */
}
