* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
body {
  background: #050f05;
  font-family: "Boogaloo", cursive;
  color: #e0e0e0;
  overflow: hidden;
}
#game-layout {
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}
#stats-bar {
  width: 100%;
  display: none; /* shown only during gameplay */
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  background: #091509;
  border: 1px solid rgba(100, 200, 80, 0.12);
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  padding: 6px 10px;
}
#wrap {
  position: relative;
  touch-action: none;
  flex: 1;
  width: 100%;
  min-height: 0;
  overflow: hidden;
}
#mapCanvas {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 10;
}
#darkCanvas {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  z-index: 50;
}
.hud {
  background: rgba(0, 0, 0, 0);
  font-size: 11px;
}
#hl {
  min-width: 150px;
}
#hr {
  min-width: 150px;
  text-align: right;
  justify-self: end;
}
#htimer {
  text-align: center;
  padding: 2px 18px;
  justify-self: center;
}
#hb {
  width: 100%;
  font-size: 10px;
  letter-spacing: 1px;
  color: rgba(255, 255, 255, 0.4);
  white-space: nowrap;
  text-align: center;
  padding: 5px 0;
  background: #091509;
  border: 1px solid rgba(100, 200, 80, 0.12);
  border-top: none;
  border-radius: 0 0 6px 6px;
  display: none;
}
.tlabel {
  font-size: 10px;
  font-weight: bold;
  letter-spacing: 3px;
  margin-bottom: 5px;
}
.score-big {
  font-size: 22px;
  font-weight: bold;
  letter-spacing: 2px;
  margin-bottom: 2px;
}
.score-sub {
  font-size: 9px;
  color: rgba(255, 255, 255, 0.4);
  letter-spacing: 1px;
}
.timer-val {
  font-size: 24px;
  font-weight: bold;
  letter-spacing: 3px;
}
.timer-label {
  font-size: 9px;
  color: rgba(255, 255, 255, 0.35);
  letter-spacing: 2px;
  margin-top: 2px;
}
.timer-warn {
  color: #ffaa00 !important;
}
.timer-crit {
  color: #f4a028 !important;
}
#ov,
#rs {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.93);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  overflow-y: auto;
  touch-action: pan-y;
  padding: 8px 0;
  z-index: 200;
  pointer-events: all;
}
#ov::before,
#ov::after,
#rs::before,
#rs::after {
  content: "";
  flex: 1;
  min-height: 0;
}
#rs {
  display: none;
}
#rs.show {
  display: flex;
}
#round-countdown-overlay {
  display: none;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 300;
  pointer-events: none;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 28px;
}
#round-countdown-overlay.show {
  display: flex;
}
#round-countdown-text {
  font-family: "Boogaloo", cursive;
  font-size: 15px;
  letter-spacing: 3px;
  color: rgba(255, 255, 255, 0.75);
  background: rgba(0, 0, 0, 0.55);
  padding: 6px 18px;
  border-radius: 20px;
  border: 1px solid rgba(100, 200, 80, 0.25);
}
@media (max-height: 480px) {
  h1 {
    font-size: 20px !important;
    margin-bottom: 2px !important;
  }
  .sub {
    font-size: 10px !important;
    margin-bottom: 10px !important;
  }
  .sg {
    gap: 10px !important;
    margin-bottom: 10px !important;
  }
  .leg {
    gap: 10px !important;
    margin-bottom: 10px !important;
  }
  .tb,
  .lb {
    padding: 7px 10px !important;
  }
  .btn {
    padding: 8px 32px !important;
    margin-top: 2px !important;
  }
}
h1 {
  font-size: 28px;
  letter-spacing: 8px;
  color: #fff;
  margin-bottom: 4px;
  text-transform: uppercase;
}
.sub {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.35);
  letter-spacing: 3px;
  margin-bottom: 20px;
}
/* ── Main menu ── */
#ov {
  background:
    radial-gradient(
      circle at 18% 18%,
      rgba(137, 196, 58, 0.18),
      transparent 22%
    ),
    radial-gradient(
      circle at 80% 8%,
      rgba(34, 114, 61, 0.28),
      transparent 26%
    ),
    linear-gradient(
      135deg,
      rgba(9, 36, 18, 0.94),
      rgba(2, 13, 7, 0.97) 48%,
      rgba(24, 43, 13, 0.96)
    );
  padding: 18px 12px;
}
#ov::before {
  background:
    linear-gradient(
      135deg,
      transparent 0 44%,
      rgba(69, 122, 31, 0.45) 45% 51%,
      transparent 52%
    ),
    linear-gradient(
      45deg,
      transparent 0 54%,
      rgba(24, 89, 37, 0.42) 55% 61%,
      transparent 62%
    );
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.45;
  flex: none;
}
#ov::after {
  background:
    radial-gradient(
      ellipse at 12% 0%,
      rgba(78, 154, 46, 0.5) 0 12%,
      transparent 13%
    ),
    radial-gradient(
      ellipse at 28% 2%,
      rgba(25, 103, 45, 0.62) 0 11%,
      transparent 12%
    ),
    radial-gradient(
      ellipse at 48% -2%,
      rgba(105, 155, 40, 0.48) 0 13%,
      transparent 14%
    ),
    radial-gradient(
      ellipse at 70% 1%,
      rgba(31, 119, 57, 0.58) 0 11%,
      transparent 12%
    ),
    radial-gradient(
      ellipse at 88% 0%,
      rgba(86, 148, 42, 0.5) 0 12%,
      transparent 13%
    );
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 150px;
  pointer-events: none;
  flex: none;
}
.menu-shell {
  position: relative;
  z-index: 1;
  width: min(760px, 96vw);
  min-height: min(590px, calc(100vh - 104px));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
}
.menu-shell::before,
.menu-shell::after {
  content: "";
  position: absolute;
  width: 94px;
  height: 170px;
  top: 20px;
  border-radius: 999px 999px 12px 12px;
  background:
    linear-gradient(
      90deg,
      rgba(28, 72, 24, 0.18),
      transparent 45%,
      rgba(255, 236, 155, 0.08)
    ),
    repeating-linear-gradient(90deg, #513615 0 5px, #7a5623 6px 12px);
  box-shadow: inset 0 0 18px rgba(20, 10, 0, 0.45);
  opacity: 0.8;
  pointer-events: none;
}
.menu-shell::before {
  left: 0;
  transform: rotate(-7deg);
}
.menu-shell::after {
  right: 0;
  transform: rotate(7deg);
}
.menu-title {
  position: relative;
  text-align: center;
  text-transform: uppercase;
  color: #fff6c7;
  text-shadow:
    0 3px 0 rgba(47, 31, 8, 0.9),
    0 0 24px rgba(116, 211, 76, 0.35);
}
.menu-title h1 {
  font-size: clamp(30px, 7vw, 54px);
  letter-spacing: 5px;
  line-height: 0.9;
  margin-bottom: 0;
}
.menu-title .sub {
  color: rgba(232, 255, 199, 0.64);
  font-size: 12px;
  margin: 8px 0 0;
}
.menu-panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 0;
  width: min(640px, 94vw);
}
.tb {
  position: relative;
  background:
    linear-gradient(
      180deg,
      rgba(255, 245, 184, 0.06),
      rgba(5, 31, 14, 0.54)
    ),
    rgba(7, 43, 20, 0.78);
  border: 1px solid rgba(180, 218, 108, 0.22);
  border-radius: 8px;
  box-shadow:
    0 18px 38px rgba(0, 0, 0, 0.28),
    inset 0 0 0 1px rgba(255, 255, 255, 0.04);
  min-height: 218px;
  overflow: hidden;
  padding: 14px;
  text-align: center;
}
.tb::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(
      circle at 16% 14%,
      rgba(255, 246, 178, 0.14),
      transparent 18%
    ),
    repeating-linear-gradient(
      120deg,
      transparent 0 20px,
      rgba(255, 255, 255, 0.025) 21px 22px
    );
  pointer-events: none;
}
.tb.sk {
  border-color: rgba(237, 164, 54, 0.46);
}
.tb.hi {
  border-color: rgba(126, 211, 93, 0.46);
}
.tb-art {
  height: 72px;
  display: flex;
  align-items: end;
  justify-content: center;
  position: relative;
  z-index: 1;
}
.tb-art::before {
  content: "";
  position: absolute;
  bottom: 4px;
  width: 110px;
  height: 22px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.25);
  filter: blur(2px);
}
.tb-art img {
  position: relative;
  z-index: 1;
  width: 64px;
  height: 64px;
  object-fit: contain;
  filter: drop-shadow(0 8px 10px rgba(0, 0, 0, 0.45));
}
.tb h3 {
  position: relative;
  z-index: 1;
  font-size: 11px;
  letter-spacing: 3px;
  margin: 4px 0 10px;
  text-transform: uppercase;
}
.tb.hi h3 {
  color: #93e56c;
}
.tb.sk h3 {
  color: #ffc15f;
}
.kh {
  position: relative;
  z-index: 1;
  font-size: 9px;
  color: rgba(232, 255, 199, 0.5);
  margin-top: 3px;
  line-height: 1.7;
}
.kh.hi {
  color: rgba(147, 229, 108, 0.85);
}
.kh.sk {
  color: rgba(255, 193, 95, 0.9);
}
.menu-actions {
  position: relative;
  z-index: 1;
  width: min(360px, 88vw);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  margin-top: 2px;
}
.format-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}
.format-row span {
  color: rgba(232, 255, 199, 0.66);
  font-size: 10px;
  letter-spacing: 2px;
  white-space: nowrap;
}
.minput {
  background:
    linear-gradient(
      180deg,
      rgba(255, 227, 124, 0.11),
      rgba(88, 58, 19, 0.16)
    ),
    rgba(10, 48, 21, 0.86);
  border: 1px solid rgba(255, 223, 128, 0.28);
  color: #fff6c7;
  padding: 8px 12px;
  font-family: "Boogaloo", cursive;
  font-size: 12px;
  letter-spacing: 2px;
  border-radius: 6px;
  width: 100%;
  margin-bottom: 0;
  outline: none;
  pointer-events: all;
}
.minput:focus {
  border-color: rgba(255, 245, 190, 0.62);
}
.minput::placeholder {
  color: rgba(232, 255, 199, 0.42);
}
.join-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.join-row .minput {
  margin-bottom: 0;
  flex: 1;
}
.btn {
  background: rgba(60, 120, 60, 0.1);
  border: 1px solid rgba(100, 200, 80, 0.35);
  color: #fff;
  padding: 10px 28px;
  font-family: "Boogaloo", cursive;
  font-size: 12px;
  letter-spacing: 3px;
  text-transform: uppercase;
  cursor: pointer;
  border-radius: 4px;
  pointer-events: all;
}
.btn:hover {
  background: rgba(60, 120, 60, 0.2);
  border-color: rgba(255, 255, 255, 0.6);
}
.btn:disabled {
  opacity: 0.35;
  cursor: default;
}
.btn.sk {
  border-color: rgba(244, 160, 40, 0.6);
  color: #f4a028;
}
.btn.sk:hover {
  background: rgba(244, 160, 40, 0.15);
}
.btn.hi {
  border-color: rgba(94, 196, 94, 0.6);
  color: #5ec45e;
}
.btn.hi:hover {
  background: rgba(94, 196, 94, 0.15);
}
#ov .btn,
#lobby .btn {
  position: relative;
  z-index: 1;
  background:
    linear-gradient(
      180deg,
      rgba(255, 237, 159, 0.14),
      rgba(69, 45, 14, 0.3)
    ),
    rgba(25, 78, 31, 0.92);
  border-color: rgba(255, 223, 128, 0.34);
  box-shadow:
    0 8px 0 rgba(35, 21, 5, 0.42),
    0 14px 24px rgba(0, 0, 0, 0.2);
  color: #fff6c7;
  min-height: 40px;
  text-shadow: 0 2px 0 rgba(44, 27, 4, 0.76);
}
#ov .btn:hover,
#lobby .btn:hover {
  background:
    linear-gradient(
      180deg,
      rgba(255, 237, 159, 0.22),
      rgba(89, 56, 16, 0.34)
    ),
    rgba(38, 104, 45, 0.96);
  border-color: rgba(255, 245, 190, 0.6);
}
#ov .btn.sk,
#lobby .btn.sk {
  background:
    linear-gradient(
      180deg,
      rgba(255, 224, 139, 0.22),
      rgba(95, 50, 16, 0.32)
    ),
    rgba(98, 60, 18, 0.94);
  border-color: rgba(255, 185, 80, 0.62);
  color: #ffd18a;
}
#ov .btn.hi,
#lobby .btn.hi {
  border-color: rgba(151, 235, 96, 0.58);
  color: #adf281;
}
.btn-sm {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.4);
  padding: 6px 18px;
  font-family: "Boogaloo", cursive;
  font-size: 10px;
  letter-spacing: 2px;
  text-transform: uppercase;
  cursor: pointer;
  border-radius: 4px;
  pointer-events: all;
  margin-top: 10px;
}
.btn-sm:hover {
  border-color: rgba(255, 255, 255, 0.4);
  color: rgba(255, 255, 255, 0.7);
}
#ov .btn-sm,
#lobby .btn-sm {
  position: relative;
  z-index: 1;
  background: rgba(6, 31, 14, 0.6);
  border-color: rgba(213, 242, 148, 0.22);
  color: rgba(232, 255, 199, 0.68);
}
.divider {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.2);
  letter-spacing: 3px;
  text-align: center;
  margin: 10px 0;
}
.errmsg {
  font-size: 10px;
  color: #f4a028;
  letter-spacing: 1px;
  margin-top: 6px;
  min-height: 14px;
}
/* ── Lobby ── */
#lobby {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(
      circle at 18% 18%,
      rgba(137, 196, 58, 0.18),
      transparent 22%
    ),
    radial-gradient(
      circle at 80% 8%,
      rgba(34, 114, 61, 0.28),
      transparent 26%
    ),
    linear-gradient(
      135deg,
      rgba(9, 36, 18, 0.94),
      rgba(2, 13, 7, 0.97) 48%,
      rgba(24, 43, 13, 0.96)
    );
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  overflow-y: auto;
  touch-action: pan-y;
  padding: 18px 12px;
  z-index: 200;
  pointer-events: all;
}
#lobby::before {
  background:
    linear-gradient(
      135deg,
      transparent 0 44%,
      rgba(69, 122, 31, 0.45) 45% 51%,
      transparent 52%
    ),
    linear-gradient(
      45deg,
      transparent 0 54%,
      rgba(24, 89, 37, 0.42) 55% 61%,
      transparent 62%
    );
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.45;
}
#lobby::after {
  background:
    radial-gradient(
      ellipse at 12% 0%,
      rgba(78, 154, 46, 0.5) 0 12%,
      transparent 13%
    ),
    radial-gradient(
      ellipse at 28% 2%,
      rgba(25, 103, 45, 0.62) 0 11%,
      transparent 12%
    ),
    radial-gradient(
      ellipse at 48% -2%,
      rgba(105, 155, 40, 0.48) 0 13%,
      transparent 14%
    ),
    radial-gradient(
      ellipse at 70% 1%,
      rgba(31, 119, 57, 0.58) 0 11%,
      transparent 12%
    ),
    radial-gradient(
      ellipse at 88% 0%,
      rgba(86, 148, 42, 0.5) 0 12%,
      transparent 13%
    );
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 150px;
  pointer-events: none;
}
#lobby::before,
#lobby::after {
  flex: none;
}
#lobby.show {
  display: flex;
}
.lobby-shell {
  position: relative;
  z-index: 1;
  width: min(760px, 96vw);
  min-height: min(590px, calc(100vh - 104px));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
}
.lobby-shell::before,
.lobby-shell::after {
  content: "";
  position: absolute;
  width: 94px;
  height: 170px;
  top: 20px;
  border-radius: 999px 999px 12px 12px;
  background:
    linear-gradient(
      90deg,
      rgba(28, 72, 24, 0.18),
      transparent 45%,
      rgba(255, 236, 155, 0.08)
    ),
    repeating-linear-gradient(90deg, #513615 0 5px, #7a5623 6px 12px);
  box-shadow: inset 0 0 18px rgba(20, 10, 0, 0.45);
  opacity: 0.8;
  pointer-events: none;
}
.lobby-shell::before {
  left: 0;
  transform: rotate(-7deg);
}
.lobby-shell::after {
  right: 0;
  transform: rotate(7deg);
}
.lobby-title {
  position: relative;
  text-align: center;
  text-transform: uppercase;
  color: #fff6c7;
  text-shadow:
    0 3px 0 rgba(47, 31, 8, 0.9),
    0 0 24px rgba(116, 211, 76, 0.35);
}
.lobby-title h2 {
  font-size: clamp(28px, 7vw, 54px);
  letter-spacing: 5px;
  line-height: 0.9;
}
.lobby-title .sub {
  color: rgba(232, 255, 199, 0.64);
  margin: 8px 0 0;
  font-size: 12px;
}
.lobby-code {
  background:
    linear-gradient(
      180deg,
      rgba(255, 227, 124, 0.18),
      rgba(88, 58, 19, 0.26)
    ),
    rgba(10, 48, 21, 0.92);
  border: 1px solid rgba(255, 223, 128, 0.36);
  border-bottom-color: rgba(65, 37, 12, 0.7);
  border-radius: 8px;
  box-shadow:
    0 16px 36px rgba(0, 0, 0, 0.34),
    inset 0 0 0 1px rgba(255, 255, 255, 0.05);
  color: rgba(232, 255, 199, 0.72);
  font-size: 10px;
  letter-spacing: 3px;
  margin-bottom: 0;
  min-width: min(330px, 82vw);
  padding: 10px 22px;
  text-align: center;
  text-transform: uppercase;
}
.lobby-code span {
  color: #fff6c7;
  display: inline-block;
  font-size: 28px;
  font-weight: bold;
  letter-spacing: 6px;
  line-height: 1.1;
  margin-top: 2px;
  text-shadow: 0 2px 0 rgba(62, 37, 9, 0.95);
}
.lobby-teams {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 4px 0 2px;
  width: min(640px, 94vw);
}
.team-col {
  position: relative;
  background:
    linear-gradient(
      180deg,
      rgba(255, 245, 184, 0.06),
      rgba(5, 31, 14, 0.54)
    ),
    rgba(7, 43, 20, 0.78);
  border: 1px solid rgba(180, 218, 108, 0.22);
  border-radius: 8px;
  box-shadow:
    0 18px 38px rgba(0, 0, 0, 0.28),
    inset 0 0 0 1px rgba(255, 255, 255, 0.04);
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 250px;
  overflow: hidden;
  padding: 12px;
}
.team-col::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(
      circle at 16% 14%,
      rgba(255, 246, 178, 0.14),
      transparent 18%
    ),
    repeating-linear-gradient(
      120deg,
      transparent 0 20px,
      rgba(255, 255, 255, 0.025) 21px 22px
    );
  pointer-events: none;
}
.team-col.sk {
  border-color: rgba(237, 164, 54, 0.46);
}
.team-col.hi {
  border-color: rgba(126, 211, 93, 0.46);
}
.team-art {
  height: 86px;
  display: flex;
  align-items: end;
  justify-content: center;
  margin: -2px 0 -4px;
  position: relative;
  z-index: 1;
}
.team-art::before {
  content: "";
  position: absolute;
  bottom: 5px;
  width: 118px;
  height: 24px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.26);
  filter: blur(2px);
}
.team-art img {
  position: relative;
  z-index: 1;
  width: 74px;
  height: 74px;
  object-fit: contain;
  filter: drop-shadow(0 8px 10px rgba(0, 0, 0, 0.45));
}
.team-hdr {
  position: relative;
  z-index: 1;
  font-size: 10px;
  letter-spacing: 3px;
  font-weight: bold;
  margin-bottom: 2px;
  text-align: center;
  text-transform: uppercase;
}
.team-hdr.sk {
  color: #ffc15f;
}
.team-hdr.hi {
  color: #93e56c;
}
.team-list {
  position: relative;
  z-index: 1;
  min-height: 70px;
  font-size: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}
