:root {
  --bg: #0b1220;
  --bg-card: #121c30;
  --bg-elev: #192642;
  --border: #263659;
  --text: #e9f0fb;
  --muted: #93a7c8;
  --accent: #22c55e;
  --accent-hover: #16a34a;
  --blue: #38bdf8;
  --warn: #f59e0b;
  --err: #ef4444;
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: radial-gradient(circle at top right, #162647 0%, var(--bg) 55%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  line-height: 1.5;
  min-height: 100vh;
}

.wrap {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 18px 60px;
}

header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 18px;
}

h1 {
  margin: 0;
  font-size: 1.65rem;
  letter-spacing: -0.02em;
}
.subtitle {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.lang-switch {
  display: flex;
  gap: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px;
}
.lang-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 6px 12px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
}
.lang-btn.active {
  background: var(--blue);
  color: #061224;
}

.privacy-banner {
  background: rgba(34, 197, 94, 0.11);
  border: 1px solid rgba(34, 197, 94, 0.35);
  color: #bbf7d0;
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 0.92rem;
  margin-bottom: 20px;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 18px;
}
@media (max-width: 820px) {
  .tabs { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 520px) {
  .tabs { grid-template-columns: 1fr; }
}
.tab-btn {
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--muted);
  padding: 12px 14px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: center;
}
.tab-btn:hover { border-color: var(--blue); color: var(--text); }
.tab-btn.active {
  background: var(--bg-elev);
  border-color: var(--blue);
  color: var(--text);
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.35);
}

.panel { display: none; }
.panel.active { display: block; }

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}
.card h2 {
  margin: 0 0 6px;
  font-size: 1.15rem;
}
.card p.hint {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 0.92rem;
}

.step-badge {
  display: inline-block;
  background: rgba(56, 189, 248, 0.18);
  color: var(--blue);
  font-weight: 700;
  font-size: 0.78rem;
  padding: 2px 9px;
  border-radius: 999px;
  margin-right: 6px;
  vertical-align: middle;
}

