/* ========================================================
   COLOR SPILL - THE BOARD GAME & CARDS
   Fully Responsive (100% Viewport Fit on PC, Tablet & Mobile)
   ======================================================== */

:root {
  --bg-dark: #0a0c14;
  --bg-card: rgba(18, 22, 36, 0.9);
  --bg-card-border: rgba(90, 105, 160, 0.28);
  --text-main: #f0f4ff;
  --text-muted: #8c9bb5;

  /* Color Spill 4 Players Palette */
  --p1-color: #1acc33;
  --p1-glow: rgba(26, 204, 51, 0.45);
  --p2-color: #a020f0;
  --p2-glow: rgba(160, 32, 240, 0.45);
  --p3-color: #00e5ff;
  --p3-glow: rgba(0, 229, 255, 0.45);
  --p4-color: #ffd700;
  --p4-glow: rgba(255, 215, 0, 0.45);
  --empty-cell: #1a1e2e;

  /* Card Type Badges */
  --card-buff: #00e676;
  --card-debuff: #ff3366;
  --card-neutral: #ffd000;
  --card-passive: #4fc3f7;

  --accent-cyan: #00e5ff;
  --accent-purple: #9d4edd;
  --accent-gold: #ffb703;
  --danger-red: #ff3864;

  --font-main: 'Montserrat', sans-serif;
  --font-title: 'Orbitron', sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden; /* No scroll on main window */
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: var(--font-main);
}

/* Ambient glow & cyber grid */
.bg-glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  pointer-events: none;
  z-index: 0;
}
.bg-glow-1 {
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(160, 32, 240, 0.18), transparent 70%);
  top: -100px;
  left: -100px;
}
.bg-glow-2 {
  width: 450px;
  height: 450px;
  background: radial-gradient(circle, rgba(0, 229, 255, 0.16), transparent 70%);
  bottom: -100px;
  right: -100px;
}
.grid-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background-image: 
    linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 32px 32px;
  pointer-events: none;
  z-index: 0;
}

/* Main Container: Exact 100vh Fit */
.app-container {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  max-height: 100vh;
  max-height: 100dvh;
  max-width: 1440px;
  margin: 0 auto;
  padding: 6px 12px;
  overflow: hidden;
}

/* Glassmorphism Common */
.glassmorphism {
  background: var(--bg-card);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--bg-card-border);
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

/* Utility text */
.text-coral { color: #ff3366; }
.text-teal { color: var(--accent-cyan); }
.text-yellow { color: var(--accent-gold); }
.gradient-text {
  background: linear-gradient(135deg, #00e5ff 0%, #9d4edd 50%, #ff3366 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.hidden { display: none !important; }
.w-full { width: 100%; }
.mt-20 { margin-top: 20px; }

/* ========================================================
   HEADER & HUD (COMPACT & CLEAN)
   ======================================================== */
.game-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  gap: 10px;
  min-height: 44px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.brand-badge {
  font-family: var(--font-title);
  font-size: 0.62rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--p1-color), var(--accent-cyan));
  color: #000;
  padding: 2px 6px;
  border-radius: 6px;
  letter-spacing: 0.8px;
}
.brand-title {
  font-family: var(--font-title);
  font-weight: 900;
  font-size: 1.05rem;
  letter-spacing: 1.2px;
}

.hud-container {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  justify-content: flex-end;
  min-width: 0;
}

/* Territory Progress Bar */
.territory-bar-wrapper {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 60px;
  max-width: 100px;
  flex-shrink: 0;
}
.territory-label {
  display: flex;
  align-items: center;
  font-size: 0.65rem;
  font-weight: 700;
  white-space: nowrap;
}
.hud-title-tag {
  color: var(--text-muted);
  white-space: nowrap;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.5px;
}
.hud-player-badges {
  display: flex;
  gap: 4px;
  align-items: center;
  white-space: nowrap;
  flex-shrink: 1;
  min-width: 0;
  overflow: hidden;
}
.hud-badge {
  font-size: 0.64rem;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 50px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #fff;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  transition: all 0.2s ease;
}
.hud-badge-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.hud-badge-name {
  max-width: 60px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hud-badge-pct {
  color: #fff;
  font-weight: 800;
}

.territory-bar {
  display: flex;
  height: 8px;
  border-radius: 5px;
  overflow: hidden;
  background: #111422;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.6);
}
.bar-seg {
  height: 100%;
  transition: width 0.35s ease;
}
.seg-p1 { background: var(--p1-color); box-shadow: 0 0 8px var(--p1-glow); }
.seg-p2 { background: var(--p2-color); box-shadow: 0 0 8px var(--p2-glow); }
.seg-p3 { background: var(--p3-color); box-shadow: 0 0 8px var(--p3-glow); }
.seg-p4 { background: var(--p4-color); box-shadow: 0 0 8px var(--p4-glow); }
.seg-empty { background: #23283b; }

.hud-stats {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  white-space: nowrap;
}
.stat-pill {
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  padding: 3px 10px;
  border-radius: 50px;
  font-size: 0.74rem;
  font-weight: 700;
  white-space: nowrap;
}
.turn-pill {
  border-color: rgba(0, 229, 255, 0.35);
  background: rgba(0, 229, 255, 0.1);
  max-width: 170px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.turn-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--p1-color);
  box-shadow: 0 0 8px var(--p1-color);
  animation: pulseDot 1.2s infinite alternate;
  flex-shrink: 0;
}
@keyframes pulseDot {
  0% { transform: scale(0.85); opacity: 0.7; }
  100% { transform: scale(1.3); opacity: 1; }
}
.timer-pill {
  color: var(--accent-gold);
  border-color: rgba(255, 183, 3, 0.35);
}
.timer-pill.urgent {
  color: var(--danger-red);
  border-color: var(--danger-red);
  animation: blinkTimer 0.6s infinite alternate;
}
@keyframes blinkTimer {
  0% { opacity: 0.7; transform: scale(0.98); }
  100% { opacity: 1; transform: scale(1.06); }
}

.hud-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.btn-icon {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: var(--text-main);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.btn-icon:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-2px) scale(1.06);
}
.btn-danger-icon:hover {
  background: rgba(255, 56, 100, 0.35);
  border-color: var(--danger-red);
}

/* ========================================================
   MAIN CONTENT & SCREENS
   ======================================================== */
.main-content {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 4px 0 0;
  overflow: hidden;
}

/* SCREEN 1: LOBBY SCREEN (SCROLLABLE CARD IF SCREEN IS SMALL) */
.setup-screen {
  display: flex;
  justify-content: center;
  align-items: center;
  flex: 1;
  overflow-y: auto;
  padding: 10px 0;
}
.lobby-card {
  width: 100%;
  max-width: 540px;
  padding: 26px 24px;
  max-height: 94vh;
  overflow-y: auto;
}
.lobby-badge {
  font-family: var(--font-title);
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--accent-cyan);
  letter-spacing: 1.2px;
  margin-bottom: 4px;
  text-align: center;
}
.hero-title {
  font-family: var(--font-title);
  font-size: 1.9rem;
  font-weight: 900;
  text-align: center;
  letter-spacing: 1.2px;
  margin-bottom: 6px;
}
.hero-subtitle {
  text-align: center;
  font-size: 0.84rem;
  color: var(--text-muted);
  margin-bottom: 20px;
  line-height: 1.4;
}

.form-group {
  margin-bottom: 16px;
}
.form-group label {
  display: block;
  font-size: 0.74rem;
  font-weight: 800;
  color: var(--text-muted);
  letter-spacing: 0.6px;
  margin-bottom: 6px;
}
.input-with-action {
  display: flex;
  gap: 8px;
}
input[type="text"], input[type="password"] {
  flex: 1;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 50px;
  padding: 10px 18px;
  color: var(--text-main);
  font-family: var(--font-main);
  font-size: 0.9rem;
  font-weight: 600;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
input[type="text"]:focus, input[type="password"]:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 12px rgba(0, 229, 255, 0.35);
}

.color-palette {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.color-choice {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 8px 6px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
}
.color-choice:hover {
  background: rgba(255, 255, 255, 0.08);
  transform: translateY(-2px);
}
.color-choice.active {
  border-color: var(--accent-cyan);
  background: rgba(0, 229, 255, 0.12);
  box-shadow: 0 0 14px rgba(0, 229, 255, 0.35);
}
.color-circle {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  box-shadow: 0 0 8px currentColor;
}
.color-name {
  font-size: 0.7rem;
  font-weight: 700;
}

.segmented-control {
  display: flex;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 50px;
  padding: 4px;
  gap: 4px;
}
.seg-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-main);
  font-size: 0.8rem;
  font-weight: 700;
  padding: 8px 12px;
  border-radius: 50px;
  cursor: pointer;
  transition: all 0.2s;
}
.seg-btn.active {
  background: linear-gradient(135deg, rgba(0, 229, 255, 0.3), rgba(160, 32, 240, 0.3));
  color: #fff;
  border: 1px solid rgba(0, 229, 255, 0.45);
}

