:root {
  color-scheme: dark;
  font-family:
    "Trebuchet MS", "Lucida Grande", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background: #120918;
  color: #fff7d6;
  --ink: #170d20;
  --panel: #2b1738;
  --panel-2: #3c2350;
  --gold: #f4c95d;
  --gold-dark: #9f6b1b;
  --rune: #70e0ff;
  --danger: #ff667d;
  --ok: #91f7b5;
  --line: #6e477e;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(18, 9, 24, 0.8), rgba(18, 9, 24, 0.98)),
    repeating-linear-gradient(90deg, #1a0d24 0 16px, #20102c 16px 32px);
}

button,
input {
  font: inherit;
}

button {
  border: 3px solid #120918;
  box-shadow: 0 4px 0 #120918;
  cursor: pointer;
  font-weight: 800;
}

button:disabled {
  cursor: wait;
  filter: grayscale(0.6);
  opacity: 0.7;
}

input {
  width: 100%;
  border: 3px solid #120918;
  background: #fff7d6;
  color: #1f1229;
  padding: 10px 12px;
  outline: 0;
}

input:focus {
  box-shadow: 0 0 0 4px rgba(112, 224, 255, 0.3);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(34px, 5vw, 64px);
  line-height: 0.95;
  text-shadow: 4px 4px 0 #120918;
}

h2 {
  font-size: 28px;
}

.shell {
  width: min(1180px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 24px 0 36px;
}

.topbar,
.panel-heading,
.battle-header,
.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar {
  min-height: 96px;
  margin-bottom: 20px;
}

.eyebrow {
  color: var(--gold);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.connection,
.badge {
  border: 3px solid #120918;
  background: #1eae74;
  color: #07150f;
  font-weight: 900;
  padding: 8px 12px;
  box-shadow: 0 4px 0 #120918;
}

.lobby-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.screen {
  display: none;
}

.screen.active {
  display: grid;
}

#lobby-screen {
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 18px;
}

.hero-panel,
.lobby-panel,
.combatant,
.battle-log,
dialog {
  border: 4px solid #120918;
  background: var(--panel);
  box-shadow: 8px 8px 0 #120918;
}

.hero-panel,
.lobby-panel,
.battle-log {
  padding: 18px;
}

.hero-panel {
  display: grid;
  gap: 18px;
  align-content: start;
}

.avatar-ring {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border: 4px solid #120918;
  background:
    linear-gradient(135deg, rgba(244, 201, 93, 0.24), transparent 45%),
    #241230;
  image-rendering: pixelated;
  overflow: hidden;
}

.avatar-ring svg {
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}

.avatar-ring.large {
  width: min(260px, 100%);
  justify-self: center;
}

.field {
  display: grid;
  gap: 7px;
  color: #f7df93;
  font-size: 14px;
  font-weight: 900;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 12px 0;
}

.primary {
  background: var(--gold);
  color: #201209;
  padding: 11px 16px;
}

.ghost {
  background: #2f1b3d;
  color: #fff7d6;
  padding: 10px 14px;
}

.players {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.player-card {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  border: 3px solid #120918;
  background: var(--panel-2);
  color: #fff7d6;
  padding: 10px;
  text-align: left;
  box-shadow: 4px 4px 0 #120918;
}

.player-card .avatar-ring {
  border-width: 3px;
}

.player-card strong,
.combatant h3 {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-card span,
.combatant p {
  color: #d9c6e8;
  font-size: 13px;
}

.empty {
  border: 3px dashed var(--line);
  color: #d9c6e8;
  padding: 24px;
  text-align: center;
}

#battle-screen {
  gap: 18px;
}

.arena {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 160px minmax(0, 1fr);
  gap: 18px;
  align-items: center;
}

.combatant {
  display: grid;
  gap: 12px;
  min-width: 0;
  padding: 18px;
  text-align: center;
}

.versus {
  display: grid;
  gap: 16px;
  justify-items: center;
}

.versus span {
  color: var(--danger);
  font-size: 46px;
  font-weight: 1000;
  text-shadow: 4px 4px 0 #120918;
}

.battle-log {
  min-height: 86px;
  color: #f7df93;
  font-weight: 800;
}

.protocol-log {
  display: grid;
  gap: 7px;
  margin: 14px 0 0;
  padding-left: 26px;
  color: #d9c6e8;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.35;
}

.protocol-log li::marker {
  color: var(--rune);
  font-weight: 900;
}

.win {
  color: var(--ok);
}

.lose {
  color: var(--danger);
}

dialog {
  color: #fff7d6;
  max-width: min(440px, calc(100vw - 28px));
  padding: 20px;
}

dialog::backdrop {
  background: rgba(5, 3, 8, 0.72);
}

@media (max-width: 880px) {
  #lobby-screen,
  .arena {
    grid-template-columns: 1fr;
  }

  .topbar,
  .panel-heading,
  .battle-header {
    align-items: start;
    flex-direction: column;
  }

  .versus {
    order: 2;
  }
}

@media (max-width: 520px) {
  .shell {
    width: min(100vw - 16px, 1180px);
    padding-top: 14px;
  }

  .stats-grid,
  .player-card {
    grid-template-columns: 1fr;
  }
}
