:root {
  --bg: #1a1d24;
  --bg-2: #232730;
  --panel: #2b2f3a;
  --text: #e6e8ec;
  --muted: #8c93a3;
  --accent: #f0b400;
  --grid: #3a3f4b;
  --grid-2: #303540;
  --wall: #c4b59a;
  --rubble: #5a4b3a;
  --castle: #d4af37;
  --enclosed: rgba(255, 255, 200, 0.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.hidden { display: none !important; }

/* ── Overlays (lobby, game over) ───────────────────────────── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 12, 16, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.panel {
  background: var(--panel);
  padding: 32px 40px;
  border-radius: 12px;
  min-width: 360px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
}

.panel h1 {
  margin: 0 0 4px 0;
  color: var(--accent);
  text-align: center;
  font-size: 28px;
  letter-spacing: 0.5px;
}

.tagline {
  color: var(--muted);
  margin: 0 0 16px;
  text-align: center;
  font-size: 13px;
}

.lobby-panel {
  width: 420px;
  min-width: 0;
  padding: 20px 22px 16px;
}

.footer-tagline {
  margin: 12px 0 0;
  text-align: center;
  font-size: 11px;
  color: var(--muted);
}

/* Name + Beitreten side by side */
.join-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}
.join-row input[type="text"] {
  flex: 1;
  padding: 8px 12px;
  background: var(--bg-2);
  border: 1px solid var(--grid);
  border-radius: 6px;
  color: var(--text);
  font-size: 14px;
}
.join-row button {
  margin: 0;
  padding: 8px 16px;
  background: var(--bg-2);
  color: var(--text);
  border: 1px solid var(--grid);
  border-radius: 6px;
  font-weight: 500;
  cursor: pointer;
  font-size: 13px;
}
.join-row button:hover:not(:disabled) {
  background: var(--grid);
}

.panel label {
  display: block;
  margin: 16px 0 8px;
  font-size: 14px;
  color: var(--muted);
}

.panel input[type="text"] {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-2);
  border: 1px solid var(--grid);
  border-radius: 6px;
  color: var(--text);
  font-size: 16px;
}

.panel button {
  margin-top: 12px;
  padding: 10px 16px;
  background: var(--accent);
  color: #1a1d24;
  border: none;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  font-size: 14px;
}

.panel button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.panel button:hover:not(:disabled) {
  filter: brightness(1.1);
}

.lobby-list {
  margin: 8px 0;
  min-height: 80px;
  background: var(--bg-2);
  border-radius: 6px;
  padding: 8px 12px;
}

.lobby-list.teams-layout {
  display: flex;
  gap: 10px;
  background: transparent;
  padding: 0;
}

.team-panel {
  --team-col: #888;
  flex: 1;
  background: var(--bg-2);
  border: 1px solid var(--team-col);
  border-radius: 6px;
  padding: 6px 10px 8px;
  min-height: 115px;
}

.team-panel .team-title {
  text-align: center;
  color: var(--team-col);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.team-panel .team-title.clickable {
  cursor: pointer;
  user-select: none;
}
.team-panel .team-title.clickable:hover {
  text-decoration: underline;
}

.lobby-list .player-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  font-size: 13px;
}

.team-panel .player-row .player-name {
  color: var(--text);
}

.player-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.player-name { flex: 1; }

.ready-tag {
  font-size: 11px;
  color: #3acb5a;
  text-transform: uppercase;
}

.hint { font-size: 12px; color: var(--muted); }

/* Lobby bottom action row */
.lobby-actions .add-bot-btn,
.lobby-actions .ready-btn {
  flex: 1;
  margin-top: 0;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 6px;
  border: 1px solid var(--grid);
  background: var(--bg-2);
  color: var(--text);
  cursor: pointer;
}
.lobby-actions .add-bot-btn:hover:not(:disabled),
.lobby-actions .ready-btn:hover:not(:disabled) {
  background: var(--grid);
}
.lobby-actions .ready-btn {
  border-color: #3acb5a;
  color: #3acb5a;
}
.lobby-actions .ready-btn.is-ready {
  background: #3acb5a;
  color: #111;
}

/* ── Game HUD overlays ──────────────────────────────────────
   The play field is full-screen. HUD elements float on top of
   the canvas as positioned overlays. */
