/* Hidden Valley Arena - UI styling. */

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

:root {
  --accent: #d1842f;
  --accent2: #88a85d;
  --ink: #151915;
  --panel: rgba(20, 22, 17, 0.82);
  --paper: #f2dfb5;
  --paper2: #c89d62;
  --red: #8c2f28;
  --text: #fff4d5;
}

html, body { width: 100%; height: 100%; overflow: hidden; }
body {
  font-family: "Avenir Next", "Segoe UI", system-ui, sans-serif;
  color: var(--text);
  background: #0a101c;
  user-select: none;
}

#game, #game canvas { position: fixed; inset: 0; }

.hidden { display: none !important; }

/* ============================== MENU ============================== */
#menu {
  position: fixed; inset: 0; z-index: 30;
  display: flex; align-items: center; justify-content: flex-start;
  padding: clamp(18px, 5vw, 72px);
  background:
    linear-gradient(90deg, rgba(5, 8, 6, 0.7), rgba(5, 8, 6, 0.18) 52%, rgba(5, 8, 6, 0.45)),
    radial-gradient(ellipse at 51% 57%, rgba(6, 7, 4, 0.52), transparent 34%),
    url("assets/menu-leaf-village.png") center / cover no-repeat,
    #09100f;
  overflow: hidden;
}

#menu::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(4, 5, 3, 0.12), rgba(4, 5, 3, 0.56)),
    radial-gradient(ellipse at center, transparent 40%, rgba(3, 4, 2, 0.55) 100%);
}

.menu-leaves {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.menu-leaves span {
  position: absolute;
  width: 18px;
  height: 8px;
  border-radius: 100% 0 100% 0;
  background: linear-gradient(90deg, #9fc56f, #425d2e);
  opacity: 0.58;
  transform: rotate(22deg);
  animation: leaf-drift 9s linear infinite;
}

.menu-leaves span:nth-child(1) { left: 12%; top: -8%; animation-delay: 0s; }
.menu-leaves span:nth-child(2) { left: 38%; top: -10%; animation-delay: 1.8s; animation-duration: 11s; }
.menu-leaves span:nth-child(3) { left: 64%; top: -7%; animation-delay: 3.1s; animation-duration: 10s; }
.menu-leaves span:nth-child(4) { left: 80%; top: -9%; animation-delay: 4.6s; animation-duration: 12s; }
.menu-leaves span:nth-child(5) { left: 25%; top: -12%; animation-delay: 6.2s; animation-duration: 13s; }

@keyframes leaf-drift {
  0% { transform: translate3d(0, -20px, 0) rotate(15deg); opacity: 0; }
  12% { opacity: 0.6; }
  100% { transform: translate3d(18vw, 110vh, 0) rotate(395deg); opacity: 0; }
}

.panel {
  position: relative;
  width: min(390px, calc(100vw - 36px));
  max-height: calc(100vh - 36px);
  overflow-y: auto;
  padding: 28px 30px 26px;
  background:
    linear-gradient(180deg, rgba(34, 39, 27, 0.91), rgba(12, 14, 11, 0.91)),
    radial-gradient(ellipse at top, rgba(217, 154, 56, 0.2), transparent 55%);
  border: 1px solid rgba(242, 223, 181, 0.38);
  border-radius: 6px;
  box-shadow:
    0 24px 80px rgba(0, 0, 0, 0.55),
    inset 0 0 0 1px rgba(0, 0, 0, 0.38);
  text-align: center;
  backdrop-filter: blur(10px);
}

.panel::before,
.panel::after {
  content: "";
  position: absolute;
  left: 22px;
  right: 22px;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(217, 154, 56, 0.8), transparent);
  pointer-events: none;
}

.panel::before { top: 14px; }
.panel::after { bottom: 14px; }

.menu-mark {
  width: 58px;
  height: 58px;
  margin: 0 auto 12px;
  display: grid;
  place-items: center;
  color: var(--paper);
  background:
    radial-gradient(circle at 40% 35%, rgba(242, 223, 181, 0.16), transparent 48%),
    linear-gradient(145deg, #883126, #4b1d1a);
  border: 2px solid rgba(242, 223, 181, 0.45);
  border-radius: 50%;
  box-shadow: 0 0 24px rgba(217, 154, 56, 0.28);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 30px;
  line-height: 1;
}

.panel h1 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 32px;
  letter-spacing: 5px;
  line-height: 1.03;
  color: var(--paper);
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.5), 0 0 18px rgba(217, 154, 56, 0.42);
}
.panel h1 span { color: var(--accent); }
.tagline {
  font-size: 12px;
  letter-spacing: 3px;
  color: #c9d8a4;
  margin: 9px 0 24px;
  text-transform: uppercase;
}