/* Uniform Form Styling for all Lobby Views */
.lobby-view input[type="text"],
.lobby-view input[type="password"] {
  height: 42px;
  border-radius: 10px;
  padding: 0 16px;
  box-sizing: border-box;
}

.lobby-view .segmented-control {
  border-radius: 10px;
  padding: 4px;
}

.lobby-view .seg-btn {
  border-radius: 8px;
  font-size: 0.82rem;
  padding: 8px 12px;
}

.main-menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 18px 0 12px;
}
.btn-menu-large {
  padding: 13px 20px;
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.6px;
  border-radius: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.2s;
}
.btn-primary {
  background: linear-gradient(135deg, #00c853 0%, #00e5ff 100%);
  color: #000;
  border: none;
  border-radius: 50px;
  padding: 10px 24px;
  font-size: 0.9rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(0, 200, 83, 0.35);
  transition: all 0.2s;
}
.btn-primary:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 6px 24px rgba(0, 229, 255, 0.45);
}
.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: var(--text-main);
  border-radius: 50px;
  padding: 10px 24px;
  font-size: 0.9rem;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.16);
  transform: translateY(-2px);
}
.btn-danger {
  background: rgba(255, 56, 100, 0.25);
  border: 1px solid var(--danger-red);
  color: #fff;
  border-radius: 50px;
  padding: 10px 24px;
  font-size: 0.9rem;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-dice {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}

.lobby-footer-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
}
.btn-text {
  background: none;
  border: none;
  color: var(--accent-cyan);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline;
}
.lobby-footer-stats {
  font-size: 0.74rem;
  color: var(--text-muted);
}

/* View Header & Back Button (Shared across ViewOffline, ViewCreateRoom, ViewFindRoom, ViewWaiting) */
.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  gap: 12px;
  width: 100%;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.view-header h2 {
  font-family: var(--font-title);
  font-size: 1.15rem;
  font-weight: 900;
  letter-spacing: 0.8px;
  text-align: center;
  flex: 1;
  margin: 0;
  color: var(--text-main);
  white-space: nowrap;
}
.waiting-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.waiting-title-box {
  display: flex;
  align-items: center;
  overflow: hidden;
}
.waiting-title-box h2 {
  text-align: left;
  font-size: 1.08rem;
  margin: 0;
}
.header-badges-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.btn-back {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: var(--text-main);
  padding: 8px 16px;
  border-radius: 10px;
  font-family: var(--font-main);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  flex-shrink: 0;
  min-width: 95px;
}
.btn-back:hover {
  background: rgba(0, 229, 255, 0.15);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
  transform: translateX(-3px);
  box-shadow: 0 0 14px rgba(0, 229, 255, 0.3);
}

/* Room Waiting view */
.room-code-display {
  background: rgba(0, 0, 0, 0.45);
  border: 1px dashed rgba(0, 229, 255, 0.4);
  border-radius: 14px;
  padding: 14px 18px;
  text-align: center;
  margin-bottom: 16px;
}
.room-code-text {
  font-family: var(--font-title);
  font-size: 1.65rem;
  font-weight: 900;
  letter-spacing: 2px;
  color: var(--accent-cyan);
}
.code-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 6px 0;
}
.btn-icon-pill {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.btn-icon-pill:hover {
  background: rgba(0, 229, 255, 0.2);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
}
.waiting-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 10px 0 14px;
}
.waiting-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  padding: 8px 12px;
}
.waiting-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  flex-shrink: 0;
}
.waiting-name {
  font-weight: 700;
  font-size: 0.86rem;
}
.badge-host {
  background: var(--accent-gold);
  color: #000;
  font-size: 0.64rem;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 6px;
  margin-left: auto;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Host & Guest Lobby Bottom Action Bars */
.lobby-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
}
.lobby-actions .btn-primary {
  flex: 1;
  height: 44px;
  border-radius: 10px;
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.lobby-actions .btn-cancel-host {
  width: 110px;
  height: 44px;
  border-radius: 10px;
  font-size: 0.86rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.lobby-guest-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
}
.lobby-guest-actions button {
  height: 42px;
  border-radius: 10px;
  font-size: 0.86rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Privacy Badges */
.badge-privacy {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.4px;
  white-space: nowrap;
  flex-shrink: 0;
  line-height: 1;
}
.badge-public {
  background: rgba(0, 229, 255, 0.15);
  color: var(--accent-cyan);
  border: 1px solid rgba(0, 229, 255, 0.4);
}
.badge-private {
  background: rgba(255, 56, 100, 0.18);
  color: #ff6b8b;
  border: 1px solid rgba(255, 56, 100, 0.4);
}

/* Online Find Room View */
.find-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}
.find-section label {
  font-size: 0.76rem;
  font-weight: 800;
  color: var(--text-muted);
  letter-spacing: 0.6px;
}
.section-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.divider-text {
  display: flex;
  align-items: center;
  text-align: center;
  margin: 12px 0;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 1px;
}
.divider-text::before,
.divider-text::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}
.divider-text span {
  padding: 0 10px;
}

/* Direct Join Status feedback */
.join-status-text {
  min-height: 22px;
  font-size: 0.78rem;
  font-weight: 700;
  margin-top: 6px;
  transition: all 0.25s ease;
}
.status-connecting {
  color: #ffd166;
}
.status-success {
  color: #00e676;
}
.status-error {
  color: #ff5252;
  background: rgba(255, 82, 82, 0.12);
  border: 1px solid rgba(255, 82, 82, 0.3);
  border-radius: 8px;
  padding: 6px 10px;
}
.spinner-inline {
  display: inline-block;
  animation: pulseRotate 1s infinite alternate;
}
@keyframes pulseRotate {
  0% { transform: scale(0.95); opacity: 0.7; }
  100% { transform: scale(1.15); opacity: 1; }
}

/* Rotating icon animation */
.rotating {
  animation: rotateIcon 0.6s linear;
}
@keyframes rotateIcon {
  100% { transform: rotate(360deg); }
}

/* Public Rooms Container */
.rooms-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
  padding-right: 4px;
  scrollbar-width: thin;
}
.rooms-container::-webkit-scrollbar {
  width: 5px;
}
.rooms-container::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

/* Room Card */
.room-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 10px 14px;
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.room-card:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(0, 229, 255, 0.4);
  transform: translateY(-1px);
}
.room-card-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.room-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
}
.room-name {
  font-weight: 800;
  font-size: 0.88rem;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.room-meta-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.74rem;
  color: var(--text-muted);
  flex-wrap: wrap;
}
.room-code-tag {
  background: rgba(0, 0, 0, 0.3);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-title);
  color: var(--accent-cyan);
}
.btn-room-join {
  flex-shrink: 0;
  padding: 7px 14px;
  font-size: 0.78rem;
  font-weight: 800;
  border-radius: 50px;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  white-space: nowrap;
}
.btn-room-join.disabled {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
  cursor: not-allowed;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Empty Rooms State */
.rooms-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 24px 16px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px dashed rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  gap: 6px;
}
.empty-radar {
  font-size: 2rem;
  margin-bottom: 2px;
  animation: pulseRotate 2s infinite ease-in-out;
}
.empty-title {
  font-weight: 800;
  font-size: 0.86rem;
  color: var(--text-main);
}
.empty-sub {
  font-size: 0.74rem;
  color: var(--text-muted);
  max-width: 320px;
  line-height: 1.4;
}

/* ========================================================
   SCREEN 2: BOARD GAME ARENA (ZERO OVERFLOW, PERFECT FIT)
   ======================================================== */
