@import url("https://fonts.googleapis.com/css2?family=Fredoka:wght@400;500;600;700&family=JetBrains+Mono:wght@400;600&display=swap");

:root {
  --bg: #0f172a;
  --bg2: #1e293b;
  --panel: #1e293bcc;
  --line: #334155;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --blue: #3b82f6;
  --red: #f43f5e;
  --gold: #facc15;
  --green: #22c55e;
  --radius: 14px;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Fredoka", system-ui, sans-serif;
  background:
    radial-gradient(circle at 15% 0%, #1d4ed855, transparent 40%),
    radial-gradient(circle at 85% 100%, #be123c44, transparent 40%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
}

h1, h2, h3 {
  margin: 0;
  font-weight: 700;
}
a {
  color: #93c5fd;
}
code, pre, .mono {
  font-family: "JetBrains Mono", ui-monospace, monospace;
}
.hidden {
  display: none !important;
}
.muted {
  color: var(--muted);
}

/* ---------- buttons and inputs ---------- */

button, .button {
  font: inherit;
  font-weight: 600;
  border: 0;
  border-radius: 10px;
  padding: 8px 14px;
  background: #334155;
  color: var(--text);
  cursor: pointer;
  box-shadow: 0 3px 0 #0f172a;
  transition: transform 0.08s, filter 0.15s;
  white-space: nowrap;
}
button:hover {
  filter: brightness(1.15);
}
button:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #0f172a;
}
button:disabled {
  opacity: 0.5;
  cursor: default;
}
button.primary {
  background: linear-gradient(#22c55e, #16a34a);
  color: #052e16;
}
button.gold {
  background: linear-gradient(#fde047, #eab308);
  color: #422006;
}
button.danger {
  background: linear-gradient(#fb7185, #e11d48);
  color: #fff;
}
button.ghost {
  background: transparent;
  box-shadow: none;
  color: var(--muted);
}

input, select, textarea {
  font: inherit;
  background: #0f172a;
  color: var(--text);
  border: 2px solid var(--line);
  border-radius: 10px;
  padding: 7px 10px;
}
input:focus, select:focus {
  outline: none;
  border-color: var(--blue);
}
label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 14px;
  color: var(--muted);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  backdrop-filter: blur(6px);
}
.panel h2 {
  font-size: 18px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.grow {
  flex: 1;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 18px;
  background: #0b1222cc;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(8px);
}
.logo {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0.5px;
}
.logo span {
  color: var(--gold);
}

.tabs {
  display: flex;
  gap: 4px;
}
.tabs button {
  background: transparent;
  box-shadow: none;
  color: var(--muted);
}
.tabs button.active {
  background: #334155;
  color: var(--text);
}

/* ---------- match view ---------- */

.match-view {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.match-view .hud {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
}
.match-view .side {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.match-view .side.right {
  justify-content: flex-end;
}
.match-view .name {
  font-weight: 700;
  font-size: 1.15em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.match-view .left .name {
  color: #93c5fd;
}
.match-view .right .name {
  color: #fda4af;
}
.match-view .score {
  font-size: 2.2em;
  font-weight: 700;
  min-width: 1.6em;
  text-align: center;
  border-radius: 12px;
  padding: 0 10px;
  color: #fff;
  text-shadow: 0 2px 0 #0008;
}
.match-view .left .score {
  background: linear-gradient(#3b82f6, #1d4ed8);
}
.match-view .right .score {
  background: linear-gradient(#f43f5e, #be123c);
}
.match-view .score.pop {
  animation: pop 0.6s ease-out;
}
@keyframes pop {
  0% {
    transform: scale(1);
  }
  30% {
    transform: scale(1.5) rotate(-6deg);
    filter: brightness(1.6);
  }
  100% {
    transform: scale(1);
  }
}
.match-view .clock {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 110px;
}
.match-view .time {
  font-size: 1.4em;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.match-view .time.hurry {
  color: #fb7185;
  animation: blink 0.5s infinite alternate;
}
@keyframes blink {
  to {
    opacity: 0.4;
  }
}
.match-view .bar {
  width: 100%;
  height: 6px;
  background: #334155;
  border-radius: 3px;
  overflow: hidden;
}
.match-view .bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--gold), #f97316);
  transition: width 0.3s linear;
}
.match-view .stage {
  position: relative;
}
.match-view canvas {
  width: 100%;
  aspect-ratio: 20 / 12;
  display: block;
  border-radius: var(--radius);
  box-shadow: 0 10px 40px #0008, 0 0 0 3px #0b1222;
}
.match-view .banner {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  pointer-events: none;
  animation: banner-in 0.6s cubic-bezier(0.2, 1.6, 0.4, 1);
}
.match-view .banner b {
  font-size: clamp(22px, 4vw, 52px);
  padding: 10px 28px;
  border-radius: 18px;
  background: #0f172ae6;
  border: 4px solid var(--team);
  box-shadow: 0 0 40px var(--team);
}
.match-view .banner span {
  font-size: clamp(18px, 3vw, 36px);
  font-weight: 700;
  background: #0f172ae6;
  padding: 2px 16px;
  border-radius: 10px;
}
@keyframes banner-in {
  from {
    transform: scale(0.3);
    opacity: 0;
  }
}

/* ---------- lists ---------- */

.ranking {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
}
.ranking li {
  display: grid;
  grid-template-columns: 2.2em 1fr auto auto;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 10px;
  background: #0f172a99;
  border: 1px solid var(--line);
  transition: transform 0.6s cubic-bezier(0.2, 1.2, 0.4, 1), background 0.6s;
}
.ranking li.mine {
  border-color: var(--gold);
  box-shadow: 0 0 0 1px var(--gold) inset;
}
.ranking li.house {
  opacity: 0.8;
}
.ranking .rank {
  font-weight: 700;
  text-align: center;
}
.ranking li:nth-child(1) .rank::before {
  content: "🥇";
}
.ranking li:nth-child(2) .rank::before {
  content: "🥈";
}
.ranking li:nth-child(3) .rank::before {
  content: "🥉";
}
.ranking li:nth-child(-n+3) .rank span {
  display: none;
}
.ranking .who {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ranking .who small {
  color: var(--muted);
}
.ranking .elo {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.ranking .move {
  width: 2.6em;
  text-align: right;
  font-size: 0.85em;
  font-weight: 700;
}
.ranking .move.up {
  color: var(--green);
}
.ranking .move.down {
  color: #fb7185;
}
.ranking li.flash {
  background: #facc1533;
}

.toast-area {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 50;
}
.toast {
  background: linear-gradient(135deg, #facc15, #f97316);
  color: #1c1917;
  font-weight: 600;
  padding: 12px 18px;
  border-radius: 12px;
  box-shadow: 0 8px 30px #0008;
  animation: toast-in 0.5s cubic-bezier(0.2, 1.5, 0.4, 1), toast-out 0.6s 5.4s forwards;
}
@keyframes toast-in {
  from {
    transform: translateX(120%);
  }
}
@keyframes toast-out {
  to {
    transform: translateX(120%);
    opacity: 0;
  }
}

table {
  border-collapse: collapse;
  width: 100%;
}
th, td {
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
}
th {
  color: var(--muted);
  font-weight: 500;
  font-size: 14px;
}

.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: #334155;
}
.badge.win {
  background: #166534;
  color: #bbf7d0;
}
.badge.loss {
  background: #9f1239;
  color: #fecdd3;
}
.badge.draw {
  background: #854d0e;
  color: #fef08a;
}

.spark {
  vertical-align: middle;
}

.match-view .banner .note {
  font-size: clamp(13px, 1.6vw, 22px);
  font-weight: 600;
}
.match-view .intro {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4%;
  pointer-events: none;
  background: radial-gradient(circle, #0f172acc 0%, #0f172a66 70%, transparent);
  border-radius: var(--radius);
  animation: intro-out 0.5s 2.1s forwards;
}
.match-view .intro b {
  font-size: clamp(16px, 3vw, 48px);
  padding: 8px 20px;
  border-radius: 16px;
  color: #fff;
  text-shadow: 0 3px 0 #0006;
  max-width: 42%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.match-view .intro .l {
  background: linear-gradient(#3b82f6, #1d4ed8);
  animation: from-left 0.6s cubic-bezier(0.2, 1.4, 0.4, 1);
}
.match-view .intro .r {
  background: linear-gradient(#f43f5e, #be123c);
  animation: from-right 0.6s cubic-bezier(0.2, 1.4, 0.4, 1);
}
.match-view .intro i {
  font-style: normal;
  font-weight: 700;
  font-size: clamp(28px, 6vw, 90px);
  color: var(--gold);
  text-shadow: 0 0 30px #facc15aa, 0 4px 0 #a16207;
  animation: vs 0.7s 0.3s cubic-bezier(0.2, 1.8, 0.4, 1) backwards;
}
@keyframes from-left {
  from {
    transform: translateX(-120vw) rotate(-10deg);
  }
}
@keyframes from-right {
  from {
    transform: translateX(120vw) rotate(10deg);
  }
}
@keyframes vs {
  from {
    transform: scale(4) rotate(-30deg);
    opacity: 0;
  }
}
@keyframes intro-out {
  to {
    opacity: 0;
    transform: scale(1.2);
  }
}
