/* BattleDefecator UI. The map is its own HTML document (public/maps/<id>/), this
   file only styles the lobby and the fight HUD on top of it. */

:root {
  --bg: #17131c;
  --panel: rgba(28, 22, 34, 0.88);
  --line: rgba(255, 255, 255, 0.14);
  --text: #f3efe6;
  --muted: #b3a9bd;
  --toxic: #b6e62e;
  --mustard: #e0b324;
  --brown: #7a4a21;
  --pink: #ff4f8b;
  --red: #e5383b;
  --display: Impact, Haettenschweiler, "Arial Narrow Bold", "Franklin Gothic Bold", sans-serif;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  --emoji: "Noto Color Emoji", "Apple Color Emoji", "Segoe UI Emoji", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;                 /* the game never scrolls */
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 var(--body);
  user-select: none;
  -webkit-user-select: none;
}

#app { position: fixed; inset: 0; overflow: hidden; }

#map, #stage, #floats, #hud, #lobby, #loading, #disconnected { position: absolute; inset: 0; width: 100%; height: 100%; }
#map { pointer-events: none; overflow: hidden; contain: strict; background: var(--bg); }
#stage { display: block; }
#floats { pointer-events: none; overflow: hidden; }

/* which layers are visible on which screen */
#hud, #lobby, #loading { display: none; }
#app[data-screen="loading"] #loading { display: grid; }
#app[data-screen="lobby"] #lobby { display: flex; }
#app[data-screen="lobby"] #map, #app[data-screen="loading"] #map { visibility: hidden; }
#app[data-screen="lobby"] #floats { display: none; }
#app[data-screen="fight"] #hud { display: block; }

#loading, #disconnected { place-items: center; font: 28px var(--display); letter-spacing: 0.06em; }
#disconnected { display: grid; background: rgba(10, 8, 12, 0.85); z-index: 50; text-align: center; }
#disconnected[hidden] { display: none; }

button {
  font: inherit;
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.6em 1.1em;
  cursor: pointer;
}
button:hover { background: rgba(255, 255, 255, 0.16); }
button:focus-visible { outline: 2px solid var(--toxic); outline-offset: 2px; }
button.primary {
  background: var(--toxic);
  color: #1a2205;
  border-color: transparent;
  font: 22px var(--display);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
button.primary:hover { filter: brightness(1.1); }
button.primary.on { background: var(--pink); color: #fff; }
button.ghost { padding: 0.3em 0.6em; background: transparent; }
input[type="text"] { min-width: 0; width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 7px; background: rgba(0, 0, 0, 0.25); color: var(--text); font: inherit; user-select: text; }
input[type="text"]:focus { outline: 2px solid var(--toxic); outline-offset: 1px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.form-error { min-height: 1.4em; margin: 5px 0 0; color: #ff8798; font-size: 12px; overflow-wrap: anywhere; }
.form-error:empty { min-height: 0; margin: 0; }

kbd {
  display: inline-block;
  min-width: 1.7em;
  padding: 0.05em 0.4em;
  text-align: center;
  font: 600 12px var(--body);
  background: #2c2533;
  border: 1px solid #4a4055;
  border-bottom-width: 3px;
  border-radius: 5px;
}

/* ------------------------------------------------------------------ settings */

#settings {
  position: absolute;
  top: 8px;
  right: 54px;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 4px;
  opacity: 0.75;
}
#settings:hover { opacity: 1; }
#settings input { width: 80px; accent-color: var(--toxic); }
#gamepadStatus { max-width: 210px; font-size: 11px; color: var(--muted); }
#gamepadStatus.connected { color: var(--toxic); }
#gamepadFightHint { position: absolute; bottom: 110px; left: 15%; right: 15%; margin: 0; text-align: center; font-size: 12px; color: var(--text); text-shadow: 1px 1px 2px #000; }
.gamepad-help { margin-top: 14px; font-size: 12px; color: var(--muted); }
#app[data-screen="fight"] #settings { top: auto; right: 10px; bottom: 8px; }
#app[data-screen="fight"] #gamepadStatus { max-width: 18px; white-space: nowrap; overflow: hidden; }
#helpBtn { position: absolute; top: 8px; right: 10px; z-index: 40; width: 32px; height: 32px; border-radius: 50%; font-weight: 800; }
#controlsDialog { width: min(640px, calc(100vw - 28px)); max-height: calc(100dvh - 40px); padding: 22px; color: var(--text); background: #211a29; border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 18px 80px #0009; overflow: auto; }
#controlsDialog::backdrop { background: rgba(7, 5, 10, 0.78); }
.dialog-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.dialog-header h2 { margin: 0; font: 28px var(--display); color: var(--mustard); }
#controlsDialog h3 { font: 20px var(--display); color: var(--mustard); }
#controlsDialog .gamepad-help { font-size: 14px; }

/* ------------------------------------------------------------------ lobby */

#lobby {
  flex-direction: column;
  padding: 18px 26px 22px;
  background:
    radial-gradient(ellipse 50% 30% at 16% 96%, rgba(182, 230, 46, 0.22), transparent 70%),
    radial-gradient(ellipse at 20% 0%, rgba(122, 74, 33, 0.5), transparent 55%),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.02) 0 2px, transparent 2px 5px),
    var(--bg);
}
/* The fighter preview is drawn on the (transparent) canvas above the lobby. */
#app[data-screen="lobby"] #stage { z-index: 2; pointer-events: none; }