.pentry {
  padding: 7px 9px;
  background: rgba(255, 248, 197, 0.09);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.86);
}
.pentry.me {
  background: rgba(255, 240, 144, 0.18);
  border-color: rgba(255, 231, 137, 0.28);
  font-weight: bold;
}
.p-crown {
  font-size: 10px;
}
.bot-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: min(330px, 80vw);
  font-size: 11px;
  color: rgba(232, 255, 199, 0.7);
}
.cc {
  display: flex;
  align-items: center;
  gap: 8px;
}
.cb {
  background: rgba(62, 42, 15, 0.8);
  border: 1px solid rgba(255, 223, 128, 0.32);
  color: #fff6c7;
  width: 24px;
  height: 24px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: all;
}
.cb:hover {
  background: rgba(105, 71, 24, 0.92);
}
.cn {
  font-size: 18px;
  min-width: 20px;
  text-align: center;
  color: #fff6c7;
}
@media (max-width: 620px) {
  #game-layout,
  #wrap {
    overflow-x: hidden;
  }
  #stats-bar {
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    padding: 5px 8px;
  }
  #hl,
  #hr {
    min-width: 0;
  }
  #hl-role,
  .tlabel {
    letter-spacing: 2px;
  }
  #ov,
  #lobby {
    padding: 14px 10px;
  }
  .menu-shell,
  .lobby-shell {
    justify-content: flex-start;
    min-height: calc(100vh - 28px);
  }
  .menu-shell::before,
  .menu-shell::after,
  .lobby-shell::before,
  .lobby-shell::after {
    display: none;
  }
  .menu-title h1,
  .lobby-title h2 {
    font-size: 32px;
    letter-spacing: 3px;
  }
  .menu-title .sub,
  .lobby-title .sub {
    font-size: 10px;
    letter-spacing: 2px;
  }
  .menu-panels,
  .lobby-teams {
    grid-template-columns: 1fr;
    gap: 12px;
    width: min(360px, 94vw);
  }
  .tb,
  .team-col {
    min-height: 0;
  }
  .tb-art,
  .team-art {
    height: 58px;
  }
  .tb-art img,
  .team-art img {
    width: 54px;
    height: 54px;
  }
  .menu-actions {
    width: min(360px, 94vw);
  }
  .format-row {
    align-items: stretch;
    flex-direction: column;
    gap: 5px;
  }
  .bot-row {
    width: min(330px, 94vw);
  }
}

