/* ============================================================
   ECHOES — Fenda de Duelo · v0.1.0-alpha
   Pure CSS — no framework
   ============================================================ */

:root {
  --bg:              #060612;
  --bg-gradient:     radial-gradient(circle at 50% 50%, #110e30 0%, #03030a 100%);
  --surface:         rgba(18, 18, 42, 0.65);
  --surface-hover:   rgba(30, 30, 65, 0.85);
  --border:          rgba(123, 94, 167, 0.35);
  --border-hover:    rgba(192, 132, 252, 0.6);
  --primary:         #7b5ea7;
  --primary-h:       #9b7ec8;
  --accent:          #c084fc;
  --accent-glow:     rgba(192, 132, 252, 0.25);
  --text:            #f1f1f8;
  --muted:           #a3a3c2;
  --fighter-l:       #3b82f6;
  --fighter-r:       #ef4444;
  --result:          #fbbf24;
  --font:            'Outfit', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --shadow:          0 12px 32px rgba(0, 0, 0, 0.4);
  --shadow-glow:     0 0 24px rgba(123, 94, 167, 0.15);
}

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

html, body {
  min-height: 100%;
  background: var(--bg-gradient);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ── Screen management ── */

[hidden] {
  display: none !important;
}

.screen {
  display: none;
  position: fixed;
  inset: 0;
  overflow-y: auto;
}

.screen.active {
  display: flex;
}

.screen-inner {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 2rem;
  /* establish containing block for absolute overlays (result panel) */
  position: relative;
}

/* ── Home screen ── */

.logo-block {
  text-align: center;
  padding: 3.5rem 0 2.5rem;
}

.logo-title {
  font-size: clamp(2.5rem, 12vw, 4rem);
  font-weight: 900;
  letter-spacing: 0.3em;
  color: var(--accent);
  text-shadow: 0 0 48px rgba(192, 132, 252, 0.35);
}

.logo-sub {
  font-size: 0.78rem;
  letter-spacing: 0.22em;
  color: var(--muted);
  margin-top: 0.5rem;
  text-transform: uppercase;
}

.tagline {
  font-size: 1.02rem;
  color: var(--muted);
  text-align: center;
  line-height: 1.5;
}

/* ── Card library ── */

.card-library {
  width: 100%;
  margin-top: 0.5rem;
}

.card-library h2 {
  margin-bottom: 0.75rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-align: center;
  text-transform: uppercase;
}

.card-library-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  width: 100%;
}

.library-card {
  display: grid;
  grid-template-columns: 1.4rem 48px minmax(0, 1fr) 1.35rem;
  gap: 0.6rem;
  align-items: center;
  min-width: 0;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.library-card-number {
  display: grid;
  place-items: center;
  width: 1.4rem;
  height: 1.4rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--accent);
  font-size: 0.62rem;
  font-weight: 800;
  line-height: 1;
}

.library-card img {
  display: block;
  width: 48px;
  aspect-ratio: 2.5 / 3.5;
  border-radius: 5px;
  object-fit: cover;
  background: var(--bg);
}

.library-card-body {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}

.library-card strong,
.library-card span,
.library-card code {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.library-card strong {
  color: var(--text);
  font-size: 0.68rem;
  line-height: 1.2;
}

.library-card span {
  color: var(--muted);
  font-size: 0.62rem;
}

.library-card code {
  color: var(--accent);
  font-size: 0.58rem;
}

.library-card-info {
  display: grid;
  place-items: center;
  width: 1.35rem;
  height: 1.35rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 0.68rem;
  font-family: var(--font);
  font-weight: 800;
  line-height: 1;
  cursor: help;
}

.library-card-info:hover,
.library-card-info:focus-visible {
  border-color: var(--primary);
  color: var(--accent);
  outline: none;
}

/* ── Shared layout ── */

.center-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
}

.screen-footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding-top: 1.5rem;
}

.version {
  font-size: 0.74rem;
  color: var(--muted);
  opacity: 0.45;
  display: block;
  text-align: center;
  width: 100%;
  margin-bottom: 2rem;
}

