/* =====================================================================
   Spritecraft Siege — game-specific styles on top of the Spritecraft kit.
   The arena canvas fills the whole window; the HUD floats on top of it.
   ===================================================================== */

html,
body {
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
}

#game {
  position: fixed;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  touch-action: none;
  cursor: crosshair;
}

/* ---------- HUD ------------------------------------------------------
   Corners: chips top-left, run buttons top-right, health bottom-left,
   stats bottom-right, XP as a full-width strip along the bottom edge.
   --------------------------------------------------------------------- */
.gf-hud {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
}

.gf-hud__chips {
  position: absolute;
  top: 12px;
  left: 12px;
  max-width: min(340px, 60vw);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.gf-hud__chips .sc-chip {
  font-size: var(--sc-text-label-sm);
  box-shadow: var(--sc-drop-1);
}

.gf-hud__chips .sc-chip i { font-size: 14px; }

.gf-hud__actions {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  gap: 8px;
}

.gf-hud__btn {
  pointer-events: auto;
  padding: 10px 14px;
}

/* Bottom row: health left, stats center, XP right. */
.gf-hud__bottom {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.gf-hud__hp { width: min(240px, 40vw); }

.gf-hud__metrics {
  display: flex;
  justify-content: center;
  gap: 6px;
}

.gf-metric { min-width: 88px; }

.gf-hud__xp { width: min(44%, 440px); }

/* Bars get a parchment backing so they stay readable on the grass. */
.gf-hud__hp .sc-questbar,
.gf-hud__xp .sc-questbar {
  padding: 6px 8px;
  background-color: var(--sc-surface);
  border: var(--sc-border-thin);
  box-shadow: var(--sc-bevel-light), var(--sc-drop-1);
}

.gf-hud__xp .sc-questbar__cells { min-height: 14px; }

.gf-metric {
  padding: var(--sc-space-2);
  background-color: var(--sc-surface);
  border: var(--sc-border-thin);
  box-shadow: inset 0 -2px rgba(0, 0, 0, 0.08);
}

.gf-metric strong {
  display: block;
  font-family: var(--sc-font-display);
  font-size: var(--sc-text-label-sm);
  color: var(--sc-ink);
  white-space: nowrap;
}

/* Skill toast: auto-granted passive skills pop in under the chips. */
.gf-skill {
  position: absolute;
  top: 64px;
  left: 50%;
  transform: translateX(-50%);
  animation: gf-pop 300ms var(--sc-ease);
}

.gf-skill .sc-chip {
  font-family: var(--sc-font-display);
  font-size: var(--sc-text-label-sm);
  box-shadow: var(--sc-drop-2);
}

@keyframes gf-pop {
  from { opacity: 0; translate: 0 -10px; }
  to { opacity: 1; translate: 0 0; }
}

/* Active super weapon: small name + countdown + one-line description. */
.gf-super {
  position: absolute;
  top: 108px;
  left: 50%;
  transform: translateX(-50%);
  pointer-events: none;
  display: grid;
  justify-items: center;
  gap: 3px;
}

/* display:grid would eat the hidden attribute — keep it working. */
.gf-super[hidden] {
  display: none;
}

.gf-super__row {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 10px;
  font-family: var(--sc-font-display);
  font-size: var(--sc-text-label-sm);
  color: var(--sc-on-primary);
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.3);
  background-color: var(--sc-primary);
  box-shadow: var(--sc-bevel-primary), var(--sc-drop-1);
}

.gf-super__desc {
  font-family: var(--sc-font-body);
  font-size: var(--sc-text-label-sm);
  color: var(--sc-surface);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.55);
}

.gf-super .ph { font-size: var(--sc-text-label-md); }

/* Boss bar sits center-bottom, above the other bottom HUD. */
.gf-boss {
  --cells: 24;
  position: absolute;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  width: min(38%, 420px);
  padding: var(--sc-space-2) 10px;
  background-color: var(--sc-surface);
  border: var(--sc-border-thin);
  box-shadow: var(--sc-bevel-light), var(--sc-drop-2);
  pointer-events: none;
}

