/* O3 Memories web app: the only stylesheet. Colors, sizes and radii are the variables below: a new design
   (the user's UI/UX, to come) should mostly change this block and the component rules under it. Mobile first. */
:root {
  --bg: #0b1220;            /* page */
  --bg-2: #111a2e;          /* cards, bars */
  --bg-3: #18233b;          /* inputs, rows hover */
  --line: #243251;          /* borders */
  --text: #e8edf7;
  --muted: #8b98b5;
  --accent: #f4c430;        /* FO3 gold: EP, primary buttons */
  --accent-ink: #1a1400;
  --ok: #3ccf7a;
  --warn: #ffb020;
  --bad: #ff5d5d;
  --gk: #f2b632;            /* position groups, as the client colors them */
  --df: #3d8bfd;
  --mf: #35c46a;
  --fw: #ff5a4f;
  --g1: #9aa4b8;            /* card grade colors: +1, +2..4 bronze, +5..7 silver, +8..10 gold */
  --g2: #cd7f32;
  --g5: #c8d2e0;
  --g8: #ffd24a;
  --radius: 12px;
  --radius-s: 8px;
  --pad: 14px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  --fs: 15px;
  --fs-s: 13px;
  --fs-xs: 11px;
  --nav-h: 60px;
  --top-h: 52px;
  --shadow: 0 6px 24px rgba(0, 0, 0, .35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--text); font: var(--fs)/1.4 var(--font);
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
button, input, select { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
.hidden { display: none !important; }

/* ---------------------------------------------------------------- layout */
#app { min-height: 100vh; }
.top {
  position: sticky; top: 0; z-index: 20; height: var(--top-h); display: flex; align-items: center; gap: 10px;
  padding: 0 var(--pad); background: var(--bg-2); border-bottom: 1px solid var(--line);
}
.top .club { flex: 1; min-width: 0; }
.top .club b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: var(--fs); }
.top .club small { color: var(--muted); font-size: var(--fs-xs); }
.top .crest { width: 30px; height: 30px; object-fit: contain; }
.money { text-align: right; font-size: var(--fs-s); line-height: 1.2; }
.money .ep { color: var(--accent); font-weight: 700; }
.money .es { color: var(--muted); }
main { padding: var(--pad); padding-bottom: calc(var(--nav-h) + var(--pad) + env(safe-area-inset-bottom)); max-width: 760px; margin: 0 auto; }
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom); background: var(--bg-2); border-top: 1px solid var(--line);
}
.nav a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--muted); font-size: var(--fs-xs); gap: 2px; }
.nav a .ic { font-size: 20px; line-height: 1; }
.nav a.on { color: var(--accent); }

/* ---------------------------------------------------------------- blocks */
h1 { font-size: 20px; margin: 4px 0 12px; }
h2 { font-size: 16px; margin: 18px 0 8px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.card { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--pad); margin-bottom: 12px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: var(--fs-s); }
.xs { font-size: var(--fs-xs); }
.right { text-align: right; }
.center { text-align: center; }
.ep { color: var(--accent); font-weight: 700; }
.okc { color: var(--ok); } .badc { color: var(--bad); } .warnc { color: var(--warn); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-block; padding: 2px 8px; border-radius: 999px; background: var(--bg-3); border: 1px solid var(--line); font-size: var(--fs-xs); color: var(--muted); }
.banner { border-radius: var(--radius); padding: 10px 12px; margin-bottom: 12px; font-size: var(--fs-s); }
.banner.info { background: rgba(61, 139, 253, .12); border: 1px solid rgba(61, 139, 253, .4); }
.banner.warn { background: rgba(255, 176, 32, .12); border: 1px solid rgba(255, 176, 32, .45); }
.banner.bad { background: rgba(255, 93, 93, .12); border: 1px solid rgba(255, 93, 93, .45); }
.banner.ok { background: rgba(60, 207, 122, .12); border: 1px solid rgba(60, 207, 122, .45); }