/* ── Buttons ── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.95rem 2rem;
  border: none;
  border-radius: 12px;
  font-size: 1.05rem;
  font-weight: 700;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  width: 100%;
  max-width: 320px;
  text-align: center;
  letter-spacing: 0.03em;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(123, 94, 167, 0.25);
}

.btn:active:not(:disabled) {
  transform: scale(0.98) translateY(0);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-h) 100%);
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--primary-h) 0%, #b294e0 100%);
  box-shadow: 0 8px 24px rgba(192, 132, 252, 0.35);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--surface-hover);
  color: var(--accent);
  box-shadow: 0 8px 24px rgba(192, 132, 252, 0.15);
}

.btn-back {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.88rem;
  font-family: var(--font);
  cursor: pointer;
  padding: 0.25rem 0;
  flex-shrink: 0;
}

.btn-back:hover {
  color: var(--text);
}

.ghost-button {
  background: rgba(192, 132, 252, 0.05);
  border: 1px solid rgba(192, 132, 252, 0.35);
  color: var(--accent);
  border-radius: 6px;
  padding: 0.4rem 0.8rem;
  font-size: 0.72rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, transform 0.1s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.ghost-button:hover {
  background: rgba(192, 132, 252, 0.15);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 0 10px rgba(192, 132, 252, 0.25);
}

.ghost-button:active {
  transform: scale(0.96);
}

#manual-qr-lobby-button {
  padding: 0.85rem 1.5rem;
  font-size: 0.85rem;
  width: 100%;
  margin-top: 0.6rem;
  border-radius: 10px;
}

/* ── Screen headers ── */

.screen-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
}

.screen-header h2 {
  flex: 1;
  font-size: 1rem;
  letter-spacing: 0.12em;
  color: var(--accent);
  text-transform: uppercase;
}

.step-badge {
  font-size: 0.72rem;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.2rem 0.6rem;
  flex-shrink: 0;
}

/* ── QR scanner ── */

.qr-panel {
  width: 100%;
  max-width: 100%;
  min-height: 300px;
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-items: stretch;
  justify-content: center;
  padding: 0.75rem;
  background: var(--surface);
  flex-shrink: 0;
  margin: 0 auto;
}

.qr-reader {
  width: 100%;
  min-height: 260px;
  overflow: hidden;
  border: 2px dashed var(--border);
  border-radius: 12px;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.qr-reader.is-scanning {
  border-color: var(--border);
  box-shadow: none;
}

.qr-reader.has-detected-card {
  border-style: solid;
  border-color: #34d399;
  box-shadow: 0 0 22px rgba(52, 211, 153, 0.35), inset 0 0 24px rgba(52, 211, 153, 0.08);
}

.qr-reader.is-scanning::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(68%, 220px);
  height: 2px;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, rgba(192, 132, 252, 0.95), transparent);
  box-shadow: 0 0 14px rgba(192, 132, 252, 0.55);
  animation: qr-scan-line 1.35s ease-in-out infinite;
  pointer-events: none;
  z-index: 3;
}

.qr-reader.has-detected-card::after {
  background: linear-gradient(90deg, transparent, rgba(134, 239, 172, 0.95), transparent);
  box-shadow: 0 0 16px rgba(134, 239, 172, 0.7);
}

.qr-reader:empty::before {
  content: "▣";
  display: grid;
  min-height: 240px;
  place-items: center;
  color: var(--muted);
  font-size: 3.5rem;
  opacity: 0.28;
  width: 100%;
}

.qr-reader video {
  width: 100% !important;
  height: 100% !important;
  max-width: 100% !important;
  max-height: 100% !important;
  object-fit: cover !important;
  border-radius: 8px;
}

