*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0d0d12;
  font-family: "Press Start 2P", monospace;
}

#game-wrap {
  position: relative;
  width: 100vw;
  height: 100vh;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #0d0d12;
}

#hud {
  position: absolute;
  top: 16px;
  left: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  pointer-events: none;
  z-index: 5;
}

#game-title {
  display: flex;
  align-items: center;
  color: #ffd93d;
  font-size: 10px;
  letter-spacing: 1px;
  text-shadow: 2px 2px 0 #0d0d12;
}

#credits {
  position: absolute;
  right: 16px;
  bottom: 16px;
  z-index: 5;
  color: #8a8a9a;
  font-size: 10px;
  line-height: 1.8;
  text-align: right;
}

#credits a {
  color: #b8b8c8;
  text-decoration: none;
}

#credits a:hover {
  color: #ffd93d;
  text-decoration: underline;
}

.upgrade-icons {
  position: absolute;
  top: 16px;
  right: 16px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  z-index: 5;
  pointer-events: none;
}

.upgrade-icons__icon {
  display: block;
  width: 36px;
  height: 36px;
  object-fit: contain;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: rgba(0, 0, 0, 0.65);
  border: 2px solid #4a4a6a;
  box-shadow: 0 0 0 1px #0d0d12;
  padding: 2px;
}

.upgrade-icons__icon--skull {
  border-color: #c9b458;
}

.upgrade-icons__icon--crosses {
  border-color: #7ec8ff;
}

.upgrade-icons__icon--shield {
  border-color: #6bff8f;
}

.hud-block {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(0, 0, 0, 0.65);
  border: 3px solid #4a4a6a;
  box-shadow: 0 0 0 2px #0d0d12;
}

#hp-label {
  color: #ff6b6b;
  font-size: 10px;
  letter-spacing: 1px;
}

#hp-bar-wrap {
  width: 120px;
  height: 14px;
  background: #2a2a3e;
  border: 2px solid #555;
}

#hp-bar {
  width: 100%;
  height: 100%;
  background: linear-gradient(180deg, #ff6b6b 0%, #c0392b 100%);
  transition: width 0.15s linear;
}

#hp-text,
#coins-text,
#room-text {
  color: #eee;
  font-size: 8px;
}

#coins-label {
  color: #ffd93d;
  font-size: 10px;
}

#room-label {
  color: #7ec8ff;
  font-size: 10px;
}

.hud-row--room {
  display: flex;
  align-items: stretch;
  gap: 10px;
}

.hud-leaderboard-btn {
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  font-family: "Press Start 2P", monospace;
  font-size: 8px;
  line-height: 1.4;
  color: #ffd93d;
  background: rgba(0, 0, 0, 0.65);
  border: 3px solid #c9b458;
  box-shadow: 0 0 0 2px #0d0d12;
  cursor: pointer;
  white-space: nowrap;
}

.hud-leaderboard-btn:hover {
  background: #2a2a3e;
  color: #fff3a0;
}

.hud-leaderboard-btn:active {
  transform: translateY(2px);
  box-shadow: 0 0 0 2px #0d0d12;
}

.hud-build-btn {
  border-color: #7ec8ff;
  color: #7ec8ff;
}

.hud-build-btn:hover {
  color: #b8e4ff;
}

.build-panel {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 14px;
  width: min(520px, 94vw);
  max-height: min(80vh, 640px);
  padding: 20px 18px 18px;
  background: #1a1a2e;
  border: 3px solid #7ec8ff;
  box-shadow: 0 0 0 2px #0d0d12, 0 8px 0 #0a0a14;
}

.build-panel__title {
  margin: 0;
  font-family: "Press Start 2P", monospace;
  font-size: 14px;
  color: #7ec8ff;
  text-align: center;
}

.build-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  padding-right: 4px;
}

.build-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.45);
  border: 2px solid #4a4a6a;
}

.build-row__label {
  font-family: "Press Start 2P", monospace;
  font-size: 8px;
  color: #ffd93d;
  flex-shrink: 0;
}

