/* Screens: start, menu, HUD, panels. Composition stays centred (logo above, actions below) in every shape. */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: calc(var(--u) * 1.1);
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
    max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
.overlay.dim {
  background: rgba(10, 18, 12, 0.5);
  z-index: 40;
}
.overlay:not(.hidden) > * {
  animation: popIn 0.32s var(--ease-spring) backwards;
}

.corner {
  position: fixed;
  z-index: 45;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  display: flex;
  gap: calc(var(--u) * 0.5);
}

/* ---------- Start ---------- */
.screen-start {
  cursor: pointer;
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0) 40%, rgba(8, 16, 10, 0.45));
}
.logo {
  width: min(78vw, calc(var(--u) * 30), 46vh * 2);
  height: auto;
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.4));
}
.screen-start .logo {
  animation:
    logoIn 0.6s var(--ease-spring) both,
    breathe 3.2s 0.6s ease-in-out infinite;
}
.tap {
  font-size: calc(var(--u) * 1.5);
  font-weight: 600;
  color: #fff3c8;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.55);
  animation: tapPulse 1.6s ease-in-out infinite;
}

/* ---------- Menu ---------- */
.screen-menu {
  background: linear-gradient(rgba(8, 16, 10, 0.25), rgba(8, 16, 10, 0) 30%, rgba(8, 16, 10, 0.35));
}
.screen-menu .logo {
  width: min(64vw, calc(var(--u) * 22), 30vh * 2);
}
.menu-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: calc(var(--u) * 1.2);
  width: min(94vw, calc(var(--u) * 34));
}
.menu-actions .btn {
  width: 100%;
}
.btn-big {
  --btn-h: calc(var(--u) * 4.1);
  min-width: calc(var(--u) * 13);
  font-size: calc(var(--u) * 1.4);
}
.btn-big .lbl {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.18em;
}
.btn-big small {
  font-size: 0.62em;
  font-weight: 500;
  opacity: 0.85;
}
.btn-big small:empty {
  display: none;
}

@media (orientation: portrait) {
  .menu-actions {
    grid-template-columns: 1fr;
    width: min(92vw, calc(var(--u) * 26));
  }
}

@media (orientation: landscape) and (max-height: 500px) {
  .overlay {
    gap: calc(var(--u) * 0.6);
  }
  .screen-menu .logo {
    width: min(36vw, 22vh * 2);
  }
}

/* ---------- HUD ---------- */
#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}
#hud button {
  pointer-events: auto;
}
.hud-score {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  left: max(12px, env(safe-area-inset-left));
  min-width: calc(var(--u) * 11);
  padding: calc(var(--u) * 0.75) calc(var(--u) * 1.05) calc(var(--u) * 0.85);
  display: flex;
  flex-direction: column;
  gap: calc(var(--u) * 0.3);
}
.hs-stage {
  font-size: calc(var(--u) * 0.95);
  font-weight: 600;
  color: #ffd978;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  max-width: calc(var(--u) * 16);
  line-height: 1.15;
}
.hs-main {
  display: flex;
  align-items: baseline;
  gap: 0.3em;
  color: #fff7e2;
  text-shadow: var(--shade);
}
#hud-score {
  font-size: calc(var(--u) * 2.3);
  font-weight: 600;
  line-height: 1;
}
.hs-goal {
  font-size: calc(var(--u) * 1.05);
  opacity: 0.85;
}
.streak {
  --btn-h: calc(var(--u) * 1.8);
  height: var(--btn-h);
  padding: 0 0.7em;
  font-size: var(--u);
  font-weight: 600;
  align-self: center;
  margin-left: auto;
}
.hud-score.goal-hit .bar-fill {
  filter: brightness(1.15) drop-shadow(0 0 6px rgba(255, 210, 80, 0.9));
}

.hud-wind {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: calc(var(--u) * 0.75);
  min-width: calc(var(--u) * 10.5);
  /* padding clears the painted frame (border ~1.05u) so nothing touches it */
  padding: calc(var(--u) * 1.05) calc(var(--u) * 1.6);
}
.wind-sock {
  width: calc(var(--u) * 2.2);
  height: calc(var(--u) * 2.2);
  object-fit: contain;
  transition:
    transform 0.4s var(--ease-spring),
    opacity 0.3s;
}
.wind-txt {
  display: flex;
  flex-direction: column;
  gap: calc(var(--u) * 0.12);
  line-height: 1.1;
}
.wind-lbl {
  font-size: calc(var(--u) * 0.85);
  font-weight: 600;
  color: #ffd978;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.wind-val {
  font-size: calc(var(--u) * 1.3);
  font-weight: 600;
  color: #fff7e2;
  white-space: nowrap;
}

