@import url("https://fonts.googleapis.com/css2?family=Bungee&family=Rubik:wght@400;500;700&family=Jua&family=Noto+Sans+KR:wght@400;500;700&display=swap");

:root {
  /* Light-retro palette (shared by every page; the dashboard reuses these too). */
  --paper: #f2e8d2;
  --card: #fffdf7;
  --card-2: #fbf3e1;
  --ink: #241f1b;
  --ink-soft: #564b42;
  --ghost: #8f8273;
  --line: #d9cba8;
  --teal: #2a9d8f;
  --teal-ink: #11675b;
  --orange: #e76f51;
  --orange-ink: #b0462c;
  --red: #d1495b;
  --red-ink: #ac3046;
  --mustard: #e9c46a;
  --mustard-dk: #c99b36;
  --gold-ink: #876413;

  /* Legacy aliases: existing components reference these, so re-pointing repaints them. */
  --bg: var(--paper);
  --panel: var(--card);
  --muted: var(--ink-soft);
  --accent: var(--teal-ink);
  --win: #1f7a3d;
  --tap: var(--card-2);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Rubik", "Noto Sans KR", "Malgun Gothic", "Apple SD Gothic Neo", "Segoe UI", system-ui, sans-serif;
  font-size: 17px;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 16px calc(14px + env(safe-area-inset-top));
  background: var(--card);
  border-bottom: 3px solid var(--mustard-dk);
}
.topbar::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 5px;
  background: repeating-linear-gradient(-45deg, var(--mustard) 0 8px, transparent 8px 16px);
  opacity: 0.8;
}
.brand { font-family: "Jua", "Noto Sans KR", "Malgun Gothic", sans-serif; font-size: 22px; color: var(--ink); }
.brand-sub { font-size: 12.5px; color: var(--ink-soft); }

.sheet { padding: 16px; max-width: 640px; margin: 0 auto; }
.loading { color: var(--muted); text-align: center; padding: 40px 0; }

.matchup-title { font-size: 15px; color: var(--muted); margin: 4px 0 10px; }
.totals {
  display: flex;
  justify-content: center;
  gap: 18px;
  font-size: 15px;
  margin-bottom: 16px;
  padding: 10px;
  background: var(--card);
  border: 2px solid var(--mustard-dk);
  border-radius: 12px;
}
.totals .t-team { font-family: "Jua", "Noto Sans KR", "Malgun Gothic", sans-serif; font-weight: 700; }
.totals .t-win { color: var(--win); }

.team {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 14px;
}
.team h2 { font-family: "Jua", "Noto Sans KR", "Malgun Gothic", sans-serif; font-size: 18px; margin: 0 0 10px; display: flex; justify-content: space-between; }
.team h2 .series { font-family: "Rubik", sans-serif; color: var(--ink-soft); font-weight: 500; }

.bowler { display: grid; grid-template-columns: 1fr repeat(3, 64px); align-items: center; gap: 6px; margin: 6px 0; }
.bowler .name { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bowler .name .meta { color: var(--muted); font-size: 12px; margin-left: 6px; }
.bowler .tag { font-size: 10px; color: var(--muted); border: 1px solid var(--line); border-radius: 6px; padding: 0 4px; margin-left: 4px; }

.cell {
  appearance: none;
  font: inherit;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--tap);
  color: var(--ink);
  text-align: center;
  display: flex;
  flex-direction: column;
  justify-content: center;
  line-height: 1.1;
  cursor: pointer;
}
.cell:disabled { opacity: 0.55; cursor: default; }
.cell .raw { font-size: 11px; color: var(--muted); }
.cell .adj { font-size: 15px; font-weight: 700; }
.cell.empty .adj { color: var(--muted); font-weight: 400; }
.cell input { width: 100%; height: 100%; border: none; background: transparent; color: var(--accent); font: inherit; text-align: center; }