.build-row__value {
  font-family: "Press Start 2P", monospace;
  font-size: 7px;
  color: #eee;
  line-height: 1.8;
  text-align: right;
}

.build-panel__close {
  font-family: "Press Start 2P", monospace;
  font-size: 10px;
  padding: 12px 16px;
  color: #7ec8ff;
  background: #2a2a3e;
  border: 3px solid #7ec8ff;
  box-shadow: 0 0 0 2px #0d0d12;
  cursor: pointer;
}

.game-over-btn {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, 120px);
  z-index: 10;
  padding: 14px 22px;
  font-family: "Press Start 2P", monospace;
  font-size: 12px;
  color: #eee;
  background: #2a2a3e;
  border: 3px solid #6bff8f;
  box-shadow: 0 0 0 2px #0d0d12, 0 4px 0 #1a5c34;
  cursor: pointer;
}

.game-over-btn:hover {
  background: #3a3a52;
  color: #6bff8f;
}

.game-over-btn:active {
  transform: translate(-50%, 124px);
  box-shadow: 0 0 0 2px #0d0d12;
}

.banner-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.35);
  padding: 20px;
  pointer-events: none;
}

.banner-overlay.is-open {
  display: flex;
  pointer-events: auto;
}

#leaderboard-overlay {
  z-index: 30;
}

#char-select-overlay {
  background: rgba(8, 8, 14, 0.82);
}

.banner-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  justify-content: center;
  max-width: 1200px;
  width: 100%;
}

.banner-card {
  flex: 1 1 280px;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: #1a1a2e;
  border: 3px solid #4a4a6a;
  box-shadow: 0 0 0 2px #0d0d12, 0 6px 0 #0a0a14;
}

.banner-card--skull {
  background: rgba(110, 110, 118, 0.45);
  border-color: #8b3a3a;
}

.banner-card--crosses {
  background: rgba(140, 60, 60, 0.35);
  border-color: #c9b458;
}

.banner-card--shield {
  background: rgba(55, 90, 145, 0.35);
  border-color: #5a8fd4;
}

.banner-card__img {
  width: 100%;
  max-width: 200px;
  height: auto;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.banner-card__title {
  color: #ffd93d;
  font-size: 10px;
  text-align: center;
  line-height: 1.6;
}

.banner-card__desc {
  color: #ccc;
  font-size: 8px;
  text-align: center;
  line-height: 1.8;
  min-height: 72px;
}

.banner-card__btn {
  margin-top: auto;
  padding: 12px 14px;
  font-family: "Press Start 2P", monospace;
  font-size: 8px;
  color: #eee;
  background: #2a2a3e;
  border: 3px solid #6bff8f;
  box-shadow: 0 4px 0 #1a5c34;
  cursor: pointer;
}

.banner-card__btn:hover {
  color: #6bff8f;
  background: #3a3a52;
}

.banner-card__btn:active {
  transform: translateY(4px);
  box-shadow: none;
}

.char-select {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  max-width: min(900px, 100%);
  width: 100%;
  padding: 12px;
}

.char-select__title-art {
  display: block;
  width: min(100%, 520px);
  max-width: 100%;
  height: auto;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
}

.char-select__toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: center;
  gap: 14px;
  width: 100%;
}