.dropzone {
  display: block;
  width: 100%;
  border: 2px dashed var(--border);
  background: rgba(11, 18, 32, 0.55);
  border-radius: var(--radius);
  padding: 28px 18px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.dropzone:hover, .dropzone.drag {
  border-color: var(--blue);
  background: rgba(56, 189, 248, 0.08);
}
.dropzone input[type="file"] { display: none; }
.dropzone .dz-title { font-weight: 600; font-size: 1rem; margin-bottom: 4px; }
.dropzone .dz-sub { color: var(--muted); font-size: 0.85rem; }

.status {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 0.9rem;
  display: none;
}
.status.show { display: block; }
.status.ok { background: rgba(34, 197, 94, 0.12); border: 1px solid rgba(34, 197, 94, 0.4); color: #dcfce7; }
.status.err { background: rgba(239, 68, 68, 0.12); border: 1px solid rgba(239, 68, 68, 0.45); color: #fee2e2; }
.status.warn { background: rgba(245, 158, 11, 0.12); border: 1px solid rgba(245, 158, 11, 0.45); color: #fef3c7; }
.status.info { background: rgba(56, 189, 248, 0.12); border: 1px solid rgba(56, 189, 248, 0.4); color: #e0f2fe; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}
.search-input, .select-input, .text-input {
  background: #0d1628;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 9px;
  font-size: 0.9rem;
}
.search-input { flex: 1; min-width: 180px; }
.select-input, .text-input { width: 100%; }

.btn {
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 9px;
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  transition: all 0.15s;
}
.btn:hover:not(:disabled) { border-color: var(--blue); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #052e16;
  padding: 12px 22px;
  font-size: 0.98rem;
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }

.stadium-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 8px;
  max-height: 360px;
  overflow-y: auto;
  padding-right: 4px;
  margin-bottom: 14px;
}
.st-item {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  background: rgba(11, 18, 32, 0.55);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 11px;
  cursor: pointer;
  user-select: none;
}
.st-item:hover { border-color: var(--blue); }
.st-item.checked {
  border-color: rgba(34, 197, 94, 0.65);
  background: rgba(34, 197, 94, 0.08);
}
.st-item input { margin-top: 3px; accent-color: var(--accent); }
.st-name { font-weight: 600; font-size: 0.9rem; display: block; }
.st-clubs { color: var(--muted); font-size: 0.78rem; display: block; }

.progress-wrap {
  display: none;
  margin-top: 14px;
}
.progress-wrap.show { display: block; }
.progress-bar {
  width: 100%;
  height: 10px;
  background: #0d1628;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--blue), var(--accent));
  transition: width 0.15s;
}
.progress-text {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 6px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 14px 0;
}
@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
}
.field label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 5px;
}

.compat-note {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
  font-size: 0.86rem;
}
.pill {
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #0d1628;
}
.pill-ok { border-color: rgba(34, 197, 94, 0.45); color: #bbf7d0; }
.pill-no { border-color: rgba(239, 68, 68, 0.45); color: #fecaca; }

.sound-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}
.sound-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  background: rgba(11, 18, 32, 0.65);
  border: 1px solid var(--border);
  padding: 10px 14px;
  border-radius: 10px;
}

.folder-box {
  background: #09101d;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85rem;
  color: #cbd5e1;
  overflow-x: auto;
  white-space: pre;
}

code {
  background: rgba(56, 189, 248, 0.14);
  color: #bae6fd;
  padding: 1px 6px;
  border-radius: 5px;
  font-size: 0.88em;
}

footer {
  margin-top: 26px;
  text-align: center;
  color: var(--muted);
  font-size: 0.82rem;
}
footer a { color: var(--blue); text-decoration: none; }
footer a:hover { text-decoration: underline; }

/* --- Patch Studio & Visual Editor --- */
.form-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 12px 0;
}
@media (max-width: 720px) {
  .form-grid-3 { grid-template-columns: 1fr; }
}

.studio-split {
  display: grid;
  grid-template-columns: 270px 1fr;
  gap: 14px;
  margin-top: 12px;
}
@media (max-width: 760px) {
  .studio-split { grid-template-columns: 1fr; }
}

.club-list {
  max-height: 410px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #0b1323;
  padding: 6px;
}
.club-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 7px 10px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 0.88rem;
  color: var(--text);
}
.club-item:hover { background: rgba(56, 189, 248, 0.12); }
.club-item.active {
  background: rgba(34, 197, 94, 0.18);
  border: 1px solid rgba(34, 197, 94, 0.55);
  font-weight: 600;
}
.club-abv {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
  color: var(--blue);
  background: rgba(56, 189, 248, 0.12);
  padding: 1px 6px;
  border-radius: 5px;
}

.squad-table-wrap {
  max-height: 310px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #0b1323;
  margin-top: 10px;
}
.squad-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.squad-table th, .squad-table td {
  padding: 6px 10px;
  text-align: left;
  border-bottom: 1px solid rgba(38, 54, 89, 0.55);
}
.squad-table th {
  position: sticky;
  top: 0;
  background: #131f38;
  color: var(--muted);
  font-weight: 600;
}
.squad-table tr:hover { background: rgba(56, 189, 248, 0.08); cursor: pointer; }
.squad-table tr.active { background: rgba(34, 197, 94, 0.16); }

.face-gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
  margin-top: 10px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #09101d;
}
.face-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 0.8rem;
}
.face-chip canvas {
  width: 24px;
  height: 48px;
  border-radius: 4px;
  image-rendering: pixelated;
  border: 1px solid var(--border);
}

