* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  background: #0f1115;
  color: #f4f7fb;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

#app {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: default;
  touch-action: none;
}

body.menuMode {
  background: #11151b;
}

body.menuMode #app {
  background: #11151b;
}

body.menuMode #game {
  display: none;
}

#gameTitle {
  position: absolute;
  left: 50%;
  top: 0;
  z-index: 5;
  transform: translateX(-50%);
  color: #121820;
  padding: 9px 28px 12px;
  border: 1px solid rgba(18, 24, 32, 0.12);
  border-top: 0;
  border-radius: 0 0 12px 12px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 10px 28px rgba(17, 24, 34, 0.16);
  backdrop-filter: blur(10px);
  font-size: clamp(34px, 3.6vw, 48px);
  font-weight: 950;
  line-height: 0.95;
  letter-spacing: -0.04em;
  pointer-events: none;
}

#menuPanel {
  left: 50%;
  top: 50%;
  width: 390px;
  padding: 24px;
  transform: translate(-50%, -50%);
}

body.menuMode #menuPanel {
  width: min(420px, calc(100vw - 36px));
  padding: 28px 30px 30px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: #f6f8fb;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.38);
  backdrop-filter: none;
}

.menuPreview {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-bottom: 14px;
}

.menuPreview img {
  width: 44px;
  height: 44px;
}

.menuPreview .menuPlayer {
  width: 58px;
  height: 58px;
}

.menuBrand {
  color: #ffffff;
  font-size: 42px;
  font-weight: 950;
  line-height: 1;
  text-align: center;
}

body.menuMode .menuBrand {
  color: #121820;
  font-size: clamp(43px, 10vw, 56px);
  letter-spacing: -0.06em;
}

.menuRules {
  display: grid;
  gap: 10px;
  margin: 18px 0 20px;
  padding: 0;
  border: 0;
  border-radius: 0;
  color: #475260;
  background: transparent;
  font-size: 12px;
  font-weight: 850;
  line-height: 1.2;
}

.controlGrid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.controlCard {
  display: grid;
  min-height: 88px;
  align-content: center;
  justify-items: center;
  gap: 9px;
  padding: 10px 9px;
  border: 1px solid rgba(18, 24, 32, 0.08);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 8px 18px rgba(18, 24, 32, 0.06);
}

.controlCard > span {
  color: #121820;
  font-size: 11px;
  font-weight: 950;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.singleKeyControl {
  display: flex;
  align-items: center;
  justify-content: center;
}

kbd {
  display: inline-grid;
  place-items: center;
  min-width: 26px;
  height: 24px;
  padding: 0 6px;
  border: 1px solid rgba(18, 24, 32, 0.22);
  border-radius: 6px;
  color: #121820;
  background: linear-gradient(#ffffff, #e8edf4);
  box-shadow: inset 0 -2px 0 rgba(18, 24, 32, 0.14), 0 2px 5px rgba(18, 24, 32, 0.12);
  font: 950 12px/1 Inter, ui-sans-serif, system-ui, sans-serif;
}

.actionKeys {
  display: flex;
  align-items: center;
  gap: 8px;
}

.controlKey {
  min-width: 132px;
  height: 34px;
  padding: 0 10px;
  font-size: 12px;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

#joinForm {
  display: grid;
  gap: 10px;
}

#joinForm label {
  color: #dce6f2;
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
}

body.menuMode #joinForm label {
  color: #596574;
}

#nameInput {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  outline: none;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
}

body.menuMode #nameInput {
  border-color: #d5dce5;
  color: #121820;
  background: #ffffff;
}

#nameInput:focus {
  border-color: #8ee4ff;
}

#joinForm button {
  height: 42px;
}

body.menuMode #joinForm button {
  color: #ffffff;
  background: #121820;
}

body.menuMode #joinForm button:hover {
  background: #26313f;
}

#menuStatus {
  min-height: 18px;
  margin-top: 12px;
  color: #ffc96b;
  font-size: 13px;
  text-align: center;
}

