:root {
  color-scheme: dark;
  --ink: #f8f4e7;
  --muted: #c8ceb9;
  --glass: rgba(22, 34, 24, 0.83);
  --glass-strong: rgba(18, 28, 20, 0.95);
  --line: rgba(255, 255, 255, 0.14);
  --resource-tree: #c99262;
  --resource-stone: #bdc3c6;
  --resource-gold: #f4cc4f;
  --resource-bush: #ed5369;
  --shadow: 0 18px 52px rgba(8, 14, 9, 0.42);
  --font-ui: "Baloo Paaji 2", system-ui, sans-serif;
  --hud-edge: clamp(6px, 0.85vmin, 12px);
  --hud-gap: clamp(3px, 0.5vmin, 7px);
  --hud-radius: clamp(4px, 0.45vmin, 6px);
  --side-panel-width: clamp(148px, 16.1vw, 232px);
  --inventory-gap: clamp(2px, 0.35vw, 5px);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #778e58;
  color: var(--ink);
  font-family: var(--font-ui);
  font-weight: 700;
  user-select: none;
  overscroll-behavior: none;
  scrollbar-width: none;
}

html::-webkit-scrollbar,
body::-webkit-scrollbar {
  display: none;
}

button,
input,
select {
  font: inherit;
}

button {
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}

[hidden] {
  display: none !important;
}

#gameCanvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  touch-action: none;
}

.lobby-layer {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 22px;
  background: transparent;
}

.lobby-card {
  width: min(430px, calc(100vw - 32px));
  padding: 30px 34px 24px;
  border: 1px solid rgba(255, 255, 255, 0.17);
  border-radius: 14px;
  background: linear-gradient(145deg, rgba(29, 44, 31, 0.94), rgba(15, 25, 18, 0.91));
  box-shadow: 0 24px 62px rgba(13, 18, 12, 0.28);
  backdrop-filter: blur(13px);
  text-align: center;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 22px;
  font-size: clamp(38px, 7vw, 54px);
  line-height: 1;
  letter-spacing: -0.025em;
  text-shadow: none;
  font-weight: 800;
}

h2 {
  margin: 0;
  font-size: 25px;
  letter-spacing: -0.035em;
}

.field-label {
  display: block;
  margin: 0 2px 7px;
  color: #dce3d3;
  font-size: 12px;
  font-weight: 750;
  text-align: left;
}

.server-label {
  margin-top: 14px;
}

.text-field {
  width: 100%;
  height: 45px;
  padding: 0 13px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 6px;
  outline: none;
  background: rgba(4, 9, 5, 0.29);
  color: var(--ink);
  user-select: text;
  transition: border-color 120ms, box-shadow 120ms, background 120ms;
}

.text-field:focus {
  border-color: rgba(185, 226, 110, 0.63);
  background: rgba(4, 9, 5, 0.43);
  box-shadow: 0 0 0 3px rgba(183, 224, 107, 0.1);
}

select.text-field {
  cursor: pointer;
}

.form-error {
  min-height: 17px;
  margin: 9px 0 2px;
  color: #ff8b85;
  font-size: 12px;
  font-weight: 650;
}

.lobby-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.lobby-actions .primary-button,
.lobby-actions .lobby-settings-button {
  width: 100%;
  margin: 0;
  box-shadow: none;
}

.primary-button,
.quiet-button,
.lobby-settings-button {
  width: 100%;
  min-height: 45px;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 800;
  transition: transform 100ms, filter 100ms, background 100ms;
}

.primary-button {
  background: linear-gradient(#c9ec82, #94c951);
  color: #24351f;
  box-shadow: 0 5px 0 #5c8537, 0 12px 25px rgba(11, 20, 12, 0.32);
}

.primary-button:hover {
  filter: brightness(1.06);
  transform: translateY(-1px);
}

.primary-button:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #5c8537;
}

.lobby-actions .primary-button:active {
  transform: translateY(1px);
  box-shadow: none;
}

.primary-button:disabled {
  cursor: wait;
  filter: saturate(0.5);
  opacity: 0.75;
}

.quiet-button {
  min-height: 36px;
  margin-top: 12px;
  background: transparent;
  color: #c9d2c2;
  font-size: 12px;
}

.quiet-button:hover {
  background: rgba(255, 255, 255, 0.06);
}

