* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background: #000;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

#app {
  width: 100%;
  max-width: 430px;
  height: 100dvh;
  background: #111;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  color: #fff;
  font-family: monospace;
}

#hud {
  display: flex;
  gap: 0.75rem;
  padding: 0.5rem 1rem;
  background: #0d0d0d;
  border-bottom: 1px solid #222;
  flex-wrap: wrap;
  align-items: center;
}

.hero-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
}

.hero-card-name {
  font-family: 'Metamorphous', serif;
  font-size: 0.8rem;
  font-weight: bold;
}

.hero-card-hearts {
  font-size: 1rem;
  letter-spacing: 1px;
}

.hero-card.dead .hero-card-name {
  opacity: 0.35;
}

#story {
  flex: 1;
  padding: 1rem;
  overflow-y: auto;
  font-family: 'Macondo Swash Caps', serif;
  font-size: 1.1rem;
  line-height: 1.9;
  color: #bbb;
}

.card-word {
  color: #f90;
  font-weight: bold;
  font-size: 1em;
  font-family: 'Metamorphous', serif;
}

.hero-name {
  font-family: 'Metamorphous', serif;
}

.damage-text {
  color: #e03333;
  font-weight: bold;
}

#cards {
  display: flex;
  gap: 0.6rem;
  padding: 0.75rem 1rem;
  background: #0d0d0d;
  border-top: 1px solid #222;
  overflow-x: auto;
  min-height: 120px;
  align-items: flex-end;
  flex-shrink: 0;
}

.card {
  background: #1a1522;
  border: 2px solid #444;
  border-radius: 10px;
  padding: 0.75rem 0.6rem;
  width: 110px;
  min-height: 110px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  flex-shrink: 0;
  transition: transform 0.15s ease, border-color 0.15s ease;
  animation: dealCard 0.25s ease;
}

.card:hover {
  transform: translateY(-14px);
  border-color: #f90;
}

.card:active {
  transform: translateY(-8px);
}

.card-label {
  font-family: 'Metamorphous', serif;
  font-size: 0.85rem;
  font-weight: bold;
  text-align: center;
  color: #fff;
  line-height: 1.3;
}

@keyframes dealCard {
  from {
    transform: translateY(24px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes playCard {
  to {
    transform: translateY(-70px) scale(0.85);
    opacity: 0;
  }
}

.card-playing {
  animation: playCard 0.25s ease forwards;
  pointer-events: none;
}

.card-stable {
  animation: none;
}

button {
  background: #222;
  color: #fff;
  border: 1px solid #555;
  padding: 0.75rem 1.25rem;
  font-family: monospace;
  font-size: 1rem;
  cursor: pointer;
  border-radius: 4px;
}

button:hover:not(:disabled) {
  background: #333;
}

button:active:not(:disabled) {
  background: #444;
}

button:disabled {
  cursor: default;
}

.char-cell {
  background: #1a1522;
  border: 2px solid #333;
  border-radius: 8px;
  padding: 0.5rem;
  height: 80px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s, opacity 0.15s;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.char-cell:hover:not(.taken) {
  border-color: #888;
}

.char-cell.taken {
  opacity: 0.45;
  cursor: default;
}

.char-cell.mine {
  opacity: 1 !important;
}

.char-sprite {
  width: 48px;
  height: 48px;
  image-rendering: pixelated;
  flex-shrink: 0;
}

.char-cell-text {
  flex: 1;
  min-width: 0;
}

.char-cell-name {
  font-family: 'Metamorphous', serif;
  font-size: 0.9rem;
  font-weight: bold;
  line-height: 1.2;
}

.char-cell-desc {
  font-size: 0.65rem;
  color: #777;
  line-height: 1.35;
  margin-top: 0.3rem;
  font-family: monospace;
  overflow: hidden;
  white-space: nowrap;
}

.char-cell-desc span {
  display: inline-block;
}

.char-cell.mine .char-cell-desc span {
  animation: marquee 20s linear infinite;
}

@keyframes marquee {
  0% {
    transform: translateX(0);
  }

  60% {
    transform: translateX(var(--marquee-offset, -50%));
  }

  100% {
    transform: translateX(var(--marquee-offset, -50%));
  }
}

.char-cell-badge {
  font-size: 0.6rem;
  color: #ccc;
  background: #333;
  border-radius: 3px;
  padding: 0.1rem 0.3rem;
  margin-top: 0.3rem;
  display: inline-block;
}

.hud-sprite {
  width: 28px;
  height: 28px;
  image-rendering: pixelated;
}

.inline-sprite {
  width: 14px;
  height: 14px;
  image-rendering: pixelated;
  vertical-align: middle;
  margin-left: 3px;
  margin-right: 4px;
}

#scenario-area p {
  margin-bottom: 0.6rem;
  text-indent: 1.2em;
}

#scenario-area p:last-child {
  margin-bottom: 0;
}

#scenario-area strong,
.scenario-prefix strong {
  color: #eee;
  font-family: 'Metamorphous', serif;
  font-weight: normal;
  font-size: 0.8em;
}

#scenario-area h1,
#scenario-area h2,
#scenario-area h3 {
  font-family: 'Metamorphous', serif;
  font-size: 1rem;
  color: #ccc;
  margin-bottom: 0.4rem;
}

.scenario-prefix {
  font-family: 'Macondo Swash Caps', serif;
  font-size: 0.9rem;
  line-height: 1.6;
  color: #888;
  border-bottom: 1px solid #222;
  padding-bottom: 0.75rem;
  margin-bottom: 0.75rem;
}

.scenario-prefix p {
  margin-bottom: 0.6rem;
  text-indent: 1.2em;
}

.scenario-prefix p:last-child {
  margin-bottom: 0;
}

/* Lobby layout */
#start-screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: #111;
}

.lobby-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem 1.25rem 0.75rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.lobby-title {
  font-family: 'Jacquard 24', serif;
  font-size: 3rem;
  font-weight: normal;
  color: #fff;
}

.lobby-teams {
  display: flex;
  gap: 0.75rem;
  width: 100%;
  max-width: 700px;
}

.lobby-team-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.lobby-team-label-hero {
  font-family: 'Metamorphous', serif;
  font-size: 0.75rem;
  color: #55ccff;
  text-align: center;
  letter-spacing: 0.1em;
}

.lobby-team-label-villain {
  font-family: 'Metamorphous', serif;
  font-size: 0.75rem;
  color: #b06fe0;
  text-align: center;
  letter-spacing: 0.1em;
}

#scenario-area {
  font-family: 'Macondo Swash Caps', serif;
  font-size: 0.95rem;
  line-height: 1.5;
  color: #bbb;
  max-width: 700px;
  width: 100%;
  min-height: 2rem;
}

.lobby-bottom-bar {
  flex-shrink: 0;
  background: #0d0d0d;
  border-top: 1px solid #222;
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

#start-btn {
  flex: 1;
  font-family: 'Jacquard 24', serif;
  font-size: 2rem;
  padding: 0.75rem;
}

#qr-canvas {
  border-radius: 4px;
  flex-shrink: 0;
}