body.menuMode #menuStatus {
  color: #876019;
}

.panel {
  position: absolute;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(14, 18, 24, 0.74);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(14px);
}

#chat {
  left: 18px;
  top: 18px;
  width: 340px;
  height: 280px;
  display: flex;
  flex-direction: column;
  padding: 10px;
}

#chatMessages {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 5px;
  color: #d7dee9;
  font-size: 13px;
  line-height: 1.3;
}

.chatLine {
  overflow-wrap: anywhere;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.32);
}

.chatLine.system {
  color: #ffc96b;
}

.chatName {
  color: #86d5ff;
  font-weight: 700;
}

#chatForm {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

#chatInput {
  min-width: 0;
  flex: 1;
  height: 34px;
  padding: 0 10px;
  border: 1px solid rgba(255, 255, 255, 0.17);
  border-radius: 6px;
  outline: none;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
}

#chatInput:focus {
  border-color: #7bc9ff;
}

button {
  height: 34px;
  border: 0;
  border-radius: 6px;
  padding: 0 12px;
  color: #071018;
  background: #8ee4ff;
  font-weight: 800;
  cursor: pointer;
}

button:hover {
  background: #b4efff;
}

button.locked,
button:disabled {
  color: rgba(255, 255, 255, 0.45);
  background: rgba(255, 255, 255, 0.1);
  cursor: default;
}

#hud {
  right: 18px;
  top: 18px;
  width: 270px;
  padding: 14px;
}

#areaLine {
  margin-top: 0;
  color: #dce6f2;
  font-size: 14px;
  font-weight: 700;
}

#statLine,
#cooldownLine {
  margin-top: 6px;
  color: #aab8c8;
  font-size: 13px;
}

#lobbyPanel {
  right: 18px;
  bottom: 18px;
  width: 330px;
  padding: 14px;
}

.panelTitle {
  margin: 2px 0 9px;
  color: #ffffff;
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
}

.buttonGrid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-bottom: 14px;
}

.buttonGrid.compact {
  grid-template-columns: repeat(7, 1fr);
  margin-bottom: 0;
}

.buttonGrid.compact button {
  padding: 0;
}

.abilityList {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.abilityHint {
  color: #8ee4ff;
  font-size: 12px;
  font-weight: 800;
}

.abilityStats {
  display: grid;
  gap: 7px;
  margin-bottom: 0;
}

.abilityStats div {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  padding: 7px 9px;
  color: #d8e2ee;
  background: rgba(255, 255, 255, 0.07);
  font-size: 12px;
  font-weight: 800;
}

.abilityItem {
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 6px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.07);
}

.abilityItem.active {
  border-color: rgba(142, 228, 255, 0.72);
  background: rgba(142, 228, 255, 0.14);
}

.abilityItem.locked {
  opacity: 0.48;
}

.abilityName {
  color: #ffffff;
  font-size: 12px;
  font-weight: 900;
}

.abilityText {
  margin-top: 3px;
  color: #b9c6d4;
  font-size: 12px;
  line-height: 1.25;
}

#deathPanel {
  left: 50%;
  top: 50%;
  width: 330px;
  transform: translate(-50%, -50%);
  padding: 20px;
  text-align: center;
}

.deathTitle {
  color: #ff617b;
  font-size: 28px;
  font-weight: 950;
}

#deathText {
  margin: 10px 0 18px;
  color: #d7dee9;
  font-size: 14px;
}

.hidden {
  display: none !important;
}


@media (max-width: 460px) {
  body.menuMode #menuPanel {
    padding: 22px 18px 24px;
  }

  .controlGrid {
    grid-template-columns: 1fr;
  }

  .controlCard {
    min-height: 72px;
    grid-template-columns: auto 1fr;
    justify-items: start;
    padding: 10px 12px;
  }

  .actionCard {
    grid-template-columns: auto 1fr;
  }
}
