/* Storm Royale - flat, bright HUD & menus */
:root {
  --navy: #0f1f45;
  --navy2: #172c5e;
  --panel: rgba(13, 26, 58, 0.92);
  --line: rgba(255, 255, 255, 0.14);
  --text: #ffffff;
  --muted: #a9b6d6;
  --yellow: #ffd23f;
  --yellow2: #f5b800;
  --blue: #2f8cff;
  --green: #53d86a;
  --shield: #3ab4ff;
  --red: #ff4d4d;
  --common: #a0a8b2;
  --uncommon: #4dbb4a;
  --rare: #3796f2;
  --epic: #b05df0;
  --legendary: #f3a334;
  --sat: env(safe-area-inset-top, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
}
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #7fbde8;
  color: var(--text);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Ubuntu, Arial, sans-serif;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  overscroll-behavior: none;
}
#view {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  outline: none;
}
.hidden {
  display: none !important;
}
button,
input,
select {
  font-family: inherit;
}

/* ------------------------------------------------------------ buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 10px;
  padding: 14px 22px;
  font-size: 18px;
  font-weight: 800;
  font-style: italic;
  letter-spacing: 0.02em;
  color: #fff;
  background: var(--navy2);
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.25);
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.08s ease, background 0.12s ease;
}
.btn:hover {
  background: #22407f;
}
.btn:active {
  transform: translateY(2px);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.25);
}
.btn.primary {
  background: var(--yellow);
  color: #1b1b1b;
}
.btn.primary:hover {
  background: #ffdc66;
}
.btn.ghost {
  background: rgba(255, 255, 255, 0.12);
}
.btn.ghost:hover {
  background: rgba(255, 255, 255, 0.2);
}
.btn.small {
  font-size: 15px;
  padding: 11px 16px;
}
.btn.tiny {
  font-size: 12px;
  padding: 7px 10px;
  border-radius: 7px;
}
.btn:disabled {
  opacity: 0.45;
  cursor: default;
}

/* ------------------------------------------------------------ menus */
#menu {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  padding: calc(16px + var(--sat)) calc(16px + var(--sar)) calc(16px + var(--sab)) calc(16px + var(--sal));
  background: linear-gradient(180deg, rgba(10, 30, 80, 0.15), rgba(10, 30, 80, 0.45));
  overflow-y: auto;
  touch-action: pan-y;
}
#menu.hidden {
  display: none;
}
#menu > .screen {
  margin: auto;
}
#menuMain {
  width: 100%;
  max-width: 1100px;
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  grid-template-rows: auto auto;
  align-items: center;
  gap: 20px 40px;
}
.brand {
  grid-row: 1 / span 2;
}
.logo {
  font-size: clamp(54px, 9vw, 116px);
  line-height: 0.86;
  font-weight: 900;
  font-style: italic;
  letter-spacing: -0.01em;
  color: #fff;
  text-shadow: 0 5px 0 #173a86, 0 9px 0 rgba(0, 0, 0, 0.18);
}
.logo span {
  color: var(--yellow);
}
.tagline {
  margin-top: 22px;
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
}
.main-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.main-buttons .btn {
  width: 100%;
  font-size: 22px;
  padding: 16px 22px;
}
.main-buttons .btn.small {
  font-size: 16px;
  padding: 12px;
}
.main-buttons .row2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.name-box {
  background: var(--panel);
  border-radius: 12px;
  padding: 12px 14px;
}
.name-box label {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  color: var(--muted);
}
.name-box input {
  flex: 1;
}