.hud-arrows {
  position: absolute;
  top: calc(max(12px, env(safe-area-inset-top)) + var(--u) * 3.9);
  right: max(12px, env(safe-area-inset-right));
  padding: calc(var(--u) * 0.45) calc(var(--u) * 0.8);
}
.quiver {
  display: flex;
  gap: calc(var(--u) * 0.05);
}
.quiver img {
  width: calc(var(--u) * 1.8);
  height: calc(var(--u) * 2.3);
  object-fit: contain;
  transform: rotate(25deg);
}
.quiver img.spent {
  filter: grayscale(1) brightness(0.55);
  opacity: 0.45;
}
.quiver img.bonus-pop {
  animation: arrowBonus 0.6s var(--ease-spring);
}

.hint {
  position: absolute;
  bottom: max(18px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  max-width: calc(100vw - 32px);
  padding: 0.55em 1.2em;
  border-radius: 999px;
  background: rgba(14, 26, 16, 0.62);
  font-size: calc(var(--u) * 0.85);
  font-weight: 500;

  color: #fff3d0;
  text-align: center;
  transition: opacity 0.5s ease;
}
.hint.faded {
  opacity: 0;
}
#btn-cancel-draw {
  position: absolute;
  bottom: max(24px, env(safe-area-inset-bottom));
  left: max(16px, env(safe-area-inset-left));
}

.hit-map {
  position: absolute;
  right: max(14px, env(safe-area-inset-right));
  bottom: max(14px, env(safe-area-inset-bottom));
  padding: calc(var(--u) * 0.7);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: calc(var(--u) * 0.25);
  animation: popIn 0.25s var(--ease-spring);
}
.hm-face,
.res-target {
  position: relative;
  width: calc(var(--u) * 5.6);
  aspect-ratio: 1;
}
.hm-face img,
.res-target img {
  width: 100%;
  height: 100%;
}
.pin {
  position: absolute;
  width: 14%;
  aspect-ratio: 1;
  background: url(../assets/ui/pin.webp) center / contain no-repeat;
  transform: translate(-50%, -50%);
  opacity: 0.8;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.5));
}
.pin.now {
  width: 19%;
  opacity: 1;
  filter: drop-shadow(0 0 4px rgba(255, 220, 110, 0.95));
  animation: popIn 0.3s var(--ease-spring);
}
.hm-meta {
  display: flex;
  justify-content: space-between;
  width: 100%;
  font-size: calc(var(--u) * 0.85);
  font-weight: 600;
  gap: 0.6em;
}
#hm-pts {
  color: #ffd858;
}
#hm-dist {
  color: #f3e7c8;
}

.hud-left {
  display: contents;
}
@media (orientation: portrait) {
  /* Score and wind stack in one column, so a two-line stage name pushes the wind plaque down instead of overlapping. */
  .hud-left {
    position: absolute;
    top: max(12px, env(safe-area-inset-top));
    left: max(12px, env(safe-area-inset-left));
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: calc(var(--u) * 0.45);
    max-width: calc(100vw - var(--u) * 11 - 36px);
  }
  .hud-left > .hud-score,
  .hud-left > .hud-wind {
    position: relative;
    top: auto;
    left: auto;
    transform: none;
  }
  .hud-score {
    min-width: 0;
    max-width: 100%;
  }
  .hs-stage {
    white-space: normal;
  }
}

/* ---------- Stage banner ---------- */
#stage-banner {
  position: fixed;
  top: 20%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 22;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5em;
  animation: bannerAnim 2.75s ease forwards;
}
.sb-band {
  height: var(--btn-h);
  padding: 0 calc(var(--btn-h) * 0.8);
  font-size: calc(var(--u) * 1.35);
  font-weight: 600;
  color: var(--ink-wood);
  text-shadow: var(--shade);
}
.sb-desc {
  font-size: calc(var(--u) * 1.1);
  color: #fff6e0;
  text-align: center;
  max-width: 86vw;
  padding: 0.35em 1em;
  border-radius: 999px;
  background: rgba(16, 28, 18, 0.72);
}

