* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  background: #1b1f24;
  color: #f8f8f8;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

body.match-loading #game,
body.match-loading #minimap,
body.match-loading #hud,
body.match-loading #bottom-bar,
body.match-loading #player-list,
body.match-loading #game-chat,
body.match-loading #cheat-bar,
body.match-loading #attack-notify,
body.match-loading #research-notify,
body.match-loading #age-notify {
  visibility: hidden !important;
}

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

#game {
  display: block;
  width: 100vw;
  height: 100vh;
}

#minimap {
  position: fixed;
  right: clamp(8px, 1.4vw, 16px);
  bottom: max(130px, 14vh);
  width: clamp(150px, 18vw, 200px);
  height: clamp(150px, 18vw, 200px);
  border: 2px solid rgba(140, 140, 140, 0.9);
  border-radius: 8px;
  background: rgba(18, 20, 24, 0.9);
  z-index: 30;
}

#overlay {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, rgba(13, 23, 38, 0.9), rgba(30, 36, 24, 0.9));
  display: grid;
  place-items: center;
  z-index: 10;
}

#overlay.hidden {
  display: none;
}

.panel {
  background: rgba(18, 20, 24, 0.9);
  padding: 32px 40px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  text-align: center;
  width: min(420px, 90vw);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  position: relative;
}

.main-menu-shell {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  max-width: 98vw;
}

.main-menu-shell > .panel {
  margin: 0;
}

.panel.lobby-room-active {
  width: min(980px, 96vw);
}

.panel.match-loading-active {
  width: min(980px, 96vw);
}

.panel.match-loading-active > :not(#match-loading-screen) {
  display: none !important;
}

.level-panel {
  position: absolute;
  top: 50%;
  right: calc(100% + 12px);
  transform: translateY(-50%);
  width: min(220px, 26vw);
  min-width: 180px;
  background: rgba(18, 20, 24, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  padding: 14px 12px;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.3);
  text-align: left;
}

.level-panel-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: rgba(255, 255, 255, 0.62);
}

.level-panel-level-row {
  margin-top: 4px;
  margin-bottom: 8px;
}

#level-panel-level {
  font-size: 34px;
  font-weight: 700;
  color: #b6d5ff;
  line-height: 1;
}

.level-panel-xp-row,
.level-panel-total-row {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.82);
}

.level-panel-guest-hint {
  margin-top: 9px;
  font-size: 12px;
  color: rgba(255, 214, 140, 0.95);
}

.level-panel-progress {
  margin: 8px 0;
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.18);
  overflow: hidden;
}

.level-panel-progress-fill {
  width: 0%;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #7ea8ff, #a2ffd1);
}

.panel h1 {
  margin: 0 0 12px;
  font-size: 28px;
  letter-spacing: 0.5px;
}

.panel h2 {
  margin: 0 0 12px;
  font-size: 22px;
  letter-spacing: 0.4px;
}

.panel p {
  margin: 0 0 20px;
  color: rgba(255, 255, 255, 0.7);
}

.panel button {
  background: #2c7be5;
  color: white;
  border: none;
  padding: 10px 22px;
  border-radius: 999px;
  font-size: 16px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.panel button.secondary {
  background: rgba(255, 255, 255, 0.08);
  color: #e8edf5;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.account-corner {
  position: fixed;
  top: 12px;
  right: 12px;
  display: flex;
  align-items: flex-end;
  flex-direction: column;
  gap: 8px;
  z-index: 20;
}

.account-corner-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
}

.account-corner-signed {
  display: flex;
  align-items: center;
  gap: 8px;
}

#account-logged-in-display {
  width: min(230px, 44vw);
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(10, 12, 16, 0.7);
  color: #f8f8f8;
  text-align: left;
}

#auth-modal .modal-content input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(10, 12, 16, 0.7);
  color: #f8f8f8;
}