.phase-overlay {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 8px 16px;
  background: rgba(20, 22, 28, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  z-index: 30;
  pointer-events: none;
  backdrop-filter: blur(6px);
}

.phase {
  font-weight: 700;
  text-transform: uppercase;
  color: var(--accent);
  letter-spacing: 1px;
}

.timer {
  font-size: 22px;
  font-variant-numeric: tabular-nums;
  color: #fff;
  background: var(--bg);
  padding: 4px 12px;
  border-radius: 6px;
  min-width: 50px;
  text-align: center;
}

.round {
  color: var(--muted);
  font-size: 13px;
}

.money {
  font-size: 14px;
  color: var(--accent);
  font-weight: 600;
  background: var(--bg);
  padding: 4px 10px;
  border-radius: 6px;
}

.players-overlay {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 30;
  background: rgba(20, 22, 28, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 8px 12px;
  min-width: 180px;
  pointer-events: none;
  backdrop-filter: blur(6px);
}

.players-overlay ul {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 13px;
}

.money-overlay {
  position: fixed;
  bottom: 12px;
  left: 12px;
  z-index: 30;
  pointer-events: none;
}

.money-overlay .money {
  font-size: 24px;
  padding: 12px 20px;
  background: var(--bg-2);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45), inset 0 0 0 1px rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(6px);
}

/* Brief scale + colour pulse on the money counter whenever income arrives,
   so the new total feels visually connected to the floating "+X". */
@keyframes money-pop {
  0%   { transform: scale(1);    color: var(--accent); }
  30%  { transform: scale(1.18); color: #ffe27a; }
  100% { transform: scale(1);    color: var(--accent); }
}
.money.money-pop {
  animation: money-pop 380ms ease-out;
}

/* Floating "+N" income chip that appears above the money counter and
   drifts upward while fading out. Multiple simultaneous payouts stack
   via the --stack CSS variable set in JS. */
@keyframes income-float-rise {
  0% {
    transform: translateY(0) scale(0.85);
    opacity: 0;
  }
  15% {
    transform: translateY(-6px) scale(1.1);
    opacity: 1;
  }
  100% {
    transform: translateY(-72px) scale(1);
    opacity: 0;
  }
}
.income-float {
  position: absolute;
  /* Sit just above the money chip; stack subsequent payouts higher. */
  bottom: calc(100% + 6px + var(--stack, 0) * 26px);
  left: 14px;
  font-size: 16px;
  font-weight: 700;
  color: #ffe27a;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.75), 0 0 8px rgba(255, 200, 80, 0.45);
  white-space: nowrap;
  pointer-events: none;
  animation: income-float-rise 1400ms cubic-bezier(0.22, 0.61, 0.36, 1) forwards;
}

.lobby-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.lobby-actions button { flex: 1; }

/* Lobby mode toggle */
.mode-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 0;
  margin-bottom: 8px;
}
.mode-btn {
  flex: 1;
  background: var(--bg-2);
  color: var(--text);
  border: 1px solid var(--grid);
  padding: 7px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}
.mode-btn:hover:not(.selected) {
  background: var(--grid);
}
.mode-btn.selected {
  background: var(--grid);
  color: var(--text);
  border-color: var(--muted);
}

/* Team groupings in lobby + in-game player overview */
.team-header,
.team-header-overlay {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  font-size: 13px;
  font-weight: bold;
  color: #ddd;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.team-header:first-child { margin-top: 0; }
.team-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}
.team-empty {
  color: #888;
  font-size: 12px;
  padding: 2px 0 2px 16px;
}

/* Per-row team selector */
.team-pick {
  margin-left: auto;
  display: inline-flex;
  gap: 4px;
}
.team-btn {
  --team-col: #888;
  background: transparent;
  color: #ddd;
  border: 1px solid var(--team-col);
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  cursor: pointer;
}
.team-btn.selected {
  background: var(--team-col);
  color: #111;
}

.bot-tag {
  font-size: 11px;
  color: var(--accent);
  text-transform: uppercase;
}

/* ── Stage (full-screen canvas) ────────────────────────────── */
.stage {
  position: relative;
  width: 100vw;
  height: 100vh;
  padding: 0;
}

#canvas {
  background: var(--bg);
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

/* Fertig button: floating bottom-left overlay above the money counter. */
#doneBtn.done-btn {
  position: fixed;
  bottom: 78px;
  left: 12px;
  z-index: 30;
}

#pieceCanvas {
  background: var(--bg-2);
  border-radius: 6px;
  display: block;
  margin: 4px 0 8px;
}

#pieceControls { display: flex; gap: 6px; flex-wrap: wrap; }

#pieceControls button {
  flex: 1;
  padding: 6px 8px;
  background: var(--bg-2);
  border: 1px solid var(--grid);
  border-radius: 4px;
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
}

#pieceControls button:hover { background: var(--grid); }

/* ── Build hand (3 cards floating at the bottom) ─────────────
   The hand is a fixed-position overlay that slides up from the
   bottom of the screen when the BUILD phase begins. It contains
   two groups: the cannon catalogue on the left (always the same
   three cards, smaller) and the wall-piece hand on the right
   (reshuffles after every successful placement). */
