* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: #eef2f7;
  color: #1f2933;
}

.app {
  width: 100%;
  max-width: 560px;
  flex-shrink: 0;
  padding: 24px 16px 40px;
}

h1 {
  text-align: center;
  font-size: 1.6rem;
  margin: 0 0 20px;
}

section {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(31, 41, 51, 0.08);
}

input {
  font: inherit;
  padding: 10px 12px;
  border: 1px solid #cbd5e0;
  border-radius: 8px;
  width: 100%;
}

input:focus {
  outline: 2px solid #3b82f6;
  outline-offset: -1px;
}

button {
  font: inherit;
  padding: 10px 16px;
  border: none;
  border-radius: 8px;
  background: #3b82f6;
  color: #fff;
  cursor: pointer;
  white-space: nowrap;
}

button:hover {
  background: #2f6fd6;
}

button:disabled {
  background: #b6c3d1;
  cursor: default;
}

button.secondary {
  background: #eef2f7;
  color: #4a5561;
}

button.secondary:hover {
  background: #dde5ee;
}

button.secondary:disabled {
  color: #9aa7b3;
  background: #f3f6fa;
}

button.wide {
  width: 100%;
  margin-top: 8px;
}

button.linkish {
  display: block;
  margin: 10px auto 0;
  padding: 4px 8px;
  background: none;
  color: #7b8794;
  text-decoration: underline;
}

button.linkish:hover {
  background: none;
  color: #4a5561;
}

#lobby-form,
.invite-row {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.error {
  color: #d43d3d;
  min-height: 1.2em;
  margin: 10px 0 0;
}

.muted {
  color: #7b8794;
}

/* Игровое поле */

#players {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.player {
  flex: 1;
  text-align: center;
  padding: 8px 10px;
  border-radius: 8px;
  background: #f3f6fa;
  border: 2px solid transparent;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player.active {
  border-color: #3b82f6;
  background: #e8f0fe;
  font-weight: 600;
}

.player.offline {
  opacity: 0.5;
}

#turn-line {
  text-align: center;
  margin: 0 0 4px;
  font-weight: 600;
}

#timer {
  text-align: center;
  margin: 0 0 4px;
}

#timer.urgent {
  color: #d43d3d;
  font-weight: 600;
}

#letter-line {
  text-align: center;
  margin: 0 0 12px;
  font-size: 1.15rem;
}

#letter-line b {
  font-size: 1.5rem;
  color: #3b82f6;
}

.banner {
  background: #fff7e0;
  border: 1px solid #f0d48a;
  border-radius: 8px;
  padding: 10px 12px;
  margin: 0 0 12px;
}

#history {
  list-style: none;
  margin: 0 0 12px;
  padding: 10px;
  height: 220px;
  overflow-y: auto;
  background: #f8fafc;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#history:empty::after {
  content: "Городов пока не называли";
  color: #9aa7b3;
  margin: auto;
}

#history li {
  max-width: 75%;
  padding: 6px 10px;
  border-radius: 10px;
  background: #e4e9f0;
  align-self: flex-start;
}

#history li.mine {
  align-self: flex-end;
  background: #d7e6fd;
}

#history .who {
  display: block;
  font-size: 0.72rem;
  color: #7b8794;
}

/* Карта — правая колонка, занимает всё свободное место. */
#map {
  flex: 1;
  align-self: stretch;
  margin: 24px 16px 24px 0;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(31, 41, 51, 0.08);
}

@media (max-width: 900px) {
  body {
    flex-direction: column;
    align-items: center;
  }

  #map {
    flex: none;
    align-self: auto;
    width: calc(100% - 32px);
    max-width: 560px;
    height: 260px;
    margin: 0 16px 24px;
  }
}

/* Пульсирующая подсветка последнего города на карте */
.pulse-wrap {
  background: none;
  border: none;
}

.pulse {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  animation: pulse 1.6s ease-out infinite;
}

.pulse-mine {
  background: rgba(59, 130, 246, 0.5);
}

.pulse-theirs {
  background: rgba(245, 158, 11, 0.5);
}

@keyframes pulse {
  0% {
    transform: scale(0.4);
    opacity: 0.9;
  }
  100% {
    transform: scale(2.2);
    opacity: 0;
  }
}

#attempts {
  margin: 0 0 8px;
}

#attempts .dot {
  color: #3b82f6;
  letter-spacing: 3px;
}

#move-form {
  display: flex;
  gap: 8px;
}

/* Результат */

#verdict {
  text-align: center;
  font-size: 1.3rem;
  font-weight: 600;
  margin: 0 0 12px;
}

#result-history {
  margin: 0 0 16px;
  padding-left: 24px;
  color: #4a5561;
}

#again-button {
  width: 100%;
}

#conn-status {
  text-align: center;
}