/* ── Landscape phone layout (short viewport, e.g. phone in landscape) ─────── */
@media (max-height: 520px) and (min-width: 500px) {
  #ov,
  #lobby {
    padding: 6px 10px;
    justify-content: flex-start;
    align-items: flex-start;
  }

  /* ── Main menu: left col = title+panels, right col = form ── */
  .menu-shell {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 14px;
    row-gap: 4px;
    min-height: 0;
    width: 100%;
    max-width: 100%;
    align-items: start;
  }
  .menu-shell::before,
  .menu-shell::after {
    display: none;
  }
  .menu-title {
    grid-column: 1;
    grid-row: 1;
    text-align: left;
  }
  .menu-title h1 {
    font-size: 22px;
    letter-spacing: 3px;
    line-height: 1;
  }
  .menu-title .sub {
    font-size: 9px;
    margin-top: 3px;
    letter-spacing: 1px;
  }
  .menu-panels {
    grid-column: 1;
    grid-row: 2 / span 4;
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
    margin: 0;
    align-self: start;
  }
  .menu-actions {
    grid-column: 2;
    grid-row: 1 / span 2;
    width: 100%;
    gap: 6px;
    margin-top: 0;
  }
  #menu-err {
    grid-column: 2;
    grid-row: 3;
  }
  #room-browser {
    grid-column: 2;
    grid-row: 4;
    width: 100%;
  }
  #browse-btn {
    grid-column: 2;
    grid-row: 5;
    margin-top: 0;
  }

  /* Compact panel cards */
  .tb {
    padding: 8px 10px;
    min-height: 0;
    text-align: left;
  }
  .tb-art {
    display: none;
  }
  .tb h3 {
    font-size: 10px;
    margin: 0 0 3px;
  }
  .kh {
    font-size: 8.5px;
    margin-top: 1px;
    line-height: 1.35;
  }

  /* Compact form */
  .minput {
    padding: 6px 10px;
    font-size: 12px;
  }
  .format-row {
    flex-direction: row;
    gap: 6px;
    align-items: center;
  }
  .format-row span {
    font-size: 9px;
    white-space: nowrap;
  }
  #ov .btn {
    padding: 8px 16px;
    font-size: 11px;
  }
  .divider {
    margin: 1px 0;
    font-size: 9px;
  }
  .join-row {
    gap: 6px;
  }

  /* ── Lobby: compact vertical ── */
  .lobby-shell {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    min-height: 0;
    gap: 6px;
    width: 100%;
  }
  .lobby-shell::before,
  .lobby-shell::after {
    display: none;
  }
  .lobby-title h2 {
    font-size: 20px;
    letter-spacing: 3px;
  }
  .lobby-title .sub {
    font-size: 9px;
    margin-top: 2px;
  }
  .lobby-code {
    min-width: 0;
    width: min(340px, 90vw);
    padding: 6px 16px;
    font-size: 9px;
  }
  .lobby-code span {
    font-size: 20px;
  }
  .lobby-teams {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    width: 100%;
    margin: 0;
  }
  .team-col {
    min-height: 0;
    padding: 8px 10px;
    gap: 6px;
  }
  .team-art {
    display: none;
  }
  .team-hdr {
    font-size: 9px;
  }
  .team-list {
    min-height: 0;
  }
  #lobby .btn {
    padding: 7px 12px;
    font-size: 10px;
  }
  #ready-btn,
  #start-btn {
    margin-top: 0;
    width: min(280px, 90vw);
  }
  #host-zone {
    gap: 6px !important;
    margin-top: 0 !important;
  }
  .bot-row {
    width: auto;
  }
  .btn-sm {
    margin-top: 0;
    font-size: 9px;
    padding: 5px 12px;
  }
}