.char-select__name-group {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.char-select__name-label {
  color: #ffd93d;
  font-size: 8px;
  letter-spacing: 1px;
}

.char-select__name-input {
  width: min(180px, 42vw);
  padding: 12px 14px;
  font-family: "Press Start 2P", monospace;
  font-size: 10px;
  color: #eee;
  background: #1a1a2e;
  border: 3px solid #4a4a6a;
  box-shadow: 0 0 0 2px #0d0d12;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.char-select__name-input:focus {
  outline: none;
  border-color: #ffd93d;
}

.char-select__leaderboard-btn {
  padding: 12px 16px;
  min-height: 44px;
  font-family: "Press Start 2P", monospace;
  font-size: 8px;
  line-height: 1.4;
  color: #ffd93d;
  background: rgba(0, 0, 0, 0.65);
  border: 3px solid #c9b458;
  box-shadow: 0 0 0 2px #0d0d12;
  cursor: pointer;
  white-space: nowrap;
}

.char-select__leaderboard-btn:hover {
  background: #2a2a3e;
  color: #fff3a0;
}

.char-select__leaderboard-btn:active {
  transform: translateY(2px);
}

.char-select__title {
  color: #ffd93d;
  font-size: 14px;
  text-align: center;
  text-shadow: 2px 2px 0 #0d0d12;
}

.char-select__cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 16px;
  justify-content: center;
  width: 100%;
  max-width: 720px;
  margin-top: 8px;
}

@media (min-width: 640px) {
  .char-select__cards {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.char-card {
  width: 100%;
  max-width: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 14px 12px;
  font-family: "Press Start 2P", monospace;
  color: #eee;
  background: #1a1a2e;
  border: 3px solid #4a4a6a;
  box-shadow: 0 0 0 2px #0d0d12, 0 6px 0 #0a0a14;
  cursor: pointer;
}

.char-card:hover {
  background: #2a2a3e;
}

.char-card:active {
  transform: translateY(4px);
  box-shadow: 0 0 0 2px #0d0d12;
}

.char-card--warrior {
  border-color: #5a8fd4;
}

.char-card--mage {
  border-color: #c94444;
}

.char-card--ranger {
  border-color: #6bff8f;
}

.char-card__img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.char-card__sprite-wrap {
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.char-card__name {
  color: #ffd93d;
  font-size: 10px;
}

.char-card__guild {
  color: #8a8a9a;
  font-size: 6px;
  line-height: 1.6;
  text-align: center;
}

.char-card__desc {
  color: #aaa;
  font-size: 7px;
  line-height: 1.8;
  text-align: center;
}

.leaderboard-panel {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 16px;
  width: min(680px, 94vw);
  max-height: min(80vh, 680px);
  padding: 20px 18px 18px;
  background: rgba(10, 10, 18, 0.96);
  border: 3px solid #4a4a6a;
  box-shadow: 0 0 0 2px #0d0d12;
}

.leaderboard-panel__title {
  color: #ffd93d;
  font-size: 14px;
  text-align: center;
  letter-spacing: 1px;
  text-shadow: 2px 2px 0 #0d0d12;
}

.leaderboard-list {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-right: 6px;
}

.leaderboard-row {
  display: grid;
  grid-template-columns: 36px 1fr 40px 52px 52px 52px;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  font-size: 9px;
  color: #eee;
  background: rgba(0, 0, 0, 0.35);
  border: 2px solid #2a2a3e;
}

.leaderboard-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard-row__name {
  min-width: 0;
}

.leaderboard-row__country {
  color: #6bff8f;
  font-size: 8px;
}

.leaderboard-row__class {
  color: #ffd93d;
  font-size: 8px;
  text-align: center;
}

.leaderboard-row--head {
  color: #7ec8ff;
  background: rgba(26, 26, 46, 0.9);
  border-color: #4a4a6a;
  font-size: 8px;
}

.leaderboard-row--empty {
  display: block;
  text-align: center;
  color: #8a8a9a;
  font-size: 9px;
  padding: 28px 12px;
  border: 2px dashed #4a4a6a;
}

.leaderboard-panel__close {
  align-self: center;
  padding: 14px 22px;
  font-family: "Press Start 2P", monospace;
  font-size: 10px;
  color: #eee;
  background: #2a2a3e;
  border: 3px solid #7ec8ff;
  box-shadow: 0 4px 0 #1a4a6a;
  cursor: pointer;
}

.leaderboard-panel__close:hover {
  color: #7ec8ff;
}

.leaderboard-panel__close:active {
  transform: translateY(4px);
  box-shadow: none;
}
