/* BattleClap UI: sci-fi HUD look.
   Shapes (clipped corners + borders) come from augmented-ui (lib/augmented-ui): any element with a
   data-augmented-ui="..." attribute gets them, sized/coloured by the --aug-* variables below.
   Colours and fonts are ours. */
@font-face { font-family: Rajdhani; font-weight: 500; font-display: swap; src: url(../lib/fonts/rajdhani-latin-500-normal.woff2) format('woff2'); }
@font-face { font-family: Rajdhani; font-weight: 700; font-display: swap; src: url(../lib/fonts/rajdhani-latin-700-normal.woff2) format('woff2'); }
@font-face { font-family: Orbitron; font-weight: 700; font-display: swap; src: url(../lib/fonts/orbitron-latin-700-normal.woff2) format('woff2'); }

:root {
  --bg: #060a11;
  --panel: rgba(7, 15, 26, .84);       /* HUD panels, see-through */
  --panel-solid: #0b1420;
  --well: rgba(2, 6, 12, .55);         /* sunken areas: inputs, lists, chat */
  --line: #1d4a63;                     /* default border */
  --accent: #2ee6ff;                   /* cyan */
  --accent-2: #ff2e88;                 /* magenta */
  --text: #d6f2ff;
  --muted: #6b8aa3;
  --danger: #ff4d5e;
  --head: Orbitron, 'Segoe UI', sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font: 500 16px/1.35 Rajdhani, 'Segoe UI', system-ui, sans-serif; }
canvas { display: block; cursor: none; }   /* the game draws its own crosshair */
#cursorCv { position: fixed; inset: 0; pointer-events: none; z-index: 15; }
.hidden { display: none !important; }
.hud { position: fixed; pointer-events: none; user-select: none; }
::selection { background: var(--accent); color: var(--bg); }

/* ---- augmented-ui defaults: 1px border, 10px cut corners ---- */
[data-augmented-ui] { --aug-border-all: 1px; --aug-border-bg: var(--line); --aug-tl: 10px; --aug-tr: 10px; --aug-br: 10px; --aug-bl: 10px; }
[data-augmented-ui]:not(.hud) { position: relative; }   /* the border is drawn by an absolutely positioned ::after */

/* ---- Buttons ---- */
.btn { --aug-tl: 7px; --aug-br: 7px; --aug-border-bg: var(--accent);
       font: 700 15px/1 var(--head); letter-spacing: .08em; text-transform: uppercase; color: var(--accent);
       background: rgba(46, 230, 255, .08); border: 0; padding: 10px 16px; cursor: pointer; transition: background .12s, color .12s; }
.btn:hover { background: rgba(46, 230, 255, .2); }
.btn:active { background: rgba(46, 230, 255, .32); }
.btn:focus-visible { outline: none; background: rgba(46, 230, 255, .25); }
.btn.primary { background: var(--accent); color: var(--bg); }
.btn.primary:hover { background: #8ef3ff; }
.btn.danger { --aug-border-bg: var(--danger); color: var(--danger); background: rgba(255, 77, 94, .1); }
.btn.danger:hover { background: rgba(255, 77, 94, .24); }
.btn.small { font-size: 11px; padding: 6px 10px; --aug-tl: 5px; --aug-br: 5px; }
.btn.close { font: 700 14px/1 var(--head); padding: 6px 9px; --aug-tl: 5px; --aug-br: 5px; }
.btn:disabled { opacity: .45; cursor: default; }
.full { display: block; width: 100%; }

/* ---- Inputs: a clipped .box wrapper (inputs can't have ::after) around a bare input/select ---- */
.box { display: block; background: var(--well); --aug-tl: 7px; --aug-br: 7px; }
.box:focus-within { --aug-border-bg: var(--accent); }
.box input, .box select { display: block; width: 100%; background: transparent; border: 0; outline: 0; color: var(--text);
                          font: 500 16px/1.2 Rajdhani, sans-serif; padding: 8px 10px; }
.box input::placeholder { color: var(--muted); }
.box input:disabled, .box select:disabled { color: var(--muted); cursor: default; }
.box select { appearance: none; cursor: pointer; padding-right: 28px;
              background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0h10L5 6z' fill='%232ee6ff'/%3E%3C/svg%3E") right 10px center no-repeat; }
.box select option { background: var(--panel-solid); color: var(--text); }
.box input[type=number] { appearance: textfield; }
.box input::-webkit-inner-spin-button, .box input::-webkit-outer-spin-button { -webkit-appearance: none; }

/* ---- Menu windows (start, lobby, leave dialog) ---- */
.screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 20;
          background:
            radial-gradient(ellipse at 50% 30%, rgba(46, 230, 255, .10), transparent 60%),
            repeating-linear-gradient(0deg, rgba(46, 230, 255, .045) 0 1px, transparent 1px 40px),
            repeating-linear-gradient(90deg, rgba(46, 230, 255, .045) 0 1px, transparent 1px 40px),
            var(--bg); }
.win { --aug-tl: 18px; --aug-br: 18px; --aug-tr: 10px; --aug-bl: 10px; --aug-border-bg: linear-gradient(135deg, var(--accent), var(--line) 35%, var(--line) 65%, var(--accent-2));
       background: var(--panel-solid); width: min(440px, calc(100% - 32px)); max-height: calc(100% - 32px); display: flex; flex-direction: column; }
.win.wide { width: min(880px, calc(100% - 32px)); }
.win-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 22px 0; }
.win-head h1 { font: 700 20px/1 var(--head); letter-spacing: .14em; text-transform: uppercase; color: var(--accent);
               text-shadow: 0 0 12px rgba(46, 230, 255, .5); }
