:root {
  color-scheme: dark;
  --bg: #08090d;
  --panel: rgba(17, 19, 25, 0.9);
  --panel-strong: rgba(23, 25, 33, 0.96);
  --line: rgba(255, 255, 255, 0.14);
  --muted: #aeb6c4;
  --text: #f7f8fb;
  --green: #44e0a2;
  --pink: #ff5c91;
  --gold: #ffd15a;
  --cyan: #4eddf0;
  --danger: #ff604d;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: none;
  scrollbar-width: thin;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  letter-spacing: 0;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

button,
input,
select {
  font: inherit;
}

input,
select,
textarea {
  -webkit-touch-callout: default;
  -webkit-user-select: text;
  user-select: text;
}

button {
  border: 0;
  color: var(--text);
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

#shell {
  position: fixed;
  inset: 0;
  overflow: hidden;
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  background:
    radial-gradient(circle at 18% 24%, rgba(255, 92, 145, 0.14), transparent 34%),
    radial-gradient(circle at 76% 74%, rgba(68, 224, 162, 0.12), transparent 32%),
    #08090d;
}

#arena {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.hidden {
  display: none !important;
}

.menu,
.death-panel {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(460px, calc(100vw - 56px));
  max-height: calc(100vh - 56px);
  padding: 20px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(27, 29, 38, 0.96), rgba(12, 13, 18, 0.94));
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.38);
  backdrop-filter: blur(18px);
  transform: translate(-50%, -50%);
}

.menu {
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.death-panel {
  display: grid;
  justify-items: stretch;
  gap: 10px;
  width: min(420px, calc(100vw - 40px));
  max-height: calc(100vh - 28px);
  padding: 16px 20px;
  overflow-y: auto;
  text-align: center;
}

.menu-top {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 14px;
  align-items: center;
  margin-bottom: 18px;
}

.mark {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 32%, #ffffff 0 7px, transparent 8px),
    conic-gradient(from 210deg, var(--green), var(--gold), var(--pink), var(--cyan), var(--green));
  box-shadow: 0 0 34px rgba(68, 224, 162, 0.28);
}

.mark::after {
  content: "";
  position: absolute;
  inset: 16px 10px 12px 22px;
  border: 4px solid #08090d;
  border-left: 0;
  border-radius: 50%;
  transform: rotate(-22deg);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 30px;
  line-height: 1;
  font-weight: 800;
}

h2 {
  margin-bottom: 8px;
  font-size: 25px;
}

#server-status,
#death-detail {
  margin-top: 8px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.35;
}

.death-head {
  display: grid;
  gap: 3px;
}

.death-head h2 {
  margin-bottom: 0;
}

.death-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.death-stats div {
  display: grid;
  gap: 5px;
  min-width: 0;
  min-height: 58px;
  padding: 9px 10px;
  align-content: center;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.065);
}

.death-stats div:first-child {
  grid-column: 1 / -1;
  min-height: 72px;
  background: linear-gradient(135deg, rgba(68, 224, 162, 0.18), rgba(255, 209, 90, 0.14));
}

.death-stats span {
  min-width: 0;
  overflow: hidden;
  color: var(--gold);
  font-size: 22px;
  font-weight: 900;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.death-stats div:first-child span {
  font-size: 34px;
}

.death-stats small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  line-height: 1.1;
}

#again-button {
  justify-self: center;
  width: min(176px, 100%);
}

.ad-slot {
  display: grid;
  place-content: center;
  justify-self: center;
  width: min(300px, 100%);
  height: 250px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.025)),
    rgba(0, 0, 0, 0.2);
  color: rgba(247, 248, 251, 0.72);
}

.ad-slot span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.ad-slot strong {
  margin-top: 5px;
  color: rgba(247, 248, 251, 0.9);
  font-size: 22px;
  font-weight: 900;
}

#join-form {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.language-row {
  display: grid;
  grid-template-columns: 1fr 132px;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.language-row select {
  width: 100%;
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-weight: 800;
}

.language-row select:focus {
  border-color: rgba(78, 221, 240, 0.7);
  box-shadow: 0 0 0 3px rgba(78, 221, 240, 0.12);
}