#lobby header { text-align: left; margin-bottom: 14px; }
#lobby h1 {
  margin: 0;
  font: 64px/0.95 var(--display);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--mustard);
  text-shadow: 3px 3px 0 var(--brown), 6px 6px 0 rgba(0, 0, 0, 0.5);
}
#lobby h1 span { color: var(--toxic); }
#lobby header p { margin: 6px 0 0; color: var(--muted); font-style: italic; }

#lobby main {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(220px, 26fr) minmax(360px, 46fr) minmax(230px, 28fr);
  gap: 18px;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  min-height: 0;
  overflow: auto;
}
.panel h2 {
  margin: 0 0 8px;
  font: 20px var(--display);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--mustard);
}
.panel h2 small { color: var(--muted); font: 13px var(--body); }

/* left column: only the name box is solid, the fighter preview shows through below */
.panel.you { background: none; border: 0; padding: 0; overflow: visible; display: flex; flex-direction: column; cursor: pointer; }
.namebox { pointer-events: auto; }
.namebox {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 20px;
}
.namebox input { font-size: 18px; font-weight: 700; }
.namebox button { flex: none; padding: 4px 6px; }
.name-hint { margin: 6px 0 0; font-size: 12px; color: var(--muted); cursor: default; }
.preview-hint { margin-top: auto; text-align: center; color: var(--muted); font-size: 12px; }

#charList { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.char {
  text-align: left;
  padding: 10px 12px 12px;
  border-radius: 12px;
  border: 2px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
}
.char.selected { border-color: var(--toxic); background: rgba(182, 230, 46, 0.1); }
.char h3 { margin: 0; font: 22px var(--display); letter-spacing: 0.04em; }
.char .desc { margin: 2px 0 8px; min-height: 3.9em; color: var(--muted); font-size: 12.5px; line-height: 1.3; }
.stat { display: grid; grid-template-columns: 7.2em 1fr; align-items: center; gap: 6px; font-size: 12px; margin: 3px 0; }
.stat div { height: 7px; border-radius: 4px; background: rgba(255, 255, 255, 0.1); overflow: hidden; }
.stat i { display: block; height: 100%; background: linear-gradient(90deg, var(--mustard), var(--toxic)); }
.char .meta { margin-top: 7px; font-size: 12px; color: var(--muted); }
.char .extras { font: 18px var(--emoji); vertical-align: middle; }

