*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #0d0f14;
  --bg2: #13161e;
  --bg3: #1a1e2a;
  --panel: rgba(255, 255, 255, 0);
  --border: rgba(255, 255, 255, 0.07);
  --accent: #cc302e;
  --accent2: #e5483f;
  --accent-soft: rgba(204, 48, 46, 0.15);
  --hover: #f04a43;
  --text: #e8eaf0;
  --text2: #8890a8;
  --win: #2ecc71;
  --lose: #e74c3c;
  --slot-bg: rgba(204, 48, 46, 0.06);
  --slot-border: rgba(204, 48, 46, 0.25);
  --font: 'Barlow Condensed', sans-serif;
  --font-body: 'Barlow', sans-serif;
  --radius: 6px;
}

body {
  font-family: var(--font-body);
  background-image: linear-gradient(rgba(0, 0, 0, 0.75), rgba(0, 0, 0, 0.75)), url("media/bg.jpg");
  color: var(--text);
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.hidden {
  display: none !important;
}

.login-overlay {
  position: fixed;
  inset: 0;
  background-image: linear-gradient(rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0.1)), url("media/bg.jpg");
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.login-box {
  width: 380px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 48px 40px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.login-logo {
  font-size: 48px;
  line-height: 1;
}

.login-logo img {
  width: 4rem;
  height: auto;
}

.login-box h2 {
  font-family: var(--font);
  font-size: 28px;
  font-weight: 900;
  letter-spacing: 4px;
  color: var(--accent);
}

.login-subtitle {
  font-size: 16px;
  color: var(--accent);
  letter-spacing: 1px;
  text-align: center;
}

.login-box input {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s;
}

.login-box input:focus {
  border-color: var(--accent);
}

.login-box button {
  width: 100%;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 2px;
  padding: 14px;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.login-box button:hover {
  background: var(--hover);
}

.login-box button:active {
  transform: scale(0.98);
}

.login-error {
  color: var(--lose);
  font-size: 13px;
  min-height: 18px;
  text-align: center;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 0 16px 16px;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.header-globe {
  font-size: 32px;
  line-height: 1;
}

.header-globe img {
  width: 2rem;
  height: auto;
}

.header-left h1 {
  font-family: var(--font);
  font-size: 26px;
  font-weight: 900;
  letter-spacing: 4px;
  color: var(--accent);
}

.header-sub {
  font-size: 11px;
  color: var(--text2);
  letter-spacing: 2px;
  text-transform: uppercase;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-create {
  background: var(--panel);
  backdrop-filter: blur(8px);
  border: 1px solid var(--accent);
  color: var(--accent);
  font-family: var(--font);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 1px;
  padding: 8px 20px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.btn-create:hover {
  background: var(--accent);
  color: #000;
}

.arbitre-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 14px;
  font-family: var(--font);
  font-size: 16px;
  font-weight: 600;
}

.btn-logout {
  background: none;
  border: none;
  color: var(--text2);
  cursor: pointer;
  font-size: 14px;
  padding: 0 0 0 6px;
  transition: color 0.2s;
}

.btn-logout:hover {
  color: var(--lose);
}

.panels {
  display: grid;
  grid-template-columns: 300px 1fr 300px;
  gap: 14px;
  flex: 1;
  overflow: hidden;
  padding-top: 14px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  backdrop-filter: blur(8px);
}

.panel-title {
  font-family: var(--font);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 3px;
  color: var(--text2);
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.search-wrapper {
  position: relative;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.search-icon {
  position: absolute;
  left: 22px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text2);
  font-size: 18px;
  pointer-events: none;
}

.search-wrapper input {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 12px 9px 34px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.search-wrapper input:focus {
  border-color: rgba(240, 198, 25, 0.4);
}

.players-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px 8px;
}

.players-list::-webkit-scrollbar {
  width: 4px;
}

.players-list::-webkit-scrollbar-track {
  background: transparent;
}

.players-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.player-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 12px;
  margin-bottom: 4px;
  background: var(--bg3);
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  font-family: var(--font);
  font-size: 17px;
  font-weight: 600;
}

.player-item:hover {
  border-color: var(--slot-border);
  background: var(--accent-soft);
  transform: translateX(2px);
}

.player-item.selected-1 {
  border-color: var(--accent);
  background: rgba(204, 48, 46, 0.12);
}

.player-item.selected-2 {
  border-color: var(--accent2);
  background: rgba(229, 72, 63, 0.12);
}

.player-elo-small {
  font-size: 13px;
  font-weight: 400;
  color: var(--text2);
  font-family: var(--font-body);
}

.panel-center {
  justify-content: space-between;
}

.match-arena {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 20px;
}

.match-slot {
  flex: 1;
  height: 100%;
  max-height: 280px;
  background: var(--slot-bg);
  border: 2px dashed var(--slot-border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}

.match-slot.filled {
  border-style: solid;
  cursor: pointer;
}

.match-slot.slot-1.filled,
.match-slot.slot-2.filled {
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.07);
}

.match-slot.winner-flash {
  animation: winnerPulse 0.6s ease;
}

.match-slot.loser-flash {
  animation: loserPulse 0.6s ease;
}

@keyframes winnerPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(46, 204, 113, 0.6);
  }

  50% {
    box-shadow: 0 0 40px 20px rgba(46, 204, 113, 0.3);
    background: rgba(46, 204, 113, 0.15);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(46, 204, 113, 0);
  }
}

@keyframes loserPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.6);
  }

  50% {
    box-shadow: 0 0 40px 20px rgba(231, 76, 60, 0.2);
    background: rgba(231, 76, 60, 0.1);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(231, 76, 60, 0);
  }
}