/* ---------------------------------------------------------------- forms, buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px; padding: 0 16px;
  border-radius: var(--radius-s); border: 1px solid var(--line); background: var(--bg-3); cursor: pointer; font-weight: 600;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.danger { background: transparent; color: var(--bad); border-color: var(--bad); }
.btn.small { min-height: 32px; padding: 0 10px; font-size: var(--fs-s); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.field { display: block; margin-bottom: 10px; }
.field span { display: block; font-size: var(--fs-s); color: var(--muted); margin-bottom: 4px; }
input, select {
  width: 100%; min-height: 42px; padding: 0 12px; border-radius: var(--radius-s); border: 1px solid var(--line);
  background: var(--bg-3); outline: none;
}
input:focus, select:focus { border-color: var(--accent); }
.check { display: flex; align-items: center; gap: 8px; min-height: 36px; }
.check input { width: 20px; min-height: 20px; }
.tabs { display: flex; gap: 6px; margin-bottom: 12px; overflow-x: auto; }
.tabs a { padding: 8px 12px; border-radius: 999px; background: var(--bg-2); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; font-size: var(--fs-s); }
.tabs a.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; }

/* ---------------------------------------------------------------- player rows */
.list { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin-bottom: 12px; }
.prow { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--line); cursor: pointer; content-visibility: auto; contain-intrinsic-size: 56px; }
.prow:last-child { border-bottom: 0; }
.prow:active { background: var(--bg-3); }
.prow.sel { background: rgba(244, 196, 48, .12); }
.face { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; background: var(--bg-3); flex: none; }
.face.big { width: 84px; height: 84px; }
.pos { flex: none; min-width: 38px; text-align: center; font-weight: 800; font-size: var(--fs-s); }
.pos.gk { color: var(--gk); } .pos.df { color: var(--df); } .pos.mf { color: var(--mf); } .pos.fw { color: var(--fw); } .pos.sub { color: var(--muted); }
.pname { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.pmeta { font-size: var(--fs-xs); color: var(--muted); }
.ovr { flex: none; min-width: 34px; text-align: right; font-weight: 800; font-size: 18px; }
.grade { display: inline-block; min-width: 26px; padding: 0 5px; border-radius: 5px; font-size: var(--fs-xs); font-weight: 800; text-align: center; color: #10131a; background: var(--g1); }
.grade.b { background: var(--g2); } .grade.s { background: var(--g5); } .grade.g { background: var(--g8); }
.season { display: inline-block; padding: 0 5px; border-radius: 4px; background: var(--bg-3); border: 1px solid var(--line); font-size: var(--fs-xs); color: var(--muted); max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle; }

/* ---------------------------------------------------------------- pitch (formation) */
.pitch {
  position: relative; width: 100%; aspect-ratio: 68 / 80; border-radius: var(--radius); margin-bottom: 12px; overflow: hidden;
  background: repeating-linear-gradient(180deg, #16502f 0 10%, #1a5a35 10% 20%); border: 1px solid #2a7048;
}
.pitch::before { content: ""; position: absolute; left: 8%; right: 8%; top: 0; bottom: 0; border-left: 2px solid rgba(255,255,255,.18); border-right: 2px solid rgba(255,255,255,.18); }
.pitch::after { content: ""; position: absolute; left: 30%; right: 30%; bottom: 0; height: 14%; border: 2px solid rgba(255,255,255,.18); border-bottom: 0; }
.dot { position: absolute; transform: translate(-50%, -50%); width: 64px; text-align: center; cursor: pointer; }
.dot .o { display: inline-block; min-width: 34px; padding: 2px 4px; border-radius: 6px; background: rgba(0,0,0,.55); font-weight: 800; }
.dot .n { display: block; font-size: var(--fs-xs); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-shadow: 0 1px 2px #000; }

/* ---------------------------------------------------------------- stats */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 14px; }
.stat { display: flex; justify-content: space-between; font-size: var(--fs-s); border-bottom: 1px dashed var(--line); padding: 3px 0; }
.stat b { font-variant-numeric: tabular-nums; }
.stat .plus { color: var(--ok); font-size: var(--fs-xs); margin-left: 4px; }
.roles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.roles div { background: var(--bg-3); border-radius: var(--radius-s); text-align: center; padding: 4px 0; font-size: var(--fs-xs); color: var(--muted); }
.roles div b { display: block; font-size: 16px; color: var(--text); }
.bigovr { font-size: 40px; font-weight: 900; line-height: 1; }

/* ---------------------------------------------------------------- tables */
table { width: 100%; border-collapse: collapse; font-size: var(--fs-s); }
th, td { padding: 7px 6px; border-bottom: 1px solid var(--line); text-align: left; }
th { color: var(--muted); font-weight: 600; font-size: var(--fs-xs); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.me td { background: rgba(244, 196, 48, .1); }

/* ---------------------------------------------------------------- modal, toast */
.modal-bg { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .6); display: flex; align-items: flex-end; justify-content: center; }
.modal { width: 100%; max-width: 520px; max-height: 88vh; overflow: auto; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius) var(--radius) 0 0; padding: 18px var(--pad) calc(18px + env(safe-area-inset-bottom)); box-shadow: var(--shadow); }
@media (min-width: 600px) { .modal-bg { align-items: center; } .modal { border-radius: var(--radius); } }
.modal h3 { margin: 0 0 10px; }
.modal .actions { display: flex; gap: 8px; margin-top: 14px; }
.modal .actions .btn { flex: 1; }
.toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + 16px); transform: translateX(-50%); z-index: 60; max-width: 92vw; padding: 10px 16px; border-radius: var(--radius-s); background: #222d47; border: 1px solid var(--line); box-shadow: var(--shadow); font-size: var(--fs-s); }
.toast.bad { border-color: var(--bad); }
.toast.ok { border-color: var(--ok); }
.spin { display: inline-block; width: 18px; height: 18px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: sp .8s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }
.loading { padding: 40px 0; text-align: center; color: var(--muted); }

/* ---------------------------------------------------------------- login */
.login { max-width: 380px; margin: 0 auto; padding: 48px var(--pad) 24px; }
.login .logo { text-align: center; margin-bottom: 24px; }
.login .logo b { display: block; font-size: 26px; letter-spacing: .02em; }
.login .logo span { color: var(--accent); }
.login .logo small { color: var(--muted); }
.foot { margin-top: 20px; font-size: var(--fs-xs); color: var(--muted); text-align: center; }

/* ---------------------------------------------------------------- enhance */
.duel { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; text-align: center; }
.duel .slot { background: var(--bg-3); border: 1px dashed var(--line); border-radius: var(--radius); padding: 10px 6px; min-height: 120px; cursor: pointer; }
.duel .slot.full { border-style: solid; }
.duel .plus { font-size: 24px; color: var(--muted); }
.prob { font-size: 34px; font-weight: 900; color: var(--accent); }
.result { text-align: center; padding: 10px 0; }
.result .big { font-size: 30px; font-weight: 900; }
.spark { width: 100%; height: 60px; }
.spark path { fill: none; stroke: var(--accent); stroke-width: 2; }