.panel label {
  display: block;
  text-align: left;
  font-size: 11px;
  letter-spacing: 2px;
  color: #d8bd82;
  margin: 14px 0 6px;
  text-transform: uppercase;
}

.panel input {
  width: 100%;
  padding: 11px 12px;
  background:
    linear-gradient(180deg, rgba(255, 246, 218, 0.14), rgba(91, 63, 34, 0.12)),
    rgba(15, 17, 11, 0.68);
  border: 1px solid rgba(216, 189, 130, 0.5);
  border-radius: 4px;
  color: var(--paper);
  font-size: 14px;
  outline: none;
  box-shadow: inset 0 1px 7px rgba(0, 0, 0, 0.34);
}
.panel input::placeholder { color: rgba(242, 223, 181, 0.48); }
.panel input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(217, 154, 56, 0.18), inset 0 1px 7px rgba(0, 0, 0, 0.34);
}

#swatches { display: flex; gap: 8px; justify-content: space-between; }

#skin-list {
  display: flex; gap: 8px; flex-wrap: wrap;
  min-height: 48px;
  font-size: 12px;
}
.skin-tile {
  width: 48px; height: 48px; border-radius: 5px; cursor: pointer;
  border: 2px solid rgba(216, 189, 130, 0.28);
  background: rgba(0, 0, 0, 0.24);
  image-rendering: pixelated;
}
.skin-tile:hover { border-color: rgba(217, 154, 56, 0.72); }
.skin-tile.sel { border-color: var(--accent); box-shadow: 0 0 12px rgba(217, 154, 56, 0.5); }
.swatch {
  width: 34px; height: 34px; border-radius: 50%;
  border: 2px solid rgba(242, 223, 181, 0.3); cursor: pointer;
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.22);
}
.swatch.sel { border-color: var(--paper); box-shadow: 0 0 12px currentColor, inset 0 0 0 2px rgba(0, 0, 0, 0.22); }

#connect-btn {
  width: 100%;
  margin-top: 24px;
  padding: 13px;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 2px;
  color: #22170b;
  background:
    linear-gradient(180deg, #f0be65, #b76a2a),
    var(--accent);
  border: 1px solid rgba(255, 232, 181, 0.56);
  border-radius: 4px;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.2s, filter 0.2s;
  text-shadow: 0 1px rgba(255, 236, 194, 0.4);
}
#connect-btn:hover {
  transform: translateY(-1px);
  filter: saturate(1.08);
  box-shadow: 0 0 24px rgba(217, 154, 56, 0.38);
}

#menu-error { color: #ff7a7a; font-size: 13px; margin-top: 12px; min-height: 18px; }

.controls-help {
  margin-top: 20px;
  padding-top: 14px;
  font-size: 11px;
  line-height: 1.9;
  color: rgba(242, 223, 181, 0.72);
  border-top: 1px solid rgba(216, 189, 130, 0.22);
}
.controls-help b { color: #bfe08c; }

#skin-preview-stage {
  position: relative;
  z-index: 1;
  width: min(36vw, 380px);
  height: min(76vh, 560px);
  margin-left: clamp(26px, 8vw, 130px);
  display: grid;
  place-items: end center;
  pointer-events: none;
}

#skin-preview {
  width: min(32vw, 310px);
  max-height: min(72vh, 520px);
  image-rendering: pixelated;
  filter:
    drop-shadow(0 28px 18px rgba(0, 0, 0, 0.44))
    drop-shadow(0 0 24px rgba(217, 154, 56, 0.22));
}

@media (max-width: 720px) {
  #menu {
    align-items: flex-end;
    justify-content: center;
    padding: 14px;
    background-position: 58% center;
  }
  .panel {
    width: min(390px, 100%);
    padding: 23px 22px 22px;
  }
  .menu-mark {
    width: 48px;
    height: 48px;
    font-size: 25px;
    margin-bottom: 9px;
  }
  .panel h1 {
    font-size: 25px;
    letter-spacing: 3px;
  }
  .tagline { margin-bottom: 17px; }
  .controls-help { font-size: 10px; line-height: 1.75; }
  #skin-preview-stage { display: none; }
}

/* ============================== HUD ============================== */
#hud > * { position: fixed; z-index: 10; }

#crosshair {
  top: 50%; left: 50%; transform: translate(-50%, -50%);
  font-size: 22px; color: rgba(255, 255, 255, 0.9);
  text-shadow: 0 0 4px #000; pointer-events: none;
}
#charge-ring {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: 5px; height: 44px;
  margin-left: 26px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px; overflow: hidden;
  opacity: 0; transition: opacity 0.15s;
  display: flex; align-items: flex-end;
}
#charge-fill { width: 100%; height: 0%; background: #8ef7b1; }