.lobby-settings-button {
  margin-top: 0;
  border: 0;
  background: linear-gradient(#6d8390, #4e6572);
  box-shadow: none;
  color: #f4f7f4;
}

.lobby-settings-button:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.lobby-settings-button:active {
  transform: translateY(1px);
  box-shadow: none;
}

.hud {
  position: fixed;
  inset: 0;
  z-index: 5;
  pointer-events: none;
}

.hud-top-left,
.hud-top-right,
.resource-panel,
.minimap-panel,
.inventory,
.inventory-cost-preview,
.chat-composer {
  position: absolute;
}

.hud-top-left {
  top: 12px;
  left: 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.hud-top-right {
  top: 12px;
  right: 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 7px;
}

.hud-button-row {
  display: flex;
  gap: 0;
}

.hud-button {
  height: 56px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--glass);
  box-shadow: 0 8px 25px rgba(10, 17, 11, 0.28), inset 0 1px rgba(255, 255, 255, 0.07);
  backdrop-filter: blur(8px);
  cursor: pointer;
  font-size: 18px;
  font-weight: 900;
  pointer-events: auto;
}

.hud-button:first-child {
  border-radius: 6px 0 0 6px;
}

.hud-button:last-child {
  margin-left: -1px;
  border-radius: 0 6px 6px 0;
}

.hud-button:hover,
.hud-button.active {
  position: relative;
  z-index: 1;
  border-color: rgba(185, 226, 110, 0.4);
  background: rgba(39, 58, 39, 0.94);
}

.hud-button:focus,
.hud-button:focus-visible {
  outline: none;
}

.ping-display {
  padding-right: 2px;
  color: #fff;
  font-size: 20px;
  font-weight: 850;
  line-height: 1;
  text-shadow: 0 2px 4px rgba(5, 10, 6, 0.8);
  white-space: nowrap;
}

.request-popups {
  width: 270px;
  margin-top: 5px;
  display: grid;
  gap: 7px;
  pointer-events: auto;
}

.request-card {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--glass-strong);
  box-shadow: var(--shadow);
  font-size: 12px;
}

.request-card p {
  margin: 0 0 8px;
}

.mini-actions {
  display: flex;
  gap: 6px;
}

.mini-button {
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.07);
  cursor: pointer;
  font-size: 11px;
  font-weight: 800;
}

.mini-button.accept {
  background: rgba(152, 207, 79, 0.2);
  color: #d9f3a8;
}

.mini-button.danger {
  background: rgba(239, 103, 97, 0.15);
  color: #ffaaa5;
}

.mini-button:disabled {
  cursor: default;
  opacity: 0.48;
  filter: saturate(0);
}

.leaderboard-panel {
  width: 232px;
  padding: 13px 14px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--glass);
  box-shadow: 0 8px 25px rgba(10, 17, 11, 0.25);
  backdrop-filter: blur(8px);
}

.leaderboard-panel header {
  display: flex;
  align-items: center;
  padding-bottom: 9px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
  font-size: 14px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.leaderboard-panel ol {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
  counter-reset: leaders;
}

.leaderboard-panel li {
  counter-increment: leaders;
  display: grid;
  grid-template-columns: 23px 1fr auto;
  gap: 6px;
  padding: 5px 0;
  color: #dfe5d7;
  font-size: 15px;
}

.leaderboard-panel li::before {
  content: counter(leaders) ".";
  color: #8fa085;
  font-variant-numeric: tabular-nums;
}

.leaderboard-panel li span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard-panel li b {
  color: var(--resource-gold);
  font-variant-numeric: tabular-nums;
}


.kill-panel {
  width: 232px;
  min-height: 50px;
  padding: 9px 14px;
  display: grid;
  grid-template-columns: 32px 1fr auto;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--glass);
  box-shadow: 0 8px 25px rgba(10, 17, 11, 0.25);
  backdrop-filter: blur(8px);
}

.kill-panel .kill-icon {
  display: grid;
  place-items: center;
  font-size: 23px;
  line-height: 1;
}

.kill-panel > span:not(.kill-icon) {
  font-size: 20px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.kill-panel small {
  color: #aeb8a7;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.minimap-panel {
  left: 12px;
  bottom: 12px;
  width: 180px;
  height: 180px;
  padding: 0;
  overflow: hidden;
  border: 5px solid #172018;
  border-radius: 6px;
  background: #172018;
  box-shadow: 0 8px 25px rgba(10, 17, 11, 0.25);
  backdrop-filter: blur(8px);
}

.minimap-panel canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.resource-panel {
  right: 12px;
  bottom: 12px;
  width: max-content;
  min-width: 0;
  padding: 12px;
  display: grid;
  justify-items: start;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--glass);
  box-shadow: 0 8px 25px rgba(10, 17, 11, 0.25);
  backdrop-filter: blur(8px);
}