.game-screen {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.board-arena-layout {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow: hidden;
}

/* Compact Combat Banner */
.arena-action-banner {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(90deg, rgba(18, 22, 36, 0.95), rgba(30, 18, 48, 0.95));
  border: 1px solid rgba(0, 229, 255, 0.25);
  border-radius: 12px;
  padding: 6px 14px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
  min-height: 38px;
}
.banner-icon {
  font-size: 1.25rem;
}
.banner-content {
  flex: 1;
  display: flex;
  align-items: baseline;
  gap: 10px;
  overflow: hidden;
  white-space: nowrap;
}
.banner-text {
  font-size: 0.82rem;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
}
.banner-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Center Area: Left (Players) + Center (Board) + Right (Trash) */
.board-center-area {
  flex: 1;
  min-height: 0; /* Allows shrinking in flex container */
  display: flex;
  gap: 12px;
  align-items: stretch;
  justify-content: center;
  overflow: hidden;
}

/* Left Sidebar: Players Status Panel */
.players-panel {
  width: 210px;
  flex-shrink: 0;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 8px;
  overflow-y: auto;
}
.panel-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-title);
  font-size: 0.76rem;
  font-weight: 800;
  color: var(--accent-cyan);
  letter-spacing: 0.8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 6px;
}
.players-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}
.player-card {
  display: flex;
  flex-direction: column;
  gap: 3px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 6px 8px;
  transition: all 0.2s;
}
.player-card.active-turn {
  border-color: var(--accent-cyan);
  background: rgba(0, 229, 255, 0.1);
  box-shadow: 0 0 12px rgba(0, 229, 255, 0.3);
}
.player-card.eliminated {
  opacity: 0.35;
  filter: grayscale(1);
}
.pcard-top {
  display: flex;
  align-items: center;
  gap: 6px;
}
.pcard-avatar {
  width: 18px;
  height: 18px;
  border-radius: 6px;
  box-shadow: 0 0 6px currentColor;
}
.pcard-name {
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}
.pcard-pct {
  font-size: 0.76rem;
  font-weight: 800;
  color: #fff;
}
.pcard-cards-badge {
  font-size: 0.72rem;
  font-weight: 800;
  color: #ffb703;
  background: rgba(255, 183, 3, 0.16);
  border: 1px solid rgba(255, 183, 3, 0.45);
  padding: 2.5px 8px;
  border-radius: 50px;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.pcard-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.74rem;
  color: var(--text-muted);
  gap: 6px;
  padding: 3px 2px 0;
  width: 100%;
}
.pcard-castles {
  white-space: nowrap;
  font-weight: 700;
  color: #fff;
}
.pcard-meta-pill {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
  color: var(--accent-cyan);
}
.pcard-buffs {
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
  margin-top: 2px;
}
.buff-tag {
  font-size: 0.65rem;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.12);
  padding: 2px 7px;
  border-radius: 5px;
  white-space: nowrap;
}
  font-weight: 700;
  background: rgba(255, 255, 255, 0.12);
  padding: 2px 6px;
  border-radius: 5px;
}

.deck-status-box {
  background: rgba(8, 12, 22, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  padding: 8px 12px;
  display: flex;
  justify-content: space-around;
  align-items: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  gap: 10px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}
.deck-status-item {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.deck-status-item strong {
  color: var(--accent-cyan);
  font-family: var(--font-title);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.5px;
}

/* Center: Board Canvas Wrapper */
.board-wrapper {
  flex: 1;
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  overflow: hidden;
}
.board-canvas-container {
  position: relative;
  /* Dynamically scaled so both HUD and cards fit 100% on any screen */
  height: min(44vh, 44vw, 385px);
  width: min(44vh, 44vw, 385px);
  max-height: calc(100% - 24px);
  max-width: calc(100% - 24px);
  aspect-ratio: 1 / 1;
  background: #0d101a;
  border: 2px solid rgba(90, 105, 160, 0.38);
  border-radius: 14px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.6), inset 0 0 20px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  line-height: 0;
  transition: border-color 0.25s, box-shadow 0.25s;
  touch-action: none;
}
.board-canvas-container.drag-over {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 32px rgba(0, 229, 255, 0.65), inset 0 0 24px rgba(0, 229, 255, 0.3);
}

#gameCanvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
  cursor: pointer;
  object-fit: contain;
  touch-action: none;
}
.board-hint {
  font-size: 0.68rem;
  color: var(--text-muted);
  text-align: center;
  white-space: nowrap;
}

/* Board Drop Hint Overlay */
.board-drop-hint {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 229, 255, 0.16);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 20;
}
.drop-hint-inner {
  background: rgba(10, 14, 26, 0.92);
  border: 2px solid var(--accent-cyan);
  border-radius: 50px;
  padding: 10px 22px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 0 20px rgba(0, 229, 255, 0.5);
}
.drop-hint-icon {
  font-size: 1.3rem;
}
.drop-hint-text {
  font-family: var(--font-title);
  font-size: 0.85rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: 0.8px;
}

/* Floating Turn Notification Badge (Positioned ABOVE the board canvas, never overlapping cells) */
.turn-popup {
  position: absolute;
  top: -42px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(10, 14, 26, 0.95);
  border: 2px solid var(--accent-cyan);
  border-radius: 50px;
  padding: 4px 18px;
  box-shadow: 0 0 18px rgba(0, 229, 255, 0.6);
  pointer-events: none;
  animation: slideDown 0.3s ease-out;
  z-index: 25;
  white-space: nowrap;
}
@keyframes slideDown {
  0% { transform: translate(-50%, -15px); opacity: 0; }
  100% { transform: translate(-50%, 0); opacity: 1; }
}
.turn-popup-title {
  font-family: var(--font-title);
  font-size: 0.8rem;
  font-weight: 900;
  letter-spacing: 0.8px;
  color: #fff;
}
@keyframes bannerPulse {
  0% { transform: scale(1); box-shadow: 0 0 0 rgba(0, 229, 255, 0); }
  50% { transform: scale(1.02); box-shadow: 0 0 22px rgba(0, 229, 255, 0.6); border-color: var(--accent-cyan); }
  100% { transform: scale(1); box-shadow: 0 0 0 rgba(0, 229, 255, 0); }
}
.banner-pulse {
  animation: bannerPulse 0.5s ease-out;
}

/* Right Sidebar: Dedicated Trash Bin Drop Zone */
.trash-panel {
  width: 155px;
  flex-shrink: 0;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.trash-drop-zone {
  width: 100%;
  flex: 1;
  min-height: 0;
  background: rgba(255, 56, 100, 0.05);
  border: 2px dashed rgba(255, 56, 100, 0.35);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 8px;
  text-align: center;
  transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  cursor: pointer;
}
.trash-drop-zone:hover {
  background: rgba(255, 56, 100, 0.12);
  border-color: rgba(255, 56, 100, 0.6);
  transform: scale(1.02);
}
.trash-drop-zone.drag-over {
  background: rgba(255, 56, 100, 0.25);
  border-color: var(--danger-red);
  transform: scale(1.06);
  box-shadow: 0 0 24px rgba(255, 56, 100, 0.5);
}
.trash-icon-ring {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 56, 100, 0.15);
  border: 1px solid rgba(255, 56, 100, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
}
.trash-icon {
  font-size: 1.5rem;
}
.trash-label {
  font-family: var(--font-title);
  font-size: 0.78rem;
  font-weight: 900;
  color: var(--danger-red);
  letter-spacing: 0.8px;
}
.trash-sub {
  font-size: 0.65rem;
  color: var(--text-muted);
  line-height: 1.2;
}

.trash-drop-zone.trash-ready {
  background: rgba(255, 56, 100, 0.22);
  border-color: var(--danger-red);
  box-shadow: 0 0 18px rgba(255, 56, 100, 0.6);
  animation: trashPulse 0.9s infinite alternate;
}
@keyframes trashPulse {
  0% { transform: scale(1); box-shadow: 0 0 8px rgba(255, 56, 100, 0.4); }
  100% { transform: scale(1.04); box-shadow: 0 0 22px rgba(255, 56, 100, 0.85); }
}

#deckStatusBoxMobile {
  width: 100%;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(8, 12, 22, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: stretch;
  gap: 6px;
  font-size: 0.74rem;
}
#deckStatusBoxMobile .deck-status-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  width: 100%;
  white-space: nowrap;
}
#deckStatusBoxMobile .deck-status-item strong {
  font-size: 0.82rem;
  color: var(--accent-cyan);
}

/* ========================================================
   BOTTOM DOCK: CARD HAND (COMPACT, CENTERED, VISIBLE)
   ======================================================== */
.card-hand-dock {
  flex-shrink: 0;
  padding: 4px 12px 6px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  align-items: center;
  max-height: 122px;
}
.dock-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 2px;
}
.dock-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-title);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.6px;
}
.hand-status-badge {
  font-size: 0.65rem;
  background: rgba(0, 230, 118, 0.15);
  border: 1px solid var(--card-buff);
  color: var(--card-buff);
  padding: 2px 8px;
  border-radius: 50px;
  font-family: var(--font-main);
  font-weight: 700;
}
.hand-status-badge.disabled {
  background: rgba(255, 56, 100, 0.15);
  border-color: var(--danger-red);
  color: var(--danger-red);
}
.dock-instruction {
  font-size: 0.68rem;
  color: var(--text-muted);
}
.dock-instruction strong {
  color: var(--accent-cyan);
}