.panel {
  background: var(--panel);
  border-radius: 16px;
  padding: 22px 24px;
  width: min(560px, 100%);
  box-shadow: 0 10px 0 rgba(0, 0, 0, 0.15);
}
.panel.wide {
  width: min(980px, 100%);
}
.panel h2 {
  margin: 0 0 16px;
  font-size: 30px;
  font-weight: 900;
  font-style: italic;
}
.panel h3 {
  margin: 8px 0 10px;
  font-size: 17px;
  color: var(--yellow);
  font-style: italic;
}
.form {
  display: grid;
  gap: 12px;
}
.form.two {
  grid-template-columns: 1fr 1fr;
  gap: 14px 22px;
}
.form label {
  display: grid;
  gap: 6px;
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
  position: relative;
}
.form label.check {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
}
.form .val {
  position: absolute;
  right: 0;
  top: 0;
  color: #fff;
}
input[type='text'],
input:not([type]),
input[type='password'],
select {
  width: 100%;
  background: rgba(255, 255, 255, 0.09);
  color: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 16px;
  font-weight: 600;
  outline: none;
  -webkit-user-select: text;
  user-select: text;
}
select option {
  background: var(--navy);
}
input:focus,
select:focus {
  border-color: var(--yellow);
}
input[type='range'] {
  width: 100%;
  accent-color: var(--yellow);
}
input[type='checkbox'] {
  width: 20px;
  height: 20px;
  accent-color: var(--yellow);
}
.actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 20px;
}
.actions .btn {
  min-width: 140px;
}
.status {
  margin-top: 14px;
  min-height: 22px;
  font-weight: 700;
  color: var(--muted);
}
.status.err {
  color: #ff8a8a;
}
.status.ok {
  color: #8df09c;
}
details.adv {
  margin-top: 14px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}
details.adv summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 10px;
}
.host-grid {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 24px;
}
.addr-box {
  background: rgba(0, 0, 0, 0.25);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 14px;
}
.addr-label {
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
  letter-spacing: 0.08em;
}
.addr-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}
.addr-row code {
  flex: 1;
  font-size: 22px;
  font-weight: 800;
  color: var(--yellow);
  font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.addr-status {
  margin-top: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}
.addr-status.err {
  color: #ff9a9a;
}
.lobby-title {
  font-weight: 900;
  font-style: italic;
  margin-bottom: 8px;
}
.lobby {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
  max-height: 300px;
  overflow-y: auto;
}
.lobby li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: rgba(255, 255, 255, 0.07);
  border-radius: 8px;
  padding: 8px 12px;
  font-weight: 700;
}
.lobby li .tag {
  font-size: 11px;
  font-weight: 800;
  color: #1b1b1b;
  background: var(--yellow);
  border-radius: 5px;
  padding: 2px 6px;
}
.lobby-info {
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 12px;
}
.note {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.45;
}
.controls-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}
table.keys {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
table.keys td {
  padding: 5px 4px;
  border-bottom: 1px solid var(--line);
}
table.keys td:first-child {
  color: var(--muted);
  font-weight: 700;
  width: 46%;
}
kbd {
  display: inline-block;
  min-width: 24px;
  text-align: center;
  background: #fff;
  color: #14213d;
  border-radius: 5px;
  padding: 1px 6px;
  font-weight: 800;
  font-family: inherit;
  font-size: 13px;
  margin-right: 3px;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.2);
}
.tips {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}
.loading-box {
  text-align: center;
  font-size: 22px;
  font-weight: 800;
  font-style: italic;
  background: var(--panel);
  padding: 28px 40px;
  border-radius: 16px;
}
.spinner {
  width: 46px;
  height: 46px;
  margin: 0 auto 16px;
  border-radius: 50%;
  border: 6px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--yellow);
  animation: spin 0.9s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ------------------------------------------------------------ overlays */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(8, 18, 42, 0.55);
}
.overlay .panel {
  text-align: center;
}
.overlay .sub {
  color: var(--muted);
  font-weight: 600;
  margin-top: -6px;
}
.stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
}
.stack.row {
  flex-direction: row;
  justify-content: center;
  flex-wrap: wrap;
}
.panel.results {
  width: min(620px, 100%);
}
.place {
  font-size: 72px;
  font-weight: 900;
  font-style: italic;
  color: var(--yellow);
  line-height: 1;
}
.res-title {
  font-size: 32px;
  font-weight: 900;
  font-style: italic;
  margin-top: 6px;
}
.res-sub {
  color: var(--muted);
  font-weight: 700;
  margin-top: 6px;
}
.res-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 18px 0 10px;
}
.res-stats div {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 10px 6px;
  display: grid;
}
.res-stats b {
  font-size: 28px;
  font-style: italic;
}
.res-stats span {
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
  letter-spacing: 0.06em;
}
.res-top {
  text-align: left;
  margin: 8px auto 0;
  max-width: 420px;
  padding-left: 30px;
  color: var(--muted);
  font-weight: 700;
  font-size: 14px;
}
.res-top li.me {
  color: var(--yellow);
}
#rotate {
  z-index: 60;
  background: #102452;
}
.rotate-box {
  text-align: center;
  font-size: 20px;
  font-weight: 800;
}
.phone {
  width: 60px;
  height: 100px;
  margin: 0 auto 18px;
  border: 5px solid #fff;
  border-radius: 12px;
  animation: turn 2s ease-in-out infinite;
}
@keyframes turn {
  0%,
  30% {
    transform: rotate(0deg);
  }
  60%,
  100% {
    transform: rotate(-90deg);
  }
}
#fatal {
  z-index: 70;
}
#toast {
  position: fixed;
  left: 50%;
  bottom: calc(40px + var(--sab));
  transform: translateX(-50%);
  z-index: 80;
  background: rgba(10, 20, 45, 0.92);
  padding: 10px 18px;
  border-radius: 10px;
  font-weight: 700;
}