.slot-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--text2);
  font-family: var(--font);
  font-size: 15px;
  letter-spacing: 1px;
  text-align: center;
  pointer-events: none;
}

.slot-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 20px;
  text-align: center;
  pointer-events: none;
}

.slot-pseudo {
  font-family: var(--font);
  font-size: 28px;
  font-weight: 900;
  letter-spacing: 1px;
  color: var(--text);
  line-height: 1;
}

.slot-elo {
  font-size: 14px;
  color: var(--text2);
  font-family: var(--font-body);
}

.slot-label {
  font-family: var(--font);
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--text2);
  text-transform: uppercase;
}

.slot-win-hint {
  font-family: var(--font);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--win);
  text-transform: uppercase;
  opacity: 0.7;
}

.vs-badge {
  font-family: var(--font);
  font-size: 36px;
  font-weight: 900;
  color: var(--text2);
  letter-spacing: 3px;
  flex-shrink: 0;
}

.match-instruction {
  text-align: center;
  padding: 10px;
  font-size: 13px;
  color: var(--text2);
  letter-spacing: 1px;
  flex-shrink: 0;
}

.btn-reset {
  margin: 0 20px 16px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text2);
  font-family: var(--font);
  font-size: 14px;
  letter-spacing: 1px;
  padding: 8px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.btn-reset:hover {
  border-color: var(--text2);
  color: var(--text);
}

.ranking-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px 8px;
}

.ranking-list::-webkit-scrollbar {
  width: 4px;
}

.ranking-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.rank-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  margin-bottom: 4px;
  background: var(--bg3);
  border: 1px solid transparent;
  border-radius: var(--radius);
  transition: all 0.3s;
}

.rank-item.rank-1 {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.rank-item.rank-2 {
  border-color: rgba(192, 192, 192, 0.2);
}

.rank-item.rank-3 {
  border-color: rgba(180, 100, 30, 0.2);
}

.rank-pos {
  font-family: var(--font);
  font-size: 13px;
  font-weight: 700;
  color: var(--text2);
  width: 28px;
  text-align: center;
  flex-shrink: 0;
}

.rank-1 .rank-pos {
  color: var(--accent);
  font-size: 15px;
}

.rank-2 .rank-pos {
  color: #c0c0c0;
}

.rank-3 .rank-pos {
  color: #b4641e;
}

.rank-pseudo {
  flex: 1;
  font-family: var(--font);
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rank-elo {
  font-family: var(--font);
  font-size: 16px;
  font-weight: 600;
  color: var(--accent);
  flex-shrink: 0;
}

.rank-elo-delta {
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font-body);
  padding: 2px 5px;
  border-radius: 3px;
  flex-shrink: 0;
}

.rank-elo-delta.pos {
  background: rgba(46, 204, 113, 0.15);
  color: var(--win);
}

.rank-elo-delta.neg {
  background: rgba(231, 76, 60, 0.15);
  color: var(--lose);
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.modal-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-top: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 36px 32px;
  width: 360px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-box h3 {
  font-family: var(--font);
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 3px;
  color: var(--accent);
}

.modal-box input {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  outline: none;
  width: 100%;
  transition: border-color 0.2s;
}

.modal-box input:focus {
  border-color: var(--accent);
}

.modal-error {
  color: var(--lose);
  font-size: 13px;
  min-height: 16px;
}

.modal-actions {
  display: flex;
  gap: 10px;
}

.btn-cancel {
  flex: 1;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text2);
  font-family: var(--font);
  font-size: 15px;
  letter-spacing: 1px;
  padding: 10px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-cancel:hover {
  border-color: var(--text2);
  color: var(--text);
}

.btn-confirm {
  flex: 1;
  background: var(--accent);
  border: none;
  color: #000;
  font-family: var(--font);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 1px;
  padding: 10px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.2s;
}

.btn-confirm:hover {
  background: var(--hover);
}

.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
}

.toast {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  padding: 12px 18px;
  font-family: var(--font);
  font-size: 15px;
  letter-spacing: 1px;
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
  max-width: 280px;
}

.toast.error {
  border-left-color: var(--lose);
}

.toast.win {
  border-left-color: var(--win);
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(20px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes toastOut {
  to {
    opacity: 0;
    transform: translateX(20px);
  }
}