/* CENTERED Cards Hand Row */
.cards-hand-row {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  overflow-x: auto;
  padding: 2px 4px;
  min-height: 84px;
  max-height: 88px;
}
.cards-hand-row::-webkit-scrollbar {
  height: 4px;
}
.cards-hand-row::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 2px;
}

/* Individual Compact Card UI */
.game-card-item {
  position: relative;
  width: 76px;
  height: 84px;
  flex-shrink: 0;
  background: linear-gradient(155deg, #182035, #0a0d18);
  border: 1.5px solid rgba(0, 229, 255, 0.35);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4px 3px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.2s, border-color 0.2s;
  touch-action: none;
}
.game-card-item:hover {
  transform: translateY(-6px) scale(1.05);
  border-color: var(--accent-cyan);
  box-shadow: 0 8px 20px rgba(0, 229, 255, 0.4);
  z-index: 10;
}
.game-card-item.selected {
  border-color: var(--accent-cyan) !important;
  transform: translateY(-8px) scale(1.08) !important;
  box-shadow: 0 0 22px rgba(0, 229, 255, 0.8) !important;
  z-index: 15;
  outline: 2px solid #00e5ff;
}
.game-card-item.selected-passive {
  border-color: #ffd700 !important;
  transform: translateY(-8px) scale(1.08) !important;
  box-shadow: 0 0 22px rgba(255, 215, 0, 0.8) !important;
  z-index: 15;
  outline: 2px solid #ffd700;
}
.game-card-item.dragging {
  opacity: 0.35;
}
.game-card-item.card-buff { border-color: rgba(0, 230, 118, 0.5); }
.game-card-item.card-debuff { border-color: rgba(255, 51, 102, 0.5); }
.game-card-item.card-neutral { border-color: rgba(255, 208, 0, 0.5); }
.game-card-item.card-shard {
  border-color: #ffd700;
  box-shadow: 0 0 12px rgba(255, 215, 0, 0.45);
}
.game-card-item.card-passive {
  border-color: var(--card-passive);
  box-shadow: 0 0 10px rgba(79, 195, 247, 0.3);
}

.card-item-header {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 2px;
  height: 14px;
  overflow: hidden;
}
.card-type-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 1px 4px;
  border-radius: 3px;
  color: #000;
  font-size: 0.5rem;
  font-weight: 800;
  letter-spacing: 0.3px;
  white-space: nowrap;
  max-width: 95%;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.1;
  text-transform: uppercase;
}
.type-buff { background: var(--card-buff); }
.type-debuff { background: var(--card-debuff); color: #fff; }
.type-neutral { background: var(--card-neutral); }
.type-shard { background: #ffd700; color: #000; font-weight: 900; }
.type-passive { background: var(--card-passive); color: #000; font-weight: 900; }

.card-icon-frame {
  width: 100%;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.38);
  border-radius: 6px;
  overflow: hidden;
  margin: 1px 0;
  min-height: 0;
}
.card-img-asset {
  max-width: 32px;
  max-height: 32px;
  object-fit: contain;
  filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.6));
}
.card-item-name {
  font-size: 0.62rem;
  font-weight: 800;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #fff;
  width: 100%;
  height: 14px;
  line-height: 14px;
  padding: 0 2px;
}

.empty-hand-hint {
  color: var(--text-muted);
  font-size: 0.78rem;
  margin: auto;
  font-style: italic;
}

/* Floating Drag Ghost (Mobile Touch & Pointer) */
.drag-ghost {
  position: fixed;
  pointer-events: none;
  z-index: 9999;
  width: 80px;
  height: 92px;
  border-radius: 12px;
  border: 2px solid var(--accent-cyan);
  background: rgba(10, 14, 26, 0.92);
  box-shadow: 0 0 24px rgba(0, 229, 255, 0.8);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transform: translate(-50%, -50%) scale(1.1);
  padding: 6px;
}
.drag-ghost img {
  max-width: 36px;
  max-height: 36px;
}
.drag-ghost span {
  font-size: 0.65rem;
  font-weight: 800;
  color: #fff;
}

/* ========================================================
   MODALS & POPUPS
   ======================================================== */
.modal-backdrop {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 12px;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-card {
  width: 100%;
  max-width: 500px;
  padding: 22px;
  position: relative;
  max-height: 92vh;
  overflow-y: auto;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}
.modal-header h2 {
  font-family: var(--font-title);
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: 0.8px;
}
.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

/* Target Selector Grid */
.target-options-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
  margin: 16px 0;
}
.target-card-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 14px;
  padding: 12px 10px;
  color: #fff;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  font-family: var(--font-main);
  transition: all 0.2s;
}
.target-card-btn:hover {
  background: rgba(0, 229, 255, 0.16);
  border-color: var(--accent-cyan);
  transform: translateY(-2px);
}

/* Mystery Steal Card Modal */
.steal-modal {
  max-width: 520px;
}
.mystery-cards-row {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin: 20px 0;
  flex-wrap: wrap;
}
.mystery-card-item {
  width: 82px;
  height: 115px;
  background: linear-gradient(145deg, #182238, #0d1322);
  border: 2px solid var(--accent-gold);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(255, 183, 3, 0.3);
  transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.mystery-card-item:hover {
  transform: translateY(-8px) scale(1.06);
  border-color: #fff;
  box-shadow: 0 8px 24px rgba(255, 183, 3, 0.55);
}
.mystery-question-mark {
  font-family: var(--font-title);
  font-size: 2.3rem;
  font-weight: 900;
  color: var(--accent-gold);
  text-shadow: 0 0 12px var(--accent-gold);
}
.mystery-card-sub {
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--text-muted);
}
.steal-reveal-result {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  animation: popIn 0.3s ease;
}
.reveal-card-box {
  width: 95px;
  height: 125px;
  background: linear-gradient(145deg, #1b2640, #0c1424);
  border: 2px solid var(--accent-cyan);
  border-radius: 14px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 20px rgba(0, 229, 255, 0.5);
}
.reveal-img {
  width: 48px;
  height: 48px;
  object-fit: contain;
  margin-bottom: 6px;
}
.reveal-name {
  font-size: 0.72rem;
  font-weight: 800;
  color: #fff;
}
.reveal-text {
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--accent-cyan);
}

/* Rock Paper Scissors Minigame Modal */
.rps-choices-row {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin: 22px 0;
}
.rps-choice-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid rgba(255, 255, 255, 0.18);
  border-radius: 18px;
  width: 86px;
  height: 98px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.2s;
}
.rps-choice-btn:hover {
  border-color: var(--accent-cyan);
  background: rgba(0, 229, 255, 0.15);
  transform: translateY(-4px) scale(1.06);
}
.rps-emoji {
  font-size: 2.1rem;
}
.rps-label {
  font-family: var(--font-title);
  font-size: 0.75rem;
  font-weight: 800;
  color: #fff;
}
.rps-result-text {
  font-size: 1.05rem;
  font-weight: 800;
  min-height: 28px;
  color: var(--accent-cyan);
}

/* Game Over Card */
.game-over-icon {
  font-size: 3.2rem;
  margin-bottom: 6px;
  animation: bounceCup 1s infinite alternate;
}
@keyframes bounceCup {
  from { transform: translateY(0); }
  to { transform: translateY(-8px); }
}
.game-over-title {
  font-family: var(--font-title);
  font-size: 1.7rem;
  font-weight: 900;
  margin-bottom: 6px;
}
.game-over-sub {
  font-size: 0.86rem;
  color: var(--text-muted);
  margin-bottom: 18px;
}
.game-over-stats {
  background: rgba(0, 0, 0, 0.35);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.game-over-stat-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  font-weight: 700;
}
.game-over-actions {
  display: flex;
  gap: 14px;
  justify-content: center;
}

/* Tutorial Cards Catalog */
.cards-catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
  margin-top: 8px;
  max-height: 260px;
  overflow-y: auto;
}
.catalog-card-item {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 8px 10px;
  display: flex;
  gap: 8px;
  align-items: center;
}
.catalog-card-img {
  width: 32px;
  height: 32px;
  object-fit: contain;
}
.catalog-card-name {
  font-size: 0.76rem;
  font-weight: 800;
  color: #fff;
}
.catalog-card-desc {
  font-size: 0.65rem;
  color: var(--text-muted);
  line-height: 1.3;
}

/* ========================================================
   RESPONSIVE DESIGN (MOBILE & TABLET OPTIMIZATIONS)
   ======================================================== */

