:root {
  --bg: #04150d;
  --bg2: #0a2e1d;
  --card: #10281c;
  --card2: #173826;
  --line: #24503a;
  --text: #eef4f0;
  --muted: #8fa69a;
  --accent: #7ff0a6;
  --bright: #3ddc6b;
  --danger: #ff7a6b;
  --radius: 14px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.4 Barlow, system-ui, -apple-system, sans-serif;
  min-height: 100vh;
  background: linear-gradient(180deg, var(--bg2), var(--bg) 60%) fixed;
}
main { overflow-x: clip; padding: calc(var(--safe-t) + 8px) 16px calc(90px + var(--safe-b)); max-width: 640px; margin: 0 auto; }
.view { display: flex; flex-direction: column; gap: 14px; }
h1 { font: 800 34px/1.1 "Barlow Condensed", sans-serif; text-transform: uppercase; letter-spacing: .02em; margin: 10px 0 0; }
h2 { font: 700 20px/1.2 "Barlow Condensed", sans-serif; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); margin: 0; }
h3 { font: 700 16px/1.2 "Barlow Condensed", sans-serif; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 8px 0 0; }
.hint { color: var(--muted); font-size: 14px; margin: 0; }
.block { display: block; }
.center { text-align: center; display: flex; justify-content: center; }
.center-row { justify-content: center; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; }
.gap { gap: 8px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; display: flex; flex-direction: column; gap: 10px;
}
.card.off { opacity: .6; }
.note { background: #2b2a12; border: 1px solid #5a5520; color: #f3eaa6; border-radius: var(--radius); padding: 10px 12px; font-size: 14px; }

/* controls */
input, select {
  width: 100%; font: inherit; font-size: 16px; color: var(--text);
  background: #0a1f15; border: 1px solid var(--line); border-radius: 10px; padding: 10px 11px; min-height: 44px;
}
input:focus, select:focus { outline: 2px solid var(--bright); outline-offset: -1px; }
input[type=checkbox] { width: 22px; height: 22px; min-height: 0; accent-color: var(--bright); }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); min-width: 0; }
.field > span { font-weight: 600; letter-spacing: .02em; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
.score { display: flex; align-items: center; gap: 6px; font-weight: 700; }
.score input { text-align: center; }
.check { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--text); white-space: nowrap; }