.resource-panel > div {
  display: grid;
  grid-template-columns: 32px max-content max-content;
  align-items: center;
  gap: 6px;
}

.resource-panel img {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

.resource-panel span {
  font-size: 18px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.resource-value[data-resource="tree"] {
  color: var(--resource-tree);
}

.resource-value[data-resource="stone"] {
  color: var(--resource-stone);
}

.resource-value[data-resource="gold"] {
  color: var(--resource-gold);
}

.resource-value[data-resource="bush"] {
  color: var(--resource-bush);
}

.resource-panel small {
  color: #aeb8a7;
  font-size: 12px;
  font-weight: 800;
  text-align: left;
  text-transform: uppercase;
}

.inventory {
  left: 50%;
  bottom: 12px;
  display: flex;
  gap: 5px;
  transform: translateX(-50%);
  pointer-events: auto;
}

.inventory-cost-preview {
  top: 12px;
  left: 50%;
  min-width: 190px;
  padding: 10px 14px 11px;
  transform: translateX(-50%);
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--glass-strong);
  box-shadow: 0 8px 25px rgba(10, 17, 11, 0.25);
  backdrop-filter: blur(8px);
  text-align: center;
  pointer-events: none;
}

.inventory-cost-title {
  display: block;
  margin-bottom: 7px;
  color: #eef2e8;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.inventory-cost-items {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

.inventory-cost-item {
  display: grid;
  grid-template-columns: 27px auto;
  grid-template-rows: auto auto;
  align-items: center;
  column-gap: 6px;
  text-align: left;
}

.inventory-cost-item img {
  width: 27px;
  height: 27px;
  grid-row: 1 / 3;
  object-fit: contain;
}

.inventory-cost-item b {
  color: #f3f5ed;
  font-size: 13px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.inventory-cost-item small {
  color: #aeb9a7;
  font-size: 8px;
  line-height: 1;
  text-transform: uppercase;
}

.inventory-cell {
  position: relative;
  width: min(122px, calc((100vw - 310px) / 7));
  height: auto;
  aspect-ratio: 1;
  padding: 4px;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.13);
  border-radius: 6px;
  background: rgba(24, 37, 25, 0.88);
  box-shadow: 0 7px 19px rgba(9, 16, 10, 0.3), inset 0 1px rgba(255, 255, 255, 0.06);
  cursor: pointer;
  transition: border-color 100ms, background 100ms;
}

.inventory-cell:hover {
  border-color: rgba(255, 255, 255, 0.31);
}

.inventory-cell:focus,
.inventory-cell:focus-visible {
  outline: none;
}


.inventory-cell .slot-key {
  position: absolute;
  top: 5px;
  left: 6px;
  z-index: 5;
  min-width: 20px;
  height: 20px;
  padding: 0 4px;
  display: grid;
  place-items: center;
  border-radius: 4px;
  background: rgba(5, 10, 6, 0.7);
  color: #e9f1df;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.inventory-cell .slot-limit {
  position: absolute;
  top: 5px;
  left: 29px;
  z-index: 5;
  height: 20px;
  padding: 0 5px;
  display: grid;
  place-items: center;
  border-radius: 4px;
  background: rgba(5, 10, 6, 0.62);
  color: #d4ddcb;
  font-size: 10px;
  font-weight: 900;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.inventory-cell .slot-limit.at-limit {
  color: #ff9f98;
}

.inventory-cell .inventory-art {
  position: absolute;
  top: var(--inventory-art-top, 5px);
  left: 50%;
  width: var(--inventory-art-size, 68px);
  height: var(--inventory-art-size, 68px);
  display: block;
  transform: translateX(-50%);
}

.inventory-cell .inventory-art img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  transform: rotate(var(--inventory-rotation, 0deg));
  transform-origin: center center;
}

.inventory-cell .windmill-art img {
  transform: none;
}

.inventory-cell .inventory-labels {
  position: absolute;
  right: 3px;
  bottom: 9px;
  left: 3px;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.inventory-cell .slot-name {
  width: 100%;
  overflow: hidden;
  color: #ecf1e7;
  font-size: 16px;
  font-weight: 900;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-shadow: 0 2px 3px rgba(4, 9, 5, 0.7);
}


.inventory-cell .cooldown-overlay {
  position: absolute;
  inset: 0;
  z-index: 3;
  background: rgba(5, 10, 6, 0.64);
  transform-origin: bottom;
  pointer-events: none;
}

.chat-composer {
  top: 55%;
  left: 50%;
  width: min(350px, calc(100vw - 30px));
  transform: translate(-50%, -50%);
  pointer-events: auto;
}

.chat-composer input {
  width: 100%;
  height: 44px;
  padding: 0 60px 0 14px;
  border: 1px solid rgba(197, 236, 117, 0.48);
  border-radius: 6px;
  outline: none;
  background: rgba(16, 25, 17, 0.94);
  color: white;
  box-shadow: var(--shadow);
  user-select: text;
}

.chat-composer span {
  position: absolute;
  top: 14px;
  right: 13px;
  color: #8d9b86;
  font-size: 10px;
}

.modal-shade {
  position: fixed;
  inset: 0;
  z-index: 19;
  background: rgba(7, 12, 8, 0.1);
  backdrop-filter: none;
}

.game-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 20;
  width: min(520px, calc(100vw - 30px));
  max-height: min(680px, calc(100vh - 40px));
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 10px;
  background: rgba(18, 28, 20, 0.7);
  box-shadow: 0 30px 90px rgba(5, 10, 6, 0.58), inset 0 1px rgba(255, 255, 255, 0.08);
  transform: translate(-50%, -50%);
  backdrop-filter: blur(4px);
}

body.modal-open-from-lobby .game-modal {
  background: #121c14;
  backdrop-filter: none;
}

.modal-header {
  padding: 18px 19px 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.close-button {
  width: 35px;
  height: 35px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.05);
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
}

.close-button:hover {
  background: rgba(255, 255, 255, 0.1);
}

.modal-body {
  max-height: calc(min(680px, 100vh - 40px) - 83px);
  padding: 17px 19px 20px;
  overflow-y: auto;
}

.helmets-modal {
  width: min(800px, calc(100vw - 30px));
}

.helmets-list {
  display: grid;
  gap: 8px;
}

.helmet-row {
  min-height: 90px;
  padding: 8px 10px;
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) 104px 92px;
  align-items: center;
  gap: 10px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.035);
}