#auth-modal .modal-content input::placeholder {
  color: rgba(255, 255, 255, 0.42);
}

.auth-modal-feedback {
  min-height: 22px;
  border-radius: 8px;
  border: 1px solid rgba(255, 120, 120, 0.35);
  background: rgba(111, 18, 18, 0.4);
  color: #ffd7d7;
  padding: 4px 8px;
  font-size: 13px;
  display: flex;
  align-items: center;
}

.auth-modal-feedback[data-tone="info"] {
  color: #d6ecff;
  background: rgba(18, 50, 90, 0.4);
  border-color: rgba(90, 160, 255, 0.35);
}

.auth-modal-feedback[data-tone="ok"] {
  color: #d7ffe5;
  background: rgba(18, 90, 40, 0.4);
  border-color: rgba(120, 255, 170, 0.35);
}

.lobby-create {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

#lobby-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
  max-height: 220px;
  overflow-y: auto;
}

#match-loading-screen {
  margin-top: 6px;
  text-align: left;
}

.match-loading-progress {
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.18);
  overflow: hidden;
  margin: 0 0 12px;
}

.match-loading-progress-fill {
  width: 0%;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #7ea8ff, #a2ffd1);
  transition: width 0.08s linear;
}

.match-loading-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.match-loading-player {
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(10, 12, 16, 0.76);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.match-loading-player-title {
  font-size: 14px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.92);
}

.match-loading-player-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.match-loading-player-group-title {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.68);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.match-loading-choice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.match-loading-choice-grid.single {
  grid-template-columns: 1fr;
}

.match-loading-choice-card {
  padding: 8px 10px;
  min-height: 42px;
}

.match-loading-choice-card .loadout-option-body strong {
  font-size: 13px;
}

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(8, 10, 14, 0.65);
  z-index: 30;
}

.modal-content {
  background: rgba(18, 20, 24, 0.95);
  padding: 24px 28px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  width: min(360px, 90vw);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-content p {
  margin: 0;
  color: rgba(255, 255, 255, 0.7);
}

.modal-content input {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(10, 12, 16, 0.7);
  color: #f8f8f8;
}

.modal-content input::placeholder {
  color: rgba(255, 255, 255, 0.4);
}

.loadout-modal-content {
  width: min(980px, 96vw);
  text-align: left;
  max-height: min(82vh, 760px);
  overflow-y: auto;
}

.how-to-play-modal-content {
  width: min(980px, 96vw);
  text-align: left;
  max-height: min(82vh, 760px);
  overflow-y: auto;
}

.how-to-play-sections {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.how-to-play-section {
  padding: 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(10, 12, 16, 0.7);
}

.how-to-play-section-wide {
  grid-column: 1 / -1;
}

.how-to-play-section h3 {
  margin: 0 0 8px;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.92);
}

.how-to-play-section ul {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: rgba(255, 255, 255, 0.75);
  font-size: 13px;
}

.loadout-sections {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 12px;
}

.loadout-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.loadout-section-landmarks {
  grid-column: 1 / -1;
}

.loadout-section-title {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: rgba(255, 255, 255, 0.72);
}

.loadout-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#loadout-landmark-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

#view-loadout-landmark-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.loadout-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(10, 12, 16, 0.7);
  cursor: pointer;
}

.loadout-option-disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.loadout-option-readonly {
  cursor: default;
}

.loadout-option input {
  margin-top: 2px;
  accent-color: #2c7be5;
}

.loadout-landmark-meta {
  grid-column: 1 / -1;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.78);
  margin-bottom: 2px;
}

.loadout-option-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.loadout-option-body strong {
  font-size: 14px;
}

.loadout-option-body span {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.72);
}

#match-result-modal .modal-content {
  text-align: center;
}

#match-result-title.match-result-victory {
  color: #6fe3a0;
}

#match-result-title.match-result-defeat {
  color: #ff9b9b;
}

