:root {
  --bg: #07111f;
  --card: rgba(11, 22, 40, 0.72);
  --card-border: rgba(255, 255, 255, 0.1);
  --text: #f5f8ff;
  --muted: #afbbd0;
  --accent: #6fa8ff;
  --accent-2: #9b7cff;
  --danger: #ff6b87;
  --shadow: 0 22px 60px rgba(0, 0, 0, 0.38);
  --radius: 26px;
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(111, 168, 255, 0.18), transparent 30%),
    radial-gradient(circle at right bottom, rgba(155, 124, 255, 0.18), transparent 25%),
    linear-gradient(180deg, #07111f, #040913 65%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input, select { font: inherit; }
button { cursor: pointer; border: none; transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease; }
button:active { transform: scale(.985); }
button[disabled] { cursor: not-allowed; opacity: .45; transform: none; }

select {
  color-scheme: dark;
}

input, select {
  width: 100%;
  background: rgba(255,255,255,0.06);
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 16px;
  padding: 14px 16px;
  outline: none;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}

select option {
  background: #1a2436;
  color: #f5f8ff;
}

select option:checked {
  background: #2a3b57;
  color: #f5f8ff;
}
button:focus-visible,
input:focus-visible,
select:focus-visible {
  border-color: rgba(111, 168, 255, 0.9);
  box-shadow: 0 0 0 3px rgba(111, 168, 255, 0.18);
}
input[type="checkbox"] {
  width: 18px;
  height: 18px;
  padding: 0;
  border-radius: 6px;
  accent-color: var(--accent);
}
.app-shell { width: min(1080px, 100%); margin: 0 auto; padding: 18px 16px 42px; }
.glass { background: var(--card); border: 1px solid var(--card-border); backdrop-filter: blur(16px); box-shadow: var(--shadow); }
.topbar { display:flex; align-items:center; justify-content:space-between; gap:16px; padding:16px 18px; border-radius:var(--radius); margin-bottom:18px; flex-wrap:wrap; }
.topbar-actions { display:flex; align-items:center; gap:10px; flex-wrap:wrap; justify-content:flex-end; margin-left:auto; }
.realtime-badge { min-height: 38px; display:inline-flex; align-items:center; }
.realtime-badge-live { background: rgba(85, 214, 130, 0.14); border: 1px solid rgba(85, 214, 130, 0.28); }
.realtime-badge-syncing { background: rgba(111, 168, 255, 0.14); border: 1px solid rgba(111, 168, 255, 0.28); }
.realtime-badge-connecting,
.realtime-badge-reconnecting { background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.12); }
.realtime-badge-stale { background: rgba(255, 193, 92, 0.14); border: 1px solid rgba(255, 193, 92, 0.28); }
.realtime-indicator {
  position: fixed;
  right: 16px;
  bottom: 16px;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  border: 2px solid rgba(255,255,255,0.18);
  box-shadow: 0 0 0 4px rgba(7, 17, 31, 0.42), 0 10px 24px rgba(0, 0, 0, 0.34);
  z-index: 1300;
  transition: transform .18s ease, background .18s ease, box-shadow .18s ease;
}
.realtime-indicator-live { background: #55d682; }
.realtime-indicator-syncing { background: #6fa8ff; animation: realtimePulse 1.4s ease-in-out infinite; }
.realtime-indicator-connecting,
.realtime-indicator-reconnecting { background: rgba(255,255,255,0.75); animation: realtimePulse 1.4s ease-in-out infinite; }
.realtime-indicator-stale { background: #ff6b87; animation: realtimePulse 1s ease-in-out infinite; }
.brand { display:flex; align-items:center; gap:14px; min-width:0; flex:1 1 auto; }
.brand h1 { margin:2px 0 0; font-size:28px; }
.brand-badge {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  flex: 0 0 52px;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  overflow: hidden;
}

.brand-badge-logo {
  display: block;
  width: 44px;
  height: 44px;
  object-fit: contain;
}
.eyebrow { color: var(--muted); font-size:12px; letter-spacing:.12em; text-transform:uppercase; }
.screen { display:none; animation: fadeUp .22s ease; }
.screen.active {
  display: grid;
  gap: 16px;
}
@keyframes fadeUp { from { opacity:0; transform:translateY(8px);} to {opacity:1; transform:translateY(0);} }
.grid { display:grid; gap:16px; }
.two-col { grid-template-columns:1fr 1fr; }
.card, .hero-card { border-radius: var(--radius); padding:22px; }
.hero-card { min-height:60vh; display:flex; flex-direction:column; align-items:center; justify-content:center; text-align:center; gap:10px; }
.spinner { width:52px; height:52px; border-radius:50%; border:4px solid rgba(255,255,255,0.12); border-top-color: var(--accent); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg);} }
@keyframes realtimePulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 4px rgba(7, 17, 31, 0.42), 0 10px 24px rgba(0, 0, 0, 0.34); }
  50% { transform: scale(1.16); box-shadow: 0 0 0 6px rgba(7, 17, 31, 0.28), 0 12px 28px rgba(0, 0, 0, 0.38); }
}
.card-head { display:flex; align-items:flex-start; justify-content:space-between; gap:14px; margin-bottom:18px; }
.card-head h2, .card-head h3 { margin:0; }
.chip { border-radius:999px; padding:8px 12px; background:rgba(255,255,255,0.08); font-size:12px; white-space:nowrap; }
.profile-main { display:flex; align-items:center; gap:14px; margin-bottom:18px; }
.avatar-xl { width:76px; height:76px; border-radius:22px; object-fit:cover; background: rgba(255,255,255,0.08); }
.profile-name { font-size:24px; font-weight:700; }
.profile-meta,
.muted-link {
  color: var(--muted);
}