.helmet-row.equipped {
  border-color: rgba(185, 226, 110, 0.46);
  background: rgba(152, 207, 79, 0.09);
}

.helmet-image {
  width: 72px;
  height: 72px;
  object-fit: contain;
}

.helmet-info {
  min-width: 0;
}

.helmet-info h3,
.helmet-info p {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.helmet-info h3 {
  margin: 0 0 3px;
  color: #edf3e8;
  font-size: 16px;
}

.helmet-info p {
  margin: 0;
  color: #aebaa7;
  font-size: 12px;
  font-weight: 650;
}

.helmet-price {
  grid-column: 3;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  font-size: 14px;
  font-weight: 900;
  white-space: nowrap;
}

.helmet-price img {
  width: 30px;
  height: 30px;
  object-fit: contain;
}

.helmet-action {
  grid-column: 4;
  width: 92px;
  min-height: 36px;
  border: 1px solid rgba(185, 226, 110, 0.35);
  border-radius: 5px;
  background: rgba(152, 207, 79, 0.2);
  color: #dff3b8;
  cursor: pointer;
  font-size: 12px;
  font-weight: 850;
}

.helmet-action:hover {
  background: rgba(152, 207, 79, 0.3);
}

.helmet-action.equipped {
  border-color: rgba(255, 154, 145, 0.35);
  background: rgba(211, 82, 75, 0.18);
  color: #ffc1bc;
}

.clan-create {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
}

.clan-create .text-field {
  flex: 1;
}

.clan-create .primary-button {
  width: auto;
  min-width: 105px;
  box-shadow: 0 4px 0 #5c8537;
}

.section-title {
  margin: 2px 0 9px;
  color: #aebba6;
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.data-list {
  display: grid;
  gap: 7px;
}

.data-row {
  min-height: 46px;
  padding: 9px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.035);
}

.data-row strong {
  display: block;
  font-size: 13px;
}

.data-row small {
  color: #9faa98;
  font-size: 10px;
}

.empty-copy {
  padding: 25px 12px;
  border: 1px dashed rgba(255, 255, 255, 0.13);
  border-radius: 6px;
  color: #9fac99;
  font-size: 12px;
  text-align: center;
}

.clan-heading {
  margin-bottom: 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.clan-heading h3 {
  margin: 0;
  font-size: 21px;
}

.setting-toggles {
  display: grid;
  gap: 8px;
}

.setting-toggles label {
  min-height: 56px;
  padding: 9px 11px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.035);
  cursor: pointer;
}

.setting-toggles b,
.setting-toggles small {
  display: block;
}

.setting-toggles b {
  font-size: 13px;
}

.setting-toggles small {
  margin-top: 2px;
  color: #9eaa98;
  font-size: 10px;
}

.setting-toggles input {
  width: 36px;
  height: 19px;
  accent-color: #a6d35e;
}

.settings-divider {
  margin: 20px 0 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #9eaa98;
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.settings-divider::after {
  content: "";
  height: 1px;
  flex: 1;
  background: rgba(255, 255, 255, 0.1);
}

.settings-note {
  margin-bottom: 11px;
  color: #9ea997;
  font-size: 11px;
}

.hotkey-rows {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.hotkey-row {
  min-height: 40px;
  padding: 6px 7px 6px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.035);
  color: #d8ded2;
  font-size: 11px;
  font-weight: 700;
}

.hotkey-capture {
  min-width: 42px;
  height: 28px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-bottom-width: 3px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.07);
  cursor: pointer;
  font-size: 10px;
  font-weight: 850;
  text-transform: uppercase;
}

.hotkey-capture.listening {
  border-color: #bce473;
  color: #dff3b8;
}

.quiet-button.full {
  margin-top: 13px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.toast-stack {
  position: fixed;
  top: 12px;
  left: 50%;
  z-index: 50;
  width: min(360px, calc(100vw - 30px));
  display: grid;
  gap: 7px;
  transform: translateX(-50%);
  pointer-events: none;
}

.toast {
  min-width: 190px;
  padding: 10px 14px 11px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--glass-strong);
  box-shadow: 0 8px 25px rgba(10, 17, 11, 0.25);
  backdrop-filter: blur(8px);
  color: #eef2e8;
  font-size: 12px;
  font-weight: 800;
  text-align: center;
  animation: toast-in 160ms ease-out;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-8px); }
}