.foot { padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.status { font-size: 12px; color: var(--muted); }
.status.err { color: #ff7a8a; }
.stand-row { display: grid; grid-template-columns: 32px 1fr 56px; align-items: center; gap: 8px; padding: 7px 0; border-top: 1px solid var(--line); }
.stand-row:first-of-type { border-top: none; }
.stand-row .rank { color: var(--muted); font-size: 13px; }
.stand-row .sname { font-weight: 600; }
.stand-row .spts { text-align: right; font-family: "Bungee", "Rubik", sans-serif; color: var(--ink); }

.draft-note { font-size: 11px; color: var(--muted); text-align: center; margin-top: 8px; }

.nav { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 8px; }
.nav a { color: var(--teal-ink); font-size: 14px; font-weight: 600; text-decoration: none; }
.nav a:hover { color: var(--orange-ink); text-decoration: underline; }
.nav a.here { color: var(--orange-ink); }

.rrow { display: grid; grid-template-columns: 1fr 72px 60px; align-items: center; gap: 8px; padding: 9px 0; border-top: 1px solid var(--line); }
.rrow:first-of-type { border-top: none; }
.rrow .rname { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rrow .rname .meta { color: var(--muted); font-size: 12px; font-weight: 400; margin-left: 6px; }
.rrow .rstat { text-align: right; font-size: 13px; color: var(--muted); }
.rrow .rstat b { color: var(--accent); font-size: 15px; }

.adm-form { display: flex; flex-direction: column; gap: 8px; }
.adm-form input, .adm-form textarea { font: inherit; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--tap); color: var(--ink); }
.adm-form textarea { font-family: ui-monospace, monospace; font-size: 12px; }
.adm-form button { font: inherit; padding: 11px; border: none; border-radius: 8px; background: var(--accent); color: #fff; font-weight: 700; cursor: pointer; }
.adm-form select { font: inherit; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--tap); color: var(--ink); }
.form-title { font-weight: 700; font-size: 13px; color: var(--ink-soft); }
.form-row { display: flex; gap: 8px; }
.form-row > * { flex: 1; }
.chk { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink); }
.chk input { width: auto; }
.btn-secondary { background: var(--tap); color: var(--ink); border: 1px solid var(--line); }

/* admin: teams overview */
.tcard { border-top: 1px solid var(--line); padding: 8px 0 4px; }
.tcard:first-of-type { border-top: none; }
.tcard-h { display: flex; justify-content: space-between; align-items: baseline; margin: 4px 0 2px; }
.tcard-h .tname { font-weight: 700; }
.tcard-h .tmeta { color: var(--muted); font-size: 12px; }

/* admin: member management */
.mrow { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); }
.mrow:first-of-type { border-top: none; }
.mrow .rname { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mrow .rname .meta { color: var(--muted); font-size: 12px; font-weight: 400; margin-left: 6px; }
.pill { font: inherit; font-size: 12px; padding: 5px 11px; border: 1px solid var(--line); border-radius: 999px; background: var(--tap); color: var(--ink); cursor: pointer; white-space: nowrap; }
.pill.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.linkish { background: none; border: none; color: var(--accent); cursor: pointer; font: inherit; font-size: 12px; padding: 0; white-space: nowrap; }

/* admin: team builder */
.fld { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.fld select, .fld input, .bteam input, .add-bowler { font: inherit; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--tap); color: var(--ink); width: 100%; }
.builder-meta-row { margin-bottom: 8px; }
.bteam { border-top: 1px solid var(--line); padding: 10px 0; }
.bteam:first-of-type { border-top: none; }
.bteam-h { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.bteam-h .tname { font-weight: 700; }
.bteam-ctl { display: flex; gap: 12px; align-items: center; }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--tap); border: 1px solid var(--line); border-radius: 999px; padding: 4px 6px 4px 11px; font-size: 13px; }
.chip .meta { color: var(--muted); font-size: 11px; }
.chip-x { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 16px; line-height: 1; padding: 0 2px; }
#builder-add-team { font: inherit; padding: 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--tap); color: var(--ink); font-weight: 700; cursor: pointer; }
#builder-save { font: inherit; padding: 11px; border: none; border-radius: 8px; background: var(--accent); color: #fff; font-weight: 700; cursor: pointer; }

.rep-team { margin: 10px 0; }
.rep-th { display: flex; justify-content: space-between; font-weight: 700; margin-bottom: 4px; }
.rep-tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.rep-tbl th, .rep-tbl td { border: 1px solid var(--line); padding: 5px 6px; text-align: center; }
.rep-tbl td.bn, .rep-tbl th:first-child { text-align: left; }
.rep-tot { font-weight: 700; }