.language-row select option {
  background: #f7f8fb;
  color: #11131a;
  font-weight: 700;
}

.language-row select option:checked {
  background: #9dcbf3;
  color: #07100e;
}

.field input,
.chat-form input {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.field input {
  height: 44px;
  padding: 0 13px;
  font-size: 16px;
}

.field input:focus,
.chat-form input:focus {
  border-color: rgba(78, 221, 240, 0.7);
  box-shadow: 0 0 0 3px rgba(78, 221, 240, 0.12);
}

.skin-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.skin-head button {
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
}

.skin-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
  min-width: 0;
  max-height: min(300px, calc(100vh - 380px));
  min-height: 178px;
  padding-right: 4px;
  overflow: auto;
  scrollbar-width: thin;
}

.skin-card {
  display: grid;
  grid-template-rows: 54px auto;
  gap: 6px;
  min-width: 0;
  min-height: 92px;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.065);
  text-align: left;
  touch-action: manipulation;
  transition:
    border-color 120ms ease,
    transform 120ms ease,
    background 120ms ease;
}

.skin-card:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.24);
  background: rgba(255, 255, 255, 0.1);
}

.skin-card[aria-selected="true"] {
  border-color: var(--gold);
  box-shadow: inset 0 0 0 1px rgba(255, 209, 90, 0.75);
}

.skin-card canvas {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: 54px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.18);
}

.skin-card span {
  min-width: 0;
  overflow: hidden;
  color: #f4f6fb;
  font-size: 12px;
  font-weight: 750;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.primary {
  min-height: 46px;
  padding: 0 18px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--green), var(--cyan) 48%, var(--gold));
  color: #07100e;
  font-size: 15px;
  font-weight: 900;
  box-shadow: 0 12px 30px rgba(68, 224, 162, 0.2);
}

.hud {
  pointer-events: none;
}

.hud button,
.hud input,
.menu,
.death-panel {
  pointer-events: auto;
}

.stats {
  position: absolute;
  left: 18px;
  top: 18px;
  display: grid;
  grid-template-columns: auto auto;
  gap: 1px 8px;
  min-width: 142px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(12, 13, 18, 0.68);
  backdrop-filter: blur(12px);
}

.stats span {
  color: var(--gold);
  font-size: 20px;
  font-weight: 900;
  line-height: 1;
}

.stats small {
  align-self: end;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.1;
}

.leaderboard {
  position: absolute;
  right: 18px;
  top: 18px;
  width: min(292px, calc(100vw - 36px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(12, 13, 18, 0.72);
  backdrop-filter: blur(12px);
  overflow: hidden;
}

.round {
  display: grid;
  grid-template-columns: 74px 1fr;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.11);
  background: rgba(255, 255, 255, 0.04);
}

.round strong {
  color: var(--green);
  font-size: 19px;
  font-variant-numeric: tabular-nums;
  font-weight: 900;
}

.round span {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#leader-list {
  display: grid;
  gap: 2px;
  margin: 0;
  padding: 8px;
  list-style: none;
}

#leader-list li {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-height: 28px;
  padding: 0 7px;
  border-radius: 6px;
  color: #edf1f8;
  font-size: 13px;
  font-weight: 750;
}

#leader-list li.self {
  background: rgba(68, 224, 162, 0.16);
}

#leader-list .rank {
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}

#leader-list .name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#leader-list .score {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.minimap-wrap {
  position: absolute;
  right: 18px;
  bottom: 18px;
  width: 180px;
  height: 180px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(12, 13, 18, 0.74);
  backdrop-filter: blur(12px);
}

#minimap {
  width: 100%;
  height: 100%;
  border-radius: 6px;
}

.chat {
  position: absolute;
  left: 18px;
  bottom: 18px;
  width: min(420px, calc(100vw - 232px));
  min-width: 280px;
  pointer-events: auto;
}