@media (max-width: 520px) {
  .lobby-card {
    padding-right: 22px;
    padding-left: 22px;
  }

  .helmet-row {
    min-height: 72px;
    padding: 6px;
    grid-template-columns: 54px minmax(0, 1fr) 68px 70px;
    gap: 5px;
  }

  .helmet-image {
    width: 54px;
    height: 54px;
  }

  .helmet-info h3 {
    font-size: 12px;
  }

  .helmet-info p {
    font-size: 9px;
  }

  .helmet-price {
    gap: 2px;
    font-size: 10px;
  }

  .helmet-price img {
    width: 20px;
    height: 20px;
  }

  .helmet-action {
    width: 70px;
    min-height: 31px;
    font-size: 10px;
  }

}


/* Fluid HUD sizing: viewport-relative with minimums for readability and maximums
   matching the original desktop layout. */
.hud-top-left {
  top: var(--hud-edge);
  left: var(--hud-edge);
}

.hud-top-right {
  top: var(--hud-edge);
  right: var(--hud-edge);
  gap: var(--hud-gap);
}

.hud-button {
  height: clamp(42px, 3.9vw, 56px);
  padding: 0 clamp(10px, 1.4vw, 20px);
  gap: clamp(5px, 0.65vw, 9px);
  border-radius: 0;
  font-size: clamp(13px, 1.25vw, 18px);
}

.hud-button:first-child {
  border-radius: var(--hud-radius) 0 0 var(--hud-radius);
}

.hud-button:last-child {
  border-radius: 0 var(--hud-radius) var(--hud-radius) 0;
}

.request-popups {
  width: clamp(205px, 18.75vw, 270px);
  margin-top: clamp(3px, 0.35vw, 5px);
  gap: var(--hud-gap);
}

.request-card {
  padding: clamp(7px, 0.7vw, 10px);
  border-radius: var(--hud-radius);
  font-size: clamp(10px, 0.84vw, 12px);
}