.hand {
  position: fixed;
  left: 50%;
  bottom: 20px;
  display: flex;
  gap: 22px;
  align-items: flex-end;
  padding: 8px 12px;
  z-index: 20;
  transform: translate(-50%, calc(100% + 40px));
  opacity: 1;
  transition: transform 0.45s cubic-bezier(0.16, 1, 0.3, 1),
              opacity 0.25s ease;
  /* The gaps between cards stay click-through so the player can drop
     pieces near the bottom edge of the field. Cards re-enable pointer
     events themselves. */
  pointer-events: none;
  perspective: 800px;
}

.hand.visible {
  transform: translate(-50%, 0);
}

.hand.visible .card,
.hand.visible .cannonCard {
  pointer-events: auto;
}

.piece-hand {
  display: flex;
  gap: 18px;
}

.cannon-hand {
  display: flex;
  gap: 10px;
  padding-left: 8px;
  border-left: 1px dashed rgba(255, 255, 255, 0.18);
}

.building-hand {
  display: flex;
  gap: 10px;
  padding-left: 8px;
  border-left: 1px dashed rgba(255, 255, 255, 0.18);
}

.card {
  position: relative;
  width: 150px;
  height: 200px;
  padding: 10px 10px 8px;
  background: linear-gradient(160deg, #fbf3d6 0%, #e8d291 55%, #cdae65 100%);
  color: #2c1f0d;
  border: 2px solid #5a4422;
  border-radius: 12px;
  box-shadow:
    0 12px 28px rgba(0, 0, 0, 0.55),
    inset 0 0 0 1px rgba(255, 255, 255, 0.4);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  cursor: grab;
  user-select: none;
  -webkit-user-drag: none;
  touch-action: none;
  transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
  will-change: transform;
}

.card:hover {
  transform: translateY(-10px) rotateX(4deg);
  box-shadow:
    0 18px 36px rgba(0, 0, 0, 0.6),
    inset 0 0 0 1px rgba(255, 255, 255, 0.5);
}

.card.selected,
.card.dragging {
  transform: translateY(-18px) rotateX(6deg);
  box-shadow:
    0 22px 40px rgba(240, 180, 0, 0.55),
    inset 0 0 0 2px var(--accent);
  cursor: grabbing;
}

.card.dragging {
  z-index: 22;
}

.card.unaffordable {
  filter: grayscale(0.7) brightness(0.7);
  cursor: not-allowed;
}

.card.unaffordable:hover {
  transform: none;
}

.card.used {
  visibility: hidden;
}

.cardKey {
  position: absolute;
  top: 6px;
  left: 8px;
  font-size: 12px;
  font-weight: 700;
  color: #4a3414;
  background: rgba(255, 255, 255, 0.55);
  border-radius: 4px;
  padding: 0 5px;
  line-height: 16px;
}

.cardName {
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #4a3414;
  padding: 0 22px;
  margin-bottom: 4px;
  min-height: 14px;
}

.cardCanvas {
  flex: 1;
  display: block;
  width: 100%;
  height: auto;
  background:
    radial-gradient(circle at 50% 40%, rgba(255,255,255,0.55), rgba(255,255,255,0) 70%),
    rgba(255, 255, 255, 0.25);
  border: 1px solid rgba(90, 68, 34, 0.45);
  border-radius: 6px;
  pointer-events: none;
}

.cardCost {
  position: absolute;
  bottom: 8px;
  right: 8px;
  min-width: 30px;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  color: #2c1f0d;
  background: var(--accent);
  border: 1px solid #6b4f10;
  border-radius: 999px;
  padding: 2px 8px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

#playerList li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
}

#playerList .player-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#playerList .player-money {
  font-size: 12px;
  color: var(--accent);
  font-weight: 600;
  background: var(--bg);
  padding: 1px 8px;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
}

#playerList .player-territory {
  font-size: 12px;
  color: #6fcf6f;
  font-weight: 600;
  background: var(--bg);
  padding: 1px 8px;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
}

#playerList .dead { text-decoration: line-through; color: var(--muted); }
#playerList .dead .player-money { opacity: 0.4; }
#playerList .dead .player-territory { opacity: 0.4; }