/* Mobile Portrait & Small Tablet (max-width: 820px) */
@media (max-width: 820px) {
  .app-container {
    padding: 2px 6px;
  }

  .lobby-card {
    padding: 18px 16px;
    max-height: 96vh;
    border-radius: 14px;
  }
  .view-header {
    margin-bottom: 14px;
    gap: 8px;
  }
  .view-header h2 {
    font-size: 1.02rem;
  }
  .btn-back {
    padding: 6px 12px;
    font-size: 0.75rem;
    min-width: 75px;
  }
  .view-header-spacer {
    width: 75px;
  }

  .game-header {
    padding: 2px 6px;
    gap: 4px;
    min-height: 32px;
  }
  .brand {
    gap: 4px;
    flex-shrink: 0;
  }
  .brand-badge {
    font-size: 0.5rem;
    padding: 1px 4px;
  }
  .brand-title {
    font-size: 0.8rem;
  }
  .hud-container {
    gap: 4px;
    flex: 1;
    justify-content: flex-end;
  }
  .hud-title-tag {
    display: none; /* Hide long title text to prevent squishing */
  }
  .hud-badge {
    font-size: 0.58rem;
    padding: 1px 5px;
  }
  .hud-badge-name {
    max-width: 48px;
  }
  .territory-bar-wrapper {
    min-width: 50px;
    max-width: 85px;
    gap: 1px;
    flex-shrink: 1;
  }
  .territory-label {
    font-size: 0.58rem;
  }
  .territory-bar {
    height: 5px;
  }
  .hud-stats {
    gap: 4px;
  }
  .stat-pill {
    padding: 2px 6px;
    font-size: 0.62rem;
    gap: 3px;
  }
  .turn-pill .stat-label {
    display: none; /* Dot + player name is sufficient */
  }
  .hud-actions {
    gap: 3px;
  }
  .btn-icon {
    width: 24px;
    height: 24px;
    font-size: 0.72rem;
  }

  .arena-action-banner {
    padding: 2px 8px;
    min-height: 24px;
    gap: 6px;
  }
  .banner-icon {
    font-size: 0.9rem;
  }
  .banner-text {
    font-size: 0.7rem;
  }
  .banner-sub {
    display: none; /* Hide subtext to save vertical space on mobile */
  }

  /* Center Area on Mobile: Column Layout */
  .board-center-area {
    flex-direction: column;
    align-items: center;
    gap: 4px;
    flex: 1;
    min-height: 0;
  }

  /* Players panel turns into a horizontal compact row */
  .players-panel {
    width: 100%;
    flex-direction: row;
    align-items: center;
    padding: 2px 6px;
    gap: 4px;
    overflow-x: auto;
    flex-shrink: 0;
    max-height: 38px;
  }
  .panel-header, #playersPanel .deck-status-box {
    display: none; /* Hide panel header to save vertical space */
  }
  .players-list {
    flex-direction: row;
    gap: 4px;
    width: 100%;
  }
  .player-card {
    flex: 1;
    min-width: 70px;
    padding: 2px 4px;
    gap: 1px;
    border-radius: 8px;
  }
  .pcard-avatar {
    width: 13px;
    height: 13px;
  }
  .pcard-name {
    font-size: 0.62rem;
  }
  .pcard-pct {
    font-size: 0.62rem;
  }
  .pcard-cards-badge {
    font-size: 0.58rem;
    padding: 0 4px;
  }
  .pcard-meta, .pcard-buffs {
    display: none;
  }

  /* Board Canvas takes optimal width/height without overflowing */
  .board-wrapper {
    width: 100%;
    flex: 1;
    min-height: 0;
    align-items: center;
    justify-content: center;
  }
  .board-canvas-container {
    width: min(84vw, calc(100vh - 250px)) !important;
    height: min(84vw, calc(100vh - 250px)) !important;
    max-height: calc(100% - 8px) !important;
    max-width: calc(100% - 8px) !important;
  }
  .board-hint {
    display: none;
  }

  /* Trash panel becomes a compact bar or button */
  .trash-panel {
    width: 100%;
    padding: 2px 8px;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-shrink: 0;
  }
  .trash-drop-zone {
    flex: 1;
    max-width: 220px;
    height: 28px;
    flex-direction: row;
    gap: 6px;
    padding: 2px 10px;
    border-radius: 50px;
  }
  .trash-icon-ring {
    width: 18px;
    height: 18px;
  }
  .trash-icon {
    font-size: 0.75rem;
  }
  .trash-label {
    font-size: 0.65rem;
  }
  .trash-sub {
    display: none;
  }

  #deckStatusBoxMobile {
    display: flex !important;
    flex: 1;
    max-width: 220px;
    margin: 0;
    padding: 2px 8px;
    justify-content: space-around;
    font-size: 0.68rem;
  }

  /* Card Hand Dock on Mobile */
  .card-hand-dock {
    padding: 2px 6px 3px;
    max-height: 98px;
  }
  .dock-header {
    padding-bottom: 1px;
  }
  .dock-title {
    font-size: 0.64rem;
  }
  .hand-status-badge {
    font-size: 0.58rem;
    padding: 1px 5px;
  }
  .dock-instruction {
    display: none;
  }
  .cards-hand-row {
    min-height: 76px;
    max-height: 80px;
    gap: 6px;
  }
  .game-card-item {
    width: 62px;
    height: 74px;
    padding: 2px 1px;
    border-radius: 7px;
  }
  .card-type-tag {
    font-size: 0.46rem;
    padding: 1px 3px;
    border-radius: 2px;
    white-space: nowrap;
    max-width: 95%;
  }
  .card-img-asset {
    max-width: 26px;
    max-height: 26px;
  }
  .card-item-name {
    font-size: 0.56rem;
    height: 13px;
    line-height: 13px;
  }
}

/* Smartphone Portrait Layout (width <= 650px OR orientation: portrait) */
@media (max-width: 650px), (max-width: 820px) and (orientation: portrait) {
  .board-center-area {
    flex-direction: column !important;
    align-items: center !important;
    gap: 4px !important;
    flex: 1 !important;
    min-height: 0 !important;
  }
  .players-panel {
    width: 100% !important;
    flex-direction: row !important;
    align-items: center !important;
    padding: 2px 6px !important;
    gap: 4px !important;
    overflow-x: auto !important;
    flex-shrink: 0 !important;
    max-height: 38px !important;
  }
  .players-list {
    flex-direction: row !important;
    gap: 4px !important;
    width: 100% !important;
  }
  .player-card {
    flex: 1 !important;
    min-width: 70px !important;
    padding: 2px 4px !important;
  }
  .pcard-cards-badge {
    font-size: 0.56rem !important;
    padding: 0 4px !important;
  }
  .board-wrapper {
    width: 100% !important;
    flex: 1 !important;
    min-height: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }
  .board-canvas-container {
    width: min(88vw, calc(100vh - 250px)) !important;
    height: min(88vw, calc(100vh - 250px)) !important;
    max-height: calc(100% - 6px) !important;
    max-width: calc(100% - 6px) !important;
  }
  .trash-panel {
    width: 100% !important;
    padding: 2px 8px !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    flex-shrink: 0 !important;
  }
  .trash-drop-zone {
    flex: 1 !important;
    max-width: 220px !important;
    height: 28px !important;
    flex-direction: row !important;
    gap: 6px !important;
    padding: 2px 10px !important;
    border-radius: 50px !important;
  }
  #deckStatusBoxMobile {
    display: flex !important;
    flex: 1 !important;
    max-width: 220px !important;
    margin: 0 !important;
    padding: 2px 8px !important;
    justify-content: space-around !important;
    font-size: 0.68rem !important;
  }
}

