/* ==========================================================================
   Minesweeper Arena Stylesheet - Modern Esports & Retro Dual Aesthetic
   ========================================================================== */

:root {
  --bg-color: #c0c0c0;
  --panel-bg: #c0c0c0;
  --card-bg: #ffffff;
  --border-light: #ffffff;
  --border-dark: #808080;
  --border-darker: #404040;
  --cell-size: 26px;
  --text-main: #111111;
  --digital-bg: #000000;
  --digital-color: #ff0000;
  --accent-color: #0b7285;
  --accent-gradient: linear-gradient(135deg, #0b7285, #15aabf);
}

[data-theme="dark"] {
  --bg-color: #0f111a;
  --panel-bg: #1a1c29;
  --card-bg: #222538;
  --border-light: #3d4461;
  --border-dark: #12141f;
  --border-darker: #090a10;
  --text-main: #c0caf5;
  --digital-bg: #10121c;
  --digital-color: #f7768e;
  --accent-color: #7aa2f7;
  --accent-gradient: linear-gradient(135deg, #7aa2f7, #bb9af7);
}

[data-theme="light"] {
  --bg-color: #eef2f6;
  --panel-bg: #f8fafc;
  --card-bg: #ffffff;
  --border-light: #ffffff;
  --border-dark: #cbd5e1;
  --border-darker: #94a3b8;
  --text-main: #1e293b;
  --digital-bg: #0f172a;
  --digital-color: #38bdf8;
  --accent-color: #0284c7;
  --accent-gradient: linear-gradient(135deg, #0284c7, #38bdf8);
}

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

html, body {
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden !important;
  position: relative;
}

input, select, textarea {
  font-size: 16px !important; /* Prevents iOS Safari from auto-zooming viewport */
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color 0.2s;
}

/* Header & Esports Navigation */
header {
  background: var(--panel-bg);
  border-bottom: 2px solid var(--border-dark);
  padding: 8px 16px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-container {
  max-width: 1480px;
  margin: 0 auto;
  padding: 8px 16px 4px;
}

.top-bar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: inherit;
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: 0.5px;
}

.brand-icon {
  font-size: 1.5rem;
}

/* Navigation Tabs */
.main-tabs {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  border-bottom: 2px solid rgba(255, 255, 255, 0.1);
  background: transparent !important;
  padding: 0 !important;
  border-radius: 0 !important;
  width: 100%;
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.main-tabs::-webkit-scrollbar {
  display: none;
}

[data-theme="dark"] .main-tabs {
  background: transparent !important;
}

.tab-btn {
  background: transparent !important;
  border: none !important;
  color: rgba(255, 255, 255, 0.7) !important;
  padding: 8px 16px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-bottom: 3px solid transparent !important;
  border-radius: 0 !important;
  margin-bottom: -2px;
  box-shadow: none !important;
  transition: all 0.2s ease;
}

.tab-btn:hover {
  color: #ffffff !important;
  background: transparent !important;
}

.tab-btn.active {
  color: #ffffff !important;
  background: transparent !important;
  border-bottom-color: #38bdf8 !important;
  box-shadow: none !important;
}

/* Right utility controls */
.nav-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.online-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(40, 167, 69, 0.12);
  color: #2b8a3e;
  padding: 4px 9px;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 600;
  border: 1px solid rgba(40, 167, 69, 0.3);
  user-select: none;
  line-height: 1;
}

[data-theme="dark"] .online-badge {
  background: rgba(81, 207, 102, 0.15);
  color: #51cf66;
  border-color: rgba(81, 207, 102, 0.35);
}

.pulse-dot {
  width: 7px;
  height: 7px;
  background-color: #2f9e44;
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 0 0 rgba(47, 158, 68, 0.7);
  animation: pulse-green 2s infinite;
}

[data-theme="dark"] .pulse-dot {
  background-color: #51cf66;
  box-shadow: 0 0 0 0 rgba(81, 207, 102, 0.7);
}

@keyframes pulse-green {
  0% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(47, 158, 68, 0.7);
  }
  70% {
    transform: scale(1);
    box-shadow: 0 0 0 6px rgba(47, 158, 68, 0);
  }
  100% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(47, 158, 68, 0);
  }
}

.player-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(0,0,0,0.06);
  padding: 5px 10px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border-dark);
  transition: background 0.15s;
}

.player-badge:hover {
  background: rgba(0,0,0,0.12);
}

