:root {
  --navy: #14213d;
  --navy-2: #1f3160;
  --orange: #f26b1d;
  --orange-soft: #fde5d6;
  --paper: #f6f3ec;
  --card: #ffffff;
  --ink: #1a1d24;
  --muted: #6b7180;
  --line: #e4dfd4;
  --green: #1f9d55;
  --green-soft: #dcf3e5;
  --red: #d64545;
  --red-soft: #fbe1e1;
  --amber: #c98a00;
  --amber-soft: #fff1c9;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 33, 61, .06), 0 4px 14px rgba(20, 33, 61, .06);
  --display: "Barlow Condensed", "Arial Narrow", system-ui, sans-serif;
  --body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --tabbar-h: 64px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0f1424;
    --card: #182036;
    --ink: #eef0f5;
    --muted: #98a0b3;
    --line: #283252;
    --orange-soft: #3b2415;
    --green-soft: #12301f;
    --red-soft: #3a1a1d;
    --amber-soft: #352a0b;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.45 var(--body);
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { font-family: var(--display); letter-spacing: .01em; margin: 0; line-height: 1.05; }
h1 { font-size: 30px; font-weight: 800; }
h2 { font-size: 22px; font-weight: 700; }
h3 { font-size: 17px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }

/* ---------- chrome ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--navy); color: #fff;
}
.brand { display: flex; align-items: center; gap: 8px; font-family: var(--display); font-weight: 800; font-size: 24px; letter-spacing: .02em; }
.brand svg { width: 28px; height: 28px; color: var(--orange); }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.me-chip { font-size: 13px; font-weight: 600; background: rgba(255,255,255,.12); padding: 6px 10px; border-radius: 999px; }
.sync { font-size: 12px; background: var(--amber); color: #fff; padding: 4px 8px; border-radius: 999px; font-weight: 600; }

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--card); border-top: 1px solid var(--line);
}
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11px; font-weight: 600; color: var(--muted); }
.tabbar svg { width: 24px; height: 24px; }
.tabbar a.active { color: var(--orange); }

@media (min-width: 900px) {
  body { padding-bottom: 0; padding-left: 92px; }
  .tabbar { top: 0; bottom: 0; right: auto; width: 92px; height: auto; grid-template-columns: 1fr; grid-auto-rows: 76px; align-content: start; padding-top: 70px; border-top: 0; border-right: 1px solid var(--line); }
  .topbar { margin-left: -92px; padding-left: 24px; }
}

.app { max-width: 1100px; margin: 0 auto; padding: 16px; }
.loading, .empty { color: var(--muted); text-align: center; padding: 48px 16px; }
.empty strong { display: block; color: var(--ink); font-family: var(--display); font-size: 22px; margin-bottom: 6px; }

/* ---------- common ---------- */
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.stack > * + * { margin-top: 12px; }
.section { margin-top: 22px; }
.section > h3 { margin-bottom: 10px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: var(--card); border-radius: 10px;
  padding: 10px 14px; font-weight: 600; cursor: pointer; min-height: 42px;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--orange); border-color: var(--orange); color: #fff; }
.btn.dark { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.danger { color: var(--red); border-color: var(--red-soft); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.sm { min-height: 34px; padding: 6px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.pad { padding: 16px; }

input[type=text], input[type=search], select, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; background: var(--card);
  padding: 10px 12px; min-height: 44px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--orange); box-shadow: 0 0 0 3px var(--orange-soft); }
textarea { min-height: 90px; resize: vertical; }
label.field { display: block; }
label.field > span { display: block; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 4px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.chip { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 600; white-space: nowrap; cursor: pointer; }
.chip.on { background: var(--navy); border-color: var(--navy); color: #fff; }
.chip .count { opacity: .65; margin-left: 4px; }

.seg { display: inline-flex; background: var(--line); border-radius: 10px; padding: 3px; gap: 3px; }
.seg button { border: 0; background: transparent; border-radius: 8px; padding: 7px 12px; font-weight: 600; font-size: 14px; cursor: pointer; color: var(--muted); }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.seg.status button.on[data-v=roster] { background: var(--green); color: #fff; }
.seg.status button.on[data-v=cut] { background: var(--red); color: #fff; }
.seg.status button.on[data-v=tryout] { background: var(--navy); color: #fff; }

.pill { display: inline-block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; padding: 3px 8px; border-radius: 999px; }
.pill.tryout { background: var(--orange-soft); color: var(--orange); }
.pill.roster { background: var(--green-soft); color: var(--green); }
.pill.cut { background: var(--red-soft); color: var(--red); }
.pill.private { background: var(--amber-soft); color: var(--amber); }
.pill.shared { background: var(--line); color: var(--muted); }

/* ---------- roster ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.toolbar { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.player-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }

.pcard { position: relative; display: flex; gap: 14px; padding: 14px; overflow: hidden; }
.pcard.cut { opacity: .55; }
.pcard .num {
  flex: none; width: 58px; height: 58px; border-radius: 12px;
  display: grid; place-items: center;
  background: var(--navy); color: #fff;
  font-family: var(--display); font-weight: 800; font-size: 30px;
}
.pcard.roster .num { background: var(--green); }
.pcard .name { font-family: var(--display); font-weight: 700; font-size: 21px; line-height: 1.1; }
.pcard .meta { font-size: 13px; color: var(--muted); margin-top: 2px; }
.pcard .foot { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.score {
  font-family: var(--display); font-weight: 800; font-size: 20px; line-height: 1;
  padding: 4px 8px; border-radius: 8px; background: var(--line); color: var(--ink); min-width: 44px; text-align: center;
}
.score.hi { background: var(--green-soft); color: var(--green); }
.score.mid { background: var(--amber-soft); color: var(--amber); }
.score.lo { background: var(--red-soft); color: var(--red); }
.score.none { color: var(--muted); font-size: 14px; }
.pcard .score { position: absolute; top: 12px; right: 12px; }
.flag { color: var(--amber); font-weight: 700; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line); display: inline-block; }
.dot.done { background: var(--green); }

/* ---------- player ---------- */
.hero { display: flex; gap: 16px; align-items: center; }
.hero .num { width: 84px; height: 84px; font-size: 46px; border-radius: 16px; display: grid; place-items: center; background: var(--navy); color: #fff; font-family: var(--display); font-weight: 800; flex: none; }
.hero.roster .num { background: var(--green); }
.hero.cut .num { background: var(--red); }
.hero h1 { font-size: 34px; }
.backrow { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.backrow a { font-weight: 600; color: var(--muted); }
.kv { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 14px; }
.kv div { background: var(--paper); border-radius: 10px; padding: 8px 10px; }
.kv b { display: block; font-family: var(--display); font-size: 20px; }
.kv small { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; font-weight: 700; }
.textblock { white-space: pre-wrap; }

.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--line); margin: 20px 0 14px; }
.tabs button { border: 0; background: none; padding: 10px 14px; font-weight: 700; color: var(--muted); cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -2px; }
.tabs button.on { color: var(--ink); border-color: var(--orange); }

.evalrow { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.evalrow:last-child { border-bottom: 0; }
.evalrow .cat { flex: 1; font-weight: 600; min-width: 0; }
.scale { display: flex; gap: 6px; }
.scale button {
  width: 44px; height: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--paper);
  font-family: var(--display); font-weight: 800; font-size: 20px; cursor: pointer;
}
.scale button.on { background: var(--orange); border-color: var(--orange); color: #fff; }
@media (max-width: 420px) { .scale button { width: 38px; height: 42px; } .evalrow { flex-wrap: wrap; } .evalrow .cat { flex-basis: 100%; } }

.note { padding: 12px 0; border-bottom: 1px solid var(--line); }
.note:last-child { border-bottom: 0; }
.note .by { font-size: 12px; color: var(--muted); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.note .text { margin-top: 4px; white-space: pre-wrap; }
.note.private .text { color: var(--muted); font-style: italic; }

table.grid { width: 100%; border-collapse: collapse; font-size: 14px; }
table.grid th, table.grid td { padding: 9px 8px; text-align: center; border-bottom: 1px solid var(--line); }
table.grid th:first-child, table.grid td:first-child { text-align: left; }
table.grid th { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
td.disagree { background: var(--amber-soft); font-weight: 700; }

.pager { display: flex; justify-content: space-between; gap: 8px; margin-top: 20px; }

/* ---------- tryouts board ---------- */
.board { overflow-x: auto; }
.board table { width: 100%; border-collapse: collapse; min-width: 560px; }
.board th, .board td { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: center; white-space: nowrap; }
.board th { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); position: sticky; top: 0; background: var(--card); }
.board td.name { text-align: left; font-weight: 600; }
.board td.name a { display: block; }
.board td.rank { font-family: var(--display); font-weight: 800; color: var(--muted); width: 36px; }
.board tr.cutline td { border-bottom: 3px dashed var(--orange); }
.board tr.is-roster td.name { color: var(--green); }
.board tr.is-cut td { opacity: .45; }
.board .mini { display: inline-flex; gap: 4px; }
.board .mini button { width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--line); background: var(--paper); cursor: pointer; font-weight: 800; }
.board .mini button.keep.on { background: var(--green); color: #fff; border-color: var(--green); }
.board .mini button.drop.on { background: var(--red); color: #fff; border-color: var(--red); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 10px; }

/* ---------- activity ---------- */
.feed .item { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.feed .avatar { flex: none; width: 34px; height: 34px; border-radius: 50%; background: var(--navy); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.feed .when { font-size: 12px; color: var(--muted); }

/* ---------- sheet ---------- */
.scrim { position: fixed; inset: 0; background: rgba(10, 14, 28, .45); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  background: var(--card); width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto;
  border-radius: 18px 18px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  animation: up .18s ease-out;
}
@media (min-width: 700px) { .scrim { align-items: center; } .sheet { border-radius: 18px; } }
@keyframes up { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom));
  background: var(--navy); color: #fff; padding: 10px 16px; border-radius: 999px; font-weight: 600; font-size: 14px; z-index: 60;
  box-shadow: 0 6px 20px rgba(0,0,0,.25);
}
.saving { font-size: 12px; color: var(--muted); min-height: 16px; }

@media print {
  .topbar, .tabbar, .no-print, .toolbar { display: none !important; }
  body { padding: 0; background: #fff; }
  .player-grid { grid-template-columns: repeat(3, 1fr); }
  .card { box-shadow: none; break-inside: avoid; }
}