#match-result-summary {
  color: rgba(255, 255, 255, 0.82);
}

.hidden {
  display: none !important;
}

#lobby-room-players {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.lobby-room-content {
  display: flex;
  align-items: stretch;
  gap: 14px;
  margin-top: 10px;
  text-align: left;
}

.lobby-room-main {
  flex: 0 0 560px;
  min-width: 0;
}

.lobby-player {
  display: flex;
  justify-content: space-between;
  align-items: stretch;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(12, 16, 22, 0.8);
  min-height: 122px;
}

.lobby-player-main {
  min-width: 0;
  flex: 1 1 100%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
}

.lobby-player.empty {
  border-style: dashed;
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(12, 16, 22, 0.45);
}

.lobby-player-actions {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  flex-wrap: wrap;
  gap: 8px;
}

.lobby-player.self {
  border-color: rgba(46, 204, 113, 0.85);
  background: rgba(24, 70, 42, 0.75);
  box-shadow: inset 0 0 0 1px rgba(46, 204, 113, 0.35);
}

.lobby-player-main span {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.6);
}

.lobby-view-loadout-btn {
  flex: 1 1 120px;
  min-width: 0;
  max-width: 100%;
  white-space: normal;
  line-height: 1.2;
  padding: 6px 12px !important;
  font-size: 12px !important;
}

.lobby-entry {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(12, 16, 22, 0.8);
}

.lobby-entry .meta {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  text-align: left;
}

.lobby-entry .meta span {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.6);
}

.lobby-entry button {
  padding: 6px 14px;
  font-size: 14px;
}

.button-row {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.lobby-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  margin: 12px 0 6px;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.75);
}

.lobby-toggle input {
  accent-color: #f1c40f;
}

.lobby-colors {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin: 10px 0 4px;
}

.lobby-teams {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin: 6px 0 8px;
}

.lobby-select-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  max-width: 260px;
  margin: 0 auto;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.85);
}

.lobby-select-row select {
  flex: 1;
  min-width: 0;
  padding: 7px 10px;
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(10, 12, 16, 0.7);
  color: #f0f4f8;
}

.lobby-ai-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin: 8px 0 6px;
}

#lobby-add-ai {
  min-width: 160px;
}

.lobby-ai-difficulty-select {
  flex: 1 1 120px;
  min-width: 0;
  max-width: 100%;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(10, 12, 16, 0.7);
  color: #f0f4f8;
  font-size: 12px;
}

.lobby-remove-ai-btn {
  padding: 6px 10px !important;
  min-width: 0 !important;
  flex: 1 1 100px;
  font-size: 12px !important;
}

.lobby-remove-player-btn {
  padding: 6px 10px !important;
  min-width: 0 !important;
  flex: 1 1 100px;
  font-size: 12px !important;
}

.team-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.85);
  font-size: 12px;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease;
}

.team-chip:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.12);
}

.team-chip.selected {
  outline: 2px solid rgba(241, 196, 15, 0.7);
}

.color-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.85);
  font-size: 12px;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease;
}

.color-chip:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.12);
}

.color-chip.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.color-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.4);
}

.color-chip.selected {
  outline: 2px solid rgba(241, 196, 15, 0.7);
}

.button-row button {
  min-width: 140px;
}

