:root {
  --bg: #0f231b;
  --bg-2: #163327;
  --panel: #f4f2e8;
  --panel-2: #ffffff;
  --text: #10251c;
  --muted: #5c6f64;
  --accent: #f08c3b;
  --accent-2: #2f7a4f;
  --danger: #b42318;
  --line: #d7e0d6;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.22);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: Inter, Segoe UI, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background:
    radial-gradient(circle at top left, #28543f 0, transparent 35%),
    radial-gradient(circle at bottom right, #132b21 0, transparent 30%),
    var(--bg);
  color: #fff;
  overflow-x: hidden;
}
button, input, select, textarea { font: inherit; }
a { color: inherit; }

.app-shell { min-height: 100vh; }
.loading-card {
  margin: 16px;
  background: rgba(255,255,255,0.96);
  color: var(--text);
  padding: 18px;
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 16px;
  flex-wrap: wrap;
}
.brand {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.brand h1 { margin: 0; font-size: 1.5rem; }
.brand p { margin: 0; color: rgba(255,255,255,0.78); }
.nav-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.container {
  display: grid;
  gap: 14px;
  padding: 0 16px 16px;
  min-width: 0;
}
.panel {
  background: rgba(255,255,255,0.96);
  color: var(--text);
  border-radius: 18px;
  padding: 16px;
  box-shadow: var(--shadow);
  min-width: 0;
}
.panel h2, .panel h3 { margin-top: 0; }
.grid-2 { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid-3 { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.stack { display: grid; gap: 10px; }
label { display: grid; gap: 6px; font-size: .95rem; }
input, select, textarea {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: #fff;
}
input[type="range"] { padding: 0; }
button {
  border: 0;
  border-radius: 12px;
  padding: 10px 14px;
  background: var(--accent-2);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}
button.secondary { background: #5d6f62; }
button.danger { background: var(--danger); }
button.accent { background: var(--accent); }
button:disabled { opacity: .6; cursor: not-allowed; }
.small { font-size: .9rem; color: var(--muted); }
.notice { padding: 10px 12px; border-radius: 12px; background: #eef5eb; color: #214631; }
.error { padding: 10px 12px; border-radius: 12px; background: #fdecec; color: var(--danger); }
.badge { display: inline-flex; align-items: center; padding: 4px 8px; border-radius: 999px; background: #edf3ef; color: #214631; font-size: .8rem; }

.players-list { display: grid; gap: 8px; max-height: 360px; overflow: auto; }
.player-row { display: grid; gap: 8px; grid-template-columns: auto 1fr auto; align-items: center; padding: 10px; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
.player-row strong { display: block; }
.player-meta { color: var(--muted); font-size: .88rem; }
.player-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.field-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.pitch {
  position: relative;
  min-height: 520px;
  background: linear-gradient(180deg, #23844a, #1b6c3d);
  border-radius: 18px;
  overflow: hidden;
  border: 3px solid rgba(255,255,255,.78);
}
.pitch::before,
.pitch::after {
  content: "";
  position: absolute;
  inset: 10% 10%;
  border: 2px solid rgba(255,255,255,.45);
  border-radius: 14px;
}
.pitch::after {
  inset: 50% 10% auto;
  height: 0;
  border: 0;
  border-top: 2px solid rgba(255,255,255,.45);
}
.slot {
  position: absolute;
  transform: translate(-50%, -50%);
  text-align: center;
  color: #fff;
  width: 76px;
}
.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  overflow: hidden;
  margin: 0 auto 3px;
  border: 2px solid #fff;
  background: rgba(0,0,0,.24);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: .63rem;
  letter-spacing: -.02em;
  line-height: 1;
  padding: 0 3px;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.slot small { display: block; font-size: .62rem; opacity: .86; }
.slot strong { display: block; font-size: .7rem; line-height: 1.05; text-shadow: 0 2px 5px rgba(0,0,0,.4); }

.tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.tab { background: #dfe9e0; color: var(--text); }
.tab.active { background: var(--accent-2); color: #fff; }

.role-matrix {
  display: grid;
  grid-template-columns: minmax(42px, 70px) repeat(4, minmax(0, 1fr));
  gap: 2px 6px;
  align-items: center;
  min-width: 0;
}
.role-cell {
  font-size: .83rem;
  line-height: 1.1;
  min-width: 0;
}
.role-head {
  font-weight: 700;
  color: #2d4b3b;
  font-size: .76rem;
}
.role-name {
  font-weight: 700;
  color: #1a3226;
  font-size: .78rem;
}
.role-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  margin: 0;
  padding: 0;
}
.role-toggle input[type="checkbox"] {
  margin: 0;
  width: 14px;
  height: 14px;
}

@media (max-width: 640px) {
  .topbar { padding: 12px; }
  .container { padding: 0 12px 12px; }
  .panel { padding: 14px; }
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
  .role-matrix {
    grid-template-columns: minmax(36px, 54px) repeat(4, minmax(0, 1fr));
    gap: 1px 4px;
  }
  .role-head { font-size: .66rem; }
  .role-name { font-size: .72rem; }
  .role-toggle input[type="checkbox"] {
    width: 13px;
    height: 13px;
  }
  .slot {
    width: 68px;
  }
  .avatar {
    width: 30px;
    height: 30px;
    font-size: .56rem;
  }
  .slot strong { font-size: .64rem; }
  .slot small { font-size: .56rem; }
}