.player-icon {
  font-size: 1rem;
}

.edit-icon {
  opacity: 0.6;
  font-size: 0.8rem;
}

.btn-group {
  display: inline-flex;
  border-radius: 4px;
  overflow: hidden;
}

.btn {
  background: var(--panel-bg);
  color: var(--text-main);
  border: 2px solid;
  border-color: var(--border-light) var(--border-dark) var(--border-darker) var(--border-light);
  padding: 6px 12px;
  font-size: 0.88rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: inherit;
  border-radius: 3px;
  font-weight: 500;
  transition: filter 0.1s, transform 0.05s;
}

.btn:active {
  border-color: var(--border-darker) var(--border-light) var(--border-light) var(--border-dark);
  transform: translateY(1px);
}

.btn.active {
  background: #d4d0c8;
  border-color: var(--border-darker) var(--border-light) var(--border-light) var(--border-dark);
  font-weight: bold;
}

[data-theme="dark"] .btn.active {
  background: #3b4261;
}

[data-theme="light"] .btn.active {
  background: #e2e8f0;
}

.btn-primary {
  background: var(--accent-gradient);
  color: #ffffff;
  border: none;
  font-weight: bold;
  border-radius: 4px;
}

.btn-sm {
  padding: 4px 8px;
  font-size: 0.8rem;
}

/* Main Views Controller */
main {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 18px 12px 40px;
}

.tab-view {
  display: none;
  width: 100%;
}

.tab-view.active {
  display: block;
}

/* Sub-toolbar (Solo mode) */
.sub-toolbar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.ng-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(0,0,0,0.06);
  padding: 5px 12px;
  border-radius: 4px;
  font-size: 0.85rem;
  cursor: pointer;
  border: 1px solid var(--border-dark);
}

/* Classic Beveled Game Frame */
.game-outer-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.game-frame {
  background: var(--panel-bg);
  border: 3px solid;
  border-color: var(--border-light) var(--border-dark) var(--border-darker) var(--border-light);
  padding: 8px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.25);
  display: inline-block;
  margin-bottom: 16px;
}

.game-header {
  border: 3px solid;
  border-color: var(--border-darker) var(--border-light) var(--border-light) var(--border-dark);
  padding: 6px 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  background: var(--panel-bg);
}

.lcd-display {
  background: var(--digital-bg);
  color: var(--digital-color);
  font-family: "Courier New", Courier, monospace;
  font-size: 1.9rem;
  font-weight: 900;
  letter-spacing: 2px;
  padding: 2px 6px;
  border: 2px solid;
  border-color: var(--border-darker) var(--border-light) var(--border-light) var(--border-dark);
  min-width: 76px;
  text-align: right;
  line-height: 1;
  text-shadow: 0 0 6px var(--digital-color);
}

