/* ============================================================
   SIEGE BUDDIES — in-game HUD, build tray, combat bar, overlays
   ============================================================ */

.game-screen { background: #222; }
#game-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: crosshair; }

#hud { position: absolute; inset: 0; pointer-events: none; display: flex; flex-direction: column; }
#hud > * { pointer-events: none; }
#hud button, #hud .clickable { pointer-events: auto; }

/* ---------- top bar ---------- */
.hud-top { display: flex; align-items: flex-start; justify-content: space-between; padding: 10px 12px; gap: 10px; }
.hud-player {
  display: flex; align-items: center; gap: 10px; padding: 6px 14px 8px;
  border: 3px solid var(--outline); border-radius: 14px;
  box-shadow: 0 4px 0 rgba(0,0,0,.3); min-width: 218px;
  transition: box-shadow .2s ease, filter .2s ease;
}
.hud-player.team-0 { background: linear-gradient(180deg, #4aa9ef, var(--blue-dark)); }
.hud-player.team-1 { background: linear-gradient(180deg, #ef6353, var(--red-dark)); flex-direction: row-reverse; text-align: right; }
.hud-player.active-turn { box-shadow: 0 0 0 4px var(--gold), 0 4px 0 rgba(0,0,0,.3); }
.hud-player.dimmed { filter: brightness(.72) saturate(.7); }
.hud-player .avatar { width: 46px; height: 46px; flex: 0 0 auto; }
.hud-player .hp-wrap { flex: 1; }
.hud-player .pname { font-family: var(--font-display); font-weight: 800; font-size: .95rem; text-shadow: 0 2px 0 rgba(0,0,0,.35); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; }
.hp-bar { height: 16px; border: 2px solid var(--outline); border-radius: 9px; background: rgba(0,0,0,.4); overflow: hidden; margin-top: 3px; position: relative; }
.hp-bar > .hp-fill { height: 100%; border-radius: 6px; background: linear-gradient(180deg, #8be05f, #4d9c2a); transition: width .3s ease; }
.hp-bar > .hp-fill.mid { background: linear-gradient(180deg, #ffd35c, #d88a10); }
.hp-bar > .hp-fill.low { background: linear-gradient(180deg, #f2695a, #a3221a); }
.hp-bar .hp-num { position: absolute; inset: 0; display: grid; place-items: center; font-size: .68rem; font-weight: 800; text-shadow: 0 1px 2px rgba(0,0,0,.7); }
.hud-player .team-sym { font-size: .72rem; font-weight: 900; opacity: .95; }
.hud-player .fx-icons { font-size: .8rem; min-height: 1em; }

.hud-mid { display: flex; flex-direction: column; align-items: center; gap: 5px; flex: 0 1 auto; }
.phase-chip {
  font-family: var(--font-display); font-weight: 800; color: #ffe9bd; font-size: .95rem;
  background: linear-gradient(180deg, #4a2f13, #34210c); border: 3px solid var(--outline);
  border-radius: 999px; padding: 4px 18px 6px; box-shadow: 0 3px 0 rgba(0,0,0,.3);
  white-space: nowrap;
}
.big-timer {
  font-family: var(--font-display); font-weight: 800; font-size: 1.7rem; color: #fff;
  background: linear-gradient(180deg, var(--wood-hi), var(--wood-mid));
  border: 3px solid var(--outline); border-radius: 14px; padding: 2px 20px 4px;
  box-shadow: 0 4px 0 rgba(0,0,0,.3); text-shadow: 0 2px 0 rgba(0,0,0,.35);
  min-width: 96px; text-align: center;
}
.big-timer.urgent { color: #ffb3a8; animation: timerPulse .5s ease-in-out infinite alternate; }
@keyframes timerPulse { from { transform: scale(1); } to { transform: scale(1.08); } }
.wind-widget { display: flex; align-items: center; gap: 6px; font-weight: 800; font-size: .82rem; color: #eaf6ff; text-shadow: 0 1px 2px rgba(0,0,0,.6); }
.wind-widget canvas { width: 90px; height: 22px; }
.round-score { font-weight: 800; font-size: .85rem; color: #ffe9bd; text-shadow: 0 1px 2px rgba(0,0,0,.6); }
.match-crowns { font-weight: 800; font-size: .8rem; color: var(--gold); text-shadow: 0 1px 2px rgba(0,0,0,.6); }

.hud-corner { position: absolute; right: 12px; top: 78px; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.hud-corner .btn { font-size: 1rem; padding: 6px 12px 8px; }
.net-chip { font-size: .72rem; font-weight: 800; padding: 3px 10px 4px; border-radius: 999px; border: 2px solid var(--outline); background: rgba(10,16,24,.75); }

/* ---------- bottom: build tray ---------- */
.hud-bottom { margin-top: auto; padding: 8px 10px 10px; display: flex; flex-direction: column; gap: 6px; }
#build-ui, #combat-ui { display: flex; flex-direction: column; gap: 6px; }

.tray {
  display: flex; gap: 6px; align-items: stretch; justify-content: center; flex-wrap: nowrap;
  overflow-x: auto; padding: 8px; border-radius: 14px;
  background: linear-gradient(180deg, rgba(50,31,12,.92), rgba(36,21,7,.92));
  border: 3px solid var(--outline); box-shadow: 0 5px 0 rgba(0,0,0,.3);
  pointer-events: auto;
  scrollbar-width: thin;
}
.tray-piece {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-width: 74px; padding: 5px 4px; cursor: pointer;
  background: linear-gradient(180deg, var(--wood-hi), var(--wood-mid));
  border: 3px solid var(--outline); border-radius: 10px; color: var(--cream);
  box-shadow: 0 3px 0 rgba(0,0,0,.3); position: relative;
  transition: transform .07s ease;
}
.tray-piece:hover { transform: translateY(-3px); }
.tray-piece:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.tray-piece.selected { box-shadow: 0 0 0 3px var(--gold), 0 3px 0 rgba(0,0,0,.3); }
.tray-piece.depleted { filter: grayscale(.9) brightness(.6); cursor: not-allowed; }
.tray-piece img, .tray-piece canvas { width: 48px; height: 34px; object-fit: contain; }
.tray-piece .tp-name { font-size: .58rem; font-weight: 700; text-align: center; line-height: 1.1; }
.tray-piece .tp-count { position: absolute; top: -7px; right: -5px; background: var(--gold); color: #4a2b04; font-weight: 800; font-size: .68rem; border: 2px solid var(--outline); border-radius: 999px; padding: 0 6px 1px; }
.tray-piece .tp-cost { font-size: .6rem; font-weight: 800; color: #ffd98a; }

.build-toolbar { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; }
.build-toolbar .btn { font-size: .82rem; padding: 5px 12px 7px; }
.build-info { display: flex; gap: 16px; align-items: center; font-weight: 800; font-size: .82rem; color: #ffe9bd; text-shadow: 0 1px 2px rgba(0,0,0,.7); }
.stability-dot { display: inline-block; width: 13px; height: 13px; border-radius: 50%; border: 2px solid var(--outline); vertical-align: -2px; margin-right: 4px; }
.stability-dot.good { background: #7ee05f; } .stability-dot.warn { background: #ffd35c; } .stability-dot.bad { background: #f2695a; }

/* ---------- bottom: combat bar ---------- */
#weapon-bar { display: flex; gap: 8px; justify-content: center; align-items: flex-end; pointer-events: auto; }
.weapon-slot {
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  width: 76px; padding: 6px 4px 4px; cursor: pointer; position: relative;
  background: linear-gradient(180deg, var(--wood-hi), var(--wood-mid));
  border: 3px solid var(--outline); border-radius: 12px; color: var(--cream);
  box-shadow: 0 4px 0 rgba(0,0,0,.3);
  transition: transform .07s ease;
}
.weapon-slot:hover { transform: translateY(-3px); }
.weapon-slot:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.weapon-slot.selected { box-shadow: 0 0 0 4px var(--gold), 0 4px 0 rgba(0,0,0,.3); transform: translateY(-4px); }
.weapon-slot.depleted { filter: grayscale(.9) brightness(.55); cursor: not-allowed; }
.weapon-slot img, .weapon-slot canvas { width: 42px; height: 42px; }
.weapon-slot .ws-name { font-size: .58rem; font-weight: 700; text-align: center; line-height: 1.05; }
.weapon-slot .ws-ammo { position: absolute; top: -8px; right: -6px; background: var(--cream); color: var(--ink); font-weight: 800; font-size: .7rem; border: 2px solid var(--outline); border-radius: 999px; padding: 0 6px 1px; }
.weapon-slot .ws-key { position: absolute; top: -8px; left: -4px; background: #34210c; color: #ffd98a; font-weight: 800; font-size: .62rem; border: 2px solid var(--outline); border-radius: 6px; padding: 0 5px 1px; }
.weapon-slot.special-slot { box-shadow: 0 0 0 3px #a76bff, 0 4px 0 rgba(0,0,0,.3); }
.weapon-slot.special-slot.selected { box-shadow: 0 0 0 4px var(--gold), 0 4px 0 rgba(0,0,0,.3); }

.combat-info-row { display: flex; align-items: center; justify-content: center; gap: 14px; flex-wrap: wrap; }
.aim-readout { font-family: var(--font-display); font-weight: 800; font-size: .9rem; color: #eaf6ff; text-shadow: 0 1px 3px rgba(0,0,0,.7); min-width: 200px; text-align: center; }
.power-meter { width: 200px; height: 15px; border: 3px solid var(--outline); border-radius: 9px; background: rgba(0,0,0,.5); overflow: hidden; }
.power-meter > div { height: 100%; width: 0%; background: linear-gradient(90deg, #7ee05f, #ffd35c 55%, #f2695a); }
#special-btn { font-size: .9rem; }
.weapon-tip { font-size: .74rem; font-weight: 700; color: #ffe9bd; text-shadow: 0 1px 2px rgba(0,0,0,.8); text-align: center; min-height: 1.2em; }

.emote-bar { position: absolute; left: 12px; bottom: 130px; display: flex; flex-direction: column; gap: 6px; }
.emote-bar .btn { padding: 4px 10px 6px; font-size: 1rem; }

/* ---------- banners ---------- */
#turn-banner, #big-banner {
  position: absolute; left: 50%; top: 34%; transform: translate(-50%, -50%) scale(0);
  font-family: var(--font-display); font-weight: 800; text-align: center;
  padding: 12px 46px 16px; border: 4px solid var(--outline); border-radius: 18px;
  font-size: 2.1rem; color: #fff; text-shadow: 0 3px 0 rgba(0,0,0,.35);
  box-shadow: 0 8px 0 rgba(0,0,0,.3), 0 16px 40px rgba(0,0,0,.4);
  pointer-events: none; opacity: 0; z-index: 30;
}
#turn-banner.team-0 { background: linear-gradient(180deg, #57b4f5, var(--blue-dark)); }
#turn-banner.team-1 { background: linear-gradient(180deg, #f2695a, var(--red-dark)); }
#big-banner { background: linear-gradient(180deg, #ffd35c, #d88a10); color: #4a2b04; text-shadow: 0 2px 0 rgba(255,255,255,.35); top: 26%; }
#big-banner.storm { background: linear-gradient(180deg, #8a5cf5, #4a2a9c); color: #fff; text-shadow: 0 3px 0 rgba(0,0,0,.4); }
.banner-pop { animation: bannerPop 1.9s cubic-bezier(.2,1.4,.4,1) forwards; }
@keyframes bannerPop {
  0% { transform: translate(-50%,-50%) scale(0); opacity: 0; }
  14% { transform: translate(-50%,-50%) scale(1.06); opacity: 1; }
  22% { transform: translate(-50%,-50%) scale(1); }
  78% { transform: translate(-50%,-50%) scale(1); opacity: 1; }
  100% { transform: translate(-50%,-50%) scale(.9); opacity: 0; }
}
.banner-sub { display: block; font-size: .95rem; margin-top: 2px; opacity: .95; }

#placement-hint {
  position: absolute; top: 84px; left: 50%; transform: translateX(-50%);
  font-weight: 800; color: #fff; text-shadow: 0 2px 4px rgba(0,0,0,.8);
  background: rgba(10,16,24,.6); padding: 6px 18px 8px; border-radius: 999px; border: 2px solid rgba(255,255,255,.25);
  font-size: .9rem; white-space: nowrap; z-index: 20;
}

/* ---------- result overlay ---------- */
#result-overlay, #pause-overlay {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: rgba(10,14,22,.62); z-index: 50; pointer-events: auto;
}
.result-panel { width: min(560px, 94vw); max-height: 92vh; overflow-y: auto; text-align: center; }
.result-title { font-family: var(--font-display); font-size: 2.3rem; font-weight: 800; text-shadow: 0 3px 0 rgba(0,0,0,.35); margin-bottom: 2px; }
.result-title.win { color: var(--gold); } .result-title.lose { color: #ffb3a8; } .result-title.neutral { color: #dfe9ff; }
.result-sub { font-weight: 700; color: #ffe9bd; margin-bottom: 12px; }
.reward-lines { text-align: left; margin: 10px auto 6px; max-width: 400px; }
.reward-line { display: flex; justify-content: space-between; padding: 4px 8px; font-weight: 700; border-bottom: 1px dashed rgba(0,0,0,.25); }
.reward-line .amt { color: var(--gold); font-weight: 800; }
.reward-line.total { border-top: 3px solid var(--outline); border-bottom: none; font-size: 1.15rem; margin-top: 4px; font-family: var(--font-display); }
.reward-line.challenge { color: #baffb0; }
.result-buttons { display: flex; gap: 12px; justify-content: center; margin-top: 14px; flex-wrap: wrap; }
.rematch-note { font-size: .8rem; font-weight: 700; color: #ffd98a; margin-top: 8px; min-height: 1.2em; }

.pause-panel { width: min(420px, 92vw); text-align: center; display: flex; flex-direction: column; gap: 10px; }

/* ---------- tutorial overlay ---------- */
#tutorial-overlay { position: absolute; inset: 0; z-index: 60; pointer-events: none; }
.tut-box {
  position: absolute; max-width: 380px; pointer-events: auto;
  background: linear-gradient(180deg, var(--wood-hi), var(--wood-mid));
  border: 4px solid var(--outline); border-radius: 14px; padding: 14px 16px;
  box-shadow: 0 6px 0 rgba(0,0,0,.3), 0 12px 30px rgba(0,0,0,.4);
}
.tut-box h3 { font-family: var(--font-display); color: var(--gold); margin-bottom: 6px; }
.tut-box p { font-weight: 600; font-size: .9rem; line-height: 1.45; }
.tut-box .row { margin-top: 10px; gap: 8px; justify-content: flex-end; }
.tut-arrow { position: absolute; font-size: 2.6rem; color: var(--gold); text-shadow: 0 3px 6px rgba(0,0,0,.6); animation: arrowBounce .7s ease-in-out infinite alternate; pointer-events: none; z-index: 61; }
@keyframes arrowBounce { from { transform: translateY(0); } to { transform: translateY(-12px); } }
.tut-highlight { position: absolute; border: 4px dashed var(--gold); border-radius: 14px; pointer-events: none; animation: highlightPulse 1s ease-in-out infinite alternate; z-index: 61; }
@keyframes highlightPulse { from { box-shadow: 0 0 0 0 rgba(255,193,46,.5); } to { box-shadow: 0 0 0 9px rgba(255,193,46,0); } }

/* fade for spectating / waiting */
.wait-veil { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(10,14,22,.35); z-index: 25; pointer-events: none; }
.wait-veil .msg { font-family: var(--font-display); font-weight: 800; font-size: 1.4rem; color: #fff; text-shadow: 0 2px 4px rgba(0,0,0,.7); background: rgba(10,16,24,.55); border-radius: 14px; padding: 10px 26px 12px; }