/* ------------------------------------------------------------ HUD */
#hud {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  font-weight: 800;
}
#stormTint {
  position: absolute;
  inset: 0;
  background: rgba(118, 48, 190, 0.32);
  opacity: 0;
  transition: opacity 0.4s;
}
#stormTint.on {
  opacity: 1;
}
#scope {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, transparent 0 33vmin, #000 33.3vmin);
}
#scope .scope-ring {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 66vmin;
  height: 66vmin;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 3px solid #000;
  background: linear-gradient(#000, #000) center / 1.5px 100% no-repeat, linear-gradient(#000, #000) center / 100% 1.5px no-repeat;
}
#topRight {
  position: absolute;
  top: calc(12px + var(--sat));
  right: calc(12px + var(--sar));
  width: 200px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
#minimap {
  width: 200px;
  height: 200px;
  border-radius: 12px;
  border: 3px solid rgba(255, 255, 255, 0.85);
  background: #2c7fc4;
}
#infoRow {
  display: flex;
  gap: 6px;
  justify-content: space-between;
}
.info {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: rgba(10, 20, 45, 0.72);
  border-radius: 7px;
  padding: 4px 4px;
  font-size: 15px;
}
.ico {
  width: 14px;
  height: 14px;
  display: inline-block;
  border-radius: 3px;
}
.ico-storm {
  border-radius: 50%;
  border: 3px solid #c77dff;
}
.ico-players {
  border-radius: 50% 50% 3px 3px;
  background: #fff;
  width: 12px;
}
.ico-kills {
  background: linear-gradient(45deg, transparent 42%, #ff6b6b 42% 58%, transparent 58%), linear-gradient(-45deg, transparent 42%, #ff6b6b 42% 58%, transparent 58%);
}
#stormMsg {
  text-align: right;
  font-size: 13px;
  color: #fff;
  background: rgba(10, 20, 45, 0.6);
  border-radius: 7px;
  padding: 4px 8px;
}
#stormMsg:empty {
  display: none;
}
#killfeed {
  position: absolute;
  left: calc(14px + var(--sal));
  bottom: calc(150px + var(--sab));
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 46vw;
}
.kf {
  background: rgba(10, 20, 45, 0.62);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 14px;
  font-weight: 700;
  animation: kfIn 0.2s ease-out;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kf b {
  color: #fff;
}
.kf .me {
  color: var(--yellow);
}
.kf .w {
  color: var(--muted);
}
@keyframes kfIn {
  from {
    transform: translateX(-20px);
    opacity: 0;
  }
}
#alerts {
  position: absolute;
  top: calc(70px + var(--sat));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.alert {
  background: rgba(10, 20, 45, 0.72);
  border-radius: 8px;
  padding: 7px 16px;
  font-size: 18px;
  font-style: italic;
  animation: kfIn 0.2s ease-out;
}
.alert.storm {
  background: rgba(98, 36, 170, 0.85);
}
.alert.good {
  background: rgba(255, 210, 63, 0.95);
  color: #1b1b1b;
}
#bigMsg {
  position: absolute;
  top: 28%;
  left: 50%;
  transform: translateX(-50%);
  font-size: clamp(30px, 5vw, 56px);
  font-weight: 900;
  font-style: italic;
  text-align: center;
  text-shadow: 0 4px 0 rgba(0, 0, 0, 0.3);
}
#crosshair {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0;
  height: 0;
  --g: 8px;
}
#crosshair i {
  position: absolute;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.45);
}
#crosshair .ch-t,
#crosshair .ch-b {
  width: 2px;
  height: 8px;
  left: -1px;
}
#crosshair .ch-l,
#crosshair .ch-r {
  width: 8px;
  height: 2px;
  top: -1px;
}
#crosshair .ch-t {
  top: calc(-1 * var(--g) - 8px);
}
#crosshair .ch-b {
  top: var(--g);
}
#crosshair .ch-l {
  left: calc(-1 * var(--g) - 8px);
}
#crosshair .ch-r {
  left: var(--g);
}
#crosshair .ch-dot {
  width: 2px;
  height: 2px;
  left: -1px;
  top: -1px;
}
#crosshair.circle i {
  display: none;
}
#crosshair.circle::after {
  content: '';
  position: absolute;
  left: calc(-1 * var(--g) - 4px);
  top: calc(-1 * var(--g) - 4px);
  width: calc(2 * var(--g) + 8px);
  height: calc(2 * var(--g) + 8px);
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35);
}
#crosshair.build i {
  display: none;
}
#crosshair.build .ch-dot {
  display: block;
  width: 6px;
  height: 6px;
  left: -3px;
  top: -3px;
  border-radius: 50%;
}
#hitmarker {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0;
  height: 0;
}
#hitmarker i {
  position: absolute;
  width: 3px;
  height: 10px;
  background: #fff;
  left: -1.5px;
  top: -5px;
}
#hitmarker i:nth-child(1) {
  transform: rotate(45deg) translateY(-12px);
}
#hitmarker i:nth-child(2) {
  transform: rotate(135deg) translateY(-12px);
}
#hitmarker i:nth-child(3) {
  transform: rotate(225deg) translateY(-12px);
}
#hitmarker i:nth-child(4) {
  transform: rotate(315deg) translateY(-12px);
}
#hitmarker.head i {
  background: var(--yellow);
}
#hitmarker.kill i {
  background: var(--red);
}
#nums {
  position: absolute;
  inset: 0;
  overflow: hidden;
}
.num {
  position: absolute;
  left: 0;
  top: 0;
  font-size: 24px;
  font-weight: 900;
  font-style: italic;
  color: #fff;
  -webkit-text-stroke: 1.2px #1c1c1c;
  paint-order: stroke fill;
  will-change: transform, opacity;
}
.num.sh {
  color: #6fd0ff;
}
.num.hs {
  color: var(--yellow);
  font-size: 30px;
}
.num.mat {
  font-size: 18px;
  color: #fff;
}
#dmgDirs {
  position: absolute;
  inset: 0;
}
.dmgdir {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 90px;
  height: 90px;
  margin: -45px 0 0 -45px;
  animation: fadeOut 1.1s ease-out forwards;
}
.dmgdir::before {
  content: '';
  position: absolute;
  left: 50%;
  top: -80px;
  width: 70px;
  height: 14px;
  margin-left: -35px;
  border-radius: 50% 50% 0 0;
  background: rgba(255, 60, 60, 0.85);
}
@keyframes fadeOut {
  to {
    opacity: 0;
  }
}
#prompt {
  position: absolute;
  left: 50%;
  top: 60%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(10, 20, 45, 0.78);
  border-radius: 8px;
  padding: 7px 14px 7px 8px;
  font-size: 17px;
  white-space: nowrap;
}
.key {
  display: inline-block;
  background: #fff;
  color: #14213d;
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 15px;
  font-weight: 900;
}
#progress {
  position: absolute;
  left: 50%;
  top: 64%;
  transform: translateX(-50%);
  width: 220px;
  text-align: center;
}
#progressLabel {
  font-size: 15px;
  margin-bottom: 4px;
}
.bar {
  height: 8px;
  background: rgba(0, 0, 0, 0.45);
  border-radius: 4px;
  overflow: hidden;
}
#progressFill {
  height: 100%;
  width: 0;
  background: #fff;
}
#pieceHp {
  position: absolute;
  left: 50%;
  top: calc(50% + 26px);
  transform: translateX(-50%);
  width: 110px;
  text-align: center;
  font-size: 12px;
}
#pieceHpFill {
  height: 100%;
  width: 100%;
  background: #7ee07a;
}
#vitals {
  position: absolute;
  left: calc(14px + var(--sal));
  bottom: calc(16px + var(--sab));
  width: min(320px, 34vw);
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.vbar {
  position: relative;
  height: 22px;
  background: rgba(10, 20, 45, 0.72);
  border-radius: 5px;
  overflow: hidden;
}
.vbar .fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 100%;
  transition: width 0.15s;
}
.vbar.shield .fill {
  background: var(--shield);
}
.vbar.health .fill {
  background: var(--green);
}
.vbar.health.low .fill {
  background: #ff5a4a;
}
.vbar span {
  position: absolute;
  left: 8px;
  top: 0;
  line-height: 22px;
  font-size: 15px;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.5);
}
#bottomRight {
  position: absolute;
  right: calc(12px + var(--sar));
  bottom: calc(12px + var(--sab));
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}
#resources {
  display: flex;
  gap: 5px;
}
.res {
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(10, 20, 45, 0.72);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 14px;
  min-width: 58px;
}
.res.sel {
  outline: 2px solid var(--yellow);
}
.mat {
  width: 13px;
  height: 13px;
  border-radius: 3px;
}
.mat.wood {
  background: #c98e55;
}
.mat.brick {
  background: #c2583f;
}
.mat.metal {
  background: #a3aeb9;
}
.ammo-dot {
  width: 8px;
  height: 14px;
  border-radius: 4px 4px 1px 1px;
  background: #e3c46b;
}
#hotbar,
#buildbar {
  display: flex;
  gap: 5px;
  pointer-events: auto;
}
.slot {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: 8px;
  background: rgba(10, 20, 45, 0.62);
  border: 3px solid transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  overflow: hidden;
}
.slot.r0 {
  background: linear-gradient(180deg, rgba(160, 168, 178, 0.35), rgba(160, 168, 178, 0.8));
}
.slot.r1 {
  background: linear-gradient(180deg, rgba(77, 187, 74, 0.35), rgba(77, 187, 74, 0.85));
}
.slot.r2 {
  background: linear-gradient(180deg, rgba(55, 150, 242, 0.35), rgba(55, 150, 242, 0.85));
}
.slot.r3 {
  background: linear-gradient(180deg, rgba(176, 93, 240, 0.35), rgba(176, 93, 240, 0.85));
}
.slot.r4 {
  background: linear-gradient(180deg, rgba(243, 163, 52, 0.35), rgba(243, 163, 52, 0.9));
}
.slot.sel {
  border-color: #fff;
  transform: translateY(-6px);
}
.slot canvas {
  width: 56px;
  height: 56px;
}
.slot .n {
  position: absolute;
  right: 4px;
  bottom: 1px;
  font-size: 14px;
  text-shadow: 0 1px 0 #000;
}
.slot .k {
  position: absolute;
  left: 4px;
  top: 1px;
  font-size: 11px;
  opacity: 0.8;
}
.slot .lbl {
  font-size: 11px;
  text-align: center;
  line-height: 1.1;
}
#buildbar .slot {
  background: rgba(47, 140, 255, 0.35);
}
#buildbar .slot.sel {
  background: rgba(47, 140, 255, 0.85);
}
#spectate {
  position: absolute;
  left: 50%;
  bottom: calc(110px + var(--sab));
  transform: translateX(-50%);
  text-align: center;
  background: rgba(10, 20, 45, 0.72);
  border-radius: 10px;
  padding: 8px 20px;
}
.spec-label {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.1em;
}
#specName {
  font-size: 22px;
  font-style: italic;
}
.spec-hint {
  font-size: 12px;
  color: var(--muted);
}
#busHint {
  position: absolute;
  left: 50%;
  bottom: 28%;
  transform: translateX(-50%);
  background: rgba(10, 20, 45, 0.72);
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 20px;
  font-style: italic;
}
#fps {
  position: absolute;
  left: calc(8px + var(--sal));
  top: calc(8px + var(--sat));
  font-size: 12px;
  background: rgba(0, 0, 0, 0.4);
  padding: 2px 6px;
  border-radius: 4px;
}
#netStatus {
  position: absolute;
  left: 50%;
  top: calc(10px + var(--sat));
  transform: translateX(-50%);
  background: rgba(200, 40, 40, 0.85);
  border-radius: 8px;
  padding: 5px 12px;
  font-size: 14px;
}
#fullmap {
  position: fixed;
  inset: 0;
  z-index: 15;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(8, 18, 42, 0.7);
}
#bigmap {
  width: min(92vmin, 900px);
  height: min(92vmin, 900px);
  max-height: calc(100vh - 50px);
  max-width: calc(100vh - 50px);
  border-radius: 14px;
  border: 3px solid #fff;
}
.map-hint {
  margin-top: 8px;
  font-weight: 700;
  color: var(--muted);
}