.face-btn {
  width: 40px;
  height: 40px;
  border: 3px solid;
  border-color: var(--border-light) var(--border-dark) var(--border-darker) var(--border-light);
  background: var(--panel-bg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  outline: none;
}

.face-btn:active {
  border-color: var(--border-darker) var(--border-light) var(--border-light) var(--border-dark);
}

.board-viewport {
  border: 3px solid;
  border-color: var(--border-darker) var(--border-light) var(--border-light) var(--border-dark);
  overflow: auto;
  max-width: 96vw;
  max-height: 75vh;
  position: relative;
  background: var(--panel-bg);
  touch-action: pan-x pan-y;
  -webkit-overflow-scrolling: touch;
}

.board-grid {
  display: grid;
  user-select: none;
  background: var(--panel-bg);
  margin: 0 auto;
}

.cell {
  width: var(--cell-size);
  height: var(--cell-size);
  border: 2.5px solid;
  touch-action: manipulation;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  border-color: var(--border-light) var(--border-dark) var(--border-darker) var(--border-light);
  background: var(--panel-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: calc(var(--cell-size) * 0.65);
  cursor: pointer;
  line-height: 1;
  position: relative;
}

.cell.pressed {
  border: 1px solid var(--border-dark);
  background: #bfbfbf;
}

.cell.revealed {
  border: 1px solid var(--border-dark);
  background: #c6c6c6;
  cursor: default;
}

[data-theme="dark"] .cell.revealed {
  background: #2f3549;
  border-color: #1e2233;
}

[data-theme="light"] .cell.revealed {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.cell.exploded {
  background: #ff3333 !important;
  border: 1px solid #990000 !important;
}

.cell.wrong-flag {
  background: #ffcccc !important;
  border: 1px solid #cc0000 !important;
}

/* Numbers */
.cell[data-num="1"] { color: #0000ff; }
.cell[data-num="2"] { color: #008000; }
.cell[data-num="3"] { color: #ff0000; }
.cell[data-num="4"] { color: #000080; }
.cell[data-num="5"] { color: #800000; }
.cell[data-num="6"] { color: #008080; }
.cell[data-num="7"] { color: #000000; }
.cell[data-num="8"] { color: #808080; }

[data-theme="dark"] .cell[data-num="1"] { color: #7aa2f7; }
[data-theme="dark"] .cell[data-num="2"] { color: #9ece6a; }
[data-theme="dark"] .cell[data-num="3"] { color: #f7768e; }
[data-theme="dark"] .cell[data-num="4"] { color: #bb9af7; }
[data-theme="dark"] .cell[data-num="5"] { color: #ff9e64; }
[data-theme="dark"] .cell[data-num="6"] { color: #2ac3de; }
[data-theme="dark"] .cell[data-num="7"] { color: #c0caf5; }
[data-theme="dark"] .cell[data-num="8"] { color: #565f89; }

/* Stats Bar */
.live-stats {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 8px;
  font-size: 0.85rem;
  opacity: 0.88;
  flex-wrap: wrap;
}

.stat-badge {
  background: rgba(0,0,0,0.06);
  padding: 4px 10px;
  border-radius: 4px;
  border: 1px solid var(--border-dark);
}

/* Mobile Toolbar */
.mobile-toolbar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.touch-mode-btn {
  font-size: 1rem;
  padding: 8px 18px;
  border-radius: 20px;
  background: #ffffff;
  color: #111;
  font-weight: bold;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  border: 2px solid var(--accent-color);
}

.touch-mode-btn.flag-active {
  background: #ffe3e3;
  color: #c92a2a;
  border-color: #fa5252;
}

.zoom-controls {
  display: inline-flex;
  gap: 4px;
}

/* Arena Cards & Leaderboard */
.arena-card {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.12);
  margin: 0 auto;
}

.arena-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.arena-card-header h2 {
  font-size: 1.3rem;
  color: var(--accent-color);
}

.leaderboard-filters {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.table-responsive {
  overflow-x: auto;
}

.arena-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.arena-table th, .arena-table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border-dark);
}

.arena-table th {
  background: rgba(0,0,0,0.04);
  font-weight: 700;
  color: var(--text-main);
}

.arena-table tr:hover {
  background: rgba(0,0,0,0.03);
}

/* Rank badges */
.rank-1 { color: #f59f00; font-weight: bold; }
.rank-2 { color: #868e96; font-weight: bold; }
.rank-3 { color: #d9480f; font-weight: bold; }

/* PvP Arena Layout */
.pvp-setup-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-top: 10px;
}

.pvp-option-box {
  background: rgba(0,0,0,0.03);
  border: 1px solid var(--border-dark);
  border-radius: 8px;
  padding: 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
}

.pvp-option-box h3 {
  margin-bottom: 8px;
}

.badge-online {
  background: #2b8a3e;
  color: #fff;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 600;
}

/* PvP Battle Screen & HUD */
.pvp-battle-screen {
  width: 100%;
}

.battle-hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--card-bg);
  padding: 12px 20px;
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  margin-bottom: 16px;
  gap: 16px;
}

.battle-player {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.battle-player.opp {
  text-align: right;
  align-items: flex-end;
}

.hud-role {
  font-size: 0.75rem;
  text-transform: uppercase;
  font-weight: bold;
  opacity: 0.7;
}

.hud-name {
  font-size: 1.1rem;
  font-weight: 800;
}

.progress-bar-wrap {
  width: 100%;
  height: 10px;
  background: rgba(0,0,0,0.1);
  border-radius: 5px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: #2b8a3e;
  transition: width 0.2s ease;
}

.progress-bar.opp-bar {
  background: #e03131;
}

.progress-text {
  font-size: 0.8rem;
  font-weight: bold;
}

.versus-tag {
  font-weight: 900;
  font-size: 1.4rem;
  color: #fa5252;
  font-style: italic;
}

.emote-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  background: rgba(0,0,0,0.04);
  padding: 6px 12px;
  border-radius: 6px;
}

/* Spectate Cards Grid */
.spectate-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.match-card {
  background: rgba(0,0,0,0.03);
  border: 1px solid var(--border-dark);
  border-radius: 8px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Modals */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(3px);
  z-index: 999;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-overlay.active {
  display: flex;
}

.modal-card {
  background: var(--card-bg);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  padding: 12px 18px;
  background: var(--accent-gradient);
  color: #ffffff;
  font-weight: bold;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 1rem;
}

.modal-close-btn {
  background: rgba(255,255,255,0.25);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 26px;
  height: 26px;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  font-size: 0.92rem;
  line-height: 1.5;
}

.submit-score-box {
  background: rgba(0,0,0,0.04);
  border-radius: 8px;
  padding: 14px;
  margin-top: 10px;
}

/* Replay Controls */
.replay-info-bar {
  display: flex;
  justify-content: space-between;
  padding: 8px 12px;
  background: rgba(0,0,0,0.04);
  border-radius: 6px;
  font-weight: bold;
  font-size: 0.9rem;
}

.replay-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  background: rgba(0,0,0,0.04);
  padding: 10px 14px;
  border-radius: 8px;
  flex-wrap: wrap;
}

.win-banner {
  background: #2b8a3e;
  color: #ffffff;
  padding: 14px;
  text-align: center;
  font-weight: bold;
  font-size: 1.15rem;
  border-radius: 8px;
  margin-bottom: 16px;
}

/* Spinner */
.spinner {
  width: 32px;
  height: 32px;
  border: 4px solid rgba(0,0,0,0.1);
  border-top-color: var(--accent-color);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Footer */
footer {
  text-align: center;
  padding: 16px;
  font-size: 0.82rem;
  opacity: 0.75;
}

/* Responsive Mobile Optimization */
@media (max-width: 820px) {
  .nav-container {
    padding: 6px 12px 2px;
  }
}

@media (max-width: 680px) {
  :root {
    --cell-size: 30px;
  }

  header {
    padding: 6px 10px;
  }

  .nav-container {
    padding: 4px 0 0;
  }

  .top-bar-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 8px;
  }

  .brand-zone {
    flex-shrink: 0;
  }

  .brand-text {
    font-size: 1.05rem;
  }

  .main-tabs {
    width: 100%;
    display: flex;
    padding: 0;
    gap: 4px;
    box-sizing: border-box;
    border-bottom: 2px solid rgba(255, 255, 255, 0.1);
    background: transparent !important;
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .main-tabs::-webkit-scrollbar {
    display: none;
  }

  .main-tabs .tab-btn {
    flex: 0 0 auto;
    min-width: auto;
    justify-content: center;
    padding: 7px 12px;
    font-size: 0.85rem;
    white-space: nowrap;
    gap: 4px;
    box-sizing: border-box;
    border-radius: 0;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    background: transparent !important;
  }

  .main-tabs .tab-btn.active {
    border-bottom-color: #38bdf8 !important;
    background: transparent !important;
    box-shadow: none !important;
    color: #ffffff !important;
  }

  .nav-controls {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
  }

  .online-badge {
    padding: 3px 6px;
    font-size: 0.75rem;
    gap: 4px;
  }

  .online-label {
    display: none;
  }

  .player-badge {
    padding: 3px 6px;
    font-size: 0.78rem;
    max-width: 110px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .btn-icon {
    padding: 4px 6px !important;
    font-size: 0.85rem !important;
  }

  /* Solo sub-toolbar */
  .sub-toolbar {
    flex-direction: column;
    gap: 8px;
    width: 100%;
    margin-bottom: 10px;
  }

  .diff-btn-group {
    width: 100%;
    display: flex;
    gap: 3px;
    box-sizing: border-box;
  }

  .diff-btn-group .btn {
    flex: 1 1 0;
    min-width: 0;
    justify-content: center;
    padding: 6px 1px;
    font-size: 0.78rem;
    white-space: nowrap;
    box-sizing: border-box;
  }

  .mode-dim {
    display: none;
  }

  .ng-toggle {
    padding: 4px 8px;
    font-size: 0.78rem;
  }

  /* Board Area */
  .game-frame {
    padding: 4px;
    max-width: 100%;
  }

  .board-viewport {
    max-width: 95vw;
    -webkit-overflow-scrolling: touch;
  }

  .lcd-display {
    font-size: 1.55rem;
    min-width: 62px;
    padding: 2px 4px;
  }

  .face-btn {
    width: 36px;
    height: 36px;
    font-size: 1.3rem;
  }

  .live-stats {
    gap: 4px;
    margin-top: 6px;
    font-size: 0.75rem;
  }

  .stat-badge {
    padding: 2px 6px;
  }

  /* Mobile toolbar */
  .mobile-toolbar {
    width: 100%;
    gap: 8px;
    margin-top: 10px;
  }

  .touch-mode-btn {
    flex: 1;
    text-align: center;
    padding: 8px 10px;
    font-size: 0.84rem;
  }

  .zoom-controls .btn {
    padding: 6px 8px;
    font-size: 0.78rem;
  }

  /* Modals on mobile */
  .modal-overlay {
    padding: 8px;
  }

  .modal-card {
    max-height: 94vh;
    border-radius: 8px;
  }

  .modal-header {
    padding: 10px 14px;
    font-size: 0.95rem;
  }

  .modal-body {
    padding: 14px 10px;
    font-size: 0.88rem;
  }

  /* Replay Player on mobile */
  .replay-controls {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 8px 10px;
  }

  .replay-controls-main {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 8px;
  }

  .replay-timeline-bar {
    width: 100%;
  }

  #replay-speed-group {
    width: 100%;
    display: flex;
  }

  #replay-speed-group .btn {
    flex: 1 1 0;
    min-width: 0;
    padding: 4px 2px;
    font-size: 0.75rem;
  }

  /* Leaderboard on mobile */
  .arena-card {
    padding: 14px 10px;
    border-radius: 8px;
  }

  .arena-card-header {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .arena-card-header h2 {
    font-size: 1.15rem;
    text-align: center;
  }

  .leaderboard-filters {
    justify-content: center;
  }

  .col-extra {
    display: none !important;
  }

  .arena-table th, .arena-table td {
    padding: 8px 4px;
    font-size: 0.82rem;
  }

  /* PvP on mobile */
  .pvp-setup-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .pvp-option-box {
    padding: 16px 12px;
  }

  #pvp-match-mode {
    width: 100%;
    display: flex;
    gap: 3px;
  }

  #pvp-match-mode .btn {
    flex: 1 1 0;
    min-width: 0;
    padding: 6px 1px;
    font-size: 0.78rem;
    white-space: nowrap;
  }

  .battle-hud {
    padding: 8px 10px;
    gap: 6px;
    width: 100%;
    box-sizing: border-box;
  }

  .battle-player {
    flex: 1 1 0;
    min-width: 0;
    overflow: hidden;
  }

  .battle-center-info {
    min-width: 52px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  .hud-name {
    font-size: 0.86rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
  }

  .versus-tag {
    font-size: 1.05rem;
    line-height: 1;
  }

  #battle-room-tag {
    font-size: 0.7rem;
    white-space: nowrap;
  }

  .emote-bar {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding: 4px 6px;
    width: 100%;
    box-sizing: border-box;
    gap: 4px;
  }

  .emote-bar span {
    font-size: 0.72rem;
    white-space: nowrap;
  }

  .emote-bar .btn {
    padding: 3px 5px;
    font-size: 0.8rem;
    flex-shrink: 0;
  }

  #btn-leave-pvp {
    padding: 3px 6px;
    font-size: 0.75rem;
    white-space: nowrap;
    margin-left: auto;
    flex-shrink: 0;
  }
}

#pvp-room-waiting {
  animation: fadeIn 0.2s ease-in-out;
}

[data-theme="dark"] #pvp-room-waiting {
  background: rgba(255, 255, 255, 0.05) !important;
  border-color: rgba(255, 255, 255, 0.2) !important;
}

#waiting-room-id {
  user-select: all;
}

.room-prefix-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.08);
  border: 1px solid var(--border-dark);
  border-right: none;
  border-radius: 4px 0 0 4px;
  padding: 6px 12px;
  font-family: monospace;
  font-weight: bold;
  font-size: 1.15rem;
  color: var(--text-color);
  user-select: none;
}

[data-theme="dark"] .room-prefix-label {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

.battle-banner {
  background: #2b8a3e;
  color: #fff;
  text-align: center;
  padding: 9px 16px;
  border-radius: 6px;
  font-weight: bold;
  font-size: 0.95rem;
  margin: 0 auto 14px auto;
  max-width: 480px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
  animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