.leaderboard-panel,
.kill-panel {
  width: var(--side-panel-width);
  border-radius: var(--hud-radius);
}

.leaderboard-panel {
  padding: clamp(8px, 0.9vw, 13px) clamp(9px, 0.97vw, 14px) clamp(7px, 0.84vw, 12px);
}

.leaderboard-panel header {
  padding-bottom: clamp(5px, 0.62vw, 9px);
  font-size: clamp(10px, 0.98vw, 14px);
}

.leaderboard-panel ol {
  margin-top: clamp(4px, 0.55vw, 8px);
}

.leaderboard-panel li {
  grid-template-columns: clamp(17px, 1.6vw, 23px) 1fr auto;
  gap: clamp(3px, 0.42vw, 6px);
  padding: clamp(2px, 0.35vw, 5px) 0;
  font-size: clamp(10px, 1.05vw, 15px);
}

.kill-panel {
  min-height: clamp(38px, 3.5vw, 50px);
  padding: clamp(6px, 0.63vw, 9px) clamp(9px, 0.97vw, 14px);
  grid-template-columns: clamp(23px, 2.2vw, 32px) 1fr auto;
  gap: clamp(4px, 0.55vw, 8px);
}

.kill-panel .kill-icon {
  font-size: clamp(17px, 1.6vw, 23px);
}

.kill-panel > span:not(.kill-icon) {
  font-size: clamp(15px, 1.4vw, 20px);
}

.kill-panel small {
  font-size: clamp(9px, 0.84vw, 12px);
}

.ping-display {
  padding-right: clamp(0px, 0.14vw, 2px);
  font-size: clamp(14px, 1.4vw, 20px);
}

.minimap-panel {
  left: var(--hud-edge);
  bottom: var(--hud-edge);
  width: clamp(108px, 12.5vw, 180px);
  height: clamp(108px, 12.5vw, 180px);
  border-radius: var(--hud-radius);
}

.resource-panel {
  right: var(--hud-edge);
  bottom: var(--hud-edge);
  padding: clamp(7px, 0.84vw, 12px);
  gap: clamp(3px, 0.42vw, 6px);
  border-radius: var(--hud-radius);
}

.resource-panel > div {
  grid-template-columns: clamp(23px, 2.2vw, 32px) max-content max-content;
  gap: clamp(3px, 0.42vw, 6px);
}

.resource-panel img {
  width: clamp(23px, 2.2vw, 32px);
  height: clamp(23px, 2.2vw, 32px);
}

.resource-panel span {
  font-size: clamp(13px, 1.25vw, 18px);
}

.resource-panel small {
  font-size: clamp(8px, 0.84vw, 12px);
}

.inventory {
  bottom: var(--hud-edge);
  width: min(854px, calc(100vw - 340px));
  justify-content: center;
  gap: var(--inventory-gap);
}

.inventory-cell {
  flex: 1 1 0;
  width: auto;
  min-width: 0;
  max-width: 122px;
  padding: clamp(2px, 0.28vw, 4px);
  border-width: clamp(1.5px, 0.14vw, 2px);
  border-radius: var(--hud-radius);
}


.inventory-cell .slot-key {
  top: clamp(3px, 0.35vw, 5px);
  left: clamp(3px, 0.42vw, 6px);
  min-width: clamp(16px, 1.4vw, 20px);
  height: clamp(16px, 1.4vw, 20px);
  padding: 0 clamp(2px, 0.28vw, 4px);
  border-radius: clamp(3px, 0.28vw, 4px);
  font-size: clamp(8px, 0.84vw, 12px);
}

.inventory-cell .slot-limit {
  top: clamp(3px, 0.35vw, 5px);
  left: clamp(21px, 2vw, 29px);
  height: clamp(16px, 1.4vw, 20px);
  padding: 0 clamp(2px, 0.35vw, 5px);
  border-radius: clamp(3px, 0.28vw, 4px);
  font-size: clamp(7px, 0.7vw, 10px);
}

.inventory-cell .inventory-art {
  top: var(--inventory-art-top, 4.1%);
  width: var(--inventory-art-size, 55.7%);
  height: var(--inventory-art-size, 55.7%);
}

.inventory-cell .inventory-labels {
  right: clamp(2px, 0.21vw, 3px);
  bottom: clamp(5px, 0.56vw, 8px);
  left: clamp(2px, 0.21vw, 3px);
}