/* ------------------------------------------------------------ touch controls */
#touch {
  position: fixed;
  inset: 0;
  z-index: 9; /* under the HUD: the HUD is click-through except the hotbar */
  pointer-events: none;
}
#joyZone {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 42%;
  height: 70%;
  pointer-events: auto;
}
#lookZone {
  position: absolute;
  right: 0;
  top: 0;
  width: 58%;
  height: 100%;
  pointer-events: auto;
}
#joyBase {
  position: absolute;
  left: calc(36px + var(--sal));
  bottom: calc(36px + var(--sab));
  width: 130px;
  height: 130px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  border: 2px solid rgba(255, 255, 255, 0.35);
}
#joyKnob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 58px;
  height: 58px;
  margin: -29px 0 0 -29px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.55);
}
#joyBase.sprint {
  border-color: var(--yellow);
}
.tbtn {
  position: absolute;
  pointer-events: auto;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.5);
  background: rgba(10, 20, 45, 0.42);
  color: #fff;
  font-weight: 900;
  font-size: 11px;
  font-style: italic;
  touch-action: none;
  padding: 0;
}
.tbtn.on {
  background: rgba(255, 210, 63, 0.85);
  color: #1b1b1b;
  border-color: var(--yellow);
}
.tbtn.active {
  background: rgba(255, 255, 255, 0.45);
}
.tbtn.big {
  width: 86px;
  height: 86px;
  font-size: 15px;
  background: rgba(230, 70, 60, 0.5);
}
.tbtn.small {
  width: 46px;
  height: 36px;
  border-radius: 8px;
  font-size: 11px;
}
#tFire {
  right: calc(34px + var(--sar));
  bottom: calc(96px + var(--sab));
}
#tFire2 {
  left: calc(26px + var(--sal));
  top: calc(34% + var(--sat));
  background: rgba(230, 70, 60, 0.45);
}
#tAim {
  right: calc(136px + var(--sar));
  bottom: calc(150px + var(--sab));
}
#tJump {
  right: calc(26px + var(--sar));
  bottom: calc(196px + var(--sab));
}
#tCrouch {
  right: calc(130px + var(--sar));
  bottom: calc(76px + var(--sab));
}
#tReload {
  right: calc(98px + var(--sar));
  bottom: calc(236px + var(--sab));
}
#tBuild {
  right: calc(28px + var(--sar));
  bottom: calc(282px + var(--sab));
}
#tUse {
  right: calc(210px + var(--sar));
  bottom: calc(210px + var(--sab));
  background: rgba(255, 210, 63, 0.8);
  color: #1b1b1b;
}
#tPieces {
  position: absolute;
  right: calc(200px + var(--sar));
  bottom: calc(12px + var(--sab));
  display: flex;
  gap: 6px;
  pointer-events: none;
}
#tPieces .tbtn {
  position: static;
  width: 56px;
  height: 44px;
  border-radius: 8px;
  font-size: 10px;
}
#tMap {
  left: calc(12px + var(--sal));
  top: calc(12px + var(--sat));
}
#tPause {
  left: calc(66px + var(--sal));
  top: calc(12px + var(--sat));
}
body.touch #hotbar .slot {
  width: 52px;
  height: 52px;
}
body.touch .slot canvas {
  width: 44px;
  height: 44px;
}
body.touch #bottomRight {
  right: 50%;
  transform: translateX(50%);
  bottom: calc(6px + var(--sab));
  align-items: center;
}
body.touch #buildbar {
  display: none !important;
}
body.touch #vitals {
  left: calc(12px + var(--sal));
  top: calc(56px + var(--sat));
  bottom: auto;
  width: min(220px, 30vw);
}
body.touch .vbar {
  height: 16px;
}
body.touch .vbar span {
  line-height: 16px;
  font-size: 12px;
}
body.touch #killfeed {
  bottom: auto;
  top: calc(110px + var(--sat));
}
body.touch .kf {
  font-size: 12px;
}
body.touch #topRight,
body.touch #minimap {
  width: 150px;
}
body.touch #minimap {
  height: 150px;
}
body.touch #prompt {
  top: 30%;
}
body.touch #busHint .key {
  display: none;
}
body.touch #busHint {
  font-size: 14px;
  bottom: 40%;
}