.profile-avatar-actions {
  margin-top: 4px;
}

.invite-link {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.invite-link:hover,
.invite-link:focus-visible {
  color: var(--text);
}
.field { display:flex; flex-direction:column; gap:8px; margin-bottom:14px; }
.field span { color: var(--muted); font-size:14px; }
.toggle-row { display:flex; align-items:center; gap:10px; color: var(--muted); margin: 8px 0 10px; }
.actions-stack { display:flex; flex-direction:column; gap:12px; }
.primary-btn, .secondary-btn, .ghost-btn { min-height:48px; padding:14px 18px; border-radius:18px; color: var(--text); }
.primary-btn { background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.secondary-btn { background: rgba(255,255,255,0.09); border: 1px solid rgba(255,255,255,0.12); }
.ghost-btn { background: transparent; border: 1px solid rgba(255,255,255,0.12); }
.ghost-btn.danger { border-color: rgba(255, 107, 135, 0.35); }
.large { min-height:56px; font-weight:700; }
.small { min-height:38px; padding:10px 14px; border-radius:14px; }
.join-inline { display:grid; grid-template-columns: 1fr auto; gap:10px; }
.inline-actions { display:flex; gap:10px; flex-wrap:wrap; }
.subcard {
  margin-top: 14px;
  padding: 16px;
  border-radius: 20px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
}
.public-rooms-list { display:grid; gap:12px; }
.public-room-card {
  padding: 16px;
  border-radius: 18px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
}
.public-room-top {
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  flex-wrap:wrap;
}
.public-room-meta {
  margin-top: 8px;
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  color: var(--muted);
  font-size: 14px;
}
.banner {
  margin-top:16px;
  background: rgba(111, 168, 255, 0.12);
  border:1px solid rgba(111, 168, 255, 0.16);
  border-radius:18px;
  padding:14px 16px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  flex-wrap:wrap;
}
.banner-copy { display:grid; gap:4px; }
.banner-text { color: var(--muted); }
.hidden { display:none !important; }
.rules-list { margin:0; padding-left:20px; color:var(--muted); display:grid; gap:10px; }

.field-hint,
.status-box,
.rules-summary-box,
.empty-state {
  margin-top: 14px;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.04);
}
.field-hint { color: var(--muted); }
.status-box { color: var(--text); }
.status-box.success { border-color: rgba(111, 168, 255, 0.35); }
.status-box.error { border-color: rgba(255, 107, 135, 0.35); }
.status-list,
.rules-summary-list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 8px;
}
.rules-summary-box.compact { margin-top: 16px; }
.empty-state { color: var(--muted); }

.room-head .room-meta-row { display:flex; align-items:center; justify-content:space-between; gap:12px; flex-wrap:wrap; }
.room-actions-inline { display:flex; gap:10px; flex-wrap:wrap; }

.room-side-card {
  display: grid;
  gap: 14px;
  align-content: start;
}