.qr-reader > div {
  width: 100% !important;
  height: 100% !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

.qr-reader img {
  max-width: 100%;
  height: auto;
}

.qr-status {
  min-height: 2.4em;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.35;
  text-align: center;
}

.qr-status.is-ok {
  color: #86efac;
}

.qr-status.is-error {
  color: #fca5a5;
}

@keyframes qr-scan-line {
  0% { transform: translate(-50%, -95px); opacity: 0.2; }
  15% { opacity: 1; }
  85% { opacity: 1; }
  100% { transform: translate(-50%, 95px); opacity: 0.2; }
}

/* ── Card chip ── */

.card-preview {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
}

.loaded-card-image {
  display: block;
  width: min(180px, 50vw);
  aspect-ratio: 2.5 / 3.5;
  border: 1px solid var(--border);
  border-radius: 8px;
  object-fit: cover;
  background: var(--surface);
}

.card-loaded-label {
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.card-chip {
  display: inline-block;
  padding: 0.55rem 1.1rem;
  background: var(--surface);
  border: 1px solid var(--primary);
  border-radius: 8px;
  font-size: 0.85rem;
  color: var(--accent);
  font-weight: 600;
  letter-spacing: 0.04em;
  max-width: min(320px, 90vw);
  line-height: 1.35;
}

/* ── Battle screen ── */

.battle-header {
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.75rem;
}

.battle-title {
  font-size: 0.9rem;
  letter-spacing: 0.18em;
  color: var(--accent);
  text-align: center;
  padding: 0.6rem 0;
  text-transform: uppercase;
}

.battle-arena {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.75rem 0;
  min-height: 0;
}

.fighter {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.fighter-left .stickman {
  color: var(--fighter-l);
}

.fighter-right .stickman {
  color: var(--fighter-r);
}

.stickman {
  width: clamp(60px, 18vw, 90px);
  height: auto;
  flex-shrink: 0;
  /* Fix vertical position and add subtle scale-only idle animation (no translateY) */
  transform: translateY(0);
  transform-box: fill-box;
  transform-origin: center;
  animation: idle-breathe 2.5s ease-in-out infinite;
}

@keyframes idle-breathe {
  0%   { transform: translateY(0) scale(1); }
  50%  { transform: translateY(0) scale(1.03); }
  100% { transform: translateY(0) scale(1); }
}

.fighter-name {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text);
  text-align: center;
  letter-spacing: 0.05em;
  word-break: break-word;
}

.fighter-stats {
  font-size: 0.7rem;
  color: var(--muted);
  text-align: center;
  line-height: 1.6;
}

.fighter-serial {
  font-size: 0.6rem;
  color: var(--muted);
  opacity: 0.45;
  text-align: center;
  font-family: monospace;
  word-break: break-all;
}

.battle-vs {
  font-size: 1.3rem;
  font-weight: 900;
  color: var(--border);
  padding: 0 0.25rem;
  flex-shrink: 0;
  letter-spacing: 0.05em;
}

/* ── Battle result ── */

.battle-result {
  /* panel styling (now used inside modal overlay) */
  position: relative;
  z-index: 61;
  text-align: center;
  padding: clamp(0.75rem, 3vw, 1.25rem);
  padding-top: 2rem;
  animation: fade-in 0.28s ease;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.04);
  transition: all 0.18s ease;
  margin: 0;
  width: min(90%, 420px);
  max-height: 85vh;
  overflow-y: auto;
  background: linear-gradient(180deg, rgba(6,6,12,0.95), rgba(8,8,16,0.95));
  box-shadow: 0 12px 36px rgba(0,0,0,0.6), 0 0 20px rgba(192,132,252,0.06);
  backdrop-filter: blur(6px) saturate(120%);
}

/* Modal overlay that covers viewport and prevents interaction/scroll behind */
.modal-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 60;
  background: rgba(3,3,8,0.45);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  padding: 1.25rem;
}

/* hide overlay when hidden attribute present */
.modal-overlay[hidden] {
  display: none;
}

/* prevent background scroll when modal open */
.modal-open {
  overflow: hidden !important;
}

/* Modal close button (X icon) */
.modal-close-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  color: var(--muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  transition: color 0.2s ease, background-color 0.2s ease, border-color 0.2s ease;
  z-index: 62;
}

.modal-close-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--border-hover);
  color: var(--text);
}

/* Smaller button variant for modal */
.btn-sm {
  padding: 0.6rem 1.5rem !important;
  font-size: 0.85rem !important;
  font-weight: 600 !important;
  min-width: 160px;
  max-width: 240px;
}

/* Modal actions (buttons inside modal) */
.modal-actions {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1rem;
  width: 100%;
}

.battle-result.is-victory {
  border-color: #34d399;
  background: rgba(52, 211, 153, 0.08);
  box-shadow: 0 0 15px rgba(52, 211, 153, 0.2);
}

.battle-result.is-victory .result-text {
  color: #34d399;
  text-shadow: 0 0 15px rgba(52, 211, 153, 0.4);
}

.battle-result.is-defeat {
  border-color: #f87171;
  background: rgba(248, 113, 113, 0.08);
  box-shadow: 0 0 15px rgba(248, 113, 113, 0.2);
}

.battle-result.is-defeat .result-text {
  color: #f87171;
  text-shadow: 0 0 15px rgba(248, 113, 113, 0.4);
}

