:root {
  --erw-accent: var(--league-secondary, #c8a44e);
  --erw-primary: var(--league-primary, #17202b);
}

body.erw-open { overflow: hidden; }

.erw-overlay {
  position: fixed;
  inset: 0;
  z-index: 29000;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(2, 5, 9, .7);
  backdrop-filter: blur(24px) saturate(80%);
  -webkit-backdrop-filter: blur(24px) saturate(80%);
  opacity: 0;
  transition: opacity .22s ease;
}

.erw-overlay.is-visible { opacity: 1; }

.erw-shell {
  width: min(560px, 100%);
  max-height: calc(100dvh - 40px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: visible;
  color: #eef4fa;
  transform: translateY(18px) scale(.985);
  transition: transform .3s cubic-bezier(.2,.8,.2,1);
}

.erw-overlay.is-visible .erw-shell { transform: none; }
.erw-overlay.is-manual .erw-shell { width: min(1380px, 100%); }

.erw-head {
  position: relative;
  display: grid;
  justify-items: center;
  padding: 5px 52px 15px;
  text-align: center;
}

.erw-head h2 { margin: 0; color: #fff; font-size: clamp(26px, 2.6vw, 34px); font-weight: 950; font-style: italic; letter-spacing: .045em; text-transform: uppercase; text-shadow: 0 3px 18px rgba(0,0,0,.75); }
.erw-close { position: absolute; top: 3px; right: 4px; width: 38px; height: 38px; display: grid; place-items: center; padding: 0; border: 1px solid rgba(255,255,255,.1); border-radius: 50%; background: rgba(255,255,255,.045); color: #d5dee7; font: 300 25px/1 Inter,sans-serif; cursor: pointer; }
.erw-close:hover { border-color: var(--erw-accent); color: #fff; }
.erw-close:disabled { opacity: .35; cursor: wait; }

.erw-surface {
  min-height: 0;
  max-height: calc(100dvh - 126px);
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--erw-accent) 42%, rgba(255,255,255,.1));
  border-radius: 14px;
  background:
    radial-gradient(circle at 50% -20%, color-mix(in srgb, var(--erw-accent) 15%, transparent), transparent 44%),
    color-mix(in srgb, var(--erw-primary) 24%, rgba(7,11,17,.95));
  box-shadow: 0 16px 36px rgba(0,0,0,.28);
}

.erw-body { min-height: 0; overflow-y: auto; padding: clamp(18px,3vw,26px); scrollbar-width: thin; scrollbar-color: var(--erw-accent) transparent; }
.erw-stage { min-height: 240px; display: grid; align-content: center; gap: 18px; }
.erw-stage.is-top { align-content: start; }
.erw-stage-title { text-align: center; }
.erw-stage-title h3 { margin: 0; color: #fff; font-size: clamp(22px,2.6vw,31px); font-weight: 950; font-style: italic; letter-spacing: .025em; text-transform: uppercase; }
.erw-stage-title p { max-width: 650px; margin: 9px auto 0; color: #9aa8b5; font-size: 11px; line-height: 1.6; }
.erw-stage-title b { color: var(--erw-accent); }

.erw-folder-card,.erw-upload-card,.erw-replay-row,.erw-person-card,.erw-game-panel,.erw-console-wing {
  border: 1px solid color-mix(in srgb, var(--erw-accent) 27%, rgba(255,255,255,.08));
  background: color-mix(in srgb, var(--erw-primary) 30%, rgba(5,9,14,.74));
}

.erw-folder-intro { margin: 0 0 -2px; color: #9ba9b7; font-size: 12px; font-weight: 850; letter-spacing: .07em; text-align: center; text-transform: uppercase; }
.erw-folder-card { width: min(720px,100%); display: grid; grid-template-columns: 48px minmax(0,1fr); align-items: center; gap: 14px; margin: 0 auto; padding: 17px; border: 1px solid rgba(255,255,255,.1); border-radius: 11px; background: rgba(5,9,14,.62); }
.erw-folder-card.invalid { border-color: rgba(239,68,68,.38); background: rgba(127,29,29,.09); }
.erw-folder-icon { width: 46px; height: 46px; display: grid; place-items: center; color: var(--erw-accent); }
.erw-folder-icon svg { display: block; width: 42px; height: 42px; }
.erw-folder-card.invalid .erw-folder-icon { color: #ef4444; }
.erw-folder-copy { min-width: 0; }
.erw-folder-copy strong { display: block; color: #fff; font-size: 14px; }
.erw-folder-copy span { display: block; margin-top: 4px; color: #7f8d9b; font-size: 11px; line-height: 1.45; }
.erw-folder-note { margin: -6px 0 0; color: #71808e; font-size: 11px; line-height: 1.55; text-align: center; }
.erw-folder-action,.erw-secondary-button,.erw-primary-button { min-height: 42px; padding: 0 16px; border-radius: 11px; font: 900 9px Inter,sans-serif; letter-spacing: .08em; text-transform: uppercase; cursor: pointer; }
.erw-folder-action,.erw-primary-button { border: 1px solid var(--erw-accent); background: linear-gradient(135deg,var(--erw-primary),color-mix(in srgb,var(--erw-accent) 70%,var(--erw-primary))); color: #fff; }
.erw-secondary-button { border: 1px solid color-mix(in srgb,var(--erw-accent) 38%,rgba(255,255,255,.1)); background: rgba(255,255,255,.035); color: #d2dbe4; }
.erw-primary-button:disabled,.erw-secondary-button:disabled,.erw-folder-action:disabled { opacity: .42; cursor: not-allowed; }
.erw-compat { width: min(720px,100%); margin: 0 auto; padding: 13px 15px; border: 1px solid rgba(255,255,255,.07); border-radius: 12px; color: #7f8e9d; font-size: 9px; line-height: 1.55; text-align: center; }
.erw-file-label { position: relative; overflow: hidden; display: inline-grid; place-items: center; min-height: 42px; padding: 0 16px; border: 1px solid var(--erw-accent); border-radius: 11px; background: color-mix(in srgb,var(--erw-accent) 15%,transparent); color: #fff; font-size: 9px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; cursor: pointer; }
.erw-file-label input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

.erw-scan { width: min(620px,100%); margin: 0 auto; text-align: center; }
.erw-spinner { width: 58px; height: 58px; margin: 0 auto 18px; border: 3px solid color-mix(in srgb,var(--erw-accent) 18%,transparent); border-top-color: var(--erw-accent); border-radius: 50%; animation: erw-spin .75s linear infinite; }
@keyframes erw-spin { to { transform: rotate(360deg); } }
.erw-scan strong { display: block; color: #fff; font-size: 17px; font-weight: 900; text-transform: uppercase; }
.erw-scan span { display: block; margin-top: 7px; color: #8c9aa8; font-size: 10px; }
.erw-bar { height: 7px; overflow: hidden; margin-top: 18px; border-radius: 99px; background: rgba(255,255,255,.08); }
.erw-bar > i { display: block; width: var(--erw-progress-value,0%); height: 100%; border-radius: inherit; background: linear-gradient(90deg,var(--erw-primary),var(--erw-accent),#fff); box-shadow: 0 0 14px color-mix(in srgb,var(--erw-accent) 58%,transparent); transition: width .22s ease; }

.erw-picker-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.erw-selection-count { flex: 0 0 auto; padding: 8px 11px; border: 1px solid color-mix(in srgb,var(--erw-accent) 36%,transparent); border-radius: 999px; color: var(--erw-accent); font-size: 9px; font-weight: 900; text-transform: uppercase; }
.erw-replay-search { display: grid; grid-template-columns: auto minmax(0,1fr) auto; align-items: center; gap: 9px; padding: 0 12px; border: 1px solid color-mix(in srgb,var(--erw-accent) 28%,rgba(255,255,255,.1)); border-radius: 11px; background: rgba(3,7,12,.5); color: var(--erw-accent); }
.erw-replay-search > span { font-size: 19px; line-height: 1; transform: rotate(-15deg); }
.erw-replay-search input { min-width: 0; height: 42px; padding: 0; border: 0; outline: 0; background: transparent; color: #fff; font: 750 11px Inter,sans-serif; }
.erw-replay-search input::placeholder { color: #6f7d89; }
.erw-replay-search small { color: #778694; font-size: 8px; font-weight: 800; text-transform: uppercase; }
.erw-replay-list { display: grid; gap: 9px; max-height: 440px; overflow-y: auto; padding-right: 4px; }
.erw-replay-empty { padding: 28px 15px; border: 1px dashed rgba(255,255,255,.1); border-radius: 12px; color: #7d8b98; font-size: 10px; text-align: center; }
.erw-replay-row { position: relative; display: grid; grid-template-columns: 25px minmax(0,1fr); align-items: center; gap: 13px; padding: 14px 15px; border-radius: 13px; cursor: pointer; transition: border-color .16s ease, background .16s ease; }
.erw-replay-row.is-filtered-out { display: none; }
.erw-replay-row:hover { border-color: color-mix(in srgb,var(--erw-accent) 55%,transparent); }
.erw-replay-row.is-selected { border-color: var(--erw-accent); background: color-mix(in srgb,var(--erw-accent) 12%,rgba(5,9,14,.78)); }
.erw-replay-select { position: relative; align-self: stretch; display: grid; place-items: center; cursor: pointer; }
.erw-replay-select input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.erw-check { width: 22px; height: 22px; display: grid; place-items: center; border: 1px solid color-mix(in srgb,var(--erw-accent) 44%,rgba(255,255,255,.1)); border-radius: 7px; color: transparent; font-size: 12px; }
.erw-replay-select input:focus-visible + .erw-check { outline: 2px solid #fff; outline-offset: 2px; }
.erw-replay-row.is-selected .erw-check { background: var(--erw-accent); border-color: var(--erw-accent); color: #071018; }
.erw-replay-summary { min-width: 0; display: grid; grid-template-columns: minmax(0,1fr) auto 18px; align-items: center; gap: 13px; padding: 0; border: 0; background: transparent; color: inherit; text-align: left; cursor: pointer; }
.erw-replay-copy { min-width: 0; }
.erw-replay-copy strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #f6f9fc; font-size: 14px; }
.erw-replay-copy span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 5px; color: #7d8d9b; font-size: 11px; }
.erw-replay-meta { min-width: 155px; text-align: right; }
.erw-replay-meta time { display: block; color: #dce5ed; font-size: 12px; font-weight: 800; }
.erw-replay-chevron { color: #71808e; font-size: 17px; line-height: 1; transition: transform .16s ease,color .16s ease; }
.erw-replay-row.is-expanded .erw-replay-chevron { color: var(--erw-accent); transform: rotate(180deg); }
.erw-replay-player-stats { grid-column: 2/-1; display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 6px; padding-top: 10px; border-top: 1px solid rgba(255,255,255,.07); }
.erw-replay-player-stats.is-empty { display: block; color: #71808e; font-size: 11px; text-align: center; }
.erw-replay-player-stat { min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 9px; padding: 7px 9px; border-radius: 8px; background: rgba(3,7,12,.42); }
.erw-replay-player-stat strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #eaf0f5; font-size: 11px; }
.erw-replay-player-stat small { flex: 0 0 auto; color: #8796a4; font-size: 10px; }
.erw-replay-player-stat b { color: var(--erw-accent); font-weight: 900; }

.erw-identity-wrap { width: min(650px,100%); margin: 0 auto; }
.erw-question { margin-bottom: 16px; text-align: center; }
.erw-question small { color: #7f8e9c; font-size: 8px; font-weight: 900; letter-spacing: .11em; text-transform: uppercase; }
.erw-question h3 { margin: 7px 0 0; color: #fff; font-size: clamp(24px,4vw,39px); font-weight: 950; font-style: italic; }
.erw-question h3 span { color: var(--erw-accent); }
.erw-person-list { display: grid; gap: 9px; }
.erw-person-card { width: 100%; display: grid; grid-template-columns: 44px minmax(0,1fr) 26px; align-items: center; gap: 12px; padding: 11px 13px; border-radius: 13px; color: inherit; text-align: left; cursor: pointer; }
.erw-person-card:disabled { opacity: .38; cursor: not-allowed; }
.erw-person-card.is-selected { border-color: var(--erw-accent); background: color-mix(in srgb,var(--erw-accent) 13%,rgba(5,9,14,.74)); }
.erw-person-card img,.erw-avatar { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; object-fit: cover; background: color-mix(in srgb,var(--erw-accent) 13%,#121a24); color: var(--erw-accent); font-size: 11px; font-weight: 900; }
.erw-person-copy strong { display: block; color: #fff; font-size: 12px; }
.erw-person-copy span { display: block; margin-top: 4px; color: #8493a1; font-size: 9px; text-transform: uppercase; }
.erw-person-check { color: transparent; font-size: 17px; font-weight: 900; }
.erw-person-card.is-selected .erw-person-check { color: var(--erw-accent); }

.erw-console-editor { display: grid; grid-template-columns: minmax(250px,1fr) minmax(300px,.8fr) minmax(250px,1fr); grid-template-areas: "left center right"; gap: 12px; align-items: start; }
.erw-manual-count { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.erw-manual-count span { min-width: 72px; color: var(--erw-accent); font-size: 9px; font-weight: 900; text-align: center; text-transform: uppercase; }
.erw-manual-count button { width: 30px; height: 30px; padding: 0; border: 1px solid color-mix(in srgb,var(--erw-accent) 42%,rgba(255,255,255,.1)); border-radius: 8px; background: rgba(255,255,255,.04); color: #fff; font-size: 17px; cursor: pointer; }
.erw-manual-count button:disabled { opacity: .35; cursor: not-allowed; }
.erw-console-wing { padding: 14px; border-radius: 16px; }
.erw-console-wing.left { grid-area: left; }
.erw-console-wing.right { grid-area: right; }
.erw-console-wing > strong { display: block; padding: 3px 3px 12px; color: #fff; font-size: 12px; font-weight: 950; font-style: italic; text-align: center; text-transform: uppercase; }
.erw-console-roster { display: grid; gap: 8px; }
.erw-console-player { padding: 10px; border: 1px solid rgba(255,255,255,.075); border-radius: 11px; background: rgba(3,7,12,.58); }
.erw-console-player-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.erw-console-player-head img,.erw-console-player-head .erw-avatar { width: 30px; height: 30px; }
.erw-console-player-head strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #fff; font-size: 9px; }
.erw-stat-grid { display: grid; grid-template-columns: repeat(5,minmax(0,1fr)); gap: 5px; }
.erw-stat-grid label { display: grid; gap: 4px; color: #6f7e8c; font-size: 6px; font-weight: 900; text-align: center; text-transform: uppercase; }
.erw-stat-grid input { width: 100%; min-width: 0; padding: 7px 3px; border: 1px solid rgba(255,255,255,.1); border-radius: 7px; background: #060b11; color: #fff; font: 800 10px Inter,sans-serif; text-align: center; outline: none; }
.erw-stat-grid input:focus { border-color: var(--erw-accent); }
.erw-game-panel { grid-area: center; display: grid; gap: 16px; padding: 18px; border-radius: 16px; text-align: center; }
.erw-manual-replay { width: 100%; display: grid; justify-items: center; gap: 7px; padding-top: 12px; border-top: 1px solid rgba(255,255,255,.08); }
.erw-manual-replay strong { color: #8998a6; font-size: 8px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.erw-manual-replay span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #fff; font-size: 9px; }
.erw-manual-replay button { padding: 5px 8px; border: 0; background: none; color: #ef7777; font: 800 8px Inter,sans-serif; cursor: pointer; }
.erw-game-tabs { display: flex; justify-content: center; gap: 6px; flex-wrap: wrap; }
.erw-game-tab { min-width: 36px; height: 32px; padding: 0 9px; border: 1px solid rgba(255,255,255,.1); border-radius: 9px; background: rgba(255,255,255,.035); color: #8796a4; font: 900 8px Inter,sans-serif; cursor: pointer; }
.erw-game-tab.is-active { border-color: var(--erw-accent); color: #fff; background: color-mix(in srgb,var(--erw-accent) 14%,transparent); }
.erw-scoreboard { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; }
.erw-score-team { display: grid; justify-items: center; gap: 8px; color: #fff; font-size: 9px; font-weight: 900; text-transform: uppercase; }
.erw-score-team img,.erw-team-logo { width: 70px; height: 70px; display: grid; place-items: center; object-fit: contain; border-radius: 16px; background: rgba(0,0,0,.14); color: var(--erw-accent); font-size: 18px; font-weight: 950; }
.erw-score-team input { width: 72px; padding: 9px; border: 1px solid color-mix(in srgb,var(--erw-accent) 48%,rgba(255,255,255,.1)); border-radius: 9px; background: #060b11; color: #fff; font: 950 20px Inter,sans-serif; text-align: center; outline: none; }
.erw-score-vs { color: var(--erw-accent); font-size: 9px; font-weight: 950; }
.erw-date { display: grid; gap: 6px; justify-items: center; color: #7e8d9b; font-size: 8px; font-weight: 850; text-transform: uppercase; }
.erw-date input { padding: 9px 11px; border: 1px solid rgba(255,255,255,.1); border-radius: 8px; background: #060b11; color: #fff; color-scheme: dark; }

.erw-result { width: min(620px,100%); margin: 0 auto; text-align: center; }
.erw-result-icon { width: 76px; height: 76px; display: grid; place-items: center; margin: 0 auto 18px; border: 1px solid var(--erw-accent); border-radius: 50%; background: color-mix(in srgb,var(--erw-accent) 13%,transparent); color: var(--erw-accent); font-size: 35px; box-shadow: 0 0 28px color-mix(in srgb,var(--erw-accent) 18%,transparent); }
.erw-result h3 { margin: 0; color: #fff; font-size: clamp(25px,4vw,40px); font-weight: 950; font-style: italic; text-transform: uppercase; }
.erw-result p { margin: 10px auto 0; color: #94a3b0; font-size: 11px; line-height: 1.65; }

.erw-error { padding: 10px 13px; border: 1px solid rgba(239,107,107,.35); border-radius: 10px; background: rgba(239,107,107,.08); color: #ff9b9b; font-size: 9px; line-height: 1.5; text-align: center; }
.erw-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 15px 24px calc(15px + env(safe-area-inset-bottom,0px)); border-top: 1px solid color-mix(in srgb,var(--erw-accent) 22%,transparent); }
.erw-action-note { color: #738290; font-size: 8px; line-height: 1.45; }
.erw-action-leading { display: flex; align-items: center; }
.erw-manual-link { padding: 4px 0; border: 0; background: transparent; color: #929fab; font: 800 12px Inter,sans-serif; text-align: left; text-decoration: underline; text-decoration-color: color-mix(in srgb,var(--erw-accent) 55%,transparent); text-underline-offset: 3px; cursor: pointer; }
.erw-manual-link:hover { color: #fff; }
.erw-actions-buttons { display: flex; gap: 9px; margin-left: auto; }

@media (max-width: 920px) {
  .erw-console-editor { grid-template-columns: 1fr 1fr; grid-template-areas: "center center" "left right"; }
}

@media (max-width: 680px) {
  .erw-overlay { padding: 7px; }
  .erw-shell { max-height: calc(100dvh - 14px); }
  .erw-head { padding: 6px 44px 13px; }
  .erw-head h2 { font-size: 23px; }
  .erw-surface { max-height: calc(100dvh - 76px); }
  .erw-body { padding: 17px 14px; }
  .erw-stage { min-height: 260px; }
  .erw-replay-row { grid-template-columns: 23px minmax(0,1fr); }
  .erw-replay-summary { grid-template-columns: minmax(0,1fr) 18px; }
  .erw-replay-meta { grid-column: 1; min-width: 0; text-align: left; }
  .erw-replay-chevron { grid-column: 2; grid-row: 1/3; }
  .erw-replay-player-stats { grid-column: 1/-1; grid-template-columns: 1fr; }
  .erw-replay-search { grid-template-columns: auto minmax(0,1fr); }
  .erw-replay-search small { display: none; }
  .erw-console-editor { grid-template-columns: minmax(0,1fr); grid-template-areas: "center" "left" "right"; }
  .erw-stat-grid { min-width: 260px; }
  .erw-console-player { overflow-x: auto; }
  .erw-actions { flex-wrap: wrap; padding: 12px 14px; }
  .erw-action-note { display: none; }
  .erw-action-leading { width: 100%; order: 2; }
  .erw-actions-buttons { width: 100%; order: 1; }
  .erw-actions-buttons > * { flex: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .erw-overlay,.erw-shell,.erw-replay-row,.erw-bar > i { transition: none; }
}