.lobby-chat-panel {
  flex: 1 1 auto;
  min-width: 320px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  background: rgba(10, 12, 16, 0.72);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.lobby-chat-title {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.78);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.lobby-chat-log {
  flex: 1 1 auto;
  min-height: 240px;
  max-height: 320px;
  overflow-y: auto;
  border-radius: 10px;
  background: rgba(6, 8, 12, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 8px;
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.lobby-chat-line {
  display: flex;
  gap: 6px;
  line-height: 1.35;
  color: rgba(255, 255, 255, 0.9);
}

.lobby-chat-scope {
  color: rgba(130, 185, 255, 0.9);
  font-weight: 600;
  flex: 0 0 auto;
}

.lobby-chat-prefix {
  color: rgba(142, 190, 255, 0.92);
  font-weight: 600;
  flex: 0 0 auto;
}

.lobby-chat-empty {
  color: rgba(255, 255, 255, 0.45);
  font-style: italic;
}

.lobby-chat-form {
  display: flex;
  gap: 8px;
}

.lobby-chat-form input {
  flex: 1;
  min-width: 0;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(8, 10, 14, 0.8);
  color: #f8f8f8;
  padding: 8px 10px;
  font-size: 13px;
}

.lobby-chat-form input:disabled {
  opacity: 0.55;
}

.lobby-chat-form button {
  padding: 8px 14px;
  min-width: 76px;
}

.panel button:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 20px rgba(44, 123, 229, 0.3);
}

.panel button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.panel button:disabled:hover {
  transform: none;
  box-shadow: none;
}

#status {
  margin-top: 16px;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.6);
}

#hud {
  position: fixed;
  top: clamp(8px, 1.2vw, 12px);
  left: clamp(8px, 1.2vw, 12px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 5;
  pointer-events: none;
}

#player-list {
  position: fixed;
  right: clamp(8px, 1.2vw, 16px);
  top: 50%;
  transform: translateY(-50%);
  min-width: 140px;
  max-width: min(240px, 44vw);
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(12, 14, 18, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.85);
  font-size: 12px;
  display: none;
  flex-direction: column;
  gap: 6px;
  z-index: 26;
  pointer-events: none;
}

#player-list.visible {
  display: flex;
}

#game-chat {
  position: fixed;
  right: clamp(8px, 1.2vw, 14px);
  top: clamp(8px, 1.2vw, 14px);
  width: min(400px, calc(100vw - 28px));
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 26;
  pointer-events: none;
}

#game-chat-log {
  min-height: 48px;
  max-height: 188px;
  overflow-y: auto;
  border-radius: 10px;
  background: rgba(10, 12, 16, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  pointer-events: auto;
}

#game-chat-entry {
  pointer-events: auto;
}

#game-chat-input {
  width: 100%;
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(8, 10, 14, 0.9);
  color: #f8f8f8;
  padding: 8px 10px;
  font-size: 13px;
}

.game-chat-line {
  display: flex;
  gap: 6px;
  line-height: 1.34;
  color: rgba(255, 255, 255, 0.92);
}

.game-chat-line.self .game-chat-author {
  color: rgba(120, 255, 170, 0.95);
}

.game-chat-scope {
  color: rgba(130, 185, 255, 0.95);
  font-weight: 600;
  flex: 0 0 auto;
}

.game-chat-author {
  color: rgba(245, 245, 245, 0.95);
  font-weight: 600;
  flex: 0 0 auto;
}

.game-chat-hint {
  color: rgba(255, 255, 255, 0.45);
  font-style: italic;
}

.player-entry {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.player-entry span {
  color: rgba(255, 255, 255, 0.7);
  font-weight: 500;
}

#cheat-bar {
  position: fixed;
  top: clamp(8px, 1.2vw, 12px);
  right: clamp(8px, 1.2vw, 12px);
  display: none;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  z-index: 6;
  max-width: min(440px, 82vw);
}

.cheat-toggle {
  background: rgba(255, 255, 255, 0.1);
  color: #f5f8ff;
  border: 1px solid rgba(255, 255, 255, 0.24);
  padding: 6px 12px;
  border-radius: 10px;
  font-size: 12px;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease;
}

.cheat-toggle:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.2);
}

.cheat-panel {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  max-width: min(440px, 82vw);
  max-height: 45vh;
  overflow-y: auto;
  padding: 10px;
  border-radius: 10px;
  background: rgba(12, 14, 18, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

#attack-notify {
  position: fixed;
  top: 50%;
  right: 16px;
  transform: translateY(-50%);
  background: rgba(180, 20, 20, 0.9);
  color: #fff5f5;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255, 120, 120, 0.6);
  font-weight: 600;
  display: none;
  z-index: 12;
}

#attack-notify.visible {
  display: block;
}