.gf-boss[hidden] { display: none; }

.gf-boss__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sc-space-2);
  margin-bottom: 6px;
  font-family: var(--sc-font-micro);
  font-size: var(--sc-text-label-sm);
  letter-spacing: 1px;
  line-height: 1.2;
  text-transform: uppercase;
}

.gf-boss__name {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  color: var(--sc-danger);
}

.gf-boss__name span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gf-boss__name i { flex: none; font-size: 14px; }

#boss-hp { flex: none; color: var(--sc-muted); }

.gf-boss .sc-questbar__track { padding: 4px; }
.gf-boss .sc-questbar__cells { min-height: 16px; }

/* ---------- Modal overlay -------------------------------------------- */
.gf-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: var(--sc-space-4);
  overflow: auto;
  background-color: rgba(28, 28, 28, 0.78);
}

.gf-overlay[hidden] { display: none; }

.gf-modal {
  width: min(100%, 470px);
  max-height: calc(100vh - var(--sc-space-6));
  overflow: auto;
  box-shadow: var(--sc-bevel-light), var(--sc-drop-3);
}

.gf-modal__body {
  font-family: var(--sc-font-body);
  font-size: var(--sc-text-body-lg);
  line-height: var(--sc-leading-normal);
  color: var(--sc-ink);
}

.gf-modal__body p { margin: 0 0 var(--sc-space-4); }
.gf-modal__body p:last-child { margin-bottom: 0; }

.gf-modal__body .sc-micro { color: var(--sc-muted); }

.gf-modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--sc-space-2);
  margin-top: var(--sc-space-4);
  padding-top: var(--sc-space-4);
  border-top: 2px dashed var(--sc-muted);
}

.gf-modal__actions:empty { display: none; }

.gf-choices {
  display: flex;
  flex-direction: column;
  gap: var(--sc-space-3);
}

.gf-choice {
  display: flex;
  align-items: center;
  gap: var(--sc-space-3);
  width: 100%;
  padding: var(--sc-space-3);
  background-color: var(--sc-surface);
  color: var(--sc-ink);
  border: var(--sc-border-thick);
  border-radius: 0;
  box-shadow: var(--sc-bevel-light), var(--sc-drop-1);
  text-align: left;
  cursor: pointer;
  transition: transform var(--sc-dur-fast) var(--sc-ease),
              box-shadow var(--sc-dur-fast) var(--sc-ease);
}

.gf-choice:hover,
.gf-choice:focus-visible {
  transform: translateY(-2px);
  box-shadow: var(--sc-bevel-light), var(--sc-drop-2);
}

.gf-choice:active {
  transform: translateY(2px);
  box-shadow: var(--sc-bevel-light), 0 0 0 0 rgba(0, 0, 0, 0.15);
}

.gf-choice:focus-visible {
  outline: 3px solid var(--sc-focus);
  outline-offset: 3px;
}

.gf-choice__key {
  flex: none;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  font-family: var(--sc-font-display);
  font-size: var(--sc-text-label-sm);
  color: var(--sc-on-primary);
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.3);
  background-color: var(--sc-primary);
  box-shadow: var(--sc-bevel-primary);
}

.gf-choice__art {
  flex: none;
  image-rendering: pixelated;
}

/* Pick flourish: chosen card pops, siblings fade while it lands. */
.gf-choice--picked {
  transform: scale(1.04);
  outline: 3px solid var(--sc-primary);
  outline-offset: 2px;
  animation: gf-picked 240ms var(--sc-ease);
}

.gf-choice--dim {
  opacity: 0.4;
  transform: scale(0.98);
}

@keyframes gf-picked {
  0% { transform: scale(0.96); }
  55% { transform: scale(1.07); }
  100% { transform: scale(1.04); }
}