#hitmarker {
  top: 50%; left: 50%; transform: translate(-50%, -50%);
  font-size: 26px; color: #ffe066; opacity: 0; pointer-events: none;
  text-shadow: 0 0 6px #000;
}
#hitmarker.pop { animation: hitpop 0.25s ease-out; }
@keyframes hitpop {
  0% { opacity: 1; transform: translate(-50%, -50%) scale(1.5); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(0.9); }
}

#damage-vignette {
  inset: 0; pointer-events: none; opacity: 0;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(255, 30, 60, 0.45));
}
#damage-vignette.pop { animation: dmgflash 0.4s ease-out; }
@keyframes dmgflash { 0% { opacity: 1; } 100% { opacity: 0; } }

/* vitals */
#vitals { left: 24px; bottom: 24px; width: 260px; }
.bar-label { font-size: 10px; letter-spacing: 2px; opacity: 0.8; margin: 6px 0 3px; }
.bar {
  height: 14px; border-radius: 7px; overflow: hidden;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.2);
}
.bar div { height: 100%; transition: width 0.2s; }
#hp-fill { width: 100%; background: linear-gradient(90deg, #51e07e, #aff249); }
#shield-fill { width: 0%; background: linear-gradient(90deg, #4dabf7, #7df9ff); }

/* weapon panel */
#weapon-panel {
  right: 24px; bottom: 24px; text-align: right;
  background:
    linear-gradient(180deg, rgba(43, 45, 32, 0.84), rgba(17, 19, 14, 0.86)),
    var(--panel);
  padding: 14px 18px; border-radius: 6px;
  border: 1px solid rgba(226, 158, 73, 0.46);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.34), 0 14px 34px rgba(0, 0, 0, 0.26);
}
#weapon-name { font-size: 15px; font-weight: 800; letter-spacing: 1px; color: #e0a353; }
#ammo { font-size: 30px; font-weight: 900; color: #f2dfb5; }
#orb-row { font-size: 12px; opacity: 0.85; }
#orbs { color: var(--accent2); letter-spacing: 3px; }
#boost-tag { margin-top: 6px; font-size: 11px; color: #bfe08c; font-weight: 800; }

/* status */
#status-panel {
  left: 24px; top: 20px; font-size: 12px;
  background: var(--panel); padding: 7px 12px; border-radius: 5px;
  border: 1px solid rgba(216, 189, 130, 0.34);
}
#conn-status.ok { color: #69db7c; }
#conn-status.bad { color: #ff7a7a; }

/* killfeed */
#killfeed {
  top: 20px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 4px; align-items: center;
}
.kill-row {
  background:
    linear-gradient(180deg, rgba(43, 45, 32, 0.86), rgba(17, 19, 14, 0.86)),
    var(--panel);
  padding: 5px 14px; border-radius: 5px;
  border: 1px solid rgba(216, 189, 130, 0.34);
  font-size: 13px; animation: feedin 0.2s ease-out;
}
.kill-row .killer { color: var(--accent); font-weight: 700; }
.kill-row .victim { color: var(--accent2); font-weight: 700; }
.kill-row .wp { opacity: 0.65; font-size: 11px; }
.kill-row.announce { opacity: 0.85; font-style: italic; }
@keyframes feedin { from { opacity: 0; transform: translateY(-8px); } }

/* minimap */
#minimap {
  right: 24px; top: 20px;
  border-radius: 6px;
  border: 1px solid rgba(209, 132, 47, 0.36);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.32);
}

/* scoreboard */
#scoreboard {
  top: 50%; left: 50%; transform: translate(-50%, -50%);
  min-width: 440px;
  background:
    linear-gradient(180deg, rgba(31, 34, 25, 0.94), rgba(9, 11, 9, 0.94)),
    var(--panel);
  border-radius: 6px; padding: 22px 26px;
  border: 1px solid rgba(209, 132, 47, 0.38);
}
#scoreboard h2 { font-size: 16px; letter-spacing: 4px; margin-bottom: 12px; text-align: center; }
#scoreboard table { width: 100%; border-collapse: collapse; font-size: 14px; }
#scoreboard th {
  text-align: left; font-size: 10px; letter-spacing: 2px; opacity: 0.6;
  padding: 4px 10px; border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}
#scoreboard td { padding: 5px 10px; }
#scoreboard tr.me td { color: var(--accent); font-weight: 700; }

/* respawn + pause overlays */
#respawn-overlay, #pause-overlay {
  inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: rgba(8, 6, 18, 0.55); pointer-events: none;
}
#respawn-overlay h2 {
  font-size: 44px; letter-spacing: 10px; color: var(--accent2);
  text-shadow: 0 0 30px rgba(255, 106, 213, 0.8);
}
#pause-overlay h2 { font-size: 34px; letter-spacing: 8px; color: var(--accent); }
#respawn-overlay p, #pause-overlay p { margin-top: 10px; opacity: 0.8; }
#respawn-timer { color: #fff; font-weight: 800; }
