* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* The hidden attribute must beat the layout rules below, which also set
   display on the same elements (an author `display` otherwise overrides
   the user-agent [hidden] rule). */
[hidden] {
  display: none !important;
}

/* Only the lobby title uses Michroma (SIL Open Font License, vendored as
   michroma-latin-400.woff2 beside its license text): the wide, Apollo-era
   caps are the look the landing screen is after. The rest of the UI stays
   on the system stack, and if the file is missing the title falls back to
   it too. */
@font-face {
  font-family: "Michroma";
  src: url("michroma-latin-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

html,
body {
  height: 100%;
  background: #0b0e14;
  color: #e6e6e6;
  font-family: system-ui, sans-serif;
}

main {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 1rem;
  min-height: 100%;
}

/* The title is two tracked-out uppercase lines in the display face; the
   markup keeps sentence case so the page reads normally to a screen
   reader. Michroma ships a single weight, so asking for more would only
   get a synthesized one. */
h1 {
  font-family: "Michroma", system-ui, sans-serif;
  font-size: 1.35rem;
  font-weight: 400;
  line-height: 1.5;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* The rocket rides on top of the title. It lives inside the h1 so the
   playing rule that hides the heading takes it with it, and a little
   margin gives it room above the title. */
#rocket {
  display: block;
  margin: 0 0 1rem;
  padding: 1rem;
  font-size: 4rem;
  line-height: 1;
  text-align: center;
}

#arena {
  width: 100%;
  max-width: 640px;
  aspect-ratio: 1 / 1;
  background: #11141d;
  border: 1px solid #2a2f3d;
  touch-action: none;
}

/* While a round is up the page stops scrolling: the arena takes the space
   the HUD and the control band leave, and the band keeps a thumb's worth
   of height. resize() sizes the canvas from the stage box. */
#stage {
  display: grid;
  place-items: center;
  width: 100%;
  /* Anchors the disconnect badge, which must not take layout from the
     arena it sits over. */
  position: relative;
}

/* A mid-round disconnect is told twice: this badge over the arena while
   the round runs, and the round panel's waiting line once it pauses. It
   never takes an event, so the controls underneath are unaffected. */
#friend-note {
  position: absolute;
  top: 0.5rem;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.3rem 0.7rem;
  border: 1px solid #3d4f7a;
  border-radius: 999px;
  background: #161b2ae6;
  color: #e0b98a;
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  white-space: nowrap;
  pointer-events: none;
}

body.playing main {
  height: 100dvh;
  gap: 0;
  padding: 0 0.5rem 0.5rem;
  overflow: hidden;
}

body.playing h1 {
  display: none;
}

body.playing #stage {
  /* Content-sized: the arena, then the stats, then the control band,
     which takes whatever is left. The arena is measured from the viewport
     in resize(), never from this box, so nothing here is circular. */
  flex: 0 0 auto;
  display: grid;
  place-items: start center;
}

/* Fallback only: while a round runs resize() writes an exact size in px.
   The base rule's 640px cap is lifted so the arena can use the full
   stage width when no size has been measured yet. */
body.playing #arena {
  width: 100%;
  max-width: none;
  aspect-ratio: 1 / 1;
}

/* The band takes the height the arena leaves, so a thumb gets every
   pixel the round does not need; its 140px floor is what resize() sizes
   the arena against. */
body.playing #controls {
  flex: 1 1 auto;
}

/* The control band: one floating stick per role, and a shared base and
   knob. */
#controls {
  position: relative;
  width: 100%;
  max-width: 640px;
  min-height: 140px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

#stick,
#aim {
  position: absolute;
  inset: 0;
}

#pad-base,
#pad-knob {
  position: absolute;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

#pad-base {
  border: 1px solid #3d4f7a;
  background: #161b2a80;
}

#pad-knob {
  width: 44px;
  height: 44px;
  border: 1px solid #4d5c8a;
  background: #263150;
}

/* The resting stand-in: the ghost of the stick, in the middle of the band,
   so the first thing on a fresh game screen says where a thumb goes and
   what the control looks like. It never takes an event (pointer-events:
   none), it is behind the live pad in the DOM, and controls.js takes it
   away on the first pull so it does not flicker back between pulls. */
#rest {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

/* Same shapes as the live pad, one size smaller than the ring's hit area
   and dimmed so it reads as a guide rather than a pressed control: the
   base is 98px (2 x 0.35 x 140, the stick throw), the knob is 44px like
   #pad-knob. */
#rest-pad {
  width: 98px;
  height: 98px;
  display: grid;
  place-items: center;
  border: 1px dashed #3d4f7a;
  border-radius: 50%;
  background: #161b2a40;
  opacity: 0.75;
}

#rest-knob {
  width: 44px;
  height: 44px;
  border: 1px solid #4d5c8a;
  border-radius: 50%;
  background: #263150;
}

#hud {
  display: flex;
  gap: 1.5rem;
  justify-content: center;
  width: 100%;
  max-width: 640px;
  font-variant-numeric: tabular-nums;
  /* A breath between the arena and the stats. Padding rather than margin
     so resize(), which sizes the arena against the HUD's offsetHeight,
     counts it and the band keeps its floor. */
  padding-top: 0.5rem;
}

.hud-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 4rem;
}

.hud-label {
  color: #767d8d;
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.hud-item span:last-child {
  font-size: 1.35rem;
}

section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  max-width: 480px;
  text-align: center;
}

.tagline {
  color: #aeb4c2;
  line-height: 1.5;
}

.hint {
  color: #767d8d;
  font-size: 0.875rem;
}

/* A tiny pulse spinner: a flat ring that pulses while waiting, replacing
   the earlier dotted ellipsis. */
.spinner {
  width: 1rem;
  height: 1rem;
  border: 2px solid #4c5675;
  border-top-color: #c9d3ec;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

button {
  padding: 0.7rem 1.4rem;
  border: 1px solid #3d4f7a;
  border-radius: 6px;
  background: #1c2740;
  color: #e6e6e6;
  font-size: 1rem;
  cursor: pointer;
}

button:active {
  background: #26335420;
}

#round-title {
  font-size: 1.1rem;
  font-weight: 600;
}

#round-stats {
  color: #aeb4c2;
  font-variant-numeric: tabular-nums;
}

#friend-wait {
  color: #767d8d;
  font-size: 0.875rem;
}

#error-message {
  color: #ff9b8a;
  line-height: 1.5;
}

.share {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 100%;
}

#share-link {
  width: 100%;
  padding: 0.6rem;
  border: 1px solid #2a2f3d;
  border-radius: 6px;
  background: #11141d;
  color: #aeb4c2;
  font-size: 0.9rem;
  text-align: center;
}

.actions {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
}