/* ── Results screen ── */
#rt {
  font-size: 36px;
  letter-spacing: 6px;
  margin-bottom: 6px;
}
#rs2 {
  font-size: 12px;
  letter-spacing: 2px;
  color: rgba(255, 255, 255, 0.4);
  margin-bottom: 20px;
}
.score-grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0;
  align-items: center;
  margin-bottom: 24px;
  width: 340px;
}
.score-team {
  padding: 20px 24px;
  background: rgba(60, 120, 60, 0.08);
  border: 1px solid rgba(100, 200, 80, 0.12);
  border-radius: 8px;
  text-align: center;
}
.score-team h4 {
  font-size: 9px;
  letter-spacing: 3px;
  margin-bottom: 8px;
  opacity: 0.5;
  text-transform: uppercase;
}
.score-team .big {
  font-size: 48px;
  font-weight: bold;
  line-height: 1;
}
.score-vs {
  font-size: 13px;
  letter-spacing: 2px;
  color: rgba(255, 255, 255, 0.25);
  padding: 0 14px;
}
.stat-row {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.35);
  margin-top: 6px;
}
/* ── Room browser ── */
#room-browser {
  width: min(420px, 92vw);
  margin-top: 6px;
  display: none;
  flex-direction: column;
  gap: 6px;
}
#room-browser.open {
  display: flex;
}
.room-browser-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 10px;
  letter-spacing: 2px;
  color: rgba(255, 255, 255, 0.4);
}
.room-browser-hdr button {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.5);
  padding: 3px 10px;
  font-family: "Boogaloo", cursive;
  font-size: 9px;
  letter-spacing: 1px;
  border-radius: 3px;
  cursor: pointer;
  pointer-events: all;
}
.room-browser-hdr button:hover {
  border-color: rgba(255, 255, 255, 0.4);
  color: #fff;
}
#room-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-height: 180px;
  overflow-y: auto;
}
.rentry {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(60, 120, 60, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 10px;
}
.rentry-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  min-width: 0;
}
.rentry-id {
  font-size: 13px;
  letter-spacing: 3px;
  font-weight: bold;
  color: #fff;
}
.rentry-teams {
  display: flex;
  gap: 10px;
}
.rentry-phase {
  font-size: 8px;
  letter-spacing: 2px;
  color: rgba(255, 255, 255, 0.25);
  margin-top: 1px;
}
.rentry-empty {
  font-size: 10px;
  opacity: 0.35;
  text-align: center;
  padding: 12px 0;
}
/* ── HUD role label ── */
#hl-role {
  font-size: 10px;
  font-weight: bold;
  letter-spacing: 3px;
  margin-bottom: 5px;
}
/* ── Chat UI ── */
#chat-container {
  position: absolute;
  right: 16px;
  left: auto;
  bottom: 20px;
  transform: none;
  width: min(320px, calc(50vw - 24px));
  max-width: 92vw;
  z-index: 220;
  pointer-events: none;
  display: none; /* hidden by default (main menu) */
}
.chat-shell {
  position: relative;
  display: flex;
  flex-direction: column;
  z-index: 1;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 18px 18px 14px 14px;
  border: 1px solid rgba(255, 223, 128, 0.24);
  background:
    radial-gradient(
      circle at 18% 18%,
      rgba(137, 196, 58, 0.16),
      transparent 24%
    ),
    linear-gradient(
      135deg,
      rgba(7, 28, 14, 0.94),
      rgba(4, 18, 9, 0.97) 55%,
      rgba(18, 40, 13, 0.95)
    );
  box-shadow:
    0 14px 30px rgba(0, 0, 0, 0.34),
    inset 0 0 0 1px rgba(255, 245, 190, 0.05),
    inset 0 -18px 28px rgba(0, 0, 0, 0.16);
  pointer-events: all;
  overflow: hidden;
}
.chat-shell::before,
.chat-shell::after {
  content: "";
  position: absolute;
  top: 9px;
  width: 62px;
  height: 38px;
  border-radius: 999px 999px 12px 12px;
  background:
    linear-gradient(
      90deg,
      rgba(28, 72, 24, 0.18),
      transparent 45%,
      rgba(255, 236, 155, 0.08)
    ),
    repeating-linear-gradient(90deg, #513615 0 5px, #7a5623 6px 12px);
  box-shadow: inset 0 0 12px rgba(20, 10, 0, 0.36);
  opacity: 0.7;
  z-index: 0;
  pointer-events: none;
}
.chat-shell::before {
  left: 12px;
  transform: rotate(-6deg);
}
.chat-shell::after {
  right: 12px;
  transform: rotate(6deg);
}
.chat-shell__header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 2px 6px 0;
  color: #fff6c7;
  text-transform: uppercase;
  letter-spacing: 3px;
  font-size: 10px;
  text-shadow: 0 2px 0 rgba(44, 27, 4, 0.76);
}
.chat-shell__hint {
  color: rgba(232, 255, 199, 0.54);
  font-size: 9px;
  letter-spacing: 2px;
  position: relative;
  z-index: 1000;
}
#chat-messages {
  position: relative;
  max-height: 100px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-right: 4px;
  pointer-events: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 223, 128, 0.35) rgba(6, 31, 14, 0.55);
}
#chat-messages::-webkit-scrollbar {
  width: 8px;
}
#chat-messages::-webkit-scrollbar-track {
  background: rgba(6, 31, 14, 0.55);
  border-radius: 999px;
}
#chat-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 223, 128, 0.35);
  border-radius: 999px;
}
.chat-msg {
  background:
    linear-gradient(
      180deg,
      rgba(255, 224, 139, 0.08),
      rgba(95, 50, 16, 0.18)
    ),
    rgba(6, 31, 14, 0.64);
  border: 1px solid rgba(213, 242, 148, 0.18);
  border-radius: 10px;
  padding: 6px 8px;
  color: #e8ffc7;
  font-size: 12px;
  line-height: 1.35;
  word-wrap: break-word;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.03);
}
.chat-msg--me {
  align-self: flex-start;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.04),
    rgba(10, 40, 18, 0.12)
  );
  border-color: rgba(200, 230, 150, 0.14);
  color: #e6f8d6;
  border-top-left-radius: 4px;
  border-top-right-radius: 12px;
  border-bottom-right-radius: 12px;
  border-bottom-left-radius: 12px;
}
.chat-msg--me::after {
  content: "";
  position: absolute;
  left: -6px;
  top: 10px;
  width: 0;
  height: 0;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-right: 8px solid rgba(6, 31, 14, 0.9);
  filter: drop-shadow(0 1px 0 rgba(255, 255, 255, 0.02));
  z-index: 6;
}
.chat-msg--other {
  align-self: flex-end;
  background: linear-gradient(
    180deg,
    rgba(44, 80, 30, 0.12),
    rgba(30, 60, 22, 0.28)
  );
  border-color: rgba(255, 180, 90, 0.12);
  color: #fff6c7;
  border-top-left-radius: 12px;
  border-top-right-radius: 4px;
  border-bottom-right-radius: 12px;
  border-bottom-left-radius: 12px;
}
.chat-msg--other::after {
  content: "";
  position: absolute;
  right: -6px;
  top: 10px;
  width: 0;
  height: 0;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-left: 8px solid rgba(6, 31, 14, 0.9);
  z-index: 6;
}
.chat-msg {
  position: relative;
  max-width: 78%;
  z-index: 5;
}
.chat-name {
  font-size: 10px;
  color: rgba(200, 230, 150, 0.9);
  margin-bottom: 2px;
  letter-spacing: 1px;
}
.chat-name-inline {
  font-weight: 700;
  color: rgba(200, 230, 150, 0.95);
  margin-right: 6px;
  letter-spacing: 0.5px;
}
.chat-text {
  font-size: 13px;
  line-height: 1.3;
  white-space: pre-wrap;
}
#chat-input {
  pointer-events: auto;
  background:
    linear-gradient(
      180deg,
      rgba(255, 227, 124, 0.11),
      rgba(88, 58, 19, 0.16)
    ),
    rgba(10, 48, 21, 0.86);
  border: 1px solid rgba(255, 223, 128, 0.28);
  color: #fff6c7;
  padding: 8px 12px;
  border-radius: 6px;
  width: 100%;
  margin-bottom: 0;
  outline: none;
  font-family: "Boogaloo", cursive;
  font-size: 12px;
  letter-spacing: 2px;
  position: relative;
  z-index: 12;
  display: none;
}
#chat-input::placeholder {
  color: rgba(232, 255, 199, 0.5);
  font-weight: 700;
  opacity: 0.95;
}
#chat-input:focus {
  border-color: rgba(255, 245, 190, 0.62);
}
@media (max-width: 700px) {
  #chat-container {
    right: 8px;
    left: auto;
    bottom: 12px;
    transform: none;
    width: calc(50% - 12px);
  }
  #chat-messages {
    max-height: 80px;
  }
}

