/* Visual language: military / tactical. Dark olive-charcoal panels, sand
   accent, muted team colours, condensed uppercase headings, hard edges with
   chamfered corners and corner brackets. All colours are variables here. */

@font-face {
  font-family: "Saira Condensed";
  font-weight: 600;
  font-display: swap;
  src: url("./assets/fonts/saira-condensed-latin-600-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Saira Condensed";
  font-weight: 600;
  font-display: swap;
  src: url("./assets/fonts/saira-condensed-latin-ext-600-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Saira Condensed";
  font-weight: 700;
  font-display: swap;
  src: url("./assets/fonts/saira-condensed-latin-700-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Saira Condensed";
  font-weight: 700;
  font-display: swap;
  src: url("./assets/fonts/saira-condensed-latin-ext-700-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "IBM Plex Sans";
  font-weight: 400;
  font-display: swap;
  src: url("./assets/fonts/ibm-plex-sans-latin-400-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "IBM Plex Sans";
  font-weight: 400;
  font-display: swap;
  src: url("./assets/fonts/ibm-plex-sans-latin-ext-400-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "IBM Plex Sans";
  font-weight: 600;
  font-display: swap;
  src: url("./assets/fonts/ibm-plex-sans-latin-600-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "IBM Plex Sans";
  font-weight: 600;
  font-display: swap;
  src: url("./assets/fonts/ibm-plex-sans-latin-ext-600-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "IBM Plex Mono";
  font-weight: 500;
  font-display: swap;
  src: url("./assets/fonts/ibm-plex-mono-latin-500-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "IBM Plex Mono";
  font-weight: 500;
  font-display: swap;
  src: url("./assets/fonts/ibm-plex-mono-latin-ext-500-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --ink: #12140e;
  --panel: rgba(20, 23, 17, 0.93);
  --panel-soft: rgba(20, 23, 17, 0.72);
  --line: rgba(216, 196, 154, 0.2);
  --line-strong: rgba(216, 196, 154, 0.5);
  --sand: #d8c49a;
  --sand-hi: #e8d7b0;
  --text: #ece7d9;
  --muted: #9a9680;
  --red: #c94a3d;
  --blue: #3f78c8;
  --green: #5f9e48;
  --yellow: #d1a531;
  --ok: #8fae5a;
  --f-head: "Saira Condensed", "Arial Narrow", sans-serif;
  --f-body: "IBM Plex Sans", "Segoe UI", sans-serif;
  --f-mono: "IBM Plex Mono", Consolas, monospace;
  --safe-l: max(12px, env(safe-area-inset-left));
  --safe-r: max(12px, env(safe-area-inset-right));
  --safe-b: max(12px, env(safe-area-inset-bottom));
  font-family: var(--f-body);
  color: var(--text);
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--ink);
  /* no scrolling, pinch zoom, text selection or long-press menus on phones */
  touch-action: none;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
input {
  -webkit-user-select: text;
  user-select: text;
}

/* the game renders at 1920x1080; scale it to fit any window, keep 16:9 */
canvas {
  display: block;
  width: min(100vw, 177.78vh);
  height: min(56.25vw, 100vh);
  margin: 0 auto;
}
@supports (height: 100dvh) {
  /* dvh: the visible height on phones (excludes the browser's address bar) */
  canvas {
    width: min(100vw, 177.78dvh);
    height: min(56.25vw, 100dvh);
  }
}

[hidden] {
  display: none !important;
}

/* ------------------------------------------------------------ shared pieces */
.panel {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(380px, calc(100vw - 32px));
  /* no overflow:auto here: the corner brackets sit 1px outside the panel
     and would make it scrollable (and the scrollbar would flicker on/off).
     Very short screens scroll the whole .screen instead. */
  margin: 12px 0;
  padding: 26px 24px 22px;
  box-sizing: border-box;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
/* corner brackets */
.panel::before,
.panel::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  pointer-events: none;
}
.panel::before {
  top: -1px;
  left: -1px;
  border-top: 2px solid var(--sand);
  border-left: 2px solid var(--sand);
}
.panel::after {
  right: -1px;
  bottom: -1px;
  border-right: 2px solid var(--sand);
  border-bottom: 2px solid var(--sand);
}

.panel-kicker,
.brand-kicker,
.field-label {
  font-family: var(--f-head);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
}
.panel-title {
  margin: 2px 0 0;
  font-family: var(--f-head);
  font-weight: 700;
  font-size: 30px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1;
}

.btn {
  height: 46px;
  padding: 0 18px;
  font-family: var(--f-head);
  font-weight: 600;
  font-size: 17px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--line-strong);
  border-radius: 0;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.btn:hover,
.btn:focus-visible {
  border-color: var(--sand);
  background: rgba(216, 196, 154, 0.08);
  outline: none;
}
.btn:active {
  transform: translateY(1px);
}
.btn:disabled {
  opacity: 0.45;
  cursor: default;
}
.btn-primary {
  color: var(--ink);
  background: var(--sand);
  border-color: var(--sand);
  /* chamfered corners */
  clip-path: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px);
}
.btn-primary:hover,
.btn-primary:focus-visible {
  background: var(--sand-hi);
  border-color: var(--sand-hi);
}
.btn-primary.is-on {
  color: var(--ink);
  background: var(--ok);
  border-color: var(--ok);
}
.btn-ghost {
  border-color: transparent;
  color: var(--muted);
}
.btn-ghost:hover,
.btn-ghost:focus-visible {
  color: var(--text);
  border-color: var(--line);
  background: transparent;
}
.btn-small {
  height: 34px;
  font-size: 14px;
  padding: 0 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field input,
.code-input {
  height: 44px;
  padding: 0 12px;
  font-family: var(--f-mono);
  font-weight: 500;
  font-size: 17px;
  color: var(--text);
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--line);
  border-radius: 0;
  outline: none;
  box-sizing: border-box;
}
.field input:focus,
.code-input:focus {
  border-color: var(--sand);
}
.code-input {
  min-width: 0;
  flex: 1;
  text-transform: uppercase;
  letter-spacing: 0.2em;
}

.icon-button {
  pointer-events: auto;
  display: grid;
  place-items: center;
  width: 28px;
  height: 24px;
  padding: 0;
  color: var(--muted);
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 0;
  opacity: 0.8;
  cursor: pointer;
}
.icon-button:hover {
  color: var(--text);
  opacity: 1;
}
.icon-button svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
  stroke-linecap: round;
}

/* phones: fullscreen shortcut, quiet, bottom centre, on every screen */
.fullscreen-button {
  position: fixed;
  left: 50%;
  bottom: var(--safe-b);
  z-index: 6;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  font-family: var(--f-head);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  background: rgba(18, 20, 14, 0.55);
  border: 1px solid var(--line);
  border-radius: 0;
  opacity: 0.75;
}
.fullscreen-button svg {
  width: 12px;
  height: 12px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
}

/* ------------------------------------------------------------ screens */
.screen {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: safe center;
  overflow-y: auto;
  background: radial-gradient(ellipse at center, rgba(12, 13, 9, 0.45) 0%, rgba(12, 13, 9, 0.82) 100%);
}
.screen-clear {
  background: none;
  pointer-events: none;
}
.screen > .panel {
  animation: panel-in 0.18s ease-out;
}
@keyframes panel-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 6px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.brand-title {
  margin: 0;
  font-family: var(--f-head);
  font-weight: 700;
  font-size: 56px;
  letter-spacing: 0.08em;
  line-height: 0.95;
  color: var(--sand);
}

.join-row {
  display: flex;
  gap: 8px;
}
.menu-error {
  margin: 0;
  padding: 8px 10px;
  font-size: 14px;
  color: #f1c7c0;
  background: rgba(201, 74, 61, 0.15);
  border-left: 2px solid var(--red);
}

.room-code-box {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 12px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px dashed var(--line);
}
.room-code {
  font-family: var(--f-mono);
  font-weight: 500;
  font-size: 34px;
  letter-spacing: 0.25em;
  color: var(--sand);
}

.slots {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.slot {
  --team: var(--muted);
  display: grid;
  grid-template-columns: 74px 1fr auto;
  align-items: center;
  gap: 10px;
  height: 44px;
  padding: 0 12px;
  background: rgba(0, 0, 0, 0.28);
  border-left: 3px solid var(--team);
}
.slot.team-blue {
  --team: var(--blue);
}
.slot.team-red {
  --team: var(--red);
}
.slot.team-green {
  --team: var(--green);
}
.slot.team-yellow {
  --team: var(--yellow);
}
.slot-team {
  font-family: var(--f-head);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--team);
}
.slot-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}
.slot.is-empty .slot-name {
  color: var(--muted);
  font-weight: 400;
}
.slot-state {
  font-family: var(--f-head);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}
.slot.is-ready .slot-state {
  color: var(--ok);
}

.countdown {
  font-family: var(--f-head);
  font-weight: 700;
  font-size: clamp(90px, 26vh, 240px);
  line-height: 1;
  letter-spacing: 0.04em;
  color: var(--sand);
  text-shadow: 0 6px 0 rgba(0, 0, 0, 0.35), 0 0 40px rgba(0, 0, 0, 0.5);
}
.countdown.pop {
  animation: count-pop 0.35s ease-out;
}
@keyframes count-pop {
  from {
    opacity: 0.2;
    transform: scale(1.35);
  }
}

.end-panel {
  text-align: center;
  align-items: stretch;
}
.end-title {
  margin: 0;
  font-family: var(--f-head);
  font-weight: 700;
  font-size: 64px;
  letter-spacing: 0.08em;
  line-height: 1;
  text-transform: uppercase;
  color: var(--sand);
}
.end-title.is-loss {
  color: var(--red);
}
.end-sub {
  margin: 0 0 6px;
  color: var(--muted);
}

/* ------------------------------------------------------------ in-match HUD */
.hud-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: none;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: max(10px, env(safe-area-inset-top)) var(--safe-r) 0 var(--safe-l);
  pointer-events: none;
  font-size: clamp(11px, 1.4vw, 18px);
}
body.in-match .hud-top {
  display: flex;
}

.hud-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
#status {
  margin: 0;
  padding: 0.25em 0.7em;
  font-family: var(--f-mono);
  font-size: 0.78em;
  color: var(--muted);
  background: var(--panel-soft);
  border: 1px solid var(--line);
  white-space: nowrap;
}
#status:empty {
  display: none;
}
.hud-buttons {
  display: flex;
  gap: 6px;
}

.player-card {
  --team: var(--text);
  display: flex;
  flex-direction: column;
  gap: 0.45em;
  min-width: 9em;
  max-width: 14em;
  padding: 0.55em 0.8em 0.65em;
  background: var(--panel-soft);
  border-left: 3px solid var(--team);
  transition: opacity 0.3s;
}
.player-card.team-blue {
  --team: var(--blue);
}
.player-card.team-red {
  --team: var(--red);
}
.player-card.team-green {
  --team: var(--green);
}
.player-card.team-yellow {
  --team: var(--yellow);
}
/* cards on the right edge mirror the left ones */
.card-group-right .player-card {
  border-left: none;
  border-right: 3px solid var(--team);
  align-items: flex-end;
  text-align: right;
}
.player-card.is-out {
  opacity: 0.4;
}
.card-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.card-group-right {
  align-items: flex-end;
}
.card-head {
  display: flex;
  align-items: center;
  gap: 0.5em;
  max-width: 100%;
}
.card-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--f-head);
  font-weight: 700;
  font-size: 1.15em;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.you-tag {
  display: none;
  padding: 0.05em 0.45em;
  font-family: var(--f-head);
  font-weight: 700;
  font-size: 0.72em;
  letter-spacing: 0.14em;
  color: var(--ink);
  background: var(--team);
}
.player-card.is-you .you-tag {
  display: inline-block;
}

/* health: one segment per life */
.pips {
  display: flex;
  gap: 0.35em;
}
.card-group-right .pips {
  flex-direction: row-reverse;
}
.pip {
  width: 2.1em;
  height: 0.55em;
  background: var(--team);
  transform: skewX(-20deg);
  transition: background 0.2s;
}
.pip.lost {
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--line-strong);
}
.pip.just-lost {
  animation: pip-lost 0.5s ease-out;
}
.player-card.hit {
  animation: card-hit 0.35s ease-out;
}
@keyframes pip-lost {
  0% {
    background: #fff;
  }
}
@keyframes card-hit {
  0%,
  100% {
    transform: translateX(0);
  }
  30% {
    transform: translateX(-4px);
  }
  70% {
    transform: translateX(4px);
  }
}

/* ------------------------------------------------------------ touch controls */
.touch {
  display: none;
  position: fixed;
  inset: 0;
  pointer-events: none;
  --btn: clamp(56px, 17vh, 96px);
}
body.is-touch.in-match .touch {
  display: block;
}

.touch-cluster {
  position: absolute;
  bottom: var(--safe-b);
  pointer-events: auto;
  touch-action: none;
}
.touch-left {
  left: var(--safe-l);
  display: flex;
  gap: calc(var(--btn) * 0.25);
}
.touch-right {
  right: var(--safe-r);
  display: grid;
  grid-template-columns: auto auto;
  grid-template-rows: auto auto;
  gap: calc(var(--btn) * 0.15) calc(var(--btn) * 0.25);
  align-items: center;
}

.tbtn {
  width: var(--btn);
  height: var(--btn);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: rgba(18, 20, 14, 0.38);
  color: var(--text);
  font-family: var(--f-head);
  font-size: calc(var(--btn) * 0.34);
  font-weight: 700;
  line-height: 1;
  transition: background 0.05s, transform 0.05s;
}
.tbtn.active {
  background: rgba(216, 196, 154, 0.35);
  transform: scale(0.94);
}
.tbtn.shoot {
  grid-row: 1 / span 2;
  width: calc(var(--btn) * 1.15);
  height: calc(var(--btn) * 1.15);
  border-color: rgba(201, 74, 61, 0.8);
  background: rgba(201, 74, 61, 0.2);
}
.tbtn.shoot.active {
  background: rgba(201, 74, 61, 0.55);
}
.tbtn.down {
  width: calc(var(--btn) * 0.75);
  height: calc(var(--btn) * 0.75);
  justify-self: center;
  font-size: calc(var(--btn) * 0.3);
}
.tbtn.label {
  font-size: calc(var(--btn) * 0.22);
  letter-spacing: 0.12em;
}

/* phones held upright: the game is landscape only */
.rotate-hint {
  display: none;
}
@media (orientation: portrait) {
  body.is-touch .rotate-hint {
    display: flex;
    position: fixed;
    inset: 0;
    align-items: center;
    justify-content: center;
    padding: 2em;
    text-align: center;
    font-family: var(--f-head);
    font-size: 24px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--sand);
    background: rgba(12, 13, 9, 0.92);
    z-index: 10;
  }
}

/* short landscape phones: tighter panels */
@media (max-height: 480px) {
  .panel {
    gap: 8px;
    padding: 16px 18px 14px;
  }
  .brand {
    margin-bottom: 0;
    padding-bottom: 8px;
  }
  .brand-title {
    font-size: 40px;
  }
  .btn {
    height: 40px;
  }
  .field input,
  .code-input {
    height: 40px;
  }
  .end-title {
    font-size: 46px;
  }
  .room-code {
    font-size: 26px;
  }
}

/* very short windows (small phones in landscape) */
@media (max-height: 400px) {
  .panel {
    gap: 6px;
    margin: 6px 0;
    padding: 12px 16px 10px;
  }
  .brand-kicker,
  .panel-kicker,
  .field-label {
    display: none;
  }
  .brand-title {
    font-size: 32px;
  }
  .panel-title {
    font-size: 22px;
  }
  .btn,
  .field input,
  .code-input {
    height: 36px;
  }
  .room-code-box {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
  }
  .room-code {
    font-size: 22px;
  }
  .slot {
    height: 34px;
  }
}