#research-notify {
  position: fixed;
  top: 50%;
  right: 16px;
  transform: translateY(-50%);
  display: none;
  z-index: 12;
  gap: 8px;
  flex-direction: column;
}

#research-notify.visible {
  display: flex;
}

.research-toast {
  background: rgba(30, 90, 40, 0.9);
  color: #eafff1;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid rgba(120, 255, 170, 0.4);
  font-weight: 600;
  min-width: 160px;
}

.research-toast.resign-toast {
  background: rgba(125, 35, 35, 0.92);
  border-color: rgba(255, 130, 130, 0.45);
  color: #fff1f1;
}

#age-notify {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 15;
  pointer-events: none;
}

#age-notify.visible {
  display: flex;
}

.age-toast {
  background: rgba(20, 24, 36, 0.92);
  color: #ffffff;
  border: 1px solid rgba(120, 160, 255, 0.5);
  padding: 18px 28px;
  border-radius: 14px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.6px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.4);
}

.ui-layer {
  pointer-events: auto;
}

#cheat-bar.visible {
  display: flex;
}

.cheat-btn {
  background: rgba(231, 76, 60, 0.15);
  color: #ffecec;
  border: 1px solid rgba(231, 76, 60, 0.5);
  padding: 6px 10px;
  border-radius: 10px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}

.cheat-btn:hover {
  transform: translateY(-1px);
  background: rgba(231, 76, 60, 0.3);
}

#resources {
  font-size: clamp(13px, 1.25vw, 16px);
  padding: 6px 10px;
  background: rgba(15, 18, 22, 0.7);
  border-radius: 8px;
  min-width: min(210px, 44vw);
  pointer-events: auto;
}

#resources span {
  margin-right: 10px;
  font-weight: 600;
}

#idle-villagers {
  font-size: 13px;
  padding: 4px 8px;
  background: rgba(20, 24, 30, 0.7);
  border-radius: 8px;
  width: fit-content;
  cursor: pointer;
  pointer-events: auto;
  color: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

#idle-villagers.disabled {
  opacity: 0.5;
  cursor: default;
}

#idle-traders {
  font-size: 13px;
  padding: 4px 8px;
  background: rgba(20, 24, 30, 0.7);
  border-radius: 8px;
  width: fit-content;
  pointer-events: none;
  color: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: none;
}

#idle-traders.disabled {
  opacity: 0.5;
}

#hint {
  font-size: clamp(11px, 1.05vw, 13px);
  color: rgba(255, 255, 255, 0.6);
}

#bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  min-height: 110px;
  height: auto;
  background: rgba(24, 26, 30, 0.95);
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 12px 24px;
  z-index: 25;
  gap: 6px;
  color: #f2f4f8;
}

#bottom-bar.hidden {
  display: none;
}

#selection-and-build {
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 12px;
}

#selection-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  flex: 0 1 auto;
}

#selection-title {
  font-size: 18px;
  font-weight: 600;
}

#selection-details {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.7);
}

#error-banner {
  min-height: 22px;
  font-size: 13px;
  color: #ffd7d7;
  background: rgba(111, 18, 18, 0.4);
  border: 1px solid rgba(255, 120, 120, 0.35);
  border-radius: 8px;
  padding: 4px 8px;
  display: flex;
  align-items: center;
  visibility: hidden;
}

#error-banner[data-tone="info"] {
  color: #d6ecff;
  background: rgba(18, 50, 90, 0.4);
  border-color: rgba(90, 160, 255, 0.35);
}

#error-banner[data-tone="ok"] {
  color: #d7ffe5;
  background: rgba(18, 90, 40, 0.4);
  border-color: rgba(120, 255, 170, 0.35);
}