.room-section {
  margin-top: 0;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.section-head h4 {
  margin: 0;
  font-size: 16px;
}

.room-section .rules-summary-box,
.room-side-card .status-box {
  margin-top: 0;
}

.teams-root, .history-root { display:grid; gap:14px; }
.team-card, .summary-box, .history-item, .score-item { background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.08); border-radius: 20px; padding: 16px; }
.team-title { display:flex; align-items:center; justify-content:space-between; margin-bottom:12px; font-weight:700; }
.player-list { display:grid; gap:10px; }
.player-row { display:grid; grid-template-columns:auto 1fr auto; gap:10px; align-items:center; padding:10px; border-radius:16px; background: rgba(255,255,255,0.04); }
.player-row img { width:42px; height:42px; border-radius:14px; object-fit:cover; background: rgba(255,255,255,0.08); }
.player-meta { display:flex; flex-direction:column; gap:4px; }
.player-sub { color:var(--muted); font-size:13px; }
.player-you {
  display:inline-flex;
  align-items:center;
  margin-left:8px;
  padding:2px 8px;
  border-radius:999px;
  background: rgba(111, 168, 255, 0.16);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  vertical-align: middle;
}
.player-actions {
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  justify-content:flex-end;
}
.team-select-label {
  display:grid;
  gap:6px;
  min-width:158px;
  color: var(--muted);
  font-size:12px;
}
.team-select {
  min-width:0;
  padding:10px 12px;
  border-radius:12px;
}

.settings-grid {
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap:12px;
}

.settings-grid > * {
  min-width: 0;
}

.room-section-stack {
  display: grid;
  gap: 16px;
}

.section-note {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.room-main-grid .room-title-field,
.room-main-grid .room-inline-note,
.room-rules-grid .field,
.difficulty-field,
.packs-field {
  grid-column: 1 / -1;
}

.room-inline-note {
  margin-top: -6px;
  color: var(--muted);
  font-size: 13px;
}

.room-rules-grid .toggle-row {
  margin: 0;
}

.toggles-grid { display:grid; gap:4px; margin:0; }
.extra-rules-grid { display:grid; gap:4px; margin:0; }

.room-actions-primary,
.room-actions-secondary {
  display: grid;
  gap: 10px;
}

.room-actions-secondary {
  padding-top: 10px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.difficulty-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
}

.difficulty-grid > * {
  min-width: 0;
}

.packs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  max-height: 360px;
  overflow: auto;
  padding-right: 4px;
}

.packs-grid::-webkit-scrollbar {
  width: 8px;
}

.packs-grid::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.14);
  border-radius: 999px;
}

.pack-option {
  display:flex;
  align-items:flex-start;
  gap:10px;
  padding:12px 14px;
  border-radius:16px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  min-height: 72px;
  min-width: 0;
}

.difficulty-option {
  align-items: flex-start;
  min-width: 0;
}

.pack-option input {
  margin-top: 2px;
  flex: 0 0 auto;
}

.difficulty-option input {
  margin-top: 0;
}

.pack-option-text {
  display:flex;
  flex-direction:column;
  gap:4px;
  min-width: 0;
}

.pack-option-text strong {
  line-height: 1.2;
}

.pack-option-text small {
  color: var(--muted);
  line-height: 1.35;
}