/* ── Portrait / Landscape orientation overlay ────────────────────────────── */
#orient-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background:
    radial-gradient(ellipse at 50% 30%, rgba(30, 80, 20, 0.4), transparent 60%),
    linear-gradient(160deg, #040c04, #071407 50%, #050f05);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
  pointer-events: all;
  user-select: none;
}
.orient-phone-wrap {
  animation: orient-spin 2.2s cubic-bezier(0.45, 0, 0.55, 1) infinite;
  filter: drop-shadow(0 0 18px rgba(94, 196, 94, 0.4));
}
@keyframes orient-spin {
  0%   { transform: rotate(0deg); }
  35%  { transform: rotate(0deg); }
  65%  { transform: rotate(90deg); }
  100% { transform: rotate(90deg); }
}
.orient-phone {
  width: 48px;
  height: 82px;
  border: 3px solid #5ec45e;
  border-radius: 10px;
  position: relative;
  background: rgba(94, 196, 94, 0.06);
}
.orient-phone::before {
  content: '';
  position: absolute;
  top: 7px;
  left: 50%;
  transform: translateX(-50%);
  width: 10px;
  height: 3px;
  border-radius: 2px;
  background: rgba(94, 196, 94, 0.5);
}
.orient-phone::after {
  content: '';
  position: absolute;
  bottom: 7px;
  left: 50%;
  transform: translateX(-50%);
  width: 18px;
  height: 4px;
  border-radius: 2px;
  background: #5ec45e;
}
.orient-arrows {
  position: absolute;
  right: -28px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 3px;
  opacity: 0.7;
}
.orient-arrow {
  width: 0;
  height: 0;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-left: 9px solid #5ec45e;
}
.orient-title {
  font-family: 'Boogaloo', cursive;
  font-size: 22px;
  letter-spacing: 3px;
  color: #a8e878;
  text-transform: uppercase;
  text-shadow: 0 0 20px rgba(94, 196, 94, 0.5);
}
.orient-sub {
  font-family: 'Boogaloo', cursive;
  font-size: 13px;
  letter-spacing: 2px;
  color: rgba(200, 240, 170, 0.55);
  text-transform: uppercase;
  text-align: center;
  max-width: 240px;
  line-height: 1.6;
}