#production-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

#production-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#production-queue {
  min-width: 180px;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(12, 14, 18, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.75);
  font-size: 12px;
  max-height: 120px;
  display: flex;
  flex-direction: column;
  flex-wrap: wrap;
  column-gap: 16px;
}

#production-queue .queue-title {
  font-weight: 600;
  margin-bottom: 4px;
  color: #f2f4f8;
}

#production-queue .queue-item {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 2px;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.85);
  padding: 2px 6px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
}

#production-queue .queue-item:hover {
  background: rgba(255, 255, 255, 0.08);
}

.prod-btn {
  background: rgba(44, 123, 229, 0.15);
  color: #e8f1ff;
  border: 1px solid rgba(44, 123, 229, 0.4);
  padding: 6px 12px;
  border-radius: 10px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
  width: 100%;
  white-space: nowrap;
}

.prod-btn.tech-btn {
  padding: 6px 14px;
  font-size: 12px;
}

.prod-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.prod-btn:not(:disabled):hover {
  transform: translateY(-1px);
  background: rgba(44, 123, 229, 0.3);
}

.prod-btn.tech-btn {
  background: rgba(241, 196, 15, 0.15);
  border-color: rgba(241, 196, 15, 0.45);
  color: #fff4cf;
}

.prod-btn.tech-btn:not(:disabled):hover {
  background: rgba(241, 196, 15, 0.3);
}

.prod-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: flex-start;
}

.prod-slot {
  display: flex;
  flex: 0 0 auto;
}

.prod-spacer {
  width: 110px;
  height: 30px;
  opacity: 0;
}

.tech-row {
  margin-top: 2px;
}

#build-buttons {
  display: flex;
  gap: 12px;
  align-items: stretch;
  flex: 0 0 auto;
  max-width: 100%;
  overflow-x: auto;
}

.build-hidden {
  display: none;
}

.build-column {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(12, 14, 18, 0.6);
  min-width: 150px;
}

.build-era {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.6);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.build-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.landmark-column .build-row {
  display: grid;
  grid-template-columns: repeat(2, 46px);
  gap: 8px;
  justify-content: start;
}

.build-spacer {
  width: 46px;
  height: 46px;
  opacity: 0;
}

.build-btn {
  background: rgba(46, 204, 113, 0.15);
  color: #e8fff1;
  border: 1px solid rgba(46, 204, 113, 0.45);
  padding: 6px 12px;
  border-radius: 10px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
}

.build-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.build-btn:not(:disabled):hover {
  transform: translateY(-1px);
  background: rgba(46, 204, 113, 0.3);
}

.build-btn img {
  width: 34px;
  height: 34px;
  image-rendering: auto;
}

#build-tooltip {
  position: fixed;
  z-index: 30;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(12, 14, 18, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #f2f4f8;
  font-size: 12px;
  display: none;
  pointer-events: none;
  max-width: 220px;
}

#build-tooltip.visible {
  display: block;
}

.tooltip-requirement {
  color: #e25555;
}

.tooltip-type {
  color: rgba(242, 244, 248, 0.82);
}

#garrison-panel {
  display: none;
  margin-top: 6px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(12, 14, 18, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #f2f4f8;
  font-size: 12px;
  gap: 6px;
}

#garrison-panel.visible {
  display: flex;
  flex-direction: column;
}

#garrison-title {
  font-weight: 600;
}

#garrison-list {
  color: rgba(255, 255, 255, 0.75);
}

#ungarrison-all {
  align-self: flex-start;
  background: rgba(241, 196, 15, 0.15);
  color: #fff4cf;
  border: 1px solid rgba(241, 196, 15, 0.4);
  padding: 6px 10px;
  border-radius: 10px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}

#ungarrison-all:hover {
  transform: translateY(-1px);
  background: rgba(241, 196, 15, 0.3);
}