.pack-option-empty { color: var(--muted); }
.game-top { display:grid; grid-template-columns:minmax(0, 1fr) minmax(340px, 1.2fr) minmax(0, 1fr); gap:16px; align-items:center; }
.scoreboard { display:grid; gap:10px; }
.score-value { font-size:28px; font-weight:800; }
.round-center { min-width: 0; text-align:center; }
.round-word { font-size: clamp(30px, 5vw, 52px); font-weight:900; line-height:1.16; margin:10px 0 0; padding-bottom: 8px; overflow-wrap:anywhere; }
.round-word-status {
  font-size: clamp(24px, 3.2vw, 42px);
  line-height: 1.06;
  white-space: pre-line;
  overflow-wrap: anywhere;
  word-break: normal;
  text-wrap: balance;
  max-width: min(100%, 12ch);
  margin-inline: auto;
}
.round-subtitle { margin-top: 22px; color:var(--muted); line-height: 1.55; overflow-wrap:anywhere; word-break:break-word; }
.turn-hint { color: var(--muted); min-height: 20px; margin-top: 10px; }
.game-room-meta { color: var(--muted); margin-top: 12px; font-size: 14px; }
.timer-box { text-align:right; }
.timer-value { font-size:58px; font-weight:900; }
.game-panel { display: grid; gap: 16px; }
.game-panel > .summary-editor,
.game-panel > .rules-summary-box,
.game-panel > .status-box { margin-top: 0; }
.action-grid { display:grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap:12px; }
.action-grid > #startRoundBtn { grid-column: 1 / -1; }
.action { width: 100%; min-height:86px; font-size:18px; font-weight:800; }
.toast {
  position:fixed;
  left:50%;
  bottom:24px;
  transform:translateX(-50%);
  background: rgba(7, 17, 31, 0.96);
  border:1px solid rgba(255,255,255,0.12);
  padding:14px 18px;
  border-radius:16px;
  box-shadow: var(--shadow);
  z-index:1000;
  max-width: min(92vw, 560px);
  cursor: pointer;
}
.toast.error { border-color: rgba(255, 107, 135, 0.35); }
@media (max-width: 920px) {
  .two-col, .settings-grid, .action-grid, .game-top { grid-template-columns: 1fr; }
  .difficulty-grid,
  .packs-grid { grid-template-columns: 1fr; }

  #homeScreen .two-col > :first-child { order: 2; }
  #homeScreen .two-col > :last-child { order: 1; }
  .banner { align-items: stretch; }
  .timer-box { text-align:left; }
  .player-row { grid-template-columns: auto 1fr; }
  .player-actions { grid-column: 1 / -1; justify-content: stretch; }
  .team-select-label { min-width: 0; width: 100%; }
}
.finished-summary {
  display: grid;
  gap: 16px;
  margin-bottom: 18px;
}

.finished-summary-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.finished-summary-subtitle {
  color: var(--muted);
  font-size: 14px;
}

.finished-summary-cinematic {
  gap: 20px;
}

.finished-summary-hero {
  align-items: start;
  gap: 18px;
}

.finished-summary-title {
  font-size: clamp(28px, 3.5vw, 40px);
  font-weight: 900;
  line-height: 1.05;
  margin-top: 8px;
}

.finished-cinematic-copy {
  display: grid;
  gap: 8px;
  align-content: start;
}

.finished-cinematic-intro,
.finished-summary-title,
.finished-cinematic-winner,
.finished-mvp-card,
.finished-team-card {
  opacity: 0;
  transform: translateY(26px) scale(0.975);
}

.finished-presentation-playing .finished-cinematic-intro {
  animation: finishedFadeRise 0.82s cubic-bezier(0.22, 1, 0.36, 1) 0.16s forwards;
}

.finished-presentation-playing .finished-summary-title {
  animation: finishedTitleReveal 1.04s cubic-bezier(0.2, 1, 0.3, 1) 0.86s forwards;
}

.finished-presentation-playing .finished-cinematic-winner {
  animation: finishedFadeRise 0.92s cubic-bezier(0.22, 1, 0.36, 1) 1.54s forwards;
}

.game-screen-finale-active > .game-top,
.game-screen-finale-active > .game-panel,
.game-screen-finale-active > .card.glass:last-child {
  opacity: 0;
  transform: translateY(18px) scale(0.985);
  pointer-events: none;
}

.game-screen-finale-active > .card.glass:last-child {
  visibility: hidden;
}

#gameScreen > .game-top,
#gameScreen > .game-panel,
#gameScreen > .card.glass:last-child {
  transition: opacity 0.5s ease, transform 0.6s cubic-bezier(0.2, 1, 0.3, 1), visibility 0.5s ease;
}

.game-screen-finale-returning > .game-top,
.game-screen-finale-returning > .game-panel,
.game-screen-finale-returning > .card.glass:last-child {
  animation: finishedShellReturn 1.15s cubic-bezier(0.18, 1, 0.32, 1) forwards;
}

@keyframes finishedShellReturn {
  from {
    opacity: 0;
    transform: translateY(30px) scale(0.985);
    filter: blur(8px);
  }
  to {
    opacity: 1;
    transform: none;
    filter: blur(0);
  }
}

.finished-overlay {
  position: fixed;
  inset: 0;
  z-index: 1450;
  display: grid;
  place-items: start center;
  padding: min(12vh, 104px) 18px 36px;
  opacity: 0;
  pointer-events: none;
}

.finished-overlay-backdrop {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 18%, rgba(111, 168, 255, 0.2), transparent 32%), rgba(4, 9, 19, 0.72);
  backdrop-filter: blur(10px);
}

.finished-overlay.active,
.finished-overlay.leaving {
  pointer-events: auto;
}

.finished-overlay.active {
  animation: finishedOverlayFadeIn 0.55s ease forwards;
}