/* Mobile Landscape (max-height: 520px in landscape mode, e.g. iPhone landscape 852x393) */
@media (max-height: 520px) and (orientation: landscape), (max-height: 520px) and (min-width: 500px) {
  .app-container {
    padding: 1px 6px;
  }
  .game-header {
    min-height: 26px;
    padding: 1px 6px;
    gap: 4px;
  }
  .brand {
    gap: 3px;
    flex-shrink: 0;
  }
  .brand-badge {
    font-size: 0.46rem;
    padding: 0 3px;
  }
  .brand-title {
    font-size: 0.68rem;
  }
  .hud-title-tag {
    display: none;
  }
  .hud-badge {
    font-size: 0.52rem;
    padding: 0 3px;
  }
  .territory-bar-wrapper {
    min-width: 65px;
    max-width: 110px;
    gap: 1px;
    flex-shrink: 1;
  }
  .territory-label {
    font-size: 0.54rem;
  }
  .territory-bar {
    height: 4px;
  }
  .hud-stats {
    gap: 3px;
  }
  .stat-pill {
    padding: 1px 4px;
    font-size: 0.56rem;
    gap: 2px;
  }
  .turn-pill .stat-label {
    display: none;
  }
  .hud-actions {
    gap: 2px;
  }
  .btn-icon {
    width: 20px;
    height: 20px;
    font-size: 0.65rem;
  }

  .arena-action-banner {
    min-height: 18px;
    padding: 1px 6px;
    gap: 4px;
  }
  .banner-icon {
    font-size: 0.75rem;
  }
  .banner-text {
    font-size: 0.62rem;
  }
  .banner-sub {
    display: none;
  }

  .board-center-area {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
    flex: 1;
    min-height: 0;
    overflow: hidden;
  }
  .players-panel {
    width: 120px;
    display: flex;
    flex-direction: column;
    padding: 2px 4px;
    gap: 2px;
    max-height: 100%;
    overflow-y: auto;
  }
  .panel-header, #playersPanel .deck-status-box {
    display: none;
  }
  .players-list {
    flex-direction: column;
    gap: 2px;
  }
  .player-card {
    padding: 2px 4px;
    gap: 1px;
  }
  .pcard-name {
    font-size: 0.58rem;
  }
  .pcard-pct {
    font-size: 0.58rem;
  }
  .pcard-cards-badge {
    font-size: 0.54rem;
    padding: 0 3px;
  }
  .pcard-meta, .pcard-buffs {
    display: none;
  }

  .board-wrapper {
    flex: 1;
    height: 100%;
    align-items: center;
    justify-content: center;
  }
  .board-canvas-container {
    height: min(58vh, 200px) !important;
    width: min(58vh, 200px) !important;
    max-height: calc(100% - 4px) !important;
    max-width: calc(100% - 4px) !important;
  }
  .board-hint {
    display: none;
  }

  .trash-panel {
    width: 72px;
    padding: 2px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
  }
  .trash-drop-zone {
    width: 100%;
    height: auto;
    max-height: 120px;
    padding: 4px 2px;
    gap: 2px;
  }
  .trash-icon-ring {
    width: 20px;
    height: 20px;
  }
  .trash-icon {
    font-size: 0.8rem;
  }
  .trash-label {
    font-size: 0.58rem;
  }
  .trash-sub {
    display: none;
  }

  #deckStatusBoxMobile {
    display: flex !important;
    flex-direction: column;
    gap: 1px;
    padding: 2px;
    font-size: 0.56rem;
    margin-top: 2px;
    width: 100%;
  }

  .card-hand-dock {
    min-height: 80px;
    max-height: 86px;
    padding: 2px 4px;
    flex-shrink: 0;
  }
  .dock-header {
    display: none;
  }
  .cards-hand-row {
    min-height: 72px;
    max-height: 78px;
    gap: 6px;
    padding: 2px 4px;
    justify-content: flex-start;
  }
  .game-card-item {
    width: 58px;
    height: 70px;
    padding: 2px 1px;
    border-radius: 6px;
    flex-shrink: 0;
  }
  .card-item-header {
    height: 12px;
  }
  .card-type-tag {
    font-size: 0.44rem;
    padding: 1px 3px;
    border-radius: 2px;
    white-space: nowrap;
    max-width: 95%;
  }
  .card-icon-frame {
    margin: 1px 0;
  }
  .card-img-asset {
    max-width: 24px;
    max-height: 24px;
  }
  .card-item-name {
    font-size: 0.52rem;
    height: 12px;
    line-height: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

/* Touch Drag Ghost for Mobile Touch Gestures */
.touch-drag-ghost {
  position: fixed;
  pointer-events: none;
  z-index: 9999;
  width: 68px;
  height: 76px;
  border-radius: 10px;
  background: rgba(18, 22, 36, 0.95);
  border: 2px solid var(--accent-cyan);
  box-shadow: 0 0 24px rgba(0, 229, 255, 0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4px;
  transform: translate(-50%, -50%) scale(1.08);
  transition: transform 0.05s ease-out;
}
.touch-drag-ghost img {
  max-width: 30px;
  max-height: 30px;
  object-fit: contain;
}
.touch-drag-ghost span {
  font-size: 0.6rem;
  font-weight: 800;
  color: #fff;
  margin-top: 2px;
}

/* ========================================================
   FLOATING CARD ACTIVATION SPOTLIGHT (HIỆU ỨNG TUNG CHIÊU)
   ======================================================== */
.card-cast-spotlight {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(5, 7, 15, 0.65);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.3s ease;
}

.card-cast-card {
  position: relative;
  width: 90%;
  max-width: 360px;
  background: rgba(16, 20, 36, 0.95);
  border: 2px solid var(--accent-cyan);
  border-radius: 20px;
  padding: 20px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8), 0 0 35px rgba(0, 229, 255, 0.45);
  text-align: center;
  animation: cardCastPop 1.1s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  overflow: hidden;
}

@keyframes cardCastPop {
  0% {
    transform: scale(0.6) translateY(35px);
    opacity: 0;
  }
  20% {
    transform: scale(1.05) translateY(-4px);
    opacity: 1;
  }
  30% {
    transform: scale(1) translateY(0);
  }
  80% {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
  100% {
    transform: scale(1.06) translateY(-20px);
    opacity: 0;
  }
}

.card-cast-glow {
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(0, 229, 255, 0.25) 0%, transparent 65%);
  pointer-events: none;
  animation: rotateGlow 6s linear infinite;
}

@keyframes rotateGlow {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.card-cast-header {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.card-cast-badge {
  font-size: 0.72rem;
  font-weight: 900;
  font-family: var(--font-title);
  padding: 4px 10px;
  border-radius: 50px;
  letter-spacing: 0.8px;
  text-transform: uppercase;
}

.card-cast-badge.buff {
  background: rgba(26, 204, 51, 0.2);
  border: 1px solid #1acc33;
  color: #1acc33;
}

.card-cast-badge.debuff {
  background: rgba(255, 56, 100, 0.2);
  border: 1px solid #ff3864;
  color: #ff3864;
}

.card-cast-badge.neutral {
  background: rgba(0, 229, 255, 0.2);
  border: 1px solid #00e5ff;
  color: #00e5ff;
}

.card-cast-badge.exodia {
  background: rgba(255, 215, 0, 0.25);
  border: 1px solid #ffd700;
  color: #ffd700;
  box-shadow: 0 0 12px rgba(255, 215, 0, 0.5);
}

.card-cast-action {
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--accent-cyan);
  letter-spacing: 0.5px;
}

.card-cast-body {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.card-cast-img {
  width: 90px;
  height: 126px;
  object-fit: cover;
  border-radius: 10px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
}

.card-cast-title {
  font-family: var(--font-title);
  font-size: 1.25rem;
  font-weight: 900;
  color: #fff;
  letter-spacing: 1px;
  margin: 0;
}

.card-cast-user {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--accent-cyan);
  margin-bottom: 4px;
}

.card-cast-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 8px 12px;
  margin: 0;
}

/* ========================================================
   TARGET OPPONENT SELECTOR MODAL STYLING
   ======================================================== */
.target-options-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
  width: 100%;
}

.target-card-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 14px;
  padding: 10px 14px;
  cursor: pointer;
  color: #fff;
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  text-align: left;
  width: 100%;
}

.target-card-btn:hover {
  background: rgba(0, 229, 255, 0.15);
  border-color: var(--accent-cyan);
  transform: translateX(4px);
  box-shadow: 0 4px 16px rgba(0, 229, 255, 0.3);
}

.target-card-avatar {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  flex-shrink: 0;
}

.target-card-details {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.target-card-name {
  font-weight: 800;
  font-size: 0.95rem;
}

.target-card-meta {
  font-size: 0.74rem;
  color: var(--text-muted);
}

.target-card-tags {
  display: flex;
  gap: 4px;
  margin-top: 2px;
}

.target-card-select-icon {
  font-size: 1.2rem;
  opacity: 0.7;
  transition: transform 0.2s;
}

.target-card-btn:hover .target-card-select-icon {
  opacity: 1;
  transform: scale(1.2);
}

/* ========================================================
   UNIVERSAL GAME DIALOG / POPUP SYSTEM (Replaces alert, prompt, confirm)
   ======================================================== */
.app-dialog-card {
  max-width: 440px;
  text-align: center;
  padding: 30px 26px 24px;
  border-radius: 20px;
  background: rgba(14, 18, 32, 0.96) !important;
  border: 1px solid rgba(0, 229, 255, 0.35);
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.7), 0 0 30px rgba(0, 229, 255, 0.15);
  transform: scale(0.95);
  animation: dialogPop 0.25s cubic-bezier(0.18, 0.89, 0.32, 1.28) forwards;
}