@media (max-width: 960px) {
  .main-menu-shell {
    display: flex;
    width: min(420px, 92vw);
    max-width: min(420px, 92vw);
    flex-direction: column;
    align-items: stretch;
  }

  .level-panel {
    position: static;
    transform: none;
    right: auto;
    top: auto;
    width: 100%;
    min-width: 0;
    margin-bottom: 10px;
  }
}

@media (max-width: 900px) {
  .match-loading-list {
    grid-template-columns: 1fr;
  }

  .match-loading-choice-grid {
    grid-template-columns: 1fr;
  }

  #view-loadout-landmark-options {
    grid-template-columns: 1fr;
  }

  .how-to-play-sections {
    grid-template-columns: 1fr;
  }

  .panel.lobby-room-active {
    width: min(560px, 95vw);
  }

  .lobby-room-content {
    flex-direction: column;
  }

  .lobby-room-main {
    flex: 1 1 auto;
  }

  .lobby-chat-panel {
    min-width: 0;
  }

  .lobby-chat-log {
    min-height: 170px;
    max-height: 220px;
  }

  #hud {
    gap: 6px;
  }

  #resources {
    min-width: 0;
    max-width: 56vw;
    padding: 5px 8px;
  }

  #hint {
    max-width: 56vw;
  }

  #game-chat {
    right: 8px;
    top: 8px;
    width: min(360px, calc(100vw - 16px));
  }

  #game-chat-log {
    max-height: 160px;
    font-size: 11px;
  }

  #player-list {
    top: 210px;
    transform: none;
    max-height: 30vh;
    overflow-y: auto;
    font-size: 11px;
    max-width: min(220px, 46vw);
  }

  #cheat-bar {
    max-width: min(360px, 62vw);
  }

  #minimap {
    right: 10px;
    width: clamp(122px, 20vw, 156px);
    height: clamp(122px, 20vw, 156px);
    bottom: clamp(180px, 32vh, 240px);
  }

  #bottom-bar {
    padding: 8px 10px;
    gap: 5px;
    max-height: 34vh;
    overflow-y: auto;
  }

  #selection-and-build {
    flex-direction: column;
    gap: 8px;
  }

  #selection-title {
    font-size: 16px;
  }

  #selection-details {
    font-size: 12px;
  }

  #production-row {
    flex-wrap: wrap;
    gap: 8px;
  }

  #production-buttons {
    width: 100%;
  }

  #production-queue {
    min-width: 0;
    width: 100%;
    max-height: 96px;
  }

  #build-buttons {
    gap: 8px;
  }

  .build-column {
    min-width: 130px;
  }

  .build-era {
    font-size: 11px;
  }

  #garrison-panel {
    width: 100%;
  }
}

@media (max-width: 640px), (max-height: 620px) {
  #hint {
    display: none;
  }

  #resources {
    max-width: calc(100vw - 16px);
    font-size: 12px;
  }

  #idle-villagers,
  #idle-traders {
    font-size: 11px;
    padding: 3px 6px;
  }

  #game-chat {
    right: 8px;
    left: 8px;
    width: auto;
    top: 8px;
  }

  #game-chat-log {
    max-height: 132px;
  }

  #player-list {
    top: 154px;
    right: 8px;
    max-width: min(180px, 48vw);
    max-height: 22vh;
  }

  #cheat-bar {
    top: 154px;
    right: 8px;
    max-width: min(280px, 58vw);
  }

  #minimap {
    width: clamp(102px, 24vw, 126px);
    height: clamp(102px, 24vw, 126px);
    right: 8px;
    bottom: clamp(170px, 34vh, 220px);
  }

  #bottom-bar {
    max-height: 32vh;
    padding: 6px 8px;
  }

  .build-column {
    min-width: 118px;
  }

  .build-btn {
    width: 42px;
    height: 42px;
  }

  .build-btn img {
    width: 30px;
    height: 30px;
  }
}
