:root {
  color-scheme: dark;
  font-family: 'Segoe UI', Roboto, sans-serif;
  background: #050915;
  color: #d7e7ff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  overflow: hidden;
}

.chat-panel {
  position: fixed;
  top: 50%;
  right: 1.4rem;
  transform: translateY(-50%);
  width: min(320px, calc(100vw - 2.8rem));
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  pointer-events: none;
  z-index: 900;
}

.chat-panel__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.35rem;
}

.chat-panel__message {
  display: flex;
  gap: 0.4rem;
  align-items: baseline;
  padding: 0.35rem 0.55rem;
  background: rgba(10, 18, 36, 0.7);
  border: 1px solid rgba(120, 170, 255, 0.25);
  border-radius: 8px;
  font-size: 0.85rem;
  pointer-events: auto;
  color: rgba(215, 230, 255, 0.92);
}

.chat-panel__message--self {
  border-color: rgba(150, 210, 255, 0.6);
  background: rgba(60, 110, 220, 0.55);
  color: #f6fbff;
}

.chat-panel__message-name {
  font-weight: 600;
  letter-spacing: 0.02em;
}

.chat-panel__message-text {
  flex: 1;
  word-break: break-word;
}

.chat-panel__input {
  pointer-events: auto;
}

.chat-panel__input input {
  width: 100%;
  padding: 0.4rem 0.6rem;
  border-radius: 8px;
  border: 1px solid rgba(120, 170, 255, 0.55);
  background: rgba(12, 20, 40, 0.9);
  color: inherit;
  font-size: 0.9rem;
}

.chat-panel__input input:focus {
  outline: none;
  border-color: rgba(180, 220, 255, 0.95);
  box-shadow: 0 0 0 2px rgba(90, 150, 255, 0.25);
}

.chat-panel__input--hidden {
  display: none;
}

.chat-panel--active .chat-panel__list {
  opacity: 1;
}

#game {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  background: radial-gradient(circle at center, rgba(9, 18, 40, 0.9), #050915 75%);
}

.ui-bar {
  position: fixed;
  top: 1.2rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.6rem 0.8rem;
  background: rgba(8, 16, 32, 0.65);
  border-radius: 999px;
  border: 1px solid rgba(120, 170, 255, 0.35);
  backdrop-filter: blur(4px);
  pointer-events: auto;
}

.ui-bar__form {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.ui-bar__form input {
  width: 160px;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  border: 1px solid rgba(100, 150, 255, 0.45);
  background: rgba(10, 20, 40, 0.9);
  color: inherit;
}

.ui-bar__form input:focus {
  outline: none;
  border-color: rgba(160, 200, 255, 0.9);
  box-shadow: 0 0 0 2px rgba(120, 170, 255, 0.25);
}

.ui-bar__form button {
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  border: 1px solid rgba(120, 170, 255, 0.7);
  background: rgba(30, 70, 160, 0.85);
  color: #f9fcff;
  font-weight: 600;
  cursor: pointer;
}

.ui-bar__form button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.ui-bar__status {
  min-width: 140px;
  font-size: 0.85rem;
  color: rgba(210, 225, 255, 0.9);
}

.ui-bar__status[data-tone="warn"] {
  color: #f2cf74;
}

.ui-bar__status[data-tone="error"] {
  color: #f16c7d;
}

.ui-bar__status[data-tone="success"] {
  color: #95f7c4;
}

.ui-bar__leaderboard {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(5, 9, 21, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: opacity 150ms ease, visibility 150ms ease;
}

.modal--hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.modal__dialog {
  width: min(720px, calc(100% - 3rem));
  background: rgba(6, 14, 30, 0.92);
  border: 1px solid rgba(90, 160, 255, 0.35);
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: 0 18px 48px rgba(6, 20, 40, 0.45);
  text-align: center;
}

.modal__dialog h2 {
  margin: 0 0 0.4rem;
  font-size: 2rem;
  letter-spacing: 0.05em;
}

.modal__dialog p {
  margin: 0 0 1.2rem;
  color: rgba(200, 220, 255, 0.75);
}

.modal__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
}

.creature-card {
  background: rgba(12, 24, 48, 0.85);
  border: 1px solid rgba(90, 160, 255, 0.3);
  border-radius: 12px;
  padding: 0.9rem 0.75rem 1.1rem;
  cursor: pointer;
  color: inherit;
  font: inherit;
  display: grid;
  gap: 0.6rem;
  align-items: center;
  transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.creature-card:hover,
.creature-card:focus-visible {
  border-color: rgba(140, 200, 255, 0.7);
  box-shadow: 0 18px 36px rgba(40, 90, 160, 0.25);
  outline: none;
  background: rgba(18, 34, 68, 0.95);
}

.creature-card:focus {
  outline: none;
}

.creature-card.creature-card--active {
  border-color: rgba(180, 240, 255, 0.9);
  box-shadow: 0 0 0 3px rgba(150, 210, 255, 0.35);
}

.creature-card img {
  width: 72px;
  height: 72px;
  margin: 0 auto;
  image-rendering: pixelated;
}

.creature-card span {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.creature-card:disabled {
  opacity: 0.6;
  cursor: progress;
  box-shadow: none;
  border-color: rgba(90, 160, 255, 0.3);
}

.leaderboard-panel {
  position: fixed;
  top: 1.2rem;
  right: 1.2rem;
  width: 200px;
  background: rgba(8, 16, 32, 0.7);
  border: 1px solid rgba(120, 170, 255, 0.3);
  border-radius: 12px;
  padding: 0.75rem 0.85rem;
  backdrop-filter: blur(4px);
  pointer-events: auto;
}

.leaderboard-panel h2 {
  margin: 0 0 0.6rem;
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(200, 220, 255, 0.85);
}

.leaderboard-panel ol {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: rgba(210, 225, 255, 0.85);
}

.leaderboard-panel li {
  display: flex;
  justify-content: space-between;
  gap: 0.3rem;
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  background: rgba(20, 40, 80, 0.55);
}

.leaderboard-panel li.self {
  background: rgba(80, 150, 255, 0.8);
  color: #081020;
  font-weight: 600;
}

@media (max-width: 680px) {
  .hud {
    top: auto;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 2rem);
    max-width: 420px;
  }
}