.inventory-cell .slot-name {
  font-size: clamp(10px, 1.1vw, 16px);
}


.inventory-cost-preview {
  top: var(--hud-edge);
  min-width: clamp(160px, 13.2vw, 190px);
  max-width: calc(100vw - 30px);
  padding: clamp(7px, 0.7vw, 10px) clamp(9px, 0.97vw, 14px) clamp(8px, 0.77vw, 11px);
}

.inventory-cost-title {
  margin-bottom: clamp(4px, 0.49vw, 7px);
  font-size: clamp(9px, 0.77vw, 11px);
}

.inventory-cost-items {
  gap: clamp(8px, 0.97vw, 14px);
}

.inventory-cost-item {
  grid-template-columns: clamp(21px, 1.88vw, 27px) auto;
  column-gap: clamp(3px, 0.42vw, 6px);
}

.inventory-cost-item img {
  width: clamp(21px, 1.88vw, 27px);
  height: clamp(21px, 1.88vw, 27px);
}

.inventory-cost-item b {
  font-size: clamp(10px, 0.9vw, 13px);
}

.inventory-cost-item small {
  font-size: clamp(7px, 0.56vw, 8px);
}

.toast-stack {
  top: var(--hud-edge);
  width: min(360px, calc(100vw - 30px));
}

.toast {
  min-width: clamp(160px, 13.2vw, 190px);
  padding: clamp(7px, 0.7vw, 10px) clamp(9px, 0.97vw, 14px) clamp(8px, 0.77vw, 11px);
  font-size: clamp(10px, 0.84vw, 12px);
}

.chat-composer {
  width: min(350px, 72vw);
}

.chat-composer input {
  height: clamp(38px, 3.05vw, 44px);
  padding-right: clamp(48px, 4.16vw, 60px);
  padding-left: clamp(10px, 0.97vw, 14px);
  font-size: clamp(12px, 1vw, 14px);
}

.chat-composer span {
  top: 50%;
  right: clamp(9px, 0.9vw, 13px);
  transform: translateY(-50%);
  font-size: clamp(8px, 0.7vw, 10px);
}

@media (max-width: 900px) {
  .inventory {
    width: 94vw;
  }

  .minimap-panel,
  .resource-panel {
    bottom: calc(13.43vw + 18px);
  }

  .minimap-panel {
    width: clamp(100px, 17vw, 145px);
    height: clamp(100px, 17vw, 145px);
  }

  .leaderboard-panel,
  .kill-panel {
    width: clamp(145px, 23vw, 181px);
  }

  .hotkey-rows {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .leaderboard-panel,
  .kill-panel {
    width: clamp(136px, 42vw, 155px);
  }

  .kill-panel {
    grid-template-columns: clamp(20px, 6vw, 25px) 1fr;
  }

  .kill-panel small,
  .resource-panel small {
    display: none;
  }

  .resource-panel > div {
    grid-template-columns: clamp(20px, 6.5vw, 25px) 1fr;
  }

  .resource-panel img {
    width: clamp(20px, 6.5vw, 25px);
    height: clamp(20px, 6.5vw, 25px);
  }

  .inventory-cell .slot-limit {
    left: clamp(18px, 6.6vw, 24px);
    padding-inline: 2px;
  }

  .inventory-cell .slot-name {
    font-size: clamp(8px, 2.7vw, 10px);
  }
}

@media (max-height: 520px) {
  .leaderboard-panel li {
    padding-block: 1px;
  }

  .leaderboard-panel header {
    padding-bottom: 3px;
  }

  .leaderboard-panel ol {
    margin-top: 3px;
  }

  .minimap-panel,
  .resource-panel {
    max-height: 30vh;
  }
  .leaderboard-panel ol {
    max-height: 23vh;
    overflow: hidden;
  }

  .resource-panel {
    grid-template-columns: repeat(2, max-content);
    column-gap: clamp(7px, 1.2vw, 12px);
    row-gap: 2px;
  }

  .resource-panel small {
    display: none;
  }

  .resource-panel > div {
    grid-template-columns: clamp(18px, 2.8vw, 23px) max-content;
  }

  .resource-panel img {
    width: clamp(18px, 2.8vw, 23px);
    height: clamp(18px, 2.8vw, 23px);
  }

  .minimap-panel {
    width: clamp(82px, 14vh, 100px);
    height: clamp(82px, 14vh, 100px);
  }
}