/* --- PES6 Select Team Interactive Screen --- */
.pes-select-screen {
  background:
    radial-gradient(ellipse at 50% 0%, rgba(251, 191, 36, 0.25) 0%, transparent 65%),
    linear-gradient(180deg, #1b160c 0%, #2a2112 45%, #121826 100%);
  border: 2px solid #eab308;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  margin-bottom: 16px;
}

.pes-select-topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: linear-gradient(90deg, #090d16 0%, #1e293b 60%, #090d16 100%);
  border-bottom: 2px solid #eab308;
  padding: 10px 16px;
}
.pes-select-title {
  font-weight: 800;
  font-size: 1.2rem;
  color: #fef08a;
  letter-spacing: 0.03em;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
}
.pes-search {
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(234, 179, 8, 0.5);
  color: #fff;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.86rem;
  min-width: 240px;
}
.pes-db-badge {
  font-size: 0.8rem;
  color: #fde047;
  background: rgba(234, 179, 8, 0.14);
  border: 1px solid rgba(234, 179, 8, 0.4);
  padding: 4px 10px;
  border-radius: 999px;
}

.pes-select-body {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 18px;
  padding: 18px;
}
@media (max-width: 780px) {
  .pes-select-body { grid-template-columns: 1fr; }
}

.pes-cat-box, .pes-teams-box {
  background: rgba(15, 20, 30, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 10px;
  overflow: hidden;
  backdrop-filter: blur(6px);
}
.pes-cat-header {
  background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
  color: #f8fafc;
  font-weight: 700;
  font-size: 0.95rem;
  text-align: center;
  padding: 7px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}
.pes-cat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 12px;
}
.pes-cat-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: rgba(30, 41, 59, 0.75);
  border: 2px solid rgba(148, 163, 184, 0.25);
  border-radius: 8px;
  padding: 8px 4px;
  cursor: pointer;
  transition: all 0.14s ease;
  text-align: center;
}
.pes-cat-tile:hover {
  border-color: #fde047;
  transform: translateY(-1px);
}
.pes-cat-tile.active {
  background: rgba(234, 179, 8, 0.22);
  border-color: #facc15;
  box-shadow: 0 0 10px rgba(250, 204, 21, 0.45);
}
.pes-cat-icon { font-size: 1.35rem; line-height: 1; }
.pes-cat-lbl {
  font-size: 0.68rem;
  font-weight: 700;
  color: #e2e8f0;
  line-height: 1.15;
  word-break: break-word;
}

.pes-league-edit-box {
  margin-top: 12px;
  background: rgba(15, 20, 30, 0.85);
  border: 1px solid rgba(234, 179, 8, 0.4);
  border-radius: 10px;
  padding: 10px 12px;
}
.pes-league-edit-box label {
  font-size: 0.78rem;
  color: #fde047;
  font-weight: 600;
}

.pes-focused-team-name {
  font-size: 1.35rem;
  font-weight: 800;
  color: #ffffff;
  text-align: center;
  margin-bottom: 8px;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.9);
  min-height: 32px;
}

.pes-league-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(180deg, #1e293b 0%, #090d16 100%);
  padding: 7px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.16);
  font-weight: 700;
  color: #f8fafc;
}
.pes-l1r1 {
  background: #334155;
  border: 1px solid #64748b;
  color: #f8fafc;
  font-weight: 800;
  font-size: 0.75rem;
  padding: 3px 10px;
  border-radius: 5px;
  cursor: pointer;
}
.pes-l1r1:hover { background: #475569; border-color: #fde047; }

.pes-crest-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  padding: 14px;
  max-height: 370px;
  overflow-y: auto;
}
@media (max-width: 520px) {
  .pes-crest-grid { grid-template-columns: repeat(2, 1fr); }
}