@media (max-width: 800px) and (min-height: 521px), (max-width: 560px) {
  #menuMain {
    grid-template-columns: 1fr;
  }
  .brand {
    grid-row: auto;
    text-align: center;
  }
  .form.two,
  .host-grid,
  .controls-grid {
    grid-template-columns: 1fr;
  }
  .panel {
    padding: 18px;
  }
}
@media (max-height: 520px) {
  #menuMain {
    grid-template-columns: 1fr 1fr;
    gap: 8px 20px;
  }
  .logo {
    font-size: 46px;
  }
  .tagline {
    margin-top: 8px;
    font-size: 13px;
  }
  .main-buttons .btn {
    font-size: 16px;
    padding: 9px 14px;
  }
  .main-buttons .btn.small {
    font-size: 13px;
    padding: 8px;
  }
  .main-buttons,
  .main-buttons .row2 {
    gap: 6px;
  }
  .name-box {
    padding: 6px 10px;
  }
  .name-box input {
    padding: 6px 8px;
  }
  .panel {
    padding: 14px 16px;
  }
  .panel h2 {
    font-size: 22px;
    margin-bottom: 10px;
  }
  .form {
    gap: 8px;
  }
  .actions {
    margin-top: 12px;
  }
  #topRight {
    width: 150px;
  }
  #minimap {
    width: 150px;
    height: 150px;
  }
  .slot {
    width: 52px;
    height: 52px;
  }
}