/* ---------- Panels ---------- */
.panel {
  width: min(92vw, calc(var(--u) * 30));
  max-height: calc(100vh - 32px);
  padding: calc(var(--u) * 3.4) calc(var(--u) * 2.2) calc(var(--u) * 2.2);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: calc(var(--u) * 0.9);
}
.panel.small {
  width: min(92vw, calc(var(--u) * 23));
}
.panel-band {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translate(-50%, -38%);
  height: var(--btn-h);
  min-width: 62%;
  padding: 0 calc(var(--btn-h) * 0.7);
  font-size: calc(var(--u) * 1.45);
  font-weight: 600;
  color: var(--ink-wood);
  text-shadow: var(--shade);
}
.close {
  position: absolute;
  top: calc(var(--u) * -0.2);
  right: calc(var(--u) * -0.2);
  width: calc(var(--u) * 2.8);
  height: calc(var(--u) * 2.8);
  z-index: 2;
}
.panel-col {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: calc(var(--u) * 0.75);
  width: 100%;
}
.panel-col > .btn {
  width: 100%;
}
.panel-actions {
  display: flex;
  gap: calc(var(--u) * 0.7);
  justify-content: center;
  flex-wrap: wrap;
  width: 100%;
}
.panel-actions .btn {
  flex: 1 1 auto;
  min-width: calc(var(--u) * 9);
} /* sized by its text: a long label wraps the row instead of spilling */
.row {
  display: flex;
  align-items: center;
  gap: calc(var(--u) * 0.7);
  width: 100%;
  min-height: calc(var(--u) * 2.6);
  font-size: calc(var(--u) * 1.1);
  font-weight: 600;
  color: #ffeec4;
  text-align: left;
}
.row-lbl {
  flex: 1;
  text-shadow: var(--shade);
}
.row .pill {
  --btn-h: calc(var(--u) * 2.4);
  height: var(--btn-h);
  padding: 0 calc(var(--btn-h) * 0.55);
  font-size: var(--u);
}

.lang-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: calc(var(--u) * 0.55);
  width: 100%;
}
.lang-grid .btn {
  --btn-h: calc(var(--u) * 2.7);
  min-width: 0;
  width: 100%;
  padding: 0 0.6em;
  font-size: calc(var(--u) * 0.95);
}
@media (orientation: portrait) {
  .lang-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.steps .step {
  display: flex;
  align-items: center;
  gap: calc(var(--u) * 0.8);
  font-size: calc(var(--u) * 1.05);
  color: #ffeec4;
  text-shadow: var(--shade);
  line-height: 1.25;
}
.steps .step img {
  width: calc(var(--u) * 2.6);
  height: calc(var(--u) * 2.6);
  object-fit: contain;
  flex: none;
}

/* ---------- Result ---------- */
.res-kicker {
  font-size: var(--u);
  color: #ffd978;
  font-weight: 500;
}
.stars {
  display: flex;
  gap: calc(var(--u) * 0.4);
  align-items: flex-end;
}
.stars img {
  width: calc(var(--u) * 3.2);
  height: calc(var(--u) * 3.2);
}
.stars img:nth-child(2) {
  width: calc(var(--u) * 3.8);
  height: calc(var(--u) * 3.8);
}
.stars img.on {
  animation: starIn 0.45s var(--ease-spring) both;
}
.res-body {
  display: flex;
  align-items: center;
  gap: calc(var(--u) * 1.2);
}
.res-target {
  width: calc(var(--u) * 7.5);
}
.res-stats {
  display: flex;
  flex-direction: column;
  gap: calc(var(--u) * 0.45);
}
.stat {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1em;
  min-width: calc(var(--u) * 11);
  min-height: calc(var(--u) * 2.9);
  padding: calc(var(--u) * 0.5) calc(var(--u) * 1.1);
}
.stat-lbl {
  font-size: calc(var(--u) * 0.85);
  color: #ffd978;
  font-weight: 600;
}
.stat-val {
  font-size: calc(var(--u) * 1.3);
  color: #fff7e2;
  font-weight: 600;
}
@media (orientation: portrait) {
  .res-body {
    flex-direction: column;
  }
}
@media (max-height: 520px) {
  .panel {
    padding-top: calc(var(--u) * 2.6);
    gap: calc(var(--u) * 0.5);
  }
  .stars img {
    width: calc(var(--u) * 2.4);
    height: calc(var(--u) * 2.4);
  }
  .res-target {
    width: calc(var(--u) * 5.5);
  }
}

@keyframes logoIn {
  from {
    opacity: 0;
    transform: scale(0.8) translateY(-12px);
  }
}
@keyframes breathe {
  50% {
    transform: scale(1.025);
  }
}
@keyframes tapPulse {
  50% {
    opacity: 0.55;
    transform: scale(0.97);
  }
}
@keyframes starIn {
  from {
    opacity: 0;
    transform: scale(0.2) rotate(-40deg);
  }
}

/* End of screens.css */

/* wooden score plaque: the 9-slice is sized by the plaque, not by --btn-h */
.hud-score.k-wood {
  --k-bw: calc(var(--u) * 1.6) calc(var(--u) * 1.5);
  color: inherit;
  padding: calc(var(--u) * 0.9) calc(var(--u) * 1.4) calc(var(--u) * 1);
}
body.covered #hud > *:not(#btn-cancel-draw) {
  visibility: hidden;
}