.finished-overlay.leaving {
  animation: finishedOverlayFadeOut 0.76s ease forwards;
}

@keyframes finishedOverlayFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes finishedOverlayFadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

.finished-overlay-card {
  position: relative;
  width: min(980px, calc(100vw - 36px));
  border-radius: 32px;
  padding: 28px;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(17, 30, 55, 0.9), rgba(10, 20, 38, 0.92));
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.44);
  transform-origin: center top;
}

.finished-overlay.active .finished-overlay-card {
  animation: finishedOverlayCardEnter 1.0s cubic-bezier(0.18, 1, 0.32, 1) forwards;
}

.finished-overlay.leaving .finished-overlay-card {
  animation: finishedOverlayCardLeave 0.76s cubic-bezier(0.3, 0, 0.2, 1) forwards;
}

@keyframes finishedOverlayCardEnter {
  from {
    opacity: 0;
    transform: translateY(40px) scale(0.94);
    filter: blur(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
  }
}

@keyframes finishedOverlayCardLeave {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
  }
  to {
    opacity: 0;
    transform: translateY(-20px) scale(0.82);
    filter: blur(8px);
  }
}

.finished-overlay-content {
  position: relative;
  z-index: 2;
}

.finished-overlay-summary {
  margin-bottom: 0;
}

.finished-overlay-summary .finished-summary-title {
  font-size: clamp(36px, 5vw, 62px);
}

.finished-overlay-summary .finished-summary-subtitle {
  font-size: clamp(18px, 2vw, 22px);
}

.finished-overlay-summary .finished-mvp-card {
  padding: 22px;
  min-width: min(100%, 320px);
}

.finished-overlay-summary .finished-mvp-avatar-wrap {
  width: 108px;
  height: 108px;
}

.finished-overlay-summary .finished-mvp-name {
  font-size: clamp(24px, 2.5vw, 34px);
}

.finished-overlay-summary .finished-team-card {
  min-height: 100%;
}

.finished-overlay-fireworks {
  position: absolute;
  inset: 0;
  overflow: hidden;
  z-index: 1;
  pointer-events: none;
}

.finished-firework {
  position: absolute;
  width: 180px;
  height: 180px;
  border-radius: 999px;
  opacity: 0;
  background:
    radial-gradient(circle, rgba(255,255,255,0.9) 0 3%, transparent 3.4%),
    radial-gradient(circle, rgba(255,199,92,0.92) 0 8%, transparent 8.4%),
    repeating-conic-gradient(from 0deg, rgba(111,168,255,0.0) 0deg 12deg, rgba(111,168,255,0.85) 12deg 18deg, rgba(255,199,92,0.88) 18deg 24deg, rgba(155,124,255,0.0) 24deg 36deg);
  filter: drop-shadow(0 0 12px rgba(111,168,255,0.28));
  mix-blend-mode: screen;
}

.firework-a { left: -18px; top: 14px; animation: finishedFirework 2.8s ease-out 1.9s 1 both; }
.firework-b { right: 48px; top: 24px; width: 220px; height: 220px; animation: finishedFirework 3s ease-out 2.35s 1 both; }
.firework-c { left: 24%; top: -18px; width: 160px; height: 160px; animation: finishedFirework 2.6s ease-out 2.8s 1 both; }
.firework-d { right: 18%; top: 36%; width: 150px; height: 150px; animation: finishedFirework 2.8s ease-out 3.35s 1 both; }
.firework-e { left: 12%; bottom: -20px; width: 190px; height: 190px; animation: finishedFirework 3.2s ease-out 3.7s 1 both; }

@keyframes finishedFirework {
  0% {
    opacity: 0;
    transform: scale(0.18) rotate(0deg);
  }
  14% {
    opacity: 1;
  }
  55% {
    opacity: 0.92;
  }
  100% {
    opacity: 0;
    transform: scale(1.22) rotate(28deg);
  }
}

body.finished-overlay-open {
  overflow: hidden;
}

#finishedGameActions {
  margin-top: 14px;
}

.finished-mvp-card {
  animation: finishedFadeRise 0.94s cubic-bezier(0.22, 1, 0.36, 1) 2.46s forwards;
}

.finished-presentation-playing .finished-team-card {
  animation: finishedFadeRise 0.84s cubic-bezier(0.22, 1, 0.36, 1) var(--team-enter-delay, 3.42s) forwards;
}