.btn {
  font: 700 16px/1 Barlow, sans-serif; color: var(--text); background: var(--card2);
  border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; min-height: 46px; cursor: pointer;
}
.btn.primary { background: var(--bright); color: #04150d; border-color: var(--bright); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); }
.btn.small { min-height: 38px; padding: 8px 12px; font-size: 14px; }
.btn.big { min-height: 56px; font-size: 18px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .45; }
.btn:active:not(:disabled) { transform: scale(.98); }
.icon-btn { background: none; border: 0; color: var(--muted); font-size: 18px; min-width: 40px; min-height: 40px; cursor: pointer; }

.seg { display: flex; background: #0a1f15; border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 3px; }
.seg button { flex: 1; border: 0; background: none; color: var(--muted); font: 700 15px Barlow, sans-serif; padding: 10px 6px; border-radius: 9px; min-height: 40px; cursor: pointer; }
.seg button.on { background: var(--card2); color: var(--text); box-shadow: 0 0 0 1px var(--line); }

.topbar {
  position: sticky; top: 0; z-index: 5; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px;
  margin: 0 -16px; padding: calc(var(--safe-t) + 6px) 12px 8px; background: rgba(4, 21, 13, .92); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar > div:last-child { text-align: right; }
.topbar strong { font: 700 18px "Barlow Condensed", sans-serif; text-transform: uppercase; letter-spacing: .06em; }

/* screenshots */
.shots { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.shot { position: relative; flex: 0 0 auto; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: none; padding: 0; }
.shot img { display: block; height: 120px; width: auto; }
.shot-x { position: absolute; top: 4px; right: 4px; width: 28px; height: 28px; border-radius: 50%; border: 0; background: rgba(0,0,0,.7); color: #fff; }

/* lists */
.list { display: flex; flex-direction: column; gap: 6px; }
.list-item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; color: var(--text); font: inherit;
  background: var(--card2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; min-height: 52px; cursor: pointer;
}
.list-item b { display: block; font-weight: 600; }
.list-item small { color: var(--muted); }
.chev { color: var(--muted); font-size: 22px; }
.badge { width: 30px; height: 30px; border-radius: 7px; display: grid; place-items: center; font: 800 16px "Barlow Condensed"; background: #33443b; }
.badge.S { background: #13663f; } .badge.U { background: #6d7b74; } .badge.N { background: #c9443a; }
.tag { font-size: 11px; font-weight: 700; padding: 3px 7px; border-radius: 6px; text-transform: uppercase; }
.tag.new { background: #2b4a8a; color: #dbe6ff; }

/* goals */
.goal { display: flex; flex-direction: column; gap: 6px; padding: 10px; background: #0c2218; border-radius: 12px; border: 1px solid var(--line); }
.goal .min { width: 70px; flex: 0 0 70px; }

/* lineup */
.pitch {
  display: flex; flex-direction: column; gap: 10px; padding: 12px 6px;
  background: repeating-linear-gradient(180deg, #0d3a22 0 36px, #0f4029 36px 72px); border-radius: 12px; border: 1px solid #2f5a43;
}
.pitch-row { display: flex; justify-content: space-around; gap: 4px; }
.chip {
  display: flex; flex-direction: column; align-items: center; gap: 3px; background: none; border: 2px solid transparent;
  color: var(--text); font: 600 12px "Barlow Condensed", sans-serif; padding: 4px 2px; border-radius: 10px; min-width: 0; flex: 1; max-width: 80px; cursor: pointer;
}
.chip span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.chip.sel { border-color: var(--accent); background: rgba(127, 240, 166, .15); }
.chip.gk .thumb { outline: 2px solid #f0843a; border-radius: 50%; }
.prow { display: flex; flex-direction: column; gap: 6px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.prow .num { width: 64px; flex: 0 0 64px; text-align: center; }
.small-ctl { flex-wrap: wrap; gap: 6px; }
input.is-new { border-color: #4a6fc4; box-shadow: inset 3px 0 0 #6f95ea; }
.small-ctl select { width: auto; max-width: 110px; min-height: 36px; padding: 6px 8px; font-size: 14px; }
.small-ctl .btn.small { padding: 8px 10px; }
.toggle { min-width: 36px; min-height: 36px; border-radius: 8px; border: 1px solid var(--line); background: #0a1f15; color: var(--muted); font: 700 13px Barlow; cursor: pointer; }
.toggle.on { background: var(--text); color: #04150d; }
.toggle.card-y, .toggle.card-r { min-width: 30px; width: 30px; position: relative; }
.toggle.card-y::after, .toggle.card-r::after { content: ''; position: absolute; left: 50%; top: 50%; width: 12px; height: 17px; border-radius: 2px; transform: translate(-50%, -50%) rotate(-8deg); border: 2px solid; }
.toggle.card-y::after { border-color: #f5c518; }
.toggle.card-r::after { border-color: #e0342f; }
.toggle.card-y.on { background: #3b3310; } .toggle.card-y.on::after { background: #f5c518; }
.toggle.card-r.on { background: #3d1412; } .toggle.card-r.on::after { background: #e0342f; }
.thumb { flex: 0 0 auto; }

/* table editor */
.trow { display: grid; grid-template-columns: 44px 1fr 44px 64px 48px 32px; gap: 4px; align-items: center; }
.trow input { padding: 8px 5px; min-height: 38px; font-size: 14px; }
.trow.head span { font-size: 12px; color: var(--muted); font-weight: 700; }

/* preview */
.post-wrap { background: #000; border-radius: 12px; overflow: hidden; box-shadow: 0 10px 30px rgba(0,0,0,.4); }
.post { display: block; width: 100%; height: auto; }
.post-wrap.story { max-width: 400px; margin: 0 auto; width: 100%; }

/* story */
.grid2.sides { grid-template-columns: 1fr; }
.side { display: flex; flex-direction: column; gap: 6px; background: #0c2218; border: 1px solid var(--line); border-radius: 12px; padding: 8px; min-width: 0; }
.side input { padding: 8px; min-height: 40px; }
.form-ed { display: flex; gap: 6px; }
.form-box { width: 38px; height: 38px; border-radius: 7px; border: 1px dashed var(--line); background: #0a1f15; color: var(--muted); font: 800 18px "Barlow Condensed"; cursor: pointer; }
.form-box.S { background: #13663f; color: #fff; border: 0; }
.form-box.U { background: #6d7b74; color: #fff; border: 0; }
.form-box.N { background: #c9443a; color: #fff; border: 0; }

/* squad */
.people { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 10px; }
.person { display: flex; flex-direction: column; align-items: center; gap: 4px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 6px; color: var(--text); font: inherit; cursor: pointer; }
.pname { font: 700 15px/1.1 "Barlow Condensed", sans-serif; text-align: center; }
.person small { color: var(--muted); font-size: 12px; }
.logos { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.logo-item { display: flex; flex-direction: column; align-items: center; gap: 4px; background: none; border: 0; color: var(--muted); font: inherit; cursor: pointer; }
.logo-item small { font-size: 11px; text-align: center; line-height: 1.2; }
.assign-img { max-width: 100%; max-height: 40vh; display: block; margin: 0 auto; border-radius: 10px; }

/* tab bar */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex;
  background: rgba(4, 21, 13, .95); backdrop-filter: blur(12px); border-top: 1px solid var(--line);
  padding: 6px 6px calc(6px + var(--safe-b));
}
.tabbar button {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; background: none; border: 0; color: var(--muted);
  font: 600 12px Barlow, sans-serif; padding: 6px 0; min-height: 52px; cursor: pointer;
}
.tabbar button .ti { font-size: 20px; line-height: 1; filter: grayscale(1); opacity: .7; }
.tabbar button.on { color: var(--accent); }
.tabbar button.on .ti { filter: none; opacity: 1; }

/* overlays */
.toast {
  position: fixed; left: 50%; bottom: calc(96px + var(--safe-b)); transform: translate(-50%, 20px); opacity: 0; transition: .25s;
  background: #e9f5ee; color: #04150d; padding: 12px 16px; border-radius: 12px; font-weight: 600; z-index: 100; max-width: calc(100% - 32px);
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.busy { position: fixed; inset: 0; z-index: 90; background: rgba(2, 10, 6, .85); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 24px; text-align: center; white-space: pre-line; }
.spinner { width: 44px; height: 44px; border-radius: 50%; border: 4px solid rgba(255,255,255,.15); border-top-color: var(--bright); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.sheet-back { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.6); display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  width: 100%; max-width: 640px; max-height: 88vh; display: flex; flex-direction: column; background: #0d2419; border: 1px solid var(--line);
  border-radius: 18px 18px 0 0; padding-bottom: var(--safe-b);
}
.sheet-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 12px 4px 16px; }
.sheet-head strong { font: 700 20px "Barlow Condensed", sans-serif; text-transform: uppercase; letter-spacing: .05em; }
.sheet-body { overflow-y: auto; padding: 4px 16px 12px; display: flex; flex-direction: column; gap: 10px; }
.sheet-actions { display: flex; gap: 8px; padding: 10px 16px 14px; border-top: 1px solid var(--line); }
.sheet-actions .btn { flex: 1; }

/* cropper */
.cropper { position: fixed; inset: 0; z-index: 200; background: #020a06; display: flex; flex-direction: column; padding: var(--safe-t) 0 calc(12px + var(--safe-b)); }
.cropper-bar { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; }
.cropper-stage { flex: 1; display: flex; align-items: center; justify-content: center; min-height: 0; }
.cropper-stage canvas { touch-action: none; border-radius: 4px; }
.cropper-zoom { display: flex; align-items: center; gap: 12px; padding: 8px 24px; color: var(--muted); font-size: 22px; }
.cropper-zoom input { flex: 1; min-height: 0; padding: 0; border: 0; background: none; accent-color: var(--bright); }

/* collapsible fallbacks */
details.fallback summary, details.mini-fallback summary { cursor: pointer; list-style: none; }
details.fallback summary::-webkit-details-marker, details.mini-fallback summary::-webkit-details-marker { display: none; }
details.fallback summary h2 { display: inline; color: var(--muted); }
details.fallback summary::after, details.mini-fallback summary::after { content: ' ▾'; color: var(--muted); }
details.fallback[open] > *:not(summary) { margin-top: 10px; }
details.mini-fallback { font-size: 14px; color: var(--muted); display: flex; flex-direction: column; gap: 8px; }
details.mini-fallback[open] > .row { margin-top: 8px; }
.score-tag { font: 800 20px 'Barlow Condensed', sans-serif; letter-spacing: .03em; }