.chat-log {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 6px;
  height: min(304px, calc(100vh - 190px));
  margin-bottom: 8px;
  overflow: hidden;
  mask-image: linear-gradient(transparent, #000 22%, #000);
}

.chat-line {
  width: fit-content;
  max-width: 100%;
  padding: 6px 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(8, 9, 13, 0.58);
  color: #f7f8fb;
  font-size: 12px;
  line-height: 1.25;
  overflow-wrap: anywhere;
  backdrop-filter: blur(10px);
}

.chat-line.system {
  color: #ffe09a;
}

.chat-line strong {
  color: var(--cyan);
}

.chat-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 78px;
  gap: 8px;
}

.chat-form input {
  height: 38px;
  padding: 0 11px;
  background: rgba(12, 13, 18, 0.72);
}

.chat-form button {
  min-width: 0;
  height: 38px;
  border-radius: 8px;
  background: rgba(255, 209, 90, 0.94);
  color: #1a1402;
  font-size: 13px;
  font-weight: 900;
}

.toast {
  position: absolute;
  left: 50%;
  top: 22px;
  max-width: min(520px, calc(100vw - 40px));
  padding: 11px 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(17, 19, 25, 0.9);
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
  line-height: 1.25;
  text-align: center;
  transform: translateX(-50%);
  backdrop-filter: blur(12px);
}

@media (max-width: 760px) {
  .menu {
    left: 10px;
    right: 10px;
    top: max(10px, env(safe-area-inset-top));
    bottom: max(10px, env(safe-area-inset-bottom));
    width: auto;
    max-height: none;
    padding: 12px;
    overflow-y: auto;
    overscroll-behavior: contain;
    transform: none;
  }

  #join-form {
    gap: 10px;
  }

  .death-panel {
    left: 14px;
    right: 14px;
    width: auto;
    max-height: calc(100vh - 28px);
    padding: 16px;
    transform: translateY(-50%);
  }

  h1 {
    font-size: 25px;
  }

  .menu-top {
    grid-template-columns: 48px 1fr;
    gap: 11px;
    margin-bottom: 12px;
  }

  .mark {
    width: 48px;
    height: 48px;
  }

  .skin-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-height: 34vh;
    min-height: 112px;
    padding-right: 2px;
  }

  .skin-card {
    grid-template-rows: 44px auto;
    min-height: 78px;
    padding: 6px;
  }

  .skin-card canvas {
    height: 44px;
  }

  #join-button {
    position: sticky;
    bottom: 0;
    z-index: 2;
  }

  .stats {
    left: 10px;
    top: 10px;
  }

  .leaderboard {
    right: 10px;
    top: 10px;
    width: min(236px, calc(100vw - 170px));
  }

  #leader-list li {
    grid-template-columns: 20px minmax(0, 1fr);
  }

  #leader-list .score {
    display: none;
  }

  .minimap-wrap {
    right: 10px;
    bottom: 10px;
    width: 128px;
    height: 128px;
  }

  .chat {
    left: 10px;
    bottom: 10px;
    width: calc(100vw - 158px);
    min-width: 0;
  }

  .chat-log {
    height: min(214px, calc(100vh - 220px));
  }
}

@media (max-width: 480px) {
  .language-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .field input {
    height: 42px;
  }

  .chat {
    width: calc(100vw - 150px);
  }

  .leaderboard {
    display: block;
    right: 8px;
    top: max(8px, env(safe-area-inset-top));
    width: min(190px, calc(100vw - 166px));
  }

  .round {
    grid-template-columns: 54px minmax(0, 1fr);
    gap: 6px;
    padding: 7px 8px;
  }

  .round strong {
    font-size: 13px;
  }

  .round span {
    font-size: 10px;
  }

  #leader-list {
    gap: 1px;
    padding: 5px;
  }

  #leader-list li {
    grid-template-columns: 16px minmax(0, 1fr);
    gap: 4px;
    min-height: 22px;
    padding: 0 5px;
    font-size: 10px;
  }

  #leader-list li:nth-child(n + 6) {
    display: none;
  }

  .skin-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-height: 32vh;
    min-height: 96px;
  }

  .chat-form {
    grid-template-columns: 1fr;
  }

  .chat-form button {
    display: none;
  }
}

@media (max-width: 370px) {
  .leaderboard {
    width: min(168px, calc(100vw - 158px));
  }

  #leader-list li:nth-child(n + 4) {
    display: none;
  }
}