/* ── Cannon cards (small, persistent, next to the wall hand) ── */
.cannonCard {
  position: relative;
  width: 110px;
  height: 150px;
  padding: 8px 8px 6px;
  background: linear-gradient(160deg, #d3d8e0 0%, #9aa3b3 55%, #6c7787 100%);
  color: #1a1d24;
  border: 2px solid #303744;
  border-radius: 10px;
  box-shadow:
    0 10px 22px rgba(0, 0, 0, 0.5),
    inset 0 0 0 1px rgba(255, 255, 255, 0.4);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  cursor: pointer;
  user-select: none;
  -webkit-user-drag: none;
  touch-action: none;
  transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
  will-change: transform;
}

.cannonCard:hover:not(.unaffordable) {
  transform: translateY(-6px);
  box-shadow:
    0 14px 28px rgba(0, 0, 0, 0.6),
    inset 0 0 0 1px rgba(255, 255, 255, 0.5);
}

.cannonCard.selected {
  transform: translateY(-12px);
  border-color: var(--accent);
  box-shadow:
    0 18px 32px rgba(240, 180, 0, 0.55),
    inset 0 0 0 2px var(--accent);
}

.cannonCard.unaffordable {
  filter: grayscale(0.7) brightness(0.7);
  cursor: not-allowed;
}

.cannonCard.used { visibility: hidden; }

.cannonCard .cannonName {
  text-align: center;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #161a23;
}

.cannonCard .cannonCardCanvas {
  flex: 1;
  display: block;
  width: 100%;
  height: auto;
  background:
    radial-gradient(circle at 50% 40%, rgba(255,255,255,0.45), rgba(255,255,255,0) 70%),
    rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(40, 48, 60, 0.45);
  border-radius: 6px;
  pointer-events: none;
}

.cannonCard .cannonMeta {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 2px 0;
}

.cannonCard .cannonCost {
  color: #1a1d24;
  background: var(--accent);
  border-radius: 999px;
  padding: 1px 8px;
}

.cannonCard .cannonReload {
  color: #1a1d24;
  background: rgba(255, 255, 255, 0.6);
  border-radius: 999px;
  padding: 1px 8px;
}

/* ── Building cards (Farm / Labor) ── */
.buildingCard {
  position: relative;
  width: 110px;
  height: 150px;
  padding: 8px 8px 6px;
  background: linear-gradient(160deg, #d8e6c4 0%, #93b272 55%, #65864c 100%);
  color: #1a1d24;
  border: 2px solid #36502a;
  border-radius: 10px;
  box-shadow:
    0 10px 22px rgba(0, 0, 0, 0.5),
    inset 0 0 0 1px rgba(255, 255, 255, 0.4);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  cursor: pointer;
  user-select: none;
  -webkit-user-drag: none;
  touch-action: none;
  transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
  will-change: transform;
}

.buildingCard[data-building-type="1"] {
  background: linear-gradient(160deg, #c8e0ea 0%, #6f9fbf 55%, #3f6f95 100%);
  border-color: #1f3a5c;
}

.buildingCard:hover:not(.unaffordable) {
  transform: translateY(-6px);
  box-shadow:
    0 14px 28px rgba(0, 0, 0, 0.6),
    inset 0 0 0 1px rgba(255, 255, 255, 0.5);
}

.buildingCard.selected {
  transform: translateY(-12px);
  border-color: var(--accent);
  box-shadow:
    0 18px 32px rgba(240, 180, 0, 0.55),
    inset 0 0 0 2px var(--accent);
}

.buildingCard.unaffordable {
  filter: grayscale(0.7) brightness(0.7);
  cursor: not-allowed;
}

.buildingCard.used { visibility: hidden; }

.buildingCard .buildingName {
  text-align: center;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #161a23;
}

.buildingCard .buildingCardCanvas {
  flex: 1;
  display: block;
  width: 100%;
  height: auto;
  background:
    radial-gradient(circle at 50% 40%, rgba(255,255,255,0.45), rgba(255,255,255,0) 70%),
    rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(40, 48, 60, 0.45);
  border-radius: 6px;
  pointer-events: none;
}

.buildingCard .buildingMeta {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  font-weight: 700;
  padding: 4px 2px 0;
  gap: 4px;
}

.buildingCard .buildingCost {
  color: #1a1d24;
  background: var(--accent);
  border-radius: 999px;
  padding: 1px 8px;
}

.buildingCard .buildingEffect {
  color: #1a1d24;
  background: rgba(255, 255, 255, 0.6);
  border-radius: 999px;
  padding: 1px 6px;
  white-space: nowrap;
}

/* ── Reroll card (single, refreshes the wall-piece hand) ── */
.reroll-hand {
  display: flex;
  gap: 10px;
  padding-right: 8px;
  border-right: 1px dashed rgba(255, 255, 255, 0.18);
}

.hand.visible .buildingCard,
.hand.visible .rerollCard {
  pointer-events: auto;
}

.rerollCard {
  position: relative;
  width: 110px;
  height: 150px;
  padding: 8px 8px 6px;
  background: linear-gradient(160deg, #efd8f5 0%, #b078d0 55%, #6c3f8c 100%);
  color: #1a1d24;
  border: 2px solid #3a1f55;
  border-radius: 10px;
  box-shadow:
    0 10px 22px rgba(0, 0, 0, 0.5),
    inset 0 0 0 1px rgba(255, 255, 255, 0.4);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  cursor: pointer;
  user-select: none;
  -webkit-user-drag: none;
  touch-action: none;
  transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
  will-change: transform;
}

.rerollCard:hover:not(.unaffordable) {
  transform: translateY(-6px);
  box-shadow:
    0 14px 28px rgba(0, 0, 0, 0.6),
    inset 0 0 0 1px rgba(255, 255, 255, 0.5);
}

.rerollCard.unaffordable {
  filter: grayscale(0.7) brightness(0.7);
  cursor: not-allowed;
}

.rerollCard.used { visibility: hidden; }

.rerollCard .rerollName {
  text-align: center;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #161a23;
}

.rerollCard .rerollCardCanvas {
  flex: 1;
  display: block;
  width: 100%;
  height: auto;
  background:
    radial-gradient(circle at 50% 40%, rgba(255,255,255,0.45), rgba(255,255,255,0) 70%),
    rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(40, 48, 60, 0.45);
  border-radius: 6px;
  pointer-events: none;
}

.rerollCard .rerollMeta {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  font-weight: 700;
  padding: 4px 2px 0;
  gap: 4px;
}

.rerollCard .rerollCost {
  color: #1a1d24;
  background: var(--accent);
  border-radius: 999px;
  padding: 1px 8px;
}

.rerollCard .rerollEffect {
  color: #1a1d24;
  background: rgba(255, 255, 255, 0.6);
  border-radius: 999px;
  padding: 1px 6px;
  white-space: nowrap;
}

/* ── Fertig button + done tag ───────────────────────────────── */
.done-btn {
  padding: 6px 14px;
  background: var(--accent);
  color: #1a1d24;
  border: none;
  border-radius: 6px;
  font-weight: 700;
  cursor: pointer;
  font-size: 13px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  transition: filter 0.15s ease, background 0.15s ease;
}

.done-btn:hover:not(:disabled) {
  filter: brightness(1.1);
}

.done-btn.pressed,
.done-btn:disabled {
  background: var(--bg);
  color: var(--muted);
  cursor: not-allowed;
}

.done-tag {
  font-size: 11px;
  color: var(--accent);
  text-transform: uppercase;
  font-weight: 700;
  margin-left: 4px;
}

/* ── Fire-mode bar (battle phase) ───────────────────────────
   Same layout idea as the build hand: a fixed-position row at the
   bottom of the screen that slides up when BATTLE begins. Each card
   represents either a cannon type to filter to ("Alle" + per type),
   selected card is highlighted like the build-hand cards. */
.fire-mode {
  position: fixed;
  left: 50%;
  bottom: 20px;
  display: flex;
  gap: 10px;
  align-items: flex-end;
  padding: 8px 12px;
  z-index: 20;
  transform: translate(-50%, calc(100% + 40px));
  opacity: 1;
  transition: transform 0.45s cubic-bezier(0.16, 1, 0.3, 1),
              opacity 0.25s ease;
  pointer-events: none;
}

.fire-mode.visible {
  transform: translate(-50%, 0);
}

.fire-mode.visible .fireCard {
  pointer-events: auto;
}

.fireCard {
  position: relative;
  width: 110px;
  height: 150px;
  padding: 8px 8px 6px;
  background: linear-gradient(160deg, #f5d9b3 0%, #d39b59 55%, #8c5e2c 100%);
  color: #1a1d24;
  border: 2px solid #4a2d12;
  border-radius: 10px;
  box-shadow:
    0 10px 22px rgba(0, 0, 0, 0.5),
    inset 0 0 0 1px rgba(255, 255, 255, 0.4);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  cursor: pointer;
  user-select: none;
  -webkit-user-drag: none;
  touch-action: none;
  transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
  will-change: transform;
}

.fireCard.fireCard-all {
  background: linear-gradient(160deg, #fbf3d6 0%, #e8d291 55%, #cdae65 100%);
  border-color: #5a4422;
}

.fireCard:hover:not(.unaffordable) {
  transform: translateY(-6px);
  box-shadow:
    0 14px 28px rgba(0, 0, 0, 0.6),
    inset 0 0 0 1px rgba(255, 255, 255, 0.5);
}

.fireCard.selected {
  transform: translateY(-12px);
  border-color: var(--accent);
  box-shadow:
    0 18px 32px rgba(240, 180, 0, 0.55),
    inset 0 0 0 2px var(--accent);
}

.fireCard.used { visibility: hidden; }

.fireCard.unaffordable {
  filter: grayscale(0.7) brightness(0.7);
  cursor: not-allowed;
}

.fireCard .fireName {
  text-align: center;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #161a23;
}

.fireCard .fireCardCanvas {
  flex: 1;
  display: block;
  width: 100%;
  height: auto;
  background:
    radial-gradient(circle at 50% 40%, rgba(255,255,255,0.45), rgba(255,255,255,0) 70%),
    rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(40, 48, 60, 0.45);
  border-radius: 6px;
  pointer-events: none;
}

.fireCard .fireMeta {
  display: flex;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 2px 0;
  color: #1a1d24;
}

.fireCard .fireCount {
  background: rgba(255, 255, 255, 0.6);
  border-radius: 999px;
  padding: 1px 8px;
}

/* ═══════════════════════════════════════════════════════════════
   LOBBY REDESIGN — medieval siege command post
   All selectors are scoped to #lobby or .lobby-panel so the
   game-HUD and game-over overlay are never touched.
═══════════════════════════════════════════════════════════════ */

/* Stone-textured backdrop: very low-contrast diamond check behind
   a warm radial that simulates candlelight at center */
#lobby.overlay {
  background:
    radial-gradient(ellipse 80% 80% at 50% 48%,
      rgba(26, 18, 6, 0.68), rgba(4, 3, 2, 1)),
    repeating-conic-gradient(#0d0b08 0% 25%, #110e0a 0% 50%) 0 0 / 28px 28px;
}

/* Panel: carved-stone double border via layered box-shadow */
.lobby-panel {
  width: 420px;
  min-width: 0;
  padding: 0;
  background: #1e1912;
  border: 1px solid #4a3e27;
  border-radius: 2px;
  box-shadow:
    inset 0 0 0 3px #110e08,
    0 0 0 4px #110e08,
    0 0 0 5px rgba(74, 62, 39, 0.55),
    0 32px 80px rgba(0, 0, 0, 0.92);
  overflow: hidden;
}

/* Header zone: warm gold wash, thin gold top edge stripe */
.lobby-header {
  padding: 30px 32px 22px;
  text-align: center;
  position: relative;
  background: linear-gradient(180deg, rgba(200, 158, 28, 0.07) 0%, transparent 100%);
  border-bottom: 1px solid #2c2318;
}

.lobby-header::before {
  content: '';
  position: absolute;
  top: 0; left: 28px; right: 28px;
  height: 2px;
  background: linear-gradient(90deg, transparent, #c8a020 25%, #c8a020 75%, transparent);
}

/* Title */
.lobby-panel h1 {
  margin: 0;
  font-family: 'Cinzel', Georgia, 'Times New Roman', serif;
  font-size: 38px;
  font-weight: 900;
  letter-spacing: 8px;
  text-indent: 8px;
  color: #c8a020;
  text-shadow:
    0 1px 0 #4a3a10,
    0 2px 8px rgba(0, 0, 0, 0.8),
    0 0 48px rgba(200, 158, 28, 0.18);
  text-transform: uppercase;
  line-height: 1.1;
  text-wrap: balance;
}

.lobby-header .tagline {
  margin: 10px 0 0;
  font-size: 10px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: #4e4432;
  text-align: center;
}

/* Body: form + list + actions in a flex column */
.lobby-body {
  padding: 18px 22px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Name input + join */
.lobby-panel .join-row {
  display: flex;
  gap: 8px;
  margin-bottom: 0;
}

.lobby-panel .join-row input[type="text"] {
  flex: 1;
  padding: 10px 14px;
  background: #17130d;
  border: 1px solid #3d3322;
  border-radius: 2px;
  color: #e0d4bc;
  font-size: 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.lobby-panel .join-row input[type="text"]:focus {
  outline: none;
  border-color: #c8a020;
  box-shadow: 0 0 0 2px rgba(200, 160, 32, 0.12);
}

.lobby-panel .join-row input[type="text"]::placeholder {
  color: #3e3428;
}

.lobby-panel .join-row button {
  margin-top: 0;
  padding: 10px 18px;
  background: #c8a020;
  color: #12100a;
  border: none;
  border-radius: 2px;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 1px;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
}

.lobby-panel .join-row button:hover:not(:disabled) {
  background: #dbb830;
  box-shadow: 0 2px 14px rgba(200, 160, 32, 0.28);
  filter: none;
}

.lobby-panel .join-row button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  filter: none;
}

/* Mode toggle: pill container, inset-shadow for selected state */
.lobby-panel .mode-row {
  display: flex;
  gap: 0;
  margin: 0;
  background: #17130d;
  border: 1px solid #3d3322;
  border-radius: 2px;
  padding: 2px;
}

.lobby-panel .mode-btn {
  flex: 1;
  margin-top: 0;
  background: transparent;
  color: #4e4432;
  border: none;
  border-radius: 1px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  font-weight: 600;
  transition: background 0.15s, color 0.15s;
}

.lobby-panel .mode-btn:hover:not(.selected) {
  color: #8a7a5a;
  background: rgba(255, 255, 255, 0.03);
  filter: none;
}

.lobby-panel .mode-btn.selected {
  background: #2a2418;
  color: #c8a020;
  box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.45);
  border-color: transparent;
}

/* Player roster */
.lobby-panel .lobby-list {
  min-height: 88px;
  background: #17130d;
  border: 1px solid #3d3322;
  border-radius: 2px;
  padding: 6px 10px;
  margin: 0;
}

.lobby-panel .lobby-list.teams-layout {
  display: flex;
  gap: 10px;
  background: transparent;
  border: none;
  padding: 0;
}

.lobby-panel .team-panel {
  --team-col: #888;
  flex: 1;
  background: #17130d;
  border: 1px solid var(--team-col);
  border-radius: 2px;
  padding: 6px 10px 8px;
  min-height: 115px;
}

.lobby-panel .team-panel .team-title {
  text-align: center;
  color: var(--team-col);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.lobby-panel .lobby-list .player-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  font-size: 13px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.035);
}

.lobby-panel .lobby-list .player-row:last-child {
  border-bottom: none;
}

.lobby-panel .lobby-list .player-name {
  flex: 1;
  color: #d8ccb4;
}

.lobby-panel .lobby-list .ready-tag {
  font-size: 9px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  font-weight: 700;
}

.lobby-panel .lobby-list .bot-tag {
  font-size: 9px;
  letter-spacing: 1.5px;
  color: #c8a020;
  text-transform: uppercase;
  font-weight: 600;
}

.lobby-panel .team-empty {
  color: #3e3428;
  font-size: 11px;
  padding: 4px 0;
  text-align: center;
  letter-spacing: 1px;
}

/* Bottom actions */
.lobby-panel .lobby-actions {
  display: flex;
  gap: 8px;
  margin-top: 0;
}

.lobby-panel .lobby-actions button {
  flex: 1;
}

.lobby-panel .lobby-actions .add-bot-btn {
  padding: 10px 12px;
  background: #1e1912;
  color: #6a5e48;
  border: 1px solid #3d3322;
  border-radius: 2px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  cursor: pointer;
  margin-top: 0;
  transition: background 0.15s, color 0.15s;
}

.lobby-panel .lobby-actions .add-bot-btn:hover:not(:disabled) {
  background: #2a2418;
  color: #9a8868;
  filter: none;
}

.lobby-panel .lobby-actions .add-bot-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  filter: none;
}

/* Ready button: ember-red at rest, green when confirmed */
.lobby-panel .lobby-actions .ready-btn {
  padding: 10px 12px;
  background: #1e1912;
  color: #d04a14;
  border: 1px solid #7a3010;
  border-radius: 2px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  cursor: pointer;
  margin-top: 0;
  transition: background 0.15s, color 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.lobby-panel .lobby-actions .ready-btn:hover:not(:disabled):not(.is-ready) {
  background: #2a1508;
  border-color: #c04018;
  filter: none;
}

.lobby-panel .lobby-actions .ready-btn.is-ready {
  background: #0e2012;
  border-color: #2a8040;
  color: #3acc58;
  box-shadow: 0 0 14px rgba(48, 160, 72, 0.14);
}

.lobby-panel .lobby-actions .ready-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  filter: none;
}

/* Team-pick inline selector */
.lobby-panel .team-pick {
  margin-left: auto;
  display: inline-flex;
  gap: 4px;
}

.lobby-panel .team-btn {
  --team-col: #888;
  background: transparent;
  color: #ccc;
  border: 1px solid var(--team-col);
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  cursor: pointer;
  margin-top: 0;
}

.lobby-panel .team-btn.selected {
  background: var(--team-col);
  color: #111;
}

.lobby-panel .footer-tagline { display: none; }

/* ── Two-step lobby additions ──────────────────────────────
   The first overlay (#lobby) is now a room picker: name input,
   a scrollable list of currently open rooms and a "create room"
   row. The second overlay (#roomLobby) is the joined-room
   waiting screen with chat — it reuses .lobby-panel so all the
   parchment styling from the original lobby applies. */

.lobby-panel .rooms-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-family: 'Cinzel', Georgia, serif;
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #8a7a5a;
  margin: 6px 0 2px;
}

.lobby-panel .link-btn {
  background: none;
  border: none;
  color: #c8a020;
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  cursor: pointer;
  padding: 2px 4px;
  margin: 0;
  font-weight: 600;
}

.lobby-panel .link-btn:hover {
  color: #dbb830;
  filter: none;
  background: transparent;
  box-shadow: none;
}

.lobby-panel .rooms-list {
  background: #17130d;
  border: 1px solid #3d3322;
  border-radius: 2px;
  max-height: 240px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px;
}

.lobby-panel .rooms-empty {
  text-align: center;
  color: #5a4f3a;
  font-size: 12px;
  letter-spacing: 1px;
  padding: 18px 6px;
  text-transform: uppercase;
}

.lobby-panel .room-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  background: #1e1912;
  border: 1px solid #2c2318;
  border-radius: 2px;
}

.lobby-panel .room-row-main {
  flex: 1;
  min-width: 0;
}

.lobby-panel .room-row .room-name {
  font-family: 'Cinzel', Georgia, serif;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #d8ccb4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lobby-panel .room-row .room-meta {
  display: flex;
  gap: 10px;
  font-size: 11px;
  color: #8a7a5a;
  margin-top: 2px;
  flex-wrap: wrap;
}

.lobby-panel .room-row .room-mode {
  color: #c8a020;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.lobby-panel .room-join-btn {
  padding: 8px 14px;
  background: #c8a020;
  color: #12100a;
  border: none;
  border-radius: 2px;
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  cursor: pointer;
  margin: 0;
}

.lobby-panel .room-join-btn:hover:not(:disabled) {
  background: #dbb830;
  filter: none;
  box-shadow: 0 2px 14px rgba(200, 160, 32, 0.28);
}

.lobby-panel .room-join-btn:disabled {
  background: #2a2418;
  color: #5a4f3a;
  cursor: not-allowed;
}

.lobby-panel .create-row {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.lobby-panel .create-row input[type="text"] {
  flex: 1;
  padding: 10px 14px;
  background: #17130d;
  border: 1px solid #3d3322;
  border-radius: 2px;
  color: #e0d4bc;
  font-size: 13px;
}

.lobby-panel .create-row input[type="text"]:focus {
  outline: none;
  border-color: #c8a020;
  box-shadow: 0 0 0 2px rgba(200, 160, 32, 0.12);
}

.lobby-panel .create-row input[type="text"]::placeholder {
  color: #3e3428;
}

.lobby-panel .create-room-btn {
  margin: 0;
  padding: 10px 18px;
  background: transparent;
  color: #c8a020;
  border: 1px solid #7a6020;
  border-radius: 2px;
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.lobby-panel .create-room-btn:hover {
  background: #2a2418;
  color: #dbb830;
  filter: none;
}

/* ── Step 2: joined-room overlay ──────────────────────────── */
.room-lobby-panel {
  width: 720px;
  max-width: calc(100vw - 32px);
}

.room-lobby-columns {
  display: flex;
  gap: 12px;
  align-items: stretch;
}

.room-lobby-left {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.room-lobby-columns .chat-wrap {
  width: 220px;
  flex-shrink: 0;
  margin-top: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.room-lobby-columns .chat-log {
  flex: 1;
  height: auto;
}

.room-lobby-panel .lobby-header {
  position: relative;
}

.room-lobby-panel .leave-room-btn {
  position: absolute;
  top: 10px;
  left: 14px;
  z-index: 1;
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
}

/* In-row host star + "you" tag. */
.lobby-panel .lobby-list .host-tag {
  color: #c8a020;
  font-size: 12px;
  line-height: 1;
}

.lobby-panel .lobby-list .you-tag {
  font-size: 9px;
  letter-spacing: 1.5px;
  color: #7a8aa0;
  text-transform: uppercase;
  font-weight: 600;
}

/* Disabled mode toggle for non-hosts: dim it so they understand they
   can't click, but keep the selected state visible so they see which
   mode is currently active. */
.lobby-panel .mode-btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.lobby-panel .lobby-actions .add-bot-btn:disabled {
  cursor: not-allowed;
}

/* ── Chat panel (step 2) ─────────────────────────────────── */
.chat-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
}

.chat-log {
  height: 160px;
  overflow-y: auto;
  background: #17130d;
  border: 1px solid #3d3322;
  border-radius: 2px;
  padding: 8px 10px;
  font-size: 13px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.chat-empty {
  color: #5a4f3a;
  font-size: 11px;
  letter-spacing: 1px;
  text-align: center;
  text-transform: uppercase;
  padding: 20px 0;
}

.chat-row {
  line-height: 1.35;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

.chat-row .chat-name {
  color: #c8a020;
  font-weight: 700;
  margin-right: 6px;
}

.chat-row.chat-mine .chat-name {
  color: #3acc58;
}

.chat-row .chat-text {
  color: #d8ccb4;
}

.chat-form {
  display: flex;
  gap: 8px;
}

.chat-form input[type="text"] {
  flex: 1;
  padding: 8px 12px;
  background: #17130d;
  border: 1px solid #3d3322;
  border-radius: 2px;
  color: #e0d4bc;
  font-size: 13px;
}

.chat-form input[type="text"]:focus {
  outline: none;
  border-color: #c8a020;
  box-shadow: 0 0 0 2px rgba(200, 160, 32, 0.12);
}

.chat-form input[type="text"]::placeholder {
  color: #3e3428;
}

.chat-form button {
  margin: 0;
  padding: 8px 16px;
  background: #c8a020;
  color: #12100a;
  border: none;
  border-radius: 2px;
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  cursor: pointer;
}

.chat-form button:hover {
  background: #dbb830;
  filter: none;
}

/* ── Volume controls (top-right in-game HUD) ─────────────────── */
.volume-controls {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: rgba(20, 22, 28, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 8px 12px;
  backdrop-filter: blur(6px);
  pointer-events: all;
}

.vol-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.vol-label input[type=range] {
  width: 80px;
  accent-color: var(--accent);
  cursor: pointer;
}