.battle-result.is-draw {
  border-color: var(--accent);
  background: rgba(192, 132, 252, 0.08);
  box-shadow: 0 0 15px rgba(192, 132, 252, 0.2);
}

.battle-result.is-draw .result-text {
  color: var(--accent);
  text-shadow: 0 0 15px rgba(192, 132, 252, 0.4);
}

.result-text {
  font-size: clamp(1rem, 4vw, 1.35rem);
  font-weight: 800;
  color: var(--result);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-shadow: 0 0 24px rgba(251, 191, 36, 0.4);
  line-height: 1.3;
}

.result-detail {
  margin-top: 0.5rem;
  color: var(--muted);
  font-size: clamp(0.7rem, 2.5vw, 0.8rem);
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 35vh;
  overflow-y: auto;
}

/* ── Battle footer ── */

.battle-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding-top: 1rem;
}

.battle-footer.has-overlay-action {
  position: fixed;
  left: 50%;
  bottom: max(1rem, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 70;
  width: min(100% - 2rem, 320px);
  padding: 0;
}

.battle-footer.has-overlay-action .btn {
  width: 100%;
  max-width: 100%;
  padding: 0.75rem 1rem;
  font-size: 0.88rem;
}

/* ── Animations ── */

@keyframes fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

@media (max-width: 380px) {
  .card-library-grid {
    grid-template-columns: 1fr;
  }
}


.manual-qr {
  width: 100%;
  box-sizing: border-box;
  margin-top: 0.75rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.45);
  color: var(--text);
  font-size: 0.9rem;
  text-align: center;
  outline: none;
  transition: all 0.25s ease;
}

.manual-qr:focus {
  border-color: var(--accent);
  background: rgba(0, 0, 0, 0.6);
  box-shadow: 0 0 16px var(--accent-glow);
}

/* ── Multiplayer & Matchmaking Elements ── */

.menu-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2rem;
  margin: 1.5rem 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 1.25rem;
  width: 100%;
  box-sizing: border-box;
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow), var(--shadow-glow);
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.menu-box:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow), 0 0 32px rgba(192, 132, 252, 0.15);
}

.menu-box .btn {
  max-width: 100%;
}

.join-divider {
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  position: relative;
  font-weight: 700;
}

.join-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.input-field {
  width: 100%;
  padding: 0.95rem 1.25rem;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-size: 1rem;
  text-align: center;
  outline: none;
  font-weight: 600;
  letter-spacing: 0.05em;
  transition: all 0.25s ease;
}

.input-field:focus {
  border-color: var(--accent);
  background: rgba(0, 0, 0, 0.6);
  box-shadow: 0 0 16px var(--accent-glow);
}

.room-info-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  text-align: center;
  width: 100%;
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow), var(--shadow-glow);
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.room-info-card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow), 0 0 32px rgba(192, 132, 252, 0.15);
}

.room-info-label {
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.room-code-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin: 0.5rem 0;
}

.room-code-display {
  font-size: 2.1rem;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: 0.05em;
  text-shadow: 0 0 16px rgba(192, 132, 252, 0.4);
}

.room-link-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(0, 0, 0, 0.2);
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  border: 1px dashed var(--border);
  margin-top: 0.5rem;
  gap: 0.5rem;
}

.room-link {
  font-size: 0.72rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
  flex: 1;
}

/* ── Lobby Players Panel ── */

.lobby-players {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  width: 100%;
  margin-bottom: 1.25rem;
}

.lobby-player-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.75rem;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  transition: all 0.3s ease;
}

.lobby-player-card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow), 0 0 24px rgba(192, 132, 252, 0.1);
}

.player-name {
  font-size: 1.25rem;
  font-weight: 900;
  color: var(--text);
  letter-spacing: 0.04em;
}

