:root {
  color-scheme: dark;
  --bg: #080908;
  --panel: rgba(14, 16, 17, 0.88);
  --panel-solid: #111416;
  --line: rgba(255, 255, 255, 0.12);
  --text: #f5f7f2;
  --muted: #a7b1a9;
  --green: #2ecb70;
  --red: #f05252;
  --blue: #4fa4ff;
  --gold: #f2bd4c;
  --shadow: rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  overflow: hidden;
}

button,
input {
  font: inherit;
}

.app {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  width: 100vw;
  height: 100vh;
}

.scene {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 52% 46%, rgba(255, 255, 255, 0.08), transparent 24rem),
    linear-gradient(135deg, #07100c 0%, #0d1012 44%, #110c0c 100%);
}

#sceneCanvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

.panel {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
  height: 100%;
  padding: 20px;
  background: var(--panel);
  border-left: 1px solid var(--line);
  box-shadow: -18px 0 48px var(--shadow);
  backdrop-filter: blur(18px);
  overflow-y: auto;
}

.brand,
.section-head,
.match-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.kicker {
  margin: 0 0 2px;
  color: var(--gold);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 30px;
  line-height: 1;
}

h2 {
  font-size: 15px;
}

.badge {
  padding: 7px 10px;
  border: 1px solid rgba(46, 203, 112, 0.35);
  border-radius: 8px;
  color: #b9ffd4;
  background: rgba(46, 203, 112, 0.12);
  font-size: 12px;
  font-weight: 700;
}

.scoreboard {
  display: grid;
  gap: 10px;
}

.player-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  min-height: 74px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
}

.player-card.is-active {
  border-color: rgba(242, 189, 76, 0.7);
  background: rgba(242, 189, 76, 0.12);
}

.player-card span {
  overflow: hidden;
  color: var(--muted);
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-card strong {
  color: var(--text);
  font-size: 34px;
  line-height: 1;
}

.match-meta {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.match-meta div {
  display: grid;
  gap: 3px;
}

.match-meta span,
.section-head span {
  color: var(--muted);
  font-size: 12px;
}

.match-meta strong {
  font-size: 16px;
}

.controls {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.07);
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

button:hover {
  border-color: rgba(242, 189, 76, 0.7);
  background: rgba(242, 189, 76, 0.12);
}

button:active {
  transform: translateY(1px);
}

button span {
  font-size: 24px;
  line-height: 1;
}

.throws,
.rating {
  display: grid;
  gap: 10px;
}

#throwList {
  display: grid;
  gap: 8px;
  min-height: 132px;
  max-height: 190px;
  margin: 0;
  padding: 0;
  overflow: auto;
  list-style: none;
}

#throwList li,
.rating-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
}

#throwList li span,
.rating-row span {
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#throwList li strong,
.rating-row strong {
  font-size: 16px;
}

.rating-rows {
  display: grid;
  gap: 8px;
}

.rank {
  width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: var(--gold);
  font-size: 12px;
  font-weight: 800;
}

.dialog {
  width: min(420px, calc(100vw - 28px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  background: var(--panel-solid);
  box-shadow: 0 24px 80px var(--shadow);
}

.dialog::backdrop {
  background: rgba(0, 0, 0, 0.66);
  backdrop-filter: blur(5px);
}

.dialog form {
  display: grid;
  gap: 14px;
  padding: 20px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  outline: none;
}

input:focus {
  border-color: rgba(242, 189, 76, 0.75);
}

menu {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 4px 0 0;
  padding: 0;
}

.toast {
  position: fixed;
  left: 24px;
  bottom: 24px;
  max-width: min(420px, calc(100vw - 48px));
  padding: 12px 14px;
  border: 1px solid rgba(242, 189, 76, 0.42);
  border-radius: 8px;
  color: var(--text);
  background: rgba(17, 20, 22, 0.9);
  box-shadow: 0 14px 44px var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 900px) {
  body {
    overflow: auto;
  }

  .app {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(420px, 62vh) auto;
    height: auto;
    min-height: 100vh;
  }

  .panel {
    height: auto;
    border-left: 0;
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 520px) {
  .app {
    grid-template-rows: minmax(360px, 55vh) auto;
  }

  .panel {
    padding: 14px;
  }

  h1 {
    font-size: 25px;
  }

  .match-meta {
    align-items: stretch;
  }
}