/* The bow owns the bottom of the screen: the hint and the last-hit card sit above it. */
.hint {
  top: auto;
  bottom: max(18px, env(safe-area-inset-bottom));
} /* bottom edge: never on the target */
@media (orientation: portrait) {
  .hint {
    bottom: max(14px, env(safe-area-inset-bottom));
  }
  .hit-map {
    bottom: calc(max(14px, env(safe-area-inset-bottom)) + 27vw);
  }
}
@media (orientation: landscape) {
  .hit-map {
    bottom: calc(max(14px, env(safe-area-inset-bottom)) + 16vh);
  }
}

/* Last-hit card on the left: the right side belongs to the upright bow. */
.hit-map {
  right: auto;
  left: max(14px, env(safe-area-inset-left));
}

/* Loading: logo + painted bar until the art, textures and fonts are in. */
.screen-loading {
  z-index: 60;
  background: radial-gradient(ellipse at center, #2c5a34 0%, #16301b 70%);
}
.screen-loading .logo {
  animation: breathe 2.4s ease-in-out infinite;
}
.load-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: calc(var(--u) * 0.6);
  width: min(70vw, calc(var(--u) * 20));
}
.load-bar {
  width: 100%;
  height: calc(var(--u) * 1);
}
.load-bar .bar-fill {
  transition: width 0.25s ease-out;
}
.load-txt {
  font-size: var(--u);
  color: #ffe6a3;
  font-weight: 600;
  text-shadow: var(--shade);
}
.screen-loading.leaving {
  animation: fadeOut 0.35s ease forwards;
  pointer-events: none;
}
@keyframes fadeOut {
  to {
    opacity: 0;
    visibility: hidden;
  }
}

/* Keyboard shortcut chips under the corner buttons (mouse devices only). */
.corner .rbtn {
  position: relative;
}
.key-chip {
  display: none;
}
@media (hover: hover) and (pointer: fine) {
  .corner .key-chip {
    display: grid;
    place-items: center;
    position: absolute;
    left: 50%;
    bottom: calc(var(--u) * -1.15);
    transform: translateX(-50%);
    min-width: calc(var(--u) * 1.25);
    height: calc(var(--u) * 1.15);
    padding: 0 0.3em;
    border-radius: calc(var(--u) * 0.3);
    background: rgba(14, 26, 16, 0.78);
    box-shadow: inset 0 0 0 1px rgba(232, 184, 74, 0.7);
    font-size: calc(var(--u) * 0.72);
    font-weight: 600;
    line-height: 1;
    color: #ffe6a3;
  }
}
@media (hover: hover) and (pointer: fine) {
  .hud-arrows {
    top: calc(max(12px, env(safe-area-inset-top)) + var(--u) * 5.3);
  }
}

.hint {
  white-space: nowrap;
  font-size: min(calc(var(--u) * 0.85), 3.1vw);
}
.wind-dir {
  width: calc(var(--u) * 1.5);
  height: calc(var(--u) * 1.5);
  object-fit: contain;
  transition:
    transform 0.4s var(--ease-spring),
    opacity 0.3s;
}

/* while drawing, the hint steps aside (the cancel chip and the bow need the bottom edge) */
body.drawing .hint {
  opacity: 0;
  transition: opacity 0.2s;
}

@media (orientation: portrait) {
  /* the quiver fans its arrows so 9 of them fit beside the score card */
  .quiver img {
    width: calc(var(--u) * 1.5);
    height: calc(var(--u) * 2);
  }
  .quiver img + img {
    margin-left: calc(var(--u) * -0.55);
  }
  #stage-banner {
    top: 26%;
  } /* in the sky: below the score and wind cards, above the targets */
}

.sb-desc {
  border-radius: 0.9em;
  line-height: 1.25;
  max-width: min(86vw, 34em);
}

body.panel-open #menu-overlay,
body.panel-open #result-overlay {
  visibility: hidden;
}
.hm-wind {
  display: flex;
  align-items: center;
  gap: 0.3em;
  font-size: calc(var(--u) * 0.85);
  font-weight: 600;
  color: #f3e7c8;
}
.hm-wind img {
  width: 1.5em;
  height: 1.5em;
  object-fit: contain;
}
.wind-sock {
  animation: sockFlutter var(--flutter, 0s) ease-in-out infinite alternate;
}
@keyframes sockFlutter {
  from {
    rotate: -3deg;
  }
  to {
    rotate: 4deg;
  }
}

#hit-map {
  padding: calc(var(--u) * 0.95) calc(var(--u) * 1.15);
} /* text clears the painted frame */

#btn-cancel-draw.armed {
  transform: scale(1.18);
  filter: brightness(1.25);
} /* lift here to cancel */
/* End of css/screens.css (complete file). */