.panel.chars { display: flex; flex-direction: column; overflow: hidden; }
#charList { flex: 1; min-height: 0; overflow: auto; padding-right: 4px; align-content: start; }
.actions { display: flex; gap: 10px; margin-top: 14px; }
.actions .primary { flex: 1; }
#lobbyStatus { margin: 10px 0 0; color: var(--muted); min-height: 2.8em; flex: none; }

#playerList { list-style: none; margin: 0 0 16px; padding: 0; max-height: 34vh; overflow: auto; }
#playerList li { display: flex; justify-content: space-between; gap: 8px; padding: 5px 8px; border-radius: 6px; }
#playerList li:nth-child(odd) { background: rgba(255, 255, 255, 0.04); }
#playerList li.me span { color: var(--toxic); font-weight: 700; }
#playerList small { color: var(--muted); white-space: nowrap; }
#playerList li.ready small { color: var(--toxic); }
#playerList li.match small { color: var(--pink); }
#playerList span { overflow-wrap: anywhere; min-width: 0; }
.panel.side-info { display: flex; flex-direction: column; overflow: hidden; }
.side-info > h2 { flex: none; }
.side-info #playerList { flex: 0 1 auto; max-height: 24vh; min-height: 30px; }
#lobbyChat { display: flex; flex-direction: column; flex: 1; min-height: 220px; position: relative; border-top: 1px solid var(--line); padding-top: 16px; }
#chatMessages { flex: 1; min-height: 0; overflow: auto; list-style: none; padding: 0 4px 8px 0; margin: 0 0 10px; user-select: text; }
#chatMessages li { padding: 8px 10px; margin-bottom: 6px; border-radius: 8px; background: rgba(255, 255, 255, 0.04); overflow-wrap: anywhere; }
#chatMessages strong { display: block; font-size: 12px; color: var(--mustard); }
#chatMessages .mine strong { color: var(--toxic); }
#chatMessages span { font-size: 13px; }
#chatEmpty { position: absolute; top: 55px; left: 0; right: 0; color: var(--muted); font-size: 13px; pointer-events: none; }
#chatForm { display: flex; gap: 6px; }
#chatForm input { flex: 1; font-size: 13px; }
#chatForm button { padding: 8px; font-size: 13px; }

.controls { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 0; align-items: center; }
.controls dt { white-space: nowrap; }
.controls dd { margin: 0; color: var(--muted); }

@media (max-width: 900px) {
  #lobby { overflow: auto; pointer-events: auto; }
  #lobby h1 { font-size: 40px; }
  #lobby main { display: flex; flex-direction: column; }
  .panel.you { min-height: 46vh; }
  .panel.side-info { min-height: 480px; flex-shrink: 0; }
  #controlsDialog .controls { font-size: 12px; gap: 6px; }
  #controlsDialog .controls dt { white-space: normal; }
}

/* ------------------------------------------------------------------ fight HUD */

#hud { pointer-events: none; font-family: var(--body); }
#hud button { pointer-events: auto; }