.pes-team-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  background: rgba(30, 41, 59, 0.55);
  border: 2px solid rgba(148, 163, 184, 0.2);
  border-radius: 10px;
  padding: 10px 6px 8px;
  cursor: pointer;
  transition: all 0.14s ease;
  position: relative;
}
.pes-team-tile:hover, .pes-team-tile.active {
  background: rgba(250, 204, 21, 0.18);
  border-color: #facc15;
  box-shadow: 0 0 14px rgba(250, 204, 21, 0.4);
  transform: translateY(-2px);
}
.pes-team-tile canvas {
  width: 52px;
  height: 52px;
  image-rendering: auto;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.65));
}
.pes-team-tile-name {
  font-size: 0.76rem;
  font-weight: 700;
  color: #f1f5f9;
  text-align: center;
  line-height: 1.15;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pes-team-tile-abv {
  font-size: 0.66rem;
  color: #fde047;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.pes-select-hint {
  margin-top: 8px;
  text-align: center;
  font-size: 0.83rem;
  color: #fde047;
}

/* --- Team & Squad Interactive Modal --- */
.team-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 8, 16, 0.82);
  backdrop-filter: blur(5px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.team-modal {
  background: var(--bg-card);
  border: 2px solid var(--blue);
  border-radius: 16px;
  width: 100%;
  max-width: 940px;
  max-height: 92vh;
  overflow-y: auto;
  padding: 18px 20px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.75);
}
.team-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.modal-crest-canvas {
  width: 56px;
  height: 56px;
  border-radius: 10px;
  background: rgba(11, 18, 32, 0.8);
  border: 1px solid var(--border);
  padding: 3px;
}
.team-modal-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 14px;
}
.modal-tab-btn {
  flex: 1;
  min-width: 180px;
  border: 1px solid var(--border);
  background: #0d1628;
  color: var(--muted);
  padding: 9px 12px;
  border-radius: 9px;
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
}
.modal-tab-btn.active {
  background: var(--bg-elev);
  border-color: var(--blue);
  color: var(--text);
}
.modal-tab-panel { display: none; }
.modal-tab-panel.active { display: block; }

.color-picker {
  width: 34px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  padding: 0;
}
.kit-color-rows {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.kit-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  font-size: 0.8rem;
  color: var(--muted);
}
.kit-row label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.kit-lbl {
  width: 85px;
  font-weight: 700;
  color: var(--text);
}

/* --- Tactics Pitch & Squad Split --- */
.tactics-split {
  display: grid;
  grid-template-columns: 290px 1fr;
  gap: 14px;
}
@media (max-width: 820px) {
  .tactics-split { grid-template-columns: 1fr; }
}
.pitch-box {
  position: relative;
  width: 100%;
  height: 310px;
  background:
    repeating-linear-gradient(0deg, #14532d 0px, #14532d 28px, #166534 28px, #166534 56px);
  border: 2px solid rgba(255, 255, 255, 0.75);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.45);
}
.pitch-box::before {
  content: "";
  position: absolute;
  left: 0; right: 0; top: 50%;
  height: 1px;
  background: rgba(255, 255, 255, 0.45);
}
.pitch-box::after {
  content: "";
  position: absolute;
  left: 50%; top: 50%;
  width: 64px; height: 64px;
  transform: translate(-50%, -50%);
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 50%;
  pointer-events: none;
}
.pitch-dot {
  position: absolute;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  z-index: 2;
}
.pitch-dot-circle {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #ef4444;
  border: 2px solid #ffffff;
  color: #ffffff;
  font-weight: 800;
  font-size: 0.72rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.6);
}
.pitch-dot.gk .pitch-dot-circle { background: #eab308; color: #0f172a; }
.pitch-dot.active .pitch-dot-circle {
  border-color: #fde047;
  box-shadow: 0 0 0 3px rgba(250, 204, 21, 0.65);
}
.pitch-dot-name {
  font-size: 0.66rem;
  font-weight: 700;
  color: #ffffff;
  background: rgba(0, 0, 0, 0.68);
  padding: 1px 5px;
  border-radius: 4px;
  margin-top: 2px;
  white-space: nowrap;
  max-width: 74px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.form-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
@media (max-width: 780px) {
  .form-grid-4 { grid-template-columns: repeat(2, 1fr); }
}
.stats-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}
@media (max-width: 780px) {
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
}
.player-face-canvas {
  width: 44px;
  height: 88px;
  border-radius: 8px;
  background: #0b1323;
  border: 1px solid var(--border);
  image-rendering: pixelated;
}