.player-connection-status {
  font-size: 0.85rem;
  padding: 0.35rem 0.75rem;
  border-radius: 8px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.player-connection-status.is-connected {
  background: rgba(52, 211, 153, 0.15);
  color: #34d399;
}

.player-connection-status.is-disconnected {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

.player-connection-status.is-waiting {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
}

.player-badge-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
}

.badge {
  font-size: 0.8rem;
  padding: 0.35rem 0.65rem;
  border-radius: 8px;
  font-weight: 800;
  border: 1px solid transparent;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge.is-ready {
  background: rgba(52, 211, 153, 0.1);
  border-color: rgba(52, 211, 153, 0.3);
  color: #34d399;
}

.badge.is-pending {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.1);
  color: var(--muted);
}

.player-active-card-label {
  font-size: 0.9rem;
  color: #fff;
  margin-top: 0.5rem;
  font-weight: 600;
  word-break: break-word;
  max-width: 100%;
  text-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

.lobby-actions-box {
  display: flex;
  justify-content: center;
  width: 100%;
  margin-bottom: 1.5rem;
}

.lobby-actions-box .btn {
  max-width: 320px;
  width: 100%;
}

.room-actions-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  width: 100%;
  margin-top: 1.25rem;
}

.room-actions-row .ghost-button {
  width: 100%;
  padding: 0.8rem 0.5rem;
  font-size: 0.85rem;
  font-weight: 700;
  border-radius: 10px;
}

.lobby-scanner-section {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow), var(--shadow-glow);
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.lobby-scanner-section:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow), 0 0 32px rgba(192, 132, 252, 0.15);
}

.lobby-scanner-section h3 {
  font-size: 0.9rem;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 1rem;
  letter-spacing: 0.08em;
  text-align: center;
  font-weight: 800;
}

.scanner-btn-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-top: 0.75rem;
  width: 100%;
}

.scanner-btn-row .btn {
  max-width: 100%;
  padding: 0.85rem 0.5rem;
  font-size: 0.92rem;
}

.status-tip {
  font-size: 0.8rem;
  color: var(--accent);
  text-align: center;
  font-style: italic;
  display: block;
  width: 100%;
  margin-bottom: 2rem;
}

/* ── Arena & Combat Layout additions ── */

.timer-bar-container {
  width: 100%;
  height: 5px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 0.5rem;
}

.timer-bar {
  height: 100%;
  background: var(--accent);
  transition: width 0.25s linear, background-color 0.25s ease;
}

.timer-text {
  font-size: 0.75rem;
  color: var(--muted);
  text-align: center;
  margin-top: 0.25rem;
}

.fighter-hp {
  font-size: 0.85rem;
  font-weight: bold;
  color: var(--accent);
  margin: 0.25rem 0;
  text-shadow: 0 0 12px rgba(192, 132, 252, 0.3);
}

.fighter-action-status {
  font-size: 0.72rem;
  padding: 0.35rem 0.7rem;
  border-radius: 8px;
  margin-top: 0.5rem;
  font-weight: 700;
  border: 1px solid transparent;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  animation: pulse-badge 1.5s infinite alternate;
  display: inline-block;
  text-align: center;
  word-break: break-word;
  max-width: 100%;
}

@keyframes pulse-badge {
  from { transform: scale(1); }
  to { transform: scale(1.02); }
}

.fighter-action-status.is-thinking {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
  color: var(--muted);
}

.fighter-action-status.is-ready {
  background: rgba(52, 211, 153, 0.15);
  border-color: rgba(52, 211, 153, 0.4);
  color: #34d399;
  box-shadow: 0 0 10px rgba(52, 211, 153, 0.2);
}

.fighter-action-status.is-resolved {
  background: rgba(192, 132, 252, 0.15);
  border-color: rgba(192, 132, 252, 0.4);
  color: var(--accent);
  box-shadow: 0 0 10px rgba(192, 132, 252, 0.2);
}

.action-selection-row {
  display: flex;
  justify-content: center;
  gap: 0.45rem;
  width: 100%;
  max-width: 420px;
  margin: 0.85rem auto;
}

.btn-action {
  flex: 1;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-weight: 750;
  font-size: 0.72rem;
  padding: 0.55rem 0.35rem;
  min-height: 58px;
  border-radius: 8px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  letter-spacing: 0;
}

.action-icon {
  font-size: 1.15rem;
  line-height: 1;
}

.action-label {
  line-height: 1.1;
  white-space: nowrap;
}

.btn-action:active:not(:disabled) {
  transform: scale(0.96) translateY(0);
}

#btn-action-attack:hover:not(:disabled) {
  border-color: #f87171;
  background: rgba(248, 113, 113, 0.12);
  color: #f87171;
  box-shadow: 0 0 16px rgba(248, 113, 113, 0.2);
  transform: translateY(-2px);
}

#btn-action-defend:hover:not(:disabled) {
  border-color: #60a5fa;
  background: rgba(96, 165, 250, 0.12);
  color: #60a5fa;
  box-shadow: 0 0 16px rgba(96, 165, 250, 0.2);
  transform: translateY(-2px);
}