.finished-presentation-complete .finished-summary-title,
.finished-presentation-complete .finished-cinematic-intro,
.finished-presentation-complete .finished-cinematic-winner,
.finished-presentation-complete .finished-mvp-card,
.finished-presentation-complete .finished-team-card {
  opacity: 1;
  transform: none;
  filter: blur(0);
}

.finished-ui-hidden {
  opacity: 0;
  transform: translateY(16px);
  pointer-events: none;
}

.finished-ui-visible {
  animation: finishedUiReveal 0.7s cubic-bezier(0.2, 1, 0.3, 1) forwards;
}

@keyframes finishedFadeRise {
  from {
    opacity: 0;
    transform: translateY(26px) scale(0.975);
    filter: blur(6px);
  }
  to {
    opacity: 1;
    transform: none;
    filter: blur(0);
  }
}

@keyframes finishedTitleReveal {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.985);
    filter: blur(8px);
  }
  to {
    opacity: 1;
    transform: none;
    filter: blur(0);
  }
}

@keyframes finishedUiReveal {
  from {
    opacity: 0;
    transform: translateY(22px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.finished-mvp-card {
  display: grid;
  justify-items: center;
  gap: 10px;
  text-align: center;
  align-self: start;
  padding: 18px;
  border-radius: 22px;
  background: rgba(111, 168, 255, 0.08);
  border: 1px solid rgba(111, 168, 255, 0.18);
}

.finished-mvp-avatar-wrap {
  position: relative;
  width: 88px;
  height: 88px;
}

.finished-mvp-avatar {
  width: 100%;
  height: 100%;
  border-radius: 24px;
  object-fit: cover;
  background: rgba(255,255,255,0.08);
}

.finished-mvp-crown {
  position: absolute;
  top: -12px;
  right: -10px;
  font-size: 28px;
  filter: drop-shadow(0 8px 18px rgba(0,0,0,0.35));
}

.finished-mvp-name {
  font-size: 22px;
  font-weight: 800;
}

.finished-mvp-stats {
  color: var(--muted);
  line-height: 1.55;
}

.finished-teams-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 12px;
}

.finished-team-card {
  padding: 18px;
  border-radius: 22px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
}

.finished-team-card.winner {
  background: rgba(111, 168, 255, 0.08);
  border-color: rgba(111, 168, 255, 0.24);
}

.finished-team-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.finished-team-score {
  margin-top: 6px;
  font-size: 32px;
  font-weight: 900;
}

.finished-team-meta {
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

@media (max-width: 980px) {
  .finished-overlay {
    padding-top: min(8vh, 60px);
  }

  .finished-overlay-card {
    padding: 22px;
  }

  .finished-overlay-summary .finished-summary-head {
    display: grid;
    gap: 18px;
  }
}

@media (max-width: 860px) {
  .finished-summary-hero {
    grid-template-columns: 1fr;
  }

  .finished-mvp-card {
    width: 100%;
  }
}

.finished-team-members {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.finished-player {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 16px;
  background: rgba(255,255,255,0.04);
}

.finished-player img {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  object-fit: cover;
  background: rgba(255,255,255,0.08);
}

.finished-player-name {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-weight: 700;
}

.finished-player-stats {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.summary-editor {
  display: grid;
  gap: 12px;
  margin-top: 14px;
  padding: 14px;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.03);
}

.summary-editor-note {
  font-size: 13px;
  line-height: 1.45;
  color: rgba(235, 242, 255, 0.76);
}

.summary-words-list {
  display: grid;
  gap: 10px;
}

.summary-word-row {
  display: grid;
  grid-template-columns: 1fr 180px;
  gap: 10px;
  align-items: center;
}

.summary-word-label {
  min-width: 0;
  color: var(--text);
  word-break: break-word;
}

.summary-word-select {
  width: 100%;
}

@media (max-width: 720px) {
  .summary-word-row {
    grid-template-columns: 1fr;
  }

  .finished-team-head {
    flex-direction: column;
  }

  .finished-team-meta {
    text-align: left;
  }
}
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(5, 10, 18, 0.72);
  backdrop-filter: blur(10px);
}

.modal-card {
  width: min(100%, 560px);
  max-height: min(80vh, 760px);
  overflow: auto;
  border-radius: 24px;
  padding: 18px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.42);
}
@media (max-width: 640px) {
  .topbar { align-items:flex-start; }
  .topbar-actions { width:100%; justify-content:stretch; margin-left:0; }
  .topbar-actions .ghost-btn { width:100%; }
}