/* Cards cascade in when the overlay opens. */
.gf-choices .gf-choice {
  animation: gf-card-in 220ms var(--sc-ease) backwards;
}

.gf-choices .gf-choice:nth-child(2) { animation-delay: 70ms; }
.gf-choices .gf-choice:nth-child(3) { animation-delay: 140ms; }

@keyframes gf-card-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.gf-choice__copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.gf-choice__copy strong {
  font-family: var(--sc-font-display);
  font-size: var(--sc-text-label-sm);
  line-height: 1.3;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.gf-choice__copy span {
  font-family: var(--sc-font-body);
  font-size: var(--sc-text-body-md);
  line-height: 1.2;
  color: var(--sc-muted);
}

/* ---------- Responsive ----------------------------------------------- */
@media (max-width: 600px) {
  .gf-hud__chips { max-width: calc(100vw - 132px); }
  .gf-hud__chips .sc-chip { font-size: var(--sc-text-micro); padding-inline: 6px; }
  .gf-hud__chips .sc-chip i { font-size: 12px; }

  .gf-hud__hp { width: min(200px, 42vw); }
  .gf-hud__hp .sc-questbar__head { font-size: var(--sc-text-micro); }
  .gf-hud__hp .sc-questbar__track { padding: 4px; }
  .gf-hud__hp .sc-questbar__cells { min-height: 14px; }

  .gf-metric { padding: 4px 6px; min-width: 0; }
  .gf-metric strong { font-size: var(--sc-text-micro); }

  .gf-hud__xp { width: min(74%, 420px); flex-basis: 100%; }
  .gf-hud__xp .sc-questbar__head { font-size: var(--sc-text-micro); }
  .gf-hud__xp .sc-questbar__cells { min-height: 12px; }

  /* Above the top chips so it never collides with the bottom corners. */
  .gf-boss {
    bottom: auto;
    top: 104px;
    width: calc(100% - 16px);
    padding: 6px 8px;
  }

  .gf-skill { top: 84px; }

  .gf-super { top: 136px; }

  .gf-boss__head { font-size: var(--sc-text-micro); }
  .gf-boss .sc-questbar__cells { min-height: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .gf-choice { transition-duration: 1ms; }
}

/* --- Pilot name + leaderboard (server) --------------------------------- */
.gf-board__label,
.gf-board__head {
  font-family: var(--sc-font-micro);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--sc-ink-soft);
}
.gf-board__label { display: block; margin: 0.9rem 0 0.25rem; }
.gf-board__input {
  width: 100%;
  box-sizing: border-box;
  font-family: var(--sc-font-body);
  font-size: 1.3rem;
  padding: 0.2rem 0.5rem;
  border: var(--sc-border-thin);
  border-radius: 0;
  background: var(--sc-surface-sunken);
  color: var(--sc-ink);
}
.gf-board__input:focus-visible { outline: var(--sc-focus) solid 2px; outline-offset: 2px; }
.gf-board__head { margin: 1rem 0 0.1rem; }
.gf-board {
  list-style: none;
  margin: 0;
  padding: 0;
  font-family: var(--sc-font-body);
  font-size: 1.15rem;
  line-height: 1.3;
}
.gf-board__row {
  display: grid;
  grid-template-columns: 2rem 1fr auto;
  align-items: baseline;
  gap: 0.4rem;
  padding: 0.15rem 0.4rem;
  border-bottom: 1px dashed var(--sc-ink-soft);
}
.gf-board__rank { font-family: var(--sc-font-micro); font-size: 0.65rem; }
.gf-board__name { overflow-wrap: anywhere; }
.gf-board__time { font-variant-numeric: tabular-nums; }
.gf-board__row--hi {
  background: var(--sc-primary);
  color: var(--sc-on-primary);
  border: 2px solid var(--sc-line);
  box-shadow: 2px 2px 0 0 var(--sc-ink);
}