/* touch: hide hotbar while building (piece buttons take its place) */
body.touch.building #hotbar {
  display: none;
}
body.touch #tPieces {
  left: 50%;
  right: auto;
  transform: translateX(-50%);
  bottom: calc(34px + var(--sab));
}
body.touch #stormMsg {
  display: none;
}
/* compact touch layout for landscape phones */
@media (max-height: 640px) {
  body.touch #topRight {
    width: 104px;
  }
  body.touch #minimap {
    width: 104px;
    height: 104px;
    border-width: 2px;
  }
  body.touch .info {
    font-size: 11px;
    padding: 2px 3px;
    gap: 3px;
  }
  body.touch .ico {
    width: 9px;
    height: 9px;
  }
  body.touch #infoRow {
    gap: 3px;
  }
  body.touch #vitals {
    top: calc(52px + var(--sat));
    width: min(180px, 28vw);
    gap: 3px;
  }
  body.touch .vbar {
    height: 13px;
  }
  body.touch .vbar span {
    line-height: 13px;
    font-size: 10px;
  }
  body.touch #killfeed {
    top: calc(96px + var(--sat));
    max-width: 34vw;
  }
  body.touch .kf {
    font-size: 10px;
    padding: 2px 6px;
  }
  body.touch #hotbar .slot {
    width: 42px;
    height: 42px;
    border-width: 2px;
  }
  body.touch .slot canvas {
    width: 36px;
    height: 36px;
  }
  body.touch .slot .n {
    font-size: 11px;
  }
  body.touch .res {
    font-size: 11px;
    padding: 2px 5px;
    min-width: 40px;
  }
  body.touch #bottomRight {
    gap: 3px;
  }
  body.touch .tbtn {
    width: 48px;
    height: 48px;
    font-size: 10px;
    letter-spacing: -0.02em;
  }
  body.touch #tReload,
  body.touch #tCrouch,
  body.touch #tBuild {
    font-size: 8.5px;
    letter-spacing: -0.03em;
  }
  body.touch .tbtn.big {
    width: 74px;
    height: 74px;
    font-size: 13px;
  }
  body.touch .tbtn.small {
    width: 42px;
    height: 32px;
  }
  body.touch #tFire {
    right: calc(18px + var(--sar));
    bottom: calc(24px + var(--sab));
  }
  body.touch #tJump {
    right: calc(22px + var(--sar));
    bottom: calc(108px + var(--sab));
  }
  body.touch #tAim {
    right: calc(102px + var(--sar));
    bottom: calc(80px + var(--sab));
  }
  body.touch #tCrouch {
    right: calc(104px + var(--sar));
    bottom: calc(18px + var(--sab));
    width: 44px;
    height: 44px;
  }
  body.touch #tReload {
    right: calc(158px + var(--sar));
    bottom: calc(118px + var(--sab));
    width: 44px;
    height: 44px;
  }
  body.touch #tBuild {
    right: calc(90px + var(--sar));
    bottom: calc(140px + var(--sab));
    width: 44px;
    height: 44px;
  }
  body.touch #tUse {
    right: calc(176px + var(--sar));
    bottom: calc(52px + var(--sab));
  }
  body.touch #tFire2 {
    top: auto;
    bottom: calc(172px + var(--sab));
    left: calc(20px + var(--sal));
  }
  body.touch #tPieces .tbtn {
    width: 48px;
    height: 36px;
  }
  body.touch #joyBase {
    width: 110px;
    height: 110px;
    left: calc(26px + var(--sal));
    bottom: calc(22px + var(--sab));
  }
  body.touch #prompt {
    font-size: 13px;
    top: 26%;
  }
  body.touch #alerts {
    top: calc(40px + var(--sat));
  }
  body.touch .alert {
    font-size: 13px;
    padding: 4px 10px;
  }
}

#pickups {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
}
.pk {
  background: rgba(10, 20, 45, 0.7);
  border-left: 4px solid #a0a8b2;
  border-radius: 5px;
  padding: 3px 9px;
  font-size: 13px;
  animation: kfIn 0.15s ease-out;
}
body.touch .pk {
  font-size: 10px;
  padding: 2px 6px;
}

#hurtFx {
  position: absolute;
  inset: 0;
  opacity: 0;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(210, 30, 30, 0.55) 100%);
}

#lockHint {
  position: absolute;
  left: 50%;
  top: 40%;
  transform: translateX(-50%);
  background: rgba(10, 20, 45, 0.8);
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 18px;
  font-style: italic;
}

/* every part of the game surface: no browser gestures (double-tap zoom, pinch) */
#view,
#hud,
#hud *,
#touch,
#touch * {
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
