  @import url('https://fonts.googleapis.com/css2?family=VT323&family=Press+Start+2P&display=swap');

  :root {
    --green:    #1a6b2a;
    --green-l:  #2d9440;
    --green-ll: #3db856;
    --pitch:    #1e7a30;
    --line:     #ffffff44;
    --bg:       #0a0a12;
    --bg2:      #12121e;
    --panel:    #15152a;
    --border:   #3a3a5c;
    --gold:     #f0c040;
    --red:      #c0392b;
    --white:    #e8e8e8;
    --gray:     #888;
    --accent:   #00ccff;
    --font-hud: 'Press Start 2P', monospace;
    --font-vt:  'VT323', monospace;
  }

  * { box-sizing: border-box; margin: 0; padding: 0; }

  body {
    background: var(--bg);
    color: var(--white);
    font-family: var(--font-vt);
    font-size: 20px;
    min-height: 100vh;
    overflow-x: hidden;
  }

  body::after {
    content: '';
    position: fixed; inset: 0;
    background: repeating-linear-gradient(
      to bottom,
      transparent 0px, transparent 3px,
      rgba(0,0,0,0.08) 3px, rgba(0,0,0,0.08) 4px
    );
    pointer-events: none;
    z-index: 9999;
  }

  .screen { display: none; flex-direction: column; align-items: center; min-height: 100vh; padding: 20px; }
  .screen.active { display: flex; }

  /* TITLE */
  #screen-title {
    justify-content: center;
    gap: 24px;
    background: radial-gradient(ellipse at center, #1a3a1a 0%, #0a0a12 70%);
  }

  .title-logo {
    font-family: var(--font-hud);
    font-size: clamp(18px, 4vw, 32px);
    color: var(--gold);
    text-align: center;
    text-shadow: 4px 4px 0 #7a6000, 0 0 30px #f0c04088;
    line-height: 1.4;
    letter-spacing: 2px;
  }

  .title-sub {
    font-size: 26px;
    color: var(--green-ll);
    text-align: center;
    letter-spacing: 4px;
  }

  .pitch-preview {
    width: min(400px, 90vw);
    height: 260px;
    background: var(--pitch);
    border: 3px solid var(--white);
    position: relative;
    overflow: hidden;
    box-shadow: 0 0 40px #1a6b2a88;
  }
  .pitch-preview::before {
    content: '';
    position: absolute; inset: 0;
    background:
      linear-gradient(90deg, transparent 49.5%, var(--line) 49.5%, var(--line) 50.5%, transparent 50.5%),
      radial-gradient(ellipse 80px 60px at 50% 50%, transparent 58px, var(--line) 58px, var(--line) 60px, transparent 60px);
  }
  .pitch-stripes {
    position: absolute; inset: 0;
    background: repeating-linear-gradient(
      to bottom, #1e7a30 0px, #1e7a30 26px, #1a6b2a 26px, #1a6b2a 52px
    );
    opacity: 0.5;
  }
  .pitch-goal {
    position: absolute; top: 40%; bottom: 40%; width: 3%;
    border: 2px solid var(--line); pointer-events: none; z-index: 1;
  }
  .pitch-goal-left  { left: -1px; border-left: none; }
  .pitch-goal-right { right: -1px; border-right: none; }
  .pitch-corner {
    position: absolute; width: 16px; height: 16px;
    border: 2px solid var(--line); border-radius: 50%; pointer-events: none;
  }
  .pitch-corner-tl { top: -8px;  left: -8px;  clip-path: polygon(50% 50%, 100% 50%, 100% 100%, 50% 100%); }
  .pitch-corner-bl { bottom: -8px; left: -8px; clip-path: polygon(50% 0%, 100% 0%, 100% 50%, 50% 50%); }
  .pitch-corner-tr { top: -8px; right: -8px; clip-path: polygon(0% 50%, 50% 50%, 50% 100%, 0% 100%); }
  .pitch-corner-br { bottom: -8px; right: -8px; clip-path: polygon(0% 0%, 50% 0%, 50% 50%, 0% 50%); }

  /* BUTTONS */
  .btn {
    font-family: var(--font-hud);
    font-size: 10px;
    padding: 14px 28px;
    background: var(--green);
    color: var(--white);
    border: 3px solid var(--green-ll);
    cursor: pointer;
    letter-spacing: 2px;
    transition: all 0.1s;
    box-shadow: 4px 4px 0 #0a300f;
  }
  .btn:hover  { background: var(--green-ll); transform: translate(-2px,-2px); box-shadow: 6px 6px 0 #0a300f; }
  .btn:active { transform: translate(2px,2px); box-shadow: 2px 2px 0 #0a300f; }
  .btn.btn-gold { background: #7a6000; border-color: var(--gold); color: var(--gold); box-shadow: 4px 4px 0 #3a2d00; }
  .btn.btn-gold:hover { background: #9a8000; }
  .btn.btn-red  { background: #6b0000; border-color: var(--red); color: #ffaaaa; box-shadow: 4px 4px 0 #300000; }
  .btn.btn-sm   { font-size: 8px; padding: 8px 16px; }

  .title-menu-stack {
    display: flex; flex-direction: column; gap: 10px;
    width: min(340px, 85vw);
  }
  .title-menu-stack .btn { width: 100%; }
  .btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

  /* PANEL */
  .panel {
    background: var(--panel);
    border: 2px solid var(--border);
    padding: 16px;
    width: 100%;
    max-width: 760px;
  }
  .panel-title {
    font-family: var(--font-hud);
    font-size: 9px;
    color: var(--gold);
    letter-spacing: 2px;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 8px;
  }

  /* DRAFT */
  #screen-draft { gap: 16px; padding-top: 16px; }

  .hud-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 760px;
    font-family: var(--font-hud);
    font-size: 8px;
    color: var(--gold);
    border-bottom: 2px solid var(--border);
    padding-bottom: 8px;
  }

  .drawn-card {
    background: #0d1a0d;
    border: 2px solid var(--green-ll);
    padding: 12px 16px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 16px;
  }
  .drawn-club   { color: var(--gold); font-family: var(--font-hud); font-size: 8px; }
  .drawn-season { color: var(--gray); font-size: 18px; margin-top: 2px; }

  .slot-label {
    font-family: var(--font-hud);
    font-size: 7px;
    color: var(--accent);
    letter-spacing: 1px;
    margin-bottom: 6px;
  }

  .player-list { display: flex; flex-direction: column; gap: 4px; max-height: 320px; overflow-y: auto; }
  .player-list::-webkit-scrollbar { width: 6px; }
  .player-list::-webkit-scrollbar-track { background: var(--bg2); }
  .player-list::-webkit-scrollbar-thumb { background: var(--border); }

  .player-row {
    display: flex; align-items: center; gap: 12px;
    padding: 8px 12px;
    background: var(--bg2);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.1s;
    font-size: 20px;
  }
  .player-row:hover { background: #1e2240; border-color: var(--accent); }
  .player-row.reserve { opacity: 0.65; }
  .player-row.pos-match { border-left: 3px solid var(--green-ll); }

  .player-pos  { font-family: var(--font-hud); font-size: 6px; color: var(--accent); width: 32px; flex-shrink: 0; }
  .player-name { flex: 1; }
  .player-res   { font-family: var(--font-hud); font-size: 6px; color: var(--gray); }
  .player-ovr  { font-family: var(--font-hud); font-size: 10px; width: 36px; text-align: right; }
  .player-ovr.elite { color: #ff6060; }
  .player-ovr.great { color: var(--gold); }
  .player-ovr.good  { color: var(--green-ll); }
  .player-ovr.avg   { color: var(--gray); }

  /* FORMATION */
  .formation-wrap { width: 100%; max-width: 760px; display: flex; gap: 12px; }

  .mini-pitch {
    width: 180px; min-width: 180px; height: 280px;
    background: var(--pitch);
    border: 2px solid var(--white);
    position: relative; flex-shrink: 0;
  }
  .mini-pitch::before {
    content: '';
    position: absolute; inset: 0;
    background:
      linear-gradient(90deg, transparent 49%, rgba(255,255,255,0.25) 49%, rgba(255,255,255,0.25) 51%, transparent 51%),
      radial-gradient(ellipse 36px 28px at 50% 50%, transparent 26px, rgba(255,255,255,0.25) 26px, rgba(255,255,255,0.25) 28px, transparent 28px);
  }

  .pitch-player {
    position: absolute;
    transform: translate(-50%, -50%);
    text-align: center;
    width: 40px;
  }
  .pitch-dot {
    width: 18px; height: 18px;
    border-radius: 50%;
    margin: 0 auto 2px;
    border: 2px solid var(--white);
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-hud); font-size: 5px; color: #000;
  }
  .pitch-dot.filled { background: var(--gold); }
  .pitch-dot.empty  { background: #333; border-color: var(--border); }
  .pitch-dot.current { background: var(--accent); border-color: #fff; animation: pulse 1s ease-in-out infinite; }
  @keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:0.4; } }

  .bench-strip {
    display: flex; flex-direction: column; gap: 6px; margin-top: 4px;
    width: 150px;
  }
  .bench-dot-wrap { display: flex; align-items: center; gap: 6px; text-align: left; }
  .bench-dot {
    width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0;
    border: 2px solid var(--white); display: flex; align-items: center; justify-content: center;
    font-family: var(--font-hud); font-size: 5px; color: #000;
  }
  .bench-dot.filled { background: var(--gold); opacity: 0.6; }
  .bench-dot.empty  { background: #333; border-color: var(--border); }
  .bench-dot.current { background: var(--accent); border-color: #fff; animation: pulse 1s ease-in-out infinite; }
  .bench-dot.coach.filled { background: #9b59b6; opacity: 1; }
  .bench-dot.coach.current { background: #9b59b6; border-color: #fff; animation: pulse 1s ease-in-out infinite; }
  .bench-name { font-family: var(--font-hud); font-size: 6px; color: var(--gray); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  /* MATCH PITCH — pasek 5 stref, podświetlany na żywo w trakcie meczu */
  .match-pitch {
    width: 100%; max-width: 480px; height: 280px;
    background: var(--pitch);
    border: 3px solid var(--white);
    position: relative;
    margin: 4px auto 10px;
    display: flex;
    overflow: hidden;
    box-shadow: 0 0 24px #1a6b2a66;
  }
  .match-pitch::before {
    content: '';
    position: absolute; inset: 0; pointer-events: none;
    background:
      linear-gradient(90deg, transparent 49.5%, var(--line) 49.5%, var(--line) 50.5%, transparent 50.5%),
      radial-gradient(ellipse 46px 46px at 50% 50%, transparent 38px, var(--line) 38px, var(--line) 40px, transparent 40px);
  }
  .pitch-box {
    position: absolute; top: 22%; bottom: 22%; width: 12%;
    border: 2px solid var(--line); pointer-events: none; z-index: 1;
  }
  .pitch-box-left  { left: 0; border-left: none; }
  .pitch-box-right { right: 0; border-right: none; }
  .pitch-zone {
    flex: 1; position: relative;
    border-right: 1px solid var(--line);
    transition: background 0.25s ease;
  }
  .pitch-zone:last-child { border-right: none; }
  .pitch-zone.active { background: #f0c04055; }
  .pitch-zone.active.goal-zone { background: #c0392b77; }
  .zone-pct {
    position: absolute; bottom: 6px; left: 50%; transform: translateX(-50%);
    font-family: var(--font-hud); font-size: 8px; color: #ffffffcc;
    background: #00000066; padding: 3px 5px; border-radius: 3px;
    pointer-events: none; white-space: nowrap;
  }

  .pitch-name { font-size: 9px; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40px; text-shadow: 1px 1px 0 #000; }

  .slots-list { flex: 1; display: flex; flex-direction: column; gap: 3px; }
  .slot-row {
    display: flex; align-items: center; gap: 8px;
    padding: 5px 8px;
    background: var(--bg2);
    border: 1px solid var(--border);
    font-size: 17px;
  }
  .slot-row.filled  { border-color: var(--green-ll); }
  .slot-row.current { border-color: var(--accent); }
  .slot-pos  { font-family: var(--font-hud); font-size: 6px; color: var(--accent); width: 32px; }
  .slot-name { flex: 1; }
  .slot-club { font-size: 13px; color: var(--gray); }
  .slot-ovr  { font-family: var(--font-hud); font-size: 9px; color: var(--gold); }

  /* RESULT */
  #screen-result { gap: 20px; justify-content: center; }
  .result-rating {
    font-family: var(--font-hud);
    font-size: clamp(36px, 8vw, 64px);
    text-shadow: 4px 4px 0 #7a6000;
    text-align: center;
  }
  /* PLAYOFF */
  #screen-playoff { gap: 16px; }
  .match-card {
    background: var(--panel);
    border: 2px solid var(--border);
    padding: 12px 16px;
    display: flex; align-items: center; gap: 12px;
    font-size: 19px;
  }
  .match-team { flex: 1; }
  .club-banner {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 3px;
    font-weight: bold;
    letter-spacing: 0.5px;
    transition: background 0.2s, color 0.2s;
  }
  #po-opp-team-block, #po-scoreboard-opp, #po-opp-lines { text-align: right; }
  /* Gdy gram na wyjeździe: gospodarz (rywal) zawsze po lewej, ja po prawej —
     tak jak w prawdziwym zapisie "Gospodarz - Gość". */
  .away-match #po-my-team-block { order: 3; text-align: right; }
  .away-match #po-opp-team-block { order: 1; text-align: left; }
  .away-match #po-score { order: 2; }
  .away-match #po-scoreboard-me { order: 3; text-align: right; }
  .away-match #po-scoreboard-opp { order: 1; text-align: left; }
  .away-match #po-lines-row { flex-direction: row-reverse; }
  .away-match #po-my-lines { text-align: right; }
  .away-match #po-opp-lines { text-align: left; }
  .away-match .lineups-wrap { direction: rtl; }
  .away-match .lineups-wrap > div { direction: ltr; }
  .away-match .match-pitch { flex-direction: row-reverse; }
  .match-score { font-family: var(--font-hud); font-size: 14px; color: var(--gold); min-width: 60px; text-align: center; }
  .match-score.win  { color: var(--green-ll); }
  .match-score.loss { color: var(--red); }
  .match-score.draw { color: var(--gray); }

  .match-timeline {
    margin-top: 10px;
    display: flex; flex-direction: column; gap: 4px;
    font-size: 22px; text-align: left;
    max-height: 170px; overflow-y: auto;
    padding-right: 4px;
    border: 2px solid var(--border);
    border-radius: 4px;
    padding: 8px;
    background: #0000001a;
  }
  .tl-row { padding: 3px 6px; border-left: 3px solid transparent; }
  .tl-goal-me   { border-color: var(--green-ll); background: #2d944022; color: var(--green-ll); font-weight: bold; }
  .tl-goal-opp  { border-color: var(--red); background: #c0392b22; color: #ff8a7a; font-weight: bold; }
  .tl-red       { border-color: var(--red); color: var(--red); font-weight: bold; }
  .tl-yellow    { border-color: var(--gold); color: var(--gold); }
  .tl-penalty   { border-color: var(--accent); color: var(--accent); font-weight: bold; }
  .tl-injury    { border-color: #e8944a; color: #e8944a; font-weight: bold; }
  .tl-tactic    { border-color: #9b59b6; color: #c9a0dc; font-style: italic; }
  .tl-flavor-neutral { background: #ffffff; color: #555555; border-color: #cccccc; }
  .tl-team-fill { font-weight: bold; padding: 5px 10px; border-radius: 3px; border: none; }

  @keyframes tlBlinkGoal   { 0%, 100% { background: var(--gold); color: #000; } 50% { background: transparent; } }
  @keyframes tlBlinkRed    { 0%, 100% { background: var(--red);  color: #fff; } 50% { background: transparent; } }
  @keyframes tlBlinkYellow { 0%, 100% { background: #f0c040;     color: #000; } 50% { background: transparent; } }
  @keyframes tlBlinkPenalty { 0%, 100% { background: var(--accent); color: #000; } 50% { background: transparent; } }
  .tl-blink-goal   { animation: tlBlinkGoal 0.25s ease-in-out 6; }
  .tl-blink-red    { animation: tlBlinkRed 0.25s ease-in-out 6; }
  .tl-blink-yellow { animation: tlBlinkYellow 0.25s ease-in-out 6; }
  .tl-blink-penalty { animation: tlBlinkPenalty 0.25s ease-in-out 3; }
  .tl-flavor    { border-color: var(--border); color: var(--gray); }
  .tl-marker    { border: none; text-align: center; color: var(--white); font-family: var(--font-hud); font-size: 9px; padding: 8px 0; letter-spacing: 1px; }

  .speed-btn { opacity: 0.5; }
  .speed-btn.active { opacity: 1; border-color: var(--accent); color: var(--accent); }
  .style-btn { opacity: 0.5; }
  .style-btn.active { opacity: 1; border-color: var(--gold); color: var(--gold); }
  .tactic-btn {
    font-family: var(--font-hud); font-size: 8px; padding: 8px 12px;
    background: var(--panel); color: var(--white); border: 3px solid var(--border);
    border-radius: 0; letter-spacing: 1px; cursor: pointer; opacity: 0.6;
  }
  .tactic-btn.active { opacity: 1; border-color: var(--accent); color: var(--accent); background: #00ccff11; }
  .tactic-btn.reactive { opacity: 1; }
  .tactic-btn:disabled { opacity: 0.25 !important; filter: grayscale(0.7); cursor: not-allowed; }

  details {
    background: var(--panel);
    border: 2px solid var(--border);
    border-radius: 4px;
    padding: 10px 12px;
    margin-bottom: 8px;
  }
  details summary {
    font-family: var(--font-hud);
    font-size: 10px;
    color: var(--gold);
    letter-spacing: 1px;
    cursor: pointer;
    outline: none;
    list-style: none;
  }
  details summary::-webkit-details-marker { display: none; }
  details summary::before { content: '▶ '; display: inline-block; transition: transform 0.15s; }
  details[open] summary::before { transform: rotate(90deg); }

  .legend-details {
    background: #0000002a;
    border: 1px solid var(--border);
    padding: 6px 10px;
  }
  .legend-details summary {
    font-size: 8px;
    color: var(--accent);
  }
  .legend-body {
    margin-top: 8px;
    font-size: 13px;
    color: var(--white);
    line-height: 1.5;
  }
  .legend-body p { margin-bottom: 8px; }
  .legend-body b { color: var(--gold); }

  .season-table { width: 100%; border-collapse: collapse; font-size: 13px; }
  .season-table th { font-family: var(--font-hud); font-size: 8px; color: var(--accent); padding: 6px 4px; border-bottom: 2px solid var(--border); text-align: center; }
  .season-table td { padding: 5px 4px; text-align: center; border-bottom: 1px solid var(--border); }
  .season-table tr:hover td { background: #ffffff08; }

  .season-result-row {
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 6px 10px;
    margin-bottom: 6px;
    font-size: 13px;
  }
  .season-result-score { color: var(--white); }
  .season-result-score b { color: var(--gold); }
  .season-result-scorers { color: var(--gray); font-size: 12px; margin-top: 2px; }

  .challenge-card {
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 10px 12px;
    margin-bottom: 10px;
  }
  .challenge-card-title { color: var(--gold); font-size: 15px; font-weight: bold; margin-bottom: 4px; }
  .challenge-card-desc { color: var(--gray); font-size: 13px; margin-bottom: 8px; }
  #btn-chaos:disabled { opacity: 0.3; cursor: not-allowed; }
  #tactics-panel select { font-family: var(--font-hud); font-size: 8px; padding: 8px; background: var(--panel); color: var(--white); border: 3px solid var(--border); border-radius: 0; letter-spacing: 1px; cursor: pointer; }

  .lineups-wrap {
    display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
  }
  .lineup-team-title {
    font-family: var(--font-hud); font-size: 8px; color: var(--gold);
    letter-spacing: 1px; padding-bottom: 6px; margin-bottom: 6px;
    border-bottom: 1px solid var(--border);
  }
  .lineup-row {
    display: flex; align-items: center; gap: 6px;
    padding: 2px 0; font-size: 15px;
  }
  .lineup-pos { font-family: var(--font-hud); font-size: 6px; color: var(--accent); width: 26px; flex-shrink: 0; }
  .lineup-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .lineup-ovr { font-family: var(--font-hud); font-size: 8px; color: var(--gold); flex-shrink: 0; }

  .groups-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px;
  }
  .group-box { background: var(--bg2); border: 1px solid var(--border); padding: 10px; }
  .group-box-title {
    font-family: var(--font-hud); font-size: 8px; color: var(--gold);
    letter-spacing: 1px; padding-bottom: 6px; margin-bottom: 6px;
    border-bottom: 1px solid var(--border);
  }
  .group-table { width: 100%; border-collapse: collapse; font-size: 14px; }
  .group-table th {
    font-family: var(--font-hud); font-size: 5px; color: var(--gray);
    text-align: center; padding: 3px 2px; letter-spacing: 0.5px;
  }
  .group-table th:nth-child(2) { text-align: left; }
  .group-table td { text-align: center; padding: 3px 2px; }
  .group-table .group-team-name { text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 120px; }
  .group-row-me { background: #2d944022; color: var(--green-ll); font-weight: bold; }

  /* VALIDATOR */
  #screen-validator { gap: 12px; }
  .val-ok  { color: var(--green-ll); }
  .val-err { color: var(--red); }
  .val-warn{ color: var(--gold); }

  /* MISC */
  .gap8 { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
  .mt16 { margin-top: 16px; }
  .c-elite { color: #ff6060; }
  .c-great  { color: var(--gold); }
  .c-good   { color: var(--green-ll); }
  .c-avg    { color: var(--gray); }

/* ═══ MINI-PIXELOWA ANIMACJA NA EKRANIE TYTUŁOWYM (TITLE-ANIMATIONS-BUNDLE.js) ═══ */
/* Znaczek karny (11 m od linii bramkowej) — widoczny nawet zanim canvas wystartuje. */
.pitch-preview .pitch-box::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 2px;
  height: 2px;
  background: rgba(255,255,255,0.72);
  transform: translateY(-50%);
  image-rendering: pixelated;
}
.pitch-preview .pitch-box-left::after  { left: 66.667%; }
.pitch-preview .pitch-box-right::after { right: 66.667%; }

.pitch-preview { overflow: visible; }

/* Gdy działa canvas, chowamy stare dekoracje CSS (boisko/pola karne/bramki/
   narożniki) — inaczej rysowałyby się podwójnie, jak "boisko w boisku". */
.pitch-preview.title-animation-active::before,
.pitch-preview.title-animation-active::after,
.pitch-preview.title-animation-active .pitch-stripes,
.pitch-preview.title-animation-active .pitch-box,
.pitch-preview.title-animation-active .pitch-goal,
.pitch-preview.title-animation-active .pitch-corner {
  display: none !important;
}
.pitch-preview.title-animation-active {
  background: transparent;
  border-color: transparent;
}

.title-free-kick-canvas {
  position: absolute;
  top: -12px;
  left: -8px;
  width: calc(100% + 16px);
  height: calc(100% + 24px);
  z-index: 4;
  pointer-events: none;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}