.report-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line); text-decoration: none; color: var(--ink); }
.report-row:first-of-type { border-top: none; }
.report-row .rr-title { font-weight: 600; color: var(--accent); }
.report-row .rr-when { font-size: 12px; color: var(--muted); white-space: nowrap; }

.packet-page { margin-bottom: 28px; }
.cover-head { text-align: center; margin-bottom: 20px; }
.cover-head h1 { font-size: 20px; margin: 0 0 4px; }
.cover-date { color: var(--muted); font-size: 13px; margin: 0 0 6px; }

.cover-block { margin: 18px 0; }
.cover-h { font-size: 15px; font-weight: 700; margin: 0 0 8px; color: var(--ink); }

.advancer-list { display: flex; flex-direction: column; gap: 2px; }
.advancer-row { display: grid; grid-template-columns: 120px 1fr 64px; align-items: baseline; gap: 8px; padding: 3px 0; }
.advancer-row .adv-week { color: var(--muted); font-size: 13px; }
.advancer-row .adv-name { font-weight: 600; }
.advancer-row .adv-series { text-align: right; font-weight: 700; color: var(--accent); }

.lane-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 18px; }
.lane-cell { display: grid; grid-template-columns: 72px 1fr; align-items: baseline; gap: 8px; padding: 3px 0; }
.lane-cell .lane-no { color: var(--muted); font-size: 13px; }
.lane-cell .lane-team { font-weight: 700; }

.high-line { display: flex; flex-wrap: wrap; gap: 8px 40px; }
.high-line .high-side { font-weight: 600; }

.lane-sheet-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 520px) { .lane-sheet-grid { grid-template-columns: 1fr 1fr; gap: 12px 18px; } }
.lane-block { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.lane-block-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.lane-block-head .lbh-lane { color: var(--muted); font-size: 13px; }
.lane-block-head .lbh-team { font-weight: 700; }
.lane-tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.lane-tbl th, .lane-tbl td { border-bottom: 1px solid var(--line); padding: 5px 6px; text-align: center; }
.lane-tbl th { color: var(--muted); font-weight: 600; }
.lane-tbl tr:last-child td { border-bottom: none; }
.lane-tbl .lt-name { text-align: left; }
.lane-tbl td.lt-name { font-weight: 600; }
.lane-tbl .lt-ghost td { color: var(--muted); }

.notice-body { font-size: 14px; line-height: 1.5; color: var(--ink); }

.grid-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.grid-tbl { border-collapse: collapse; font-size: 13px; white-space: nowrap; }
.grid-tbl th, .grid-tbl td { border: 1px solid var(--line); padding: 5px 8px; text-align: center; }
.grid-tbl th { color: var(--muted); font-weight: 600; }
.grid-tbl .g-name { text-align: left; }
.grid-tbl td.g-name { font-weight: 600; }
.grid-tbl .g-rank { color: var(--muted); }
.grid-tbl .g-total { font-weight: 700; color: var(--accent); }
.maxcell { color: #c00; font-weight: 700; }

.grid-tbl .mg-games-row th { font-size: 11px; color: var(--muted); font-weight: 600; }
.grid-tbl .mg-block2 td { color: var(--muted); }
.grid-tbl .mg-block2 td.g-total { color: var(--accent); }
.grid-tbl .mg-sep td { padding: 0; height: 6px; background: var(--line); border: none; }

@media print {
  :root { --bg: #fff; --panel: #fff; --ink: #000; --muted: #444; --line: #999; --accent: #000; --tap: #fff; }
  body { background: #fff; color: #000; }
  .topbar { position: static; background: #fff; border-bottom: 1px solid #999; }
  .topbar::after { display: none; }
  .foot { display: none; }
  .nav { display: none; }
  .login-btn, .adm-form button, button { display: none; }
  .team { break-inside: avoid; border-color: #999; }
  .packet-page { break-after: page; margin-bottom: 0; }
  .cover-block { break-inside: avoid; }
  .lane-block { break-inside: avoid; border-color: #999; }
  .lane-tbl th, .lane-tbl td { border-bottom-color: #999; }
  .grid-tbl th, .grid-tbl td { border-color: #999; }
  .grid-scroll { overflow-x: visible; }
  .indiv-grid-page, .team-grid-page, .master-grid-page { page: wide; }
  @page wide { size: landscape; }
  .maxcell { color: #c00; }
  .mg-sep td { background: #999; }
}