.win-body { padding: 14px 22px 18px; min-height: 0; display: flex; flex-direction: column; gap: 12px; }
.win-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 0 22px 18px; }
.intro { color: var(--muted); }
.field, .label { display: flex; flex-direction: column; gap: 5px; font: 700 11px/1 var(--head); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.row { display: flex; gap: 8px; }
.grow { flex: 1; min-width: 0; }
#pinInput { font: 700 18px/1.2 var(--head); letter-spacing: .3em; }
.sep { display: flex; align-items: center; gap: 10px; font: 700 10px/1 var(--head); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.sep::before, .sep::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.msg { padding: 8px 10px; color: #ffb3bb; border-left: 2px solid var(--danger); background: rgba(255, 77, 94, .08); word-wrap: break-word; }
.muted { color: var(--muted); }
#leaveDlg { position: fixed; inset: 0; margin: auto; height: fit-content; width: min(360px, calc(100% - 32px)); z-index: 25; }

/* ---- Lobby ---- */
.lobbyHead { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.lobbyHead .label { flex-direction: row; }
.pin { font: 700 34px/1 var(--head); letter-spacing: .2em; color: var(--accent); text-shadow: 0 0 14px rgba(46, 230, 255, .55); margin-right: 6px; }
.lobbyBody { display: flex; gap: 18px; min-height: 0; flex: 1; }
.lobbyBody .col { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.settings { display: flex; gap: 10px; }
.settings .field { flex: 1; min-width: 0; }
#players { display: flex; gap: 10px; overflow-y: auto; min-height: 160px; }
#players .team { flex: 1; min-width: 0; padding: 10px 12px; background: var(--well); --aug-border-bg: var(--team, var(--line)); }
#players h4 { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font: 700 12px/1 var(--head); letter-spacing: .1em; text-transform: uppercase; color: var(--text); }
#players h4 small { color: var(--muted); font-size: inherit; flex: 1; }
#players .p { display: flex; align-items: center; gap: 8px; padding: 2px 0; }
#players .p.me .n { color: var(--accent); font-weight: 700; }
#players .sw { width: 8px; height: 8px; flex: none; transform: rotate(45deg); }
#players .n { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#players .tag { font: 700 10px/1 var(--head); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.chatCol { max-width: 360px; }
.well { background: var(--well); }
#lobbyLog { flex: 1; min-height: 200px; max-height: 340px; overflow-y: auto; padding: 8px 10px; display: flex; flex-direction: column; gap: 3px;
            scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
#lobbyLog div { word-wrap: break-word; }
#lobbyLog div.sys { color: var(--muted); font-style: italic; }
@media (max-width: 640px) {
  .win-body { overflow-y: auto; }
  .lobbyBody { flex-direction: column; }
  .chatCol { max-width: none; }
  .pin { font-size: 26px; }
}

/* ---- In-game HUD ---- */
#status, #board, #hp, .fx, #mini, #ammo, #results, #death { background: var(--panel); }
#topbar { top: 8px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 6px; z-index: 16; }
#status { --aug-tl: 6px; --aug-br: 6px; color: var(--muted); padding: 4px 12px; white-space: nowrap; }
.hudBtn { pointer-events: auto; background: var(--panel-solid); }
.hudBtn:hover { background: #12384a; }

#board { top: 8px; left: 8px; min-width: 210px; padding: 8px 12px; }
#board h3 { margin-bottom: 6px; font: 700 11px/1 var(--head); letter-spacing: .1em; text-transform: uppercase; color: var(--accent); }
#board h3 b { font-weight: 700; }
#board .r { display: flex; gap: 8px; align-items: center; }
#board .r.me .n { color: var(--accent); font-weight: 700; }
#board .sw { width: 7px; height: 7px; flex: none; transform: rotate(45deg); }
#board .n { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 130px; }
#board .k { font-weight: 700; }
#board .d { color: var(--muted); width: 34px; text-align: right; }
#board .pg { width: 50px; text-align: right; font-size: 13px; }

#feed { top: 8px; right: 8px; display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
#feed div { background: var(--panel); padding: 3px 10px; border-right: 2px solid var(--accent-2); }

#hp { left: 8px; bottom: 8px; width: 240px; padding: 8px 12px 10px; --aug-border-bg: var(--accent); }
#hpText, #ammoText { font: 700 30px/1 var(--head); color: var(--accent); text-shadow: 0 0 10px rgba(46, 230, 255, .45); }
#hpText small, #ammoText small { font: 700 12px/1 var(--head); color: var(--muted); margin-left: 4px; text-shadow: none; }
.bar { height: 6px; margin-top: 8px; background: rgba(46, 230, 255, .12); overflow: hidden; }
.bar > div { height: 100%; width: 100%; transition: width .12s; box-shadow: 0 0 8px currentColor; }
#hpBar { background: var(--accent); }

#effects { left: 8px; bottom: 82px; display: flex; gap: 5px; flex-wrap: wrap; width: 380px; }
.fx { --aug-tl: 6px; --aug-br: 6px; --aug-border-bg: var(--fx, var(--line)); padding: 4px 9px 6px; min-width: 104px; font-weight: 700; }
.fx .bar { height: 3px; margin-top: 4px; }

#corner { right: 8px; bottom: 8px; display: flex; flex-direction: column; gap: 6px; width: 176px; }
#mini { height: 176px; padding: 6px; --aug-tl: 12px; --aug-tr: 12px; --aug-br: 12px; --aug-bl: 12px; }
#mini canvas { width: 100%; height: 100%; cursor: default; }
#ammo { padding: 8px 12px; text-align: right; --aug-border-bg: var(--accent); }
#weaponName { font: 700 11px/1 var(--head); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }

#chat { left: 8px; bottom: 136px; width: min(380px, calc(100vw - 16px)); pointer-events: none; }
#chatLog { display: flex; flex-direction: column; gap: 2px; max-height: 190px; overflow: hidden; justify-content: flex-end; }
#chatLog div { background: var(--panel); padding: 2px 8px; border-left: 2px solid var(--line); align-self: flex-start; max-width: 100%; word-wrap: break-word; transition: opacity .6s; }
#chatLog div.sys { color: var(--muted); font-style: italic; }
#chatLog div.old { opacity: 0; }
#chat.open #chatLog div.old { opacity: 1; }
#chatBox { margin-top: 5px; pointer-events: auto; background: var(--panel); }
#chatHint { color: var(--muted); margin-top: 3px; font-size: 13px; text-shadow: 0 1px 2px #000; }

#death { top: 56px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; flex-direction: column; gap: 2px;
         padding: 8px 22px; text-align: center; --aug-border-bg: var(--danger); }
#death b { font: 700 20px/1.2 var(--head); letter-spacing: .08em; text-transform: uppercase; color: var(--danger); }
#death span { color: var(--muted); }
#hit { inset: 0; box-shadow: inset 0 0 120px rgba(255, 0, 0, .55); opacity: 0; transition: opacity .25s; }
#hit.on { opacity: 1; transition: none; }
#toast { top: 30%; left: 50%; transform: translate(-50%, -50%); font: 700 26px/1 var(--head); letter-spacing: .08em;
         text-shadow: 0 0 14px currentColor, 0 2px 4px #000; opacity: 0; transition: opacity .4s, transform .4s; }
#toast.on { opacity: 1; transform: translate(-50%, -70%); transition: opacity .1s, transform .4s; }

/* End of match */
#results { top: 22%; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px;
           padding: 16px 32px; text-align: center; z-index: 12; --aug-tl: 18px; --aug-br: 18px;
           --aug-border-bg: linear-gradient(135deg, var(--accent), var(--accent-2)); background: var(--panel-solid); }
#results b { font: 700 28px/1.1 var(--head); letter-spacing: .06em; text-transform: uppercase; }
#results span { color: var(--muted); }