@keyframes dialogPop {
  to {
    transform: scale(1);
  }
}

.dialog-icon-wrapper {
  width: 68px;
  height: 68px;
  margin: 0 auto 16px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid rgba(0, 229, 255, 0.4);
  box-shadow: 0 0 20px rgba(0, 229, 255, 0.25);
  animation: iconPulse 2s infinite ease-in-out;
}

@keyframes iconPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}

.dialog-title {
  font-family: var(--font-title);
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: 1px;
  margin-bottom: 12px;
  color: #fff;
}

.dialog-message {
  font-size: 0.94rem;
  line-height: 1.6;
  color: var(--text-muted);
  white-space: pre-line;
  margin-bottom: 22px;
  word-break: break-word;
}

/* Dialog Variations */
.app-dialog-card.dialog-error {
  border-color: rgba(255, 56, 100, 0.6);
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.7), 0 0 35px rgba(255, 56, 100, 0.25);
}
.app-dialog-card.dialog-error .dialog-icon-wrapper {
  border-color: rgba(255, 56, 100, 0.6);
  box-shadow: 0 0 25px rgba(255, 56, 100, 0.35);
  background: rgba(255, 56, 100, 0.1);
}
.app-dialog-card.dialog-error .dialog-title {
  color: #ff4b72;
}

.app-dialog-card.dialog-warning {
  border-color: rgba(255, 183, 3, 0.6);
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.7), 0 0 35px rgba(255, 183, 3, 0.25);
}
.app-dialog-card.dialog-warning .dialog-icon-wrapper {
  border-color: rgba(255, 183, 3, 0.6);
  box-shadow: 0 0 25px rgba(255, 183, 3, 0.35);
  background: rgba(255, 183, 3, 0.1);
}
.app-dialog-card.dialog-warning .dialog-title {
  color: #ffb703;
}

.app-dialog-card.dialog-success {
  border-color: rgba(0, 230, 118, 0.6);
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.7), 0 0 35px rgba(0, 230, 118, 0.25);
}
.app-dialog-card.dialog-success .dialog-icon-wrapper {
  border-color: rgba(0, 230, 118, 0.6);
  box-shadow: 0 0 25px rgba(0, 230, 118, 0.35);
  background: rgba(0, 230, 118, 0.1);
}
.app-dialog-card.dialog-success .dialog-title {
  color: #00e676;
}

/* Dialog Input (for prompts) */
.dialog-input-wrapper {
  margin: 0 0 22px;
}
.dialog-input {
  width: 100%;
  padding: 13px 18px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(0, 229, 255, 0.4);
  border-radius: 12px;
  color: #fff;
  font-family: var(--font-main);
  font-size: 1rem;
  outline: none;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.3);
  transition: all 0.2s ease;
}
.dialog-input:focus {
  border-color: var(--accent-cyan);
  background: rgba(255, 255, 255, 0.09);
  box-shadow: 0 0 16px rgba(0, 229, 255, 0.35);
}

.dialog-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  align-items: center;
}
.dialog-actions button {
  min-width: 130px;
  padding: 12px 20px;
  font-weight: 700;
  border-radius: 12px;
  letter-spacing: 0.6px;
}

/* ========================================================
   TOAST NOTIFICATION COMPONENT (Floating in-game banners)
   ======================================================== */
.toast-container {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10001;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  max-width: 92vw;
  width: max-content;
}

.game-toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 22px;
  border-radius: 30px;
  background: rgba(14, 18, 32, 0.94);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(0, 229, 255, 0.4);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), 0 0 20px rgba(0, 229, 255, 0.2);
  color: #fff;
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: 0.3px;
  animation: toastSlideIn 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28) forwards;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.game-toast.toast-hiding {
  opacity: 0;
  transform: translateY(-16px) scale(0.92);
}

@keyframes toastSlideIn {
  from {
    opacity: 0;
    transform: translateY(-24px) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.game-toast.toast-error {
  border-color: rgba(255, 56, 100, 0.7);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), 0 0 25px rgba(255, 56, 100, 0.3);
}
.game-toast.toast-warning {
  border-color: rgba(255, 183, 3, 0.7);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), 0 0 25px rgba(255, 183, 3, 0.3);
}
.game-toast.toast-success {
  border-color: rgba(0, 230, 118, 0.7);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6), 0 0 25px rgba(0, 230, 118, 0.3);
}

.toast-icon {
  font-size: 1.3rem;
  line-height: 1;
}
.toast-text {
  line-height: 1.3;
}

/* ========================================================
   ESPORTS SPECTATOR MODE (LIÊN QUÂN TOURNAMENT STYLE)
   ======================================================== */

/* 1. LOBBY SPECTATOR ROLES & BUTTONS */
.header-badges-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge-role {
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  background: rgba(0, 229, 255, 0.15);
  border: 1px solid rgba(0, 229, 255, 0.4);
  color: #00e5ff;
}

.badge-role-spec {
  background: rgba(255, 183, 3, 0.18);
  border-color: rgba(255, 183, 3, 0.6);
  color: #ffd000;
}

.lobby-spectator-list {
  margin-top: 14px;
  background: rgba(10, 14, 26, 0.55);
  border: 1px dashed rgba(0, 229, 255, 0.25);
  border-radius: 12px;
  padding: 10px 14px;
}

.spectator-waiting-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 110px;
  overflow-y: auto;
}

.spectator-waiting-list .waiting-item.spectator-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.03);
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.spec-eye-icon {
  font-size: 1rem;
}

.badge-spectator {
  margin-left: auto;
  font-size: 0.68rem;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 10px;
  background: rgba(0, 229, 255, 0.2);
  color: #00e5ff;
  border: 1px solid rgba(0, 229, 255, 0.4);
}

.role-switch-bar {
  margin-top: 12px;
  width: 100%;
}

.btn-role-toggle {
  width: 100%;
  height: 40px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(0, 229, 255, 0.35);
  color: var(--text-main);
  padding: 0 16px;
  border-radius: 10px;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.btn-role-toggle:hover {
  background: rgba(0, 229, 255, 0.18);
  border-color: #00e5ff;
  color: #00e5ff;
}

.join-actions-group {
  display: flex;
  gap: 8px;
  align-items: center;
  width: 100%;
}

.btn-direct-join {
  height: 42px;
  padding: 0 16px;
  border-radius: 10px;
  font-size: 0.84rem;
  font-weight: 800;
  white-space: nowrap;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(0, 200, 83, 0.25);
}

.btn-spectate-pill {
  height: 42px;
  padding: 0 16px;
  font-size: 0.84rem;
  font-weight: 800;
  background: rgba(0, 229, 255, 0.15);
  border: 1px solid rgba(0, 229, 255, 0.45);
  color: #00e5ff;
  border-radius: 10px;
  white-space: nowrap;
  flex-shrink: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.btn-spectate-pill:hover {
  background: #00e5ff;
  color: #000;
  box-shadow: 0 0 14px rgba(0, 229, 255, 0.45);
}

.join-direct-hint {
  font-size: 0.74rem;
  color: var(--text-muted);
  margin-top: 6px;
  line-height: 1.4;
}

.room-card-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

.btn-room-join,
.btn-room-spectate {
  height: 34px;
  padding: 0 14px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: all 0.2s ease;
}

.btn-room-join {
  border: none;
}

.btn-room-spectate {
  background: rgba(0, 229, 255, 0.12);
  border: 1px solid rgba(0, 229, 255, 0.35);
  color: #00e5ff;
}

.btn-room-spectate:hover {
  background: #00e5ff;
  color: #000;
  box-shadow: 0 0 12px rgba(0, 229, 255, 0.5);
}

.btn-room-spectate.btn-spec-prominent {
  background: linear-gradient(135deg, rgba(0, 229, 255, 0.25), rgba(255, 183, 3, 0.25));
  border: 1px solid rgba(0, 229, 255, 0.6);
  color: #fff;
  box-shadow: 0 0 10px rgba(0, 229, 255, 0.25);
}

.btn-room-spectate.btn-spec-prominent:hover {
  background: #00e5ff;
  color: #000;
}

.room-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.3px;
  white-space: nowrap;
  flex-shrink: 0;
}

.room-status-badge.status-full {
  background: rgba(255, 56, 100, 0.16);
  color: #ff6b8b;
  border: 1px solid rgba(255, 56, 100, 0.35);
}

.room-status-badge.status-playing {
  background: rgba(255, 183, 3, 0.18);
  color: #ffd000;
  border: 1px solid rgba(255, 183, 3, 0.45);
}

.badge-live-stream {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 8px;
  font-size: 0.7rem;
  font-weight: 800;
  background: rgba(255, 56, 100, 0.2);
  border: 1px solid rgba(255, 56, 100, 0.5);
  color: #ff3864;
}

.live-dot-mini {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #ff3864;
  box-shadow: 0 0 6px #ff3864;
  animation: livePulse 1.2s infinite;
}

/* 2. ESPORTS TOURNAMENT SPECTATOR BAR (TOP BAR) */
.spectator-tournament-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: linear-gradient(90deg, rgba(16, 20, 36, 0.95), rgba(30, 24, 52, 0.95), rgba(16, 20, 36, 0.95));
  border: 1px solid rgba(0, 229, 255, 0.35);
  border-top: 2px solid #00e5ff;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6), inset 0 1px 1px rgba(255, 255, 255, 0.1);
  padding: 8px 16px;
  border-radius: 12px;
  margin-bottom: 8px;
  z-index: 10;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.spec-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 33, 79, 0.25);
  border: 1px solid #ff214f;
  color: #fff;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.6px;
  box-shadow: 0 0 10px rgba(255, 33, 79, 0.35);
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ff214f;
  box-shadow: 0 0 8px #ff214f;
  animation: livePulse 1s infinite alternate;
}

