:root {
  --accent: #0f766e; --accent-dark: #115e59; --accent-soft: #ccfbf1;
  --ink: #1f2933; --muted: #52606d; --faint: #9aa5b1; --line: #e4e7eb; --bg: #f6f7f9; --card: #fff;
  --bad: #b91c1c; --bad-soft: #fee2e2; --warn: #b45309; --warn-soft: #fef3c7; --good: #15803d; --good-soft: #dcfce7;
  --gold: #fff8e1;
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--accent); }
h1 { font-size: 22px; margin: 0 0 4px; } h2 { font-size: 17px; margin: 0 0 10px; } h3 { font-size: 15px; margin: 0 0 8px; }
p { margin: 0 0 10px; }
.loading { padding: 40px; text-align: center; color: var(--muted); }
.muted { color: var(--muted); } .small { font-size: 13px; } .tiny { font-size: 12px; }
.bad { color: var(--bad); } .warn { color: var(--warn); } .good { color: var(--good); }

button, .btn { font: inherit; border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 8px; padding: 7px 14px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
button:hover, .btn:hover { border-color: var(--faint); }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.primary:hover { background: var(--accent-dark); }
button.danger { color: var(--bad); }
button.link { border: 0; background: none; color: var(--accent); padding: 0; text-decoration: underline; }
button:disabled { opacity: .5; cursor: not-allowed; }
input, select, textarea { font: inherit; border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; background: #fff; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 3px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }

/* Top bar */
.topbar { background: var(--ink); color: #fff; display: flex; align-items: center; gap: 12px; padding: 10px 18px; }
.topbar a.brand { color: #fff; font-weight: 700; text-decoration: none; display: flex; align-items: center; gap: 8px; }
.topbar a.brand img { width: 26px; height: 26px; }
.topbar .spacer { flex: 1; }
.topbar .who { font-size: 13px; color: #cbd2d9; display: flex; align-items: center; gap: 8px; }
.topbar .who img { width: 26px; height: 26px; border-radius: 50%; }
.topbar button { background: transparent; color: #fff; border-color: #52606d; padding: 4px 10px; }

.page { max-width: 1100px; margin: 0 auto; padding: 20px 18px 60px; }
.card { background: var(--card); border-radius: 10px; padding: 16px; box-shadow: 0 1px 2px #0001; margin-bottom: 16px; }

/* Landing */
.hero { max-width: 560px; margin: 60px auto; text-align: center; }
.hero h1 { font-size: 30px; }
.hero p.lead { font-size: 17px; color: var(--muted); margin-bottom: 24px; }
.hero .signin { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.devlogin { border: 1px dashed var(--warn); border-radius: 8px; padding: 10px; background: var(--warn-soft); }

/* Dashboard */
.tlist { display: grid; gap: 10px; }
.titem { display: flex; align-items: center; gap: 12px; background: #fff; border-radius: 10px; padding: 12px 16px; box-shadow: 0 1px 2px #0001; text-decoration: none; color: var(--ink); }
.titem:hover { box-shadow: 0 2px 6px #0002; }
.badge { font-size: 12px; font-weight: 600; border-radius: 99px; padding: 2px 9px; background: var(--line); color: var(--muted); }
.badge.published { background: var(--good-soft); color: var(--good); }
.badge.live { background: var(--warn-soft); color: var(--warn); }

/* Editor */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 2px solid var(--line); margin-bottom: 18px; }
.tabs a { padding: 8px 12px; text-decoration: none; color: var(--muted); border-bottom: 3px solid transparent; margin-bottom: -2px; font-weight: 600; }
.tabs a.on { color: var(--accent); border-bottom-color: var(--accent); }
.tabs a .n { display: inline-block; width: 20px; height: 20px; border-radius: 50%; background: var(--line); color: var(--muted); font-size: 12px; text-align: center; line-height: 20px; margin-right: 5px; }
.tabs a.on .n { background: var(--accent); color: #fff; }
.savestate { font-size: 13px; color: var(--muted); }
.savestate.error { color: var(--bad); }
.notice { border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; }
.notice.warn { background: var(--warn-soft); color: #78350f; }
.notice.bad { background: var(--bad-soft); color: #7f1d1d; }
.notice.good { background: var(--good-soft); color: #14532d; }
.notice ul { margin: 6px 0 0; padding-left: 20px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 16px; }

.division { border-left: 6px solid var(--line); }
.swatches { display: flex; gap: 4px; }
.swatch { width: 22px; height: 22px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line); padding: 0; }
.swatch.on { box-shadow: 0 0 0 2px var(--ink); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--line); border-radius: 99px; padding: 3px 10px; font-size: 13px; cursor: pointer; user-select: none; }
.chip input { margin: 0; }
.teamrows { display: grid; gap: 6px; margin: 8px 0; }
.teamrow { display: flex; gap: 6px; }
.teamrow input { flex: 1; }
.iconbtn { padding: 4px 9px; }
.breakrow { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; flex-wrap: wrap; }

/* Schedule grid (editor, public page, print) */
.gridwrap { overflow-x: auto; }
table.sched { border-collapse: collapse; width: 100%; min-width: 520px; background: #fff; }
table.sched th, table.sched td { border: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: top; }
table.sched th { background: #f0f2f5; font-size: 13px; }
table.sched td.time { white-space: nowrap; font-weight: 700; width: 1%; }
table.sched td.game { border-left-width: 6px; cursor: default; }
table.sched td.exhibition { background: repeating-linear-gradient(45deg, #fff, #fff 6px, #f3f4f6 6px, #f3f4f6 12px); }
table.sched td.final { background: var(--gold); font-weight: 700; }
table.sched td.empty { color: var(--faint); }
table.sched tr.break td { background: #eef2f7; text-align: center; color: var(--muted); font-style: italic; }
table.sched .tag { display: block; font-size: 11px; color: var(--muted); font-weight: 400; }
table.sched td.mine { outline: 3px solid var(--accent); outline-offset: -3px; }
table.sched td.dim { opacity: .35; }
.editing table.sched td { cursor: pointer; }
.editing table.sched td.time, .editing table.sched tr.break td { cursor: default; }
table.sched td.sel { outline: 3px solid #f59e0b; outline-offset: -3px; }
table.sched td.clash { background: var(--bad-soft) !important; }
table.sched td.target:hover { background: var(--accent-soft); }
.lockmark { float: right; font-size: 12px; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin-top: 8px; }
.legend span { border-left: 6px solid; padding-left: 5px; }
.stats { display: flex; gap: 18px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin: 8px 0; }
.stats b { color: var(--ink); font-size: 15px; }
.toolbar { position: sticky; top: 0; z-index: 2; background: var(--bg); padding: 8px 0; }

/* Share */
.pin { font: 700 34px/1 ui-monospace, monospace; letter-spacing: 6px; }
.qr { width: 180px; height: 180px; }
.qr svg { width: 100%; height: 100%; }
.linkbox { font: 14px ui-monospace, monospace; background: #f0f2f5; padding: 8px 10px; border-radius: 6px; word-break: break-all; }

/* Public page */
.pubhead { background: var(--accent); color: #fff; padding: 18px; }
.pubhead h1 { color: #fff; }
.pubhead .meta { color: var(--accent-soft); }
.announce { background: var(--warn-soft); color: #78350f; padding: 10px 18px; font-weight: 600; }
.mygames { list-style: none; padding: 0; margin: 0; }
.mygames li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.footer { text-align: center; color: var(--faint); font-size: 12px; padding: 20px; }
.print-only { display: none; }

@media print {
  @page { size: landscape; margin: 8mm; }
  body { background: #fff; font-size: 11px; }
  .no-print, .topbar, .toolbar, .footer { display: none !important; }
  .print-only { display: block; }
  .page { max-width: none; padding: 0; }
  .card { box-shadow: none; padding: 0; margin: 0 0 6px; }
  .pubhead { background: none; color: var(--ink); padding: 0 0 6px; }
  .pubhead h1, .pubhead .meta { color: var(--ink); }
  table.sched { min-width: 0; }
  table.sched th, table.sched td { padding: 3px 5px; }
  table.sched td.exhibition { background: none; }
  table.sched td.mine, table.sched td.dim { outline: none; opacity: 1; }
  .gridwrap { overflow: visible; }
}
