* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}
body {
  height: 100dvh;
  display: grid;
  grid-template-rows: 64px minmax(0, 1fr) 34px;
  background: #0c121b;
  color: #dce7ef;
  font:
    14px "Segoe UI",
    sans-serif;
}
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 22px;
  border-bottom: 1px solid #2d3947;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand > span {
  color: #e6b27b;
  font-size: 34px;
}
h1 {
  font-size: 21px;
  font-weight: 600;
  margin: 0;
}
h1 small {
  display: inline-block;
  font-size: 9px;
  color: #8094a6;
  letter-spacing: 2px;
  margin-left: 18px;
}
#connection {
  font-size: 11px;
  color: #8bd3bf;
}
main {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 14px;
  padding: 14px;
}
.viewport {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border: 1px solid #2b3947;
  border-radius: 9px;
  background: #111b26;
}
canvas {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
  touch-action: none;
}
.map-head {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  display: flex;
  justify-content: space-between;
  pointer-events: none;
  font-size: 10px;
  letter-spacing: 1.5px;
  color: #a3b4c5;
}
.map-help {
  position: absolute;
  bottom: 12px;
  left: 14px;
  pointer-events: none;
  color: #a4b5c6;
  background: #101a24d9;
  padding: 7px 10px;
  border-radius: 4px;
  font-size: 11px;
}
.hint {
  position: absolute;
  bottom: 48px;
  left: 14px;
  max-width: 90%;
  padding: 10px 14px;
  background: #101b29ef;
  border: 1px solid #405366;
  border-radius: 5px;
  pointer-events: none;
  font-size: 12px;
  white-space: pre-line;
  line-height: 1.6;
}
aside {
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
  padding-right: 3px;
}
.card {
  padding: 16px;
  background: #131e29;
  border: 1px solid #2c3b4b;
  border-radius: 8px;
  margin-bottom: 12px;
}
h2 {
  font-size: 11px;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: #91a6ba;
  margin: 0 0 14px;
}
.resource {
  display: flex;
  gap: 9px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid #ffffff08;
}
.resource:last-child {
  border: 0;
}
.resource i {
  width: 9px;
  height: 9px;
  transform: rotate(45deg);
}
.resource strong {
  margin-left: auto;
  font-size: 21px;
  font-weight: 500;
}
.modes {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
}
button {
  font: inherit;
  color: #aebed0;
  background: #192635;
  border: 1px solid #334456;
  border-radius: 5px;
  cursor: pointer;
  padding: 9px 10px;
  text-align: left;
}
button:hover {
  border-color: #8ca4b9;
}
button.active {
  background: #382f24;
  border-color: #bd925d;
  color: #ffcf95;
}
button:focus-visible {
  outline: 2px solid #86dfe4;
}
.modes button {
  flex: 1;
  font-size: 12px;
}
.category {
  width: 100%;
  display: flex;
  justify-content: space-between;
  margin-top: 7px;
}
.items {
  display: grid;
  gap: 5px;
  padding: 7px 0 4px 10px;
}
.items[hidden] {
  display: none;
}
.building {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 13px;
}
.building small {
  color: #93a8b9;
  font-size: 11px;
}
#blueprint {
  font-size: 12px;
  line-height: 1.7;
  color: #a9bdce;
  margin-top: 14px;
}
#rotate {
  margin-top: 10px;
  width: 100%;
  text-align: center;
  font-size: 12px;
}
.note {
  padding: 6px 10px;
  color: #7e95aa;
  font-size: 11px;
  line-height: 1.7;
}
.note strong {
  font-size: 12px;
  color: #b5c6d6;
}
footer {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 0 20px;
  border-top: 1px solid #2c3946;
  font-size: 10px;
  color: #7e93a8;
}
#status {
  color: #c3d1dc;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
@media (max-width: 760px) {
  body {
    grid-template-rows: 54px minmax(0, 1fr) 34px;
  }
  main {
    grid-template-columns: minmax(0, 1fr) 210px;
    gap: 7px;
    padding: 7px;
  }
  .card {
    padding: 10px;
  }
  header {
    padding: 0 12px;
  }
  h1 {
    font-size: 17px;
  }
  h1 small {
    display: none;
  }
  .map-help {
    font-size: 9px;
    left: 5px;
    right: 5px;
  }
  .map-head {
    left: 8px;
    right: 8px;
    font-size: 9px;
  }
  .modes {
    flex-direction: column;
  }
  #connection {
    font-size: 9px;
  }
}

.bot-switch { display: block; margin-top: 14px; font-size: 12px; cursor: pointer; }
#bot-status, #enemy-position { font-size: 12px; line-height: 1.5; color: #c5d3dd; }
#core-health { color: #92ddd0; }
#next-wave:disabled { opacity: .45; cursor: default; }

/* Вход, лобби и результат отделены от игрового поля. */
[hidden] { display: none !important; }
.menu-shell { overflow: auto; display: grid; place-items: center; padding: 24px; }
.menu-panel { width: min(620px, 100%); padding: 30px; border: 1px solid #354655; border-radius: 16px; background: #14202c; box-shadow: 0 20px 70px #0005; }
.menu-panel h2 { margin: 8px 0 18px; font-size: 27px; letter-spacing: 0; text-transform: none; color: #e1ecef; }
.menu-panel p { line-height: 1.6; }
.eyebrow { font-size: 11px; letter-spacing: 1.7px; color: #e1af78; }
.menu-panel label { display: block; margin: 16px 0 8px; color: #c3d2dd; }
.menu-panel input { display: block; width: 100%; border: 1px solid #405466; border-radius: 7px; background: #0e1822; color: #edf3f6; font: inherit; padding: 12px; margin-bottom: 14px; }
.menu-panel input:focus { outline: 2px solid #85cdbb; }
.menu-panel button { padding: 12px 16px; }
button.primary { color: #13241f; background: #9bdac6; border-color: #9bdac6; font-weight: 600; }
button:disabled { opacity: .5; cursor: default; }
.join-line { margin-top: 24px; padding-top: 8px; border-top: 1px solid #344452; }
#join-code { text-transform: uppercase; letter-spacing: 4px; }
.muted { color: #9aafbf; font-size: 13px; }
.invitation { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.invitation span { color: #9aafbf; font-size: 12px; }
#room-code { display: block; font-size: 32px; letter-spacing: 6px; color: #a9e3cf; margin-top: 6px; }
#player-list { padding: 0; list-style: none; }
#player-list li { display: flex; align-items: center; gap: 12px; padding: 14px 0; border-bottom: 1px solid #2a3b49; }
#player-list i { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
#player-list small { margin-left: auto; color: #94b0bc; }
#server-addresses a { display: block; color: #a9cce9; margin: 5px 0; overflow-wrap: anywhere; }
.room-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 20px; }
#lobby-message, #result-message { color: #efbc86; min-height: 20px; }
.result-overlay { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; background: #080e16d9; padding: 24px; }
.result-overlay .menu-panel { text-align: center; }
@media(max-width:600px) { .menu-panel { padding: 20px; } .menu-shell { padding: 12px; } }