#btn-action-pass:hover:not(:disabled) {
  border-color: var(--muted);
  background: rgba(163, 163, 194, 0.12);
  color: var(--text);
  box-shadow: 0 0 16px rgba(163, 163, 194, 0.2);
  transform: translateY(-2px);
}

.waiting-prompt {
  text-align: center;
  font-size: 0.85rem;
  font-style: italic;
  color: var(--muted);
  margin: 1rem 0;
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 6px;
  border: 1px solid var(--border);
}

/* ── Interactive Deck Selector Carousel ── */

.deck-selector-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.5rem;
  width: 100%;
  margin-bottom: 1.5rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow), var(--shadow-glow);
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.deck-selector-card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow), 0 0 32px rgba(192, 132, 252, 0.15);
}

.deck-selector-card h4 {
  font-size: 0.9rem;
  text-transform: uppercase;
  color: var(--accent);
  letter-spacing: 0.08em;
  font-weight: 800;
}

.deck-selector-carousel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
}

.carousel-nav {
  background: rgba(192, 132, 252, 0.08);
  border: 1px solid rgba(192, 132, 252, 0.35);
  color: var(--accent);
  border-radius: 999px;
  width: 2.6rem;
  height: 2.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.25s ease;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

.carousel-nav:hover {
  background: rgba(192, 132, 252, 0.2);
  border-color: var(--accent);
  color: #fff;
}

.deck-carousel-view {
  flex: 1;
  display: flex;
  justify-content: center;
  min-height: 80px;
}

.carousel-placeholder {
  display: flex;
  align-items: center;
  font-size: 0.8rem;
  color: var(--muted);
}

.carousel-card-preview {
  display: flex;
  align-items: center;
  gap: 1rem;
  text-align: left;
  background: rgba(0, 0, 0, 0.35);
  padding: 0.75rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  width: 100%;
  max-width: 100%;
}

.carousel-card-preview.is-animated {
  animation: fade-in 0.25s ease;
}

.carousel-card-img {
  width: 52px;
  aspect-ratio: 2.5 / 3.5;
  border-radius: 6px;
  object-fit: cover;
  background: var(--bg);
  border: 1px solid var(--border);
}

.carousel-card-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
  flex: 1;
}

.carousel-card-info strong {
  font-size: 0.98rem;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.carousel-card-info span {
  font-size: 0.78rem;
  color: var(--muted);
}

.deck-selector-actions {
  display: flex;
  justify-content: center;
  width: 100%;
}

.deck-selector-actions .ghost-button {
  width: 100%;
  max-width: 320px;
  padding: 0.8rem 1rem;
  font-size: 0.85rem;
  border-radius: 10px;
}

/* ── Combat Animations (Stickmen & HP Flash) ── */

.stickman.animate-attack-left {
  animation: attack-l 0.6s ease-in-out;
}

.stickman.animate-attack-right {
  animation: attack-r 0.6s ease-in-out;
}

.stickman.animate-hit {
  animation: hit-shake 0.5s ease-in-out;
  color: #ef4444 !important;
  filter: drop-shadow(0 0 12px rgba(239, 68, 68, 0.8));
}

.stickman.animate-defend {
  animation: defend-shield 0.6s ease-in-out;
  color: #3b82f6 !important;
  filter: drop-shadow(0 0 12px rgba(59, 130, 246, 0.8));
}

@keyframes attack-l {
  0% { transform: translateX(0) scale(1); }
  25% { transform: translateX(-20px) scale(0.95); }
  50% { transform: translateX(60px) scale(1.2) rotate(15deg); }
  100% { transform: translateX(0) scale(1); }
}

@keyframes attack-r {
  0% { transform: translateX(0) scale(1); }
  25% { transform: translateX(20px) scale(0.95); }
  50% { transform: translateX(-60px) scale(1.2) rotate(-15deg); }
  100% { transform: translateX(0) scale(1); }
}

@keyframes hit-shake {
  0%, 100% { transform: translateX(0) scale(1); }
  15%, 45%, 75% { transform: translateX(-8px) scale(0.95); }
  30%, 60%, 90% { transform: translateX(8px) scale(0.95); }
}

@keyframes defend-shield {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

.fighter-hp.flash-damage {
  animation: hp-damage-flash 0.5s ease-in-out;
  color: #ef4444 !important;
  font-weight: bold;
}

@keyframes hp-damage-flash {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.25); }
}