.hud-top {
  position: absolute;
  top: 10px;
  left: 3%;
  right: 3%;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 14px;
  align-items: start;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.6));
}
.nameplate { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 3px; }
.nameplate .name { font: 22px var(--display); letter-spacing: 0.05em; text-shadow: 2px 2px 0 #000; }
.nameplate .name.me { color: var(--toxic); }
.pips { display: inline-flex; gap: 5px; }
.pips i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid #fff; background: rgba(0, 0, 0, 0.5); }
.pips i.won { background: var(--mustard); box-shadow: 0 0 8px var(--mustard); }

.bar { position: relative; height: 22px; background: rgba(0, 0, 0, 0.65); border: 2px solid #fff; border-radius: 4px; overflow: hidden; }
.bar i, .bar b { position: absolute; top: 0; bottom: 0; left: 0; }
.side-0 .bar i, .side-0 .bar b { left: auto; right: 0; }        /* player 1 drains towards the outside */
.bar.hp b { background: #fff; transition: width 0.5s 0.25s; }
.bar.hp i { z-index: 1; background: linear-gradient(180deg, #6fe04a, #2f9e1f); transition: width 0.08s; }
.bar.hp i.low { background: linear-gradient(180deg, #ff6b5e, #b81f1f); }
.bar.stomach { height: 14px; margin-top: 4px; width: 62%; border-width: 1px; }
.side-0 .bar.stomach { margin-left: auto; }
.bar.stomach i { background: repeating-linear-gradient(45deg, #9a7b1c 0 8px, #b8952a 8px 16px); transition: width 0.15s; }
.bar.stomach.charged { box-shadow: 0 0 10px var(--mustard); }
.bar.stomach.charged i { background: repeating-linear-gradient(45deg, #c9a12b 0 8px, #e8c84a 8px 16px); animation: churn 0.6s linear infinite; background-size: 22.6px 22.6px; }
.bar.stomach span { position: absolute; inset: 0; z-index: 1; font-size: 10px; line-height: 12px; text-align: center; text-transform: uppercase; letter-spacing: 0.1em; text-shadow: 1px 1px 0 #000; }
@keyframes churn { to { background-position: 22.6px 0; } }

.clock { text-align: center; min-width: 84px; }
#timer { display: block; font: 46px/1 var(--display); text-shadow: 3px 3px 0 #000; }
#timer.low { color: var(--red); animation: pulse 1s infinite; }
.clock small { color: #fff; text-transform: uppercase; letter-spacing: 0.1em; font-size: 11px; text-shadow: 1px 1px 0 #000; }
@keyframes pulse { 50% { transform: scale(1.15); } }

#announcer {
  position: absolute;
  left: 0;
  right: 0;
  top: 26%;
  text-align: center;
  opacity: 0;
  transition: opacity 0.3s;
}
#announcer.show { opacity: 1; }
#announcer .big {
  font: clamp(48px, 11vw, 150px)/1 var(--display);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--mustard);
  -webkit-text-stroke: 3px #1a1206;
  text-shadow: 5px 5px 0 var(--brown), 9px 9px 0 rgba(0, 0, 0, 0.45);
}
#announcer.show .big { animation: slam 0.35s cubic-bezier(0.2, 1.6, 0.4, 1); }
#announcer.go .big, #announcer.win .big { color: var(--toxic); }
#announcer.ko .big, #announcer.lose .big { color: var(--red); }
#announcer .sub { margin-top: 8px; font: clamp(18px, 2.6vw, 34px) var(--display); letter-spacing: 0.05em; text-shadow: 2px 2px 0 #000; }
@keyframes slam { from { transform: scale(2.4); opacity: 0; } }

#leaveBtn { position: absolute; left: 10px; bottom: 8px; font-size: 12px; opacity: 0.6; }
#leaveBtn:hover { opacity: 1; }
#leaveBtn.armed { opacity: 1; background: var(--red); border-color: #fff; font-size: 14px; }

/* --- skill bar --- */

#skillbar {
  position: absolute;
  left: 50%;
  bottom: 10px;
  transform: translateX(-50%);
  display: flex;
  gap: 14px;
  padding: 8px 10px;
  background: rgba(18, 14, 22, 0.82);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
}
#skillbar .group { display: flex; gap: 6px; }
#skillbar .group.extra { padding-left: 14px; border-left: 2px dashed var(--mustard); }

.skill {
  position: relative;
  width: clamp(44px, 5.2vw, 64px);
  aspect-ratio: 1;
  padding: 0;
  border-radius: 10px;
  border: 2px solid #5a4f66;
  background: linear-gradient(160deg, #3a3144, #231d2b);
  overflow: hidden;
  touch-action: none;
}
.skill:hover { border-color: #fff; background: linear-gradient(160deg, #4a3f57, #2c2536); }
.skill:active { transform: translateY(1px); }
.skill.hold { border-style: double; border-width: 4px; }
.extra .skill { border-color: var(--mustard); }
.skill .icon { position: absolute; inset: 0; display: grid; place-items: center; font: clamp(22px, 2.7vw, 34px) var(--emoji); }
.skill .key {
  position: absolute;
  top: 2px;
  left: 4px;
  z-index: 2;
  font: 700 12px var(--body);
  color: #fff;
  text-shadow: 1px 1px 0 #000, -1px -1px 0 #000;
}
.skill .cost { position: absolute; top: 2px; right: 4px; z-index: 2; font: 700 11px var(--body); color: var(--mustard); text-shadow: 1px 1px 0 #000; }
.gamepad .skill .key { font-size: 10px; }
.gamepad .skill .cost { top: auto; bottom: 2px; }
.skill .label { display: none; }
.skill .cd { position: absolute; left: 0; right: 0; bottom: 0; height: 0; z-index: 1; background: rgba(8, 6, 10, 0.78); border-top: 2px solid rgba(255, 255, 255, 0.5); }
.skill.cooling .icon { filter: grayscale(0.8); }
.skill.starved { opacity: 0.45; }
.skill.starved .icon { filter: grayscale(1); }
.skill.active { border-color: var(--toxic); box-shadow: 0 0 12px var(--toxic), inset 0 0 10px rgba(182, 230, 46, 0.5); }

#tooltip {
  position: absolute;
  z-index: 30;
  width: 290px;
  padding: 10px 12px;
  background: rgba(14, 11, 17, 0.96);
  border: 1px solid var(--mustard);
  border-radius: 10px;
  font-size: 13px;
}
#tooltip strong { font: 18px var(--display); letter-spacing: 0.04em; color: var(--mustard); }
#tooltip p { margin: 4px 0 8px; color: var(--muted); }
#tooltip table { width: 100%; border-collapse: collapse; }
#tooltip th { text-align: left; font-weight: 400; color: var(--muted); padding-right: 10px; white-space: nowrap; vertical-align: top; }
#tooltip td.note { color: var(--muted); font-style: italic; }

/* --- things floating over the fighters --- */

.overhead {
  position: absolute;
  left: 0;
  top: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  will-change: transform;
  font-family: var(--emoji);
}
.overhead .bubble {
  display: none;
  width: 44px;
  height: 44px;
  place-items: center;
  font-size: 26px;
  background: #fff;
  border: 3px solid #1a1206;
  border-radius: 50% 50% 50% 8px;
  box-shadow: 2px 3px 0 rgba(0, 0, 0, 0.4);
}
.overhead .bubble.on { display: grid; animation: pop 0.18s cubic-bezier(0.2, 1.8, 0.4, 1); }
.overhead .status { font-size: 22px; min-height: 4px; filter: drop-shadow(0 1px 2px #000); }
.overhead .tag { color: var(--toxic); font: 16px var(--body); text-shadow: 0 2px 0 #000; }
@keyframes pop { from { transform: scale(0); } }

.float {
  position: absolute;
  transform: translate(-50%, -50%);
  font: 30px var(--display);
  letter-spacing: 0.04em;
  white-space: nowrap;
  color: #fff;
  -webkit-text-stroke: 1.5px #000;
  text-shadow: 2px 2px 0 #000;
  animation: rise 0.95s ease-out forwards;
}
.float.dmg { color: #ffd23f; }
.float.dmg.crit { color: var(--red); font-size: 44px; }
.float.dmg.small { font-size: 20px; color: #ff9b9b; }
.float.crit { color: var(--red); }
.float.info { color: #9fd8ff; font-size: 22px; }
.float.bad { color: var(--pink); font-size: 24px; }
@keyframes rise {
  0% { transform: translate(-50%, -50%) scale(0.4); opacity: 0; }
  15% { transform: translate(-50%, -80%) scale(1.15); opacity: 1; }
  100% { transform: translate(-50%, -260%) scale(1); opacity: 0; }
}

.bot-difficulty { display: flex; align-items: center; gap: 10px; margin-top: 10px; font-size: 12px; flex-shrink: 0; }
.bot-difficulty label { flex: 1; }
#botLevel { min-width: 68px; min-height: 44px; font: inherit; font-size: 16px; background: #211a29; color: var(--text); border: 1px solid var(--line); border-radius: 7px; padding: 6px 10px; }