@keyframes livePulse {
  0% { transform: scale(0.85); opacity: 0.7; }
  100% { transform: scale(1.25); opacity: 1; box-shadow: 0 0 12px #ff214f; }
}

.spec-title-tag {
  font-family: var(--font-title);
  font-size: 0.85rem;
  font-weight: 800;
  color: #ffd700;
  letter-spacing: 1px;
  text-shadow: 0 0 8px rgba(255, 215, 0, 0.4);
}

.spec-count-tag {
  background: rgba(0, 229, 255, 0.12);
  border: 1px solid rgba(0, 229, 255, 0.4);
  color: #00e5ff;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 10px;
}

.spec-center {
  display: flex;
  align-items: center;
  gap: 8px;
}

.spec-spotlight-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 0, 0, 0.35);
  padding: 4px 8px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.spotlight-label {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-right: 4px;
}

.spec-spot-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #ccc;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.spec-spot-btn .spot-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.spec-spot-btn.active {
  background: rgba(0, 229, 255, 0.25);
  border-color: #00e5ff;
  color: #fff;
  box-shadow: 0 0 10px rgba(0, 229, 255, 0.4);
}

.spec-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-spec-action {
  background: linear-gradient(135deg, #ff9f1c, #ff4071);
  border: none;
  color: #fff;
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(255, 64, 113, 0.35);
  transition: all 0.2s ease;
}

.btn-spec-action:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(255, 64, 113, 0.55);
}

.btn-spec-action.btn-danger {
  background: rgba(255, 56, 100, 0.2);
  border: 1px solid rgba(255, 56, 100, 0.4);
  box-shadow: none;
  color: #ff3864;
}

.btn-spec-action.btn-danger:hover {
  background: #ff3864;
  color: #fff;
}

/* 3. SPECTATOR CASTER HAND INSPECTOR (BOTTOM DOCK) */
.spectator-dock-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 8px;
}

.spectator-target-badge {
  background: rgba(0, 229, 255, 0.2) !important;
  color: #00e5ff !important;
  border: 1px solid rgba(0, 229, 255, 0.4);
}

.spectator-player-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
}

.spec-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--text-main);
  padding: 4px 11px;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.spec-tab-btn .tab-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.spec-tab-btn .tab-badge-count {
  font-size: 0.72rem;
  opacity: 0.8;
}

.spec-tab-btn.active {
  background: rgba(0, 229, 255, 0.25);
  border-color: #00e5ff;
  color: #00e5ff;
  box-shadow: 0 0 10px rgba(0, 229, 255, 0.35);
}

/* All hands grid in spectator inspector */
.spectator-all-hands-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  width: 100%;
  max-height: 155px;
  overflow-y: auto;
  padding: 4px;
}

.spec-player-hand-column {
  background: rgba(18, 22, 38, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.spec-player-hand-column.active-turn-col {
  border-color: rgba(255, 215, 0, 0.5);
  box-shadow: 0 0 12px rgba(255, 215, 0, 0.2);
}

.spec-hand-col-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  padding-left: 6px;
}

.col-turn-tag {
  margin-left: auto;
  background: #ffd700;
  color: #000;
  font-size: 0.65rem;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 6px;
}

.spec-col-cards {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.spec-mini-card {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  padding: 3px 6px;
  font-size: 0.74rem;
}

.spec-mini-card.passive {
  border-color: rgba(79, 195, 247, 0.5);
  background: rgba(79, 195, 247, 0.1);
}

.spec-mini-card.shard {
  border-color: rgba(255, 215, 0, 0.5);
  background: rgba(255, 215, 0, 0.1);
}

.mini-card-icon {
  width: 18px;
  height: 18px;
  object-fit: contain;
}

.mini-card-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

.mini-card-name {
  font-weight: 600;
}

.mini-card-tag {
  font-size: 0.65rem;
  font-weight: 700;
  opacity: 0.85;
}

.spec-empty-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-style: italic;
  padding: 4px 0;
}

.spec-inspect-card {
  cursor: default !important;
}

/* 4. ESPORTS HEAD-TO-HEAD STATS MODAL (LIÊN QUÂN STYLE) */
.spectator-stats-modal {
  max-width: 900px !important;
  width: 95vw !important;
}

.header-esports-tag {
  font-size: 0.76rem;
  font-weight: 800;
  color: #ffd700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin-bottom: 2px;
}

.esports-stats-banner {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  background: rgba(10, 14, 26, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 10px 14px;
  border-radius: 10px;
  margin-bottom: 16px;
}

.stats-banner-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stats-banner-item .stats-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
}

.stats-banner-item .stats-value {
  font-size: 0.95rem;
  font-weight: 800;
}

.esports-comparison-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.esports-player-column {
  background: rgba(18, 22, 38, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 12px;
  transition: all 0.25s ease;
}

.esports-player-column.turn-focus {
  border-color: #ffd700;
  box-shadow: 0 0 16px rgba(255, 215, 0, 0.25);
}

.esp-col-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
}

.esp-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
}

.esp-pinfo {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.esp-pname {
  font-weight: 800;
  font-size: 0.92rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.esp-prole {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.esp-live-dot {
  margin-left: auto;
  font-size: 0.68rem;
  font-weight: 800;
  background: #ffd700;
  color: #000;
  padding: 2px 6px;
  border-radius: 8px;
}

.esp-metric-group {
  padding: 0 12px;
}

.esp-metric-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  margin-bottom: 4px;
}

.esp-progress-bar {
  width: 100%;
  height: 8px;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 4px;
  overflow: hidden;
}

.esp-progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s ease;
}

.esp-metric-badges {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0 12px;
}

.esp-badge-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.04);
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 0.76rem;
}

.esp-buff-list {
  padding: 0 12px;
}

.buff-title {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 4px;
}

.buff-items-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.esp-tag {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
}

.tag-shield {
  background: rgba(79, 195, 247, 0.2);
  color: #4fc3f7;
  border: 1px solid rgba(79, 195, 247, 0.4);
}

.tag-counter {
  background: rgba(255, 64, 113, 0.2);
  color: #ff4071;
  border: 1px solid rgba(255, 64, 113, 0.4);
}

.tag-immortal {
  background: rgba(255, 215, 0, 0.2);
  color: #ffd700;
  border: 1px solid rgba(255, 215, 0, 0.4);
}

.tag-debuff {
  background: rgba(255, 56, 100, 0.2);
  color: #ff3864;
  border: 1px solid rgba(255, 56, 100, 0.4);
}

.esp-tag-muted {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-style: italic;
}

.esp-action-focus {
  margin-top: auto;
  padding: 4px 12px 0 12px;
}

.btn-focus-player {
  width: 100%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid;
  border-radius: 6px;
  padding: 5px;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-focus-player:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: scale(1.02);
}

/* Responsive adjustments for Spectator Bar */
@media (max-width: 768px) {
  .spectator-tournament-bar {
    flex-wrap: wrap;
    gap: 8px;
    padding: 6px 10px;
  }
  .spec-left {
    gap: 6px;
  }
  .spec-title-tag {
    display: none;
  }
  .esports-stats-banner {
    grid-template-columns: repeat(2, 1fr);
  }
}


