:root {
  --g950: #0e2116;
  --g900: #14301f;
  --g800: #1b4029;
  --g700: #24563a;
  --g600: #2f6d49;
  --g500: #3d8a5c;
  --g400: #5fa577;
  --g200: #bfdcc5;
  --g100: #e3f1e5;
  --g50:  #f3f8f3;
  --bg: #eaf2eb;
  --card: #ffffff;
  --text: #17251c;
  --muted: #5f7165;
  --line: #d4e2d7;
  --gold: #b8860b;
  --gold-bg: #fff5d6;
  --under: #1d7a3e;
  --over: #b3261e;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 48, 31, .06), 0 6px 18px rgba(20, 48, 31, .07);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
h1, h2, h3, .brand-name, .stat-card .value, .winner .time, .eyebrow {
  font-family: Oswald, system-ui, sans-serif;
  letter-spacing: .01em;
}
h1 { font-size: 2.1rem; margin: 0; line-height: 1.15; color: var(--g900); font-weight: 600; }
h2 { font-size: 1.4rem; margin: 0 0 .5rem; color: var(--g900); font-weight: 600; }
h3 { font-size: 1.15rem; margin: 0 0 .6rem; color: var(--g800); font-weight: 600; }
a { color: var(--g600); }
p { margin: 0 0 .75rem; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.strong { font-weight: 700; }

/* ---------- header ---------- */
.site-header {
  background: linear-gradient(135deg, var(--g950), var(--g700));
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: 0 2px 12px rgba(0, 0, 0, .18);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px 20px; min-height: 66px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; }
.brand svg { width: 36px; height: 36px; flex: none; }
.brand-name { display: block; font-size: 1.35rem; font-weight: 600; line-height: 1.1; }
.brand small { display: block; color: var(--g200); font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; }
.nav { display: flex; gap: 4px; background: rgba(0, 0, 0, .2); padding: 4px; border-radius: 999px; }
.nav a { color: #d4eadb; text-decoration: none; padding: 7px 16px; border-radius: 999px; font-weight: 600; font-size: .95rem; white-space: nowrap; }
.nav a:hover { color: #fff; background: rgba(255, 255, 255, .08); }
.nav a.active { background: #fff; color: var(--g800); }
.nav a.nav-icon { display: inline-flex; align-items: center; justify-content: center; padding: 7px 12px; }

main { padding-top: 22px; padding-bottom: 32px; min-height: 60vh; }
.loading { padding: 60px 0; text-align: center; color: var(--muted); }

/* ---------- page head ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px 16px; flex-wrap: wrap; margin-bottom: 18px; }
.eyebrow { margin: 0; text-transform: uppercase; letter-spacing: .14em; font-size: .78rem; color: var(--g500); font-weight: 600; }
.back { display: inline-block; margin-bottom: 8px; text-decoration: none; font-weight: 600; font-size: .92rem; }
.back:hover { text-decoration: underline; }
.section-title { margin-top: 28px; }

/* ---------- cards & layout ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  min-width: 0;
}
.stack { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.two-col { display: grid; grid-template-columns: minmax(260px, 380px) 1fr; gap: 16px; align-items: start; margin-bottom: 16px; }
.two-col.even { grid-template-columns: 1fr 1fr; }
.stage-layout { display: grid; grid-template-columns: 1.5fr 1fr; gap: 16px; align-items: start; margin-bottom: 16px; }
.grid { display: grid; gap: 16px; }
.grid.items { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.grid.items.wide { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.grid.winners { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.grid.results { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.row-between h3 { margin: 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions.center { justify-content: center; }
.form-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 16px 0; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: 10px; border: 1px solid var(--line);
  background: #fff; color: var(--g800); font: inherit; font-weight: 600; font-size: .95rem;
  text-decoration: none; cursor: pointer; transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--g50); border-color: var(--g200); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--g600); border-color: var(--g600); color: #fff; }
.btn.primary:hover { background: var(--g700); }
.btn.block { width: 100%; padding: 12px; font-size: 1rem; }
.btn.sm { padding: 6px 11px; font-size: .85rem; border-radius: 8px; }
.btn.icon { width: 40px; padding: 8px 0; font-size: 1.3rem; line-height: 1; }
.btn.danger-outline { color: var(--over); border-color: #f0c9c6; }
.btn.danger-outline:hover { background: #fdf0ef; border-color: var(--over); }
.icon-btn {
  border: 0; background: transparent; color: var(--muted); font-size: 1.25rem; line-height: 1;
  width: 28px; height: 28px; border-radius: 6px; cursor: pointer;
}
.icon-btn:hover { background: #fdf0ef; color: var(--over); }

/* ---------- forms ---------- */
label { display: block; font-weight: 600; font-size: .88rem; color: var(--g800); margin-bottom: 12px; }
input, textarea, select {
  display: block; width: 100%; margin-top: 5px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--g50);
  font: inherit; font-weight: 400; color: var(--text);
}
input:focus, textarea:focus { outline: none; border-color: var(--g500); background: #fff; box-shadow: 0 0 0 3px rgba(61, 138, 92, .18); }
textarea { resize: vertical; }
/* iPhone Safari gives date boxes a built-in minimum width that ignores width: 100%, so they poke
   past their card. Drop the native styling, then restore height and left alignment it removes. */
input[type="date"] {
  -webkit-appearance: none; appearance: none;
  min-width: 0; max-width: 100%;
  min-height: 46px; line-height: 1.3; text-align: left;
}
input[type="date"]::-webkit-date-and-time-value { text-align: left; margin: 0; }
input[type="date"]::-webkit-calendar-picker-indicator { margin-left: auto; }
input[type="range"] { padding: 0; background: none; border: 0; accent-color: var(--g600); box-shadow: none; margin: 0; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.form-row.three { grid-template-columns: 1fr 1fr 1fr; }
.record-form { border-top: 4px solid var(--g500); }
.hint { color: var(--muted); font-size: .88rem; margin: 6px 0 10px; }

select {
  appearance: none; -webkit-appearance: none; padding-right: 36px;
  background: var(--g50) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%232f6d49' stroke-width='2'/%3E%3C/svg%3E") no-repeat right 12px center;
}

/* ---------- record form: penalties ---------- */
.pen-grid { border: 1px solid var(--line); border-radius: 12px; padding: 6px 14px 4px; margin: 0 0 14px; display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.pen-grid legend { font-weight: 700; font-size: .88rem; color: var(--g800); padding: 0 6px; }
.pen-grid legend a { font-weight: 600; margin-left: 6px; }
.pen { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--g100); }
.pen-label { font-weight: 600; font-size: .9rem; line-height: 1.2; }
.pen-label small { display: block; font-weight: 500; color: var(--muted); font-size: .76rem; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; flex: none; }
.stepper input { width: 42px; margin: 0; border: 0; border-radius: 0; text-align: center; padding: 8px 0; background: #fff; font-weight: 700; -moz-appearance: textfield; }
.stepper input::-webkit-inner-spin-button, .stepper input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.stepper input:focus { box-shadow: none; }
.step { border: 0; background: var(--g50); color: var(--g700); width: 38px; height: 38px; font-size: 1.25rem; font-weight: 700; cursor: pointer; }
.step:hover { background: var(--g100); }
.final-line { min-height: 1.5em; margin: 0 0 12px; font-size: 1rem; }
.final-line strong { font-family: Oswald, system-ui, sans-serif; font-size: 1.3rem; color: var(--g800); }
.pen-note { display: block; font-size: .74rem; font-weight: 500; color: var(--over); white-space: nowrap; }
.winner .pen-note { color: #8a6d10; }

/* ---------- settings ---------- */
.settings-card { max-width: 720px; }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0 16px; margin: 14px 0 4px; }
.input-suffix { display: flex; align-items: center; gap: 8px; }
.input-suffix input { flex: 1; }
.input-suffix span { color: var(--muted); font-weight: 600; margin-top: 5px; }
.range-row input.deg { width: 64px; flex: none; margin: 0; padding: 6px 8px; text-align: right; }

/* ---------- tables ---------- */
.table { width: 100%; border-collapse: collapse; font-size: .93rem; }
.table th { text-align: left; font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; padding: 6px 8px; border-bottom: 2px solid var(--line); }
.table td { padding: 8px; border-bottom: 1px solid var(--g100); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .rank { width: 34px; text-align: center; font-weight: 700; color: var(--muted); }
.table tr.first td { background: var(--gold-bg); }
.table a { text-decoration: none; white-space: nowrap; }
.scroll { max-height: 420px; overflow: auto; }
.count { background: var(--g100); color: var(--g700); font-size: .8rem; padding: 2px 9px; border-radius: 999px; vertical-align: middle; font-family: system-ui, sans-serif; }
.vs { font-weight: 700; font-variant-numeric: tabular-nums; }
.vs.under { color: var(--under); }
.vs.over { color: var(--over); }

/* ---------- pills, tags, chips ---------- */
.pill { display: inline-block; background: var(--g100); color: var(--g700); font-weight: 700; font-size: .8rem; padding: 3px 10px; border-radius: 999px; }
.pill.danger { background: #fdecea; color: var(--over); }
.kind { display: inline-block; font-size: .7rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; padding: 3px 8px; border-radius: 6px; }
.kind.drill { background: var(--g100); color: var(--g700); }
.kind.stage { background: #e6eef6; color: #2f5d8a; }
.tag { display: inline-block; font-weight: 800; font-size: .8rem; padding: 2px 9px; border-radius: 999px; color: #fff; background: var(--g800); }
.tag-steel { background: #455a64; }
.tag-box { background: #8a6d45; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 18px; }
.chip { background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; font-size: .85rem; text-decoration: none; color: var(--g700); font-weight: 600; }
.chip:hover { border-color: var(--g400); }
.chip.active { background: var(--g600); border-color: var(--g600); color: #fff; }

/* ---------- stats ---------- */
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.stats-row.tight { grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; min-width: 0;
}
.stat-card .value { font-size: 1.8rem; font-weight: 600; color: var(--g800); line-height: 1.15; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat-card .value small { font-size: .55em; margin-left: 2px; color: var(--muted); }
.stat-card .label { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; }
.stat-card.accent { background: linear-gradient(135deg, var(--g700), var(--g500)); border-color: transparent; }
.stat-card.accent .value, .stat-card.accent .value small, .stat-card.accent .label { color: #fff; }
.stat-card.gold { background: var(--gold-bg); border-color: #f0dc9c; }
.stat-card.gold .value { font-size: 1.35rem; color: #6d5208; }

/* ---------- day view ---------- */
.day-nav { display: flex; gap: 8px; align-items: center; }
.day-nav input { margin: 0; width: auto; background: #fff; }
.winner-card { display: flex; flex-direction: column; gap: 6px; text-decoration: none; color: inherit; transition: transform .15s, box-shadow .15s; }
a.winner-card:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(20, 48, 31, .12); }
.winner-card .kind { align-self: flex-start; }
.winner-card h3 { margin: 2px 0 0; }
.winner { display: flex; align-items: center; gap: 12px; background: var(--gold-bg); border-radius: 10px; padding: 10px 12px; }
.trophy { font-size: 1.9rem; }
.winner .who { font-weight: 700; color: #5e4708; }
.winner .time { font-size: 1.9rem; font-weight: 600; color: var(--g900); line-height: 1; }
.winner .time small { font-size: .5em; margin-left: 2px; color: var(--muted); }
.par-line { font-size: .88rem; color: var(--muted); }
.result-head { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.result-head h3 a { text-decoration: none; color: inherit; }
.result-head h3 a:hover { color: var(--g600); }

/* ---------- item cards ---------- */
.item-card { display: flex; gap: 14px; text-decoration: none; color: inherit; transition: transform .15s, box-shadow .15s; align-items: center; }
.item-card:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(20, 48, 31, .12); }
.item-card h3 { margin-bottom: 6px; }
.item-body { min-width: 0; flex: 1; }
.meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; color: var(--muted); font-size: .88rem; margin-bottom: 8px; }
.best { font-size: .9rem; font-weight: 600; color: var(--g800); }
.thumb { flex: none; }
.target-thumb { width: 70px; background: var(--g50); border-radius: 10px; padding: 6px; }
.stage-card { flex-direction: column; align-items: stretch; }
.stage-card .thumb { border-radius: 10px; overflow: hidden; }

/* ---------- target ---------- */
.target-svg { display: block; width: 100%; height: auto; user-select: none; -webkit-user-select: none; }
.target-card { background: linear-gradient(180deg, #f6faf6, #e5efe7); }
.target-card .target-svg, .target-editor .target-svg { max-width: 340px; margin: 0 auto; }
.target-svg.editable { cursor: crosshair; touch-action: manipulation; }
.target-svg.editable .mark { cursor: pointer; }
.target-svg.editable .mark:hover path:last-of-type { stroke: #ff5252; }
.mark-num { font: 700 11px sans-serif; fill: #b71c1c; paint-order: stroke; stroke: #fff; stroke-width: 3px; }
.target-editor { position: sticky; top: 84px; }
.targets { display: grid; grid-template-columns: repeat(var(--cols, 1), minmax(0, 1fr)); gap: 14px; align-items: end; }
.tgt { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; }
.tgt figcaption { display: flex; align-items: center; gap: 6px; font-size: .8rem; color: var(--muted); font-weight: 600; min-height: 28px; }
.tgt-label { background: var(--g800); color: #fff; font-weight: 800; font-size: .75rem; letter-spacing: .04em; padding: 2px 9px; border-radius: 999px; }
.tgt figcaption .icon-btn { width: 28px; height: 28px; font-size: 1.15rem; }
.tgt-dist { font-weight: 800; color: var(--g800); font-size: .8rem; }
.tgt-dist-input { display: flex; align-items: center; gap: 4px; margin: 0; font-size: .8rem; color: var(--muted); font-weight: 700; }
.tgt-dist-input input { width: 58px; margin: 0; padding: 6px 6px; text-align: center; font-weight: 700; }
.targets .target-svg { width: 100%; max-width: 340px; }
.target-card.multi { margin-bottom: 16px; }
.target-card.multi .target-svg { max-width: 260px; }
.target-card.multi .hint { margin: 10px 0 0; }
.target-thumb.multi { width: auto; }
.target-thumb.multi .targets { gap: 4px; }
.target-thumb.multi .tgt { width: 36px; }
.target-thumb.multi .mark-body { transform: scale(2); }
.target-editor button:disabled { opacity: .45; cursor: not-allowed; }
.instructions { line-height: 1.6; }

/* ---------- stage / bay ---------- */
.bay { display: block; width: 100%; height: auto; border-radius: 8px; user-select: none; -webkit-user-select: none; }
.bay-card { padding: 10px; }
.bay .hit { fill: transparent; }
.bay .sel { fill: none; stroke: #ffd43b; stroke-width: 2; stroke-dasharray: 4 3; }
.bay.editing { touch-action: none; }
.bay.editing .obj { cursor: grab; }
.bay.editing .obj:active { cursor: grabbing; }
.bay.clickable .obj { cursor: pointer; }
.callout { background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--g500); border-radius: 10px; padding: 10px 14px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; min-height: 46px; }
.target-table tr[data-id] { cursor: pointer; }
.target-table tr[data-id]:hover td { background: var(--g50); }
.target-table tr.hl td { background: #fff7d1; }
ul.plain { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }

.palette { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 16px 0; padding: 12px; }
.palette-title { font-weight: 700; color: var(--muted); font-size: .85rem; text-transform: uppercase; letter-spacing: .08em; margin-right: 4px; }
.tool {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px;
  border: 1px solid var(--line); background: var(--g50); border-radius: 10px;
  font: inherit; font-weight: 600; font-size: .9rem; color: var(--g800); cursor: pointer;
}
.tool:hover { border-color: var(--g400); background: #fff; }
.tool svg { display: block; }
.draw-tool[aria-pressed="true"] { background: var(--g600); border-color: var(--g600); color: #fff; }
.bay.drawing, .bay.drawing .obj { cursor: crosshair; }
.field { margin-bottom: 12px; }
.field-label { display: block; font-weight: 600; font-size: .88rem; color: var(--g800); margin-bottom: 6px; }
.swatches { display: flex; gap: 8px; }
.swatch { width: 32px; height: 32px; border-radius: 50%; border: 2px solid rgba(0, 0, 0, .25); cursor: pointer; padding: 0; }
.swatch.on { box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--g600); }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg-btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; min-height: 40px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--g50);
  font: inherit; font-weight: 600; font-size: .88rem; color: var(--g800); cursor: pointer;
}
.seg-btn.on { border-color: var(--g600); background: #fff; box-shadow: 0 0 0 2px var(--g600); }
.box-swatch { display: inline-block; width: 16px; height: 16px; border: 2.5px solid; border-radius: 3px; flex: none; outline: 1px solid rgba(0, 0, 0, .25); background-color: #c9ad84; }
.map-key { display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 8px 4px 0; font-size: .82rem; font-weight: 600; color: var(--muted); }
.map-key > span { display: inline-flex; align-items: center; gap: 6px; }
.tag-box.moving { background: #d93636; }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 600; }
label.check input { width: auto; margin: 0; accent-color: var(--g600); }
.stage-editor { display: grid; grid-template-columns: 1fr 300px; gap: 16px; align-items: start; }
.props { position: sticky; top: 84px; }
.range-row { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.range-row input { flex: 1; }
.range-row .val { font-weight: 600; font-size: .85rem; color: var(--muted); min-width: 46px; text-align: right; }
.legend { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.legend li { display: flex; align-items: center; gap: 10px; font-size: .9rem; }

/* ---------- empty / footer / toast ---------- */
.empty { text-align: center; padding: 40px 20px; }
.empty-icon { font-size: 2.6rem; margin-bottom: 6px; }
.empty p { color: var(--muted); }
.site-footer { padding-bottom: 30px; }
.mode-banner {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--g100); border: 1px solid var(--g200); color: var(--g800);
  border-radius: 12px; padding: 12px 16px; font-size: .9rem;
}
.mode-banner.error { background: #fdecea; border-color: #f4c3be; color: var(--over); }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px);
  background: var(--g900); color: #fff; padding: 12px 20px; border-radius: 12px;
  font-weight: 600; box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 50;
  width: max-content; max-width: calc(100% - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .two-col, .two-col.even, .stage-layout, .stage-editor { grid-template-columns: 1fr; }
  .target-editor, .props { position: static; }
  .grid.results { grid-template-columns: 1fr; }
}
/* ---------- shooter history ---------- */
.shooter-link { color: inherit; text-decoration: none; border-bottom: 1px dotted var(--g400); }
.shooter-link:hover { color: var(--g600); border-bottom-style: solid; }
.history-head { align-items: flex-end; }
.who-label { margin: 0; min-width: 220px; }
.history-stats { margin-bottom: 4px; }
.progress-grid { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); margin-bottom: 16px; }
.progress-card { display: flex; flex-direction: column; gap: 10px; }
.progress-card .result-head h3 { margin: 0; }
.progress-card .result-head h3 a { color: inherit; text-decoration: none; }
.progress-card p { margin: 0; }
.trend { font-weight: 700; font-size: .9rem; }
.trend.up { color: var(--under); }
.trend.down { color: var(--over); }
.trend.flat { color: var(--muted); font-weight: 600; }
.mini-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; background: var(--g50); border-radius: 10px; padding: 10px; }
.mini-stats > div { display: flex; flex-direction: column; min-width: 0; }
.mini-stats .label { font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.mini-stats .value { font-family: Oswald, system-ui, sans-serif; font-size: 1.25rem; font-weight: 600; color: var(--g900); white-space: nowrap; }
.mini-stats .value small { font-family: system-ui, sans-serif; font-size: .7rem; color: var(--muted); font-weight: 600; }
.chart-caption { font-size: .78rem; color: var(--muted); font-weight: 600; margin-bottom: -6px; }
.trend-chart { position: relative; width: 100%; min-height: 180px; touch-action: pan-y; }
.trend-chart svg { display: block; overflow: visible; }
.trend-chart .grid line { stroke: #e3ece5; stroke-width: 1; }
.trend-chart .axis text { font: 11px system-ui, sans-serif; fill: var(--muted); font-variant-numeric: tabular-nums; }
.trend-chart .par-line { stroke: var(--gold); stroke-width: 1.5; }
.trend-chart .par-label { font: 700 11px system-ui, sans-serif; fill: #6d5208; }
.trend-chart .trend-line { fill: none; stroke: var(--g600); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.trend-chart .trend-dot { fill: var(--g600); stroke: #fff; stroke-width: 2; }
.trend-chart .trend-dot.on { r: 6.5; }
.trend-chart .pb-label { font: 700 11px system-ui, sans-serif; fill: var(--text); }
.trend-chart .crosshair { stroke: var(--g400); stroke-width: 1; }
.trend-chart .hover-zone { fill: transparent; cursor: crosshair; }
.chart-tip {
  position: absolute; pointer-events: none; z-index: 2;
  display: flex; flex-direction: column; gap: 1px;
  background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px;
  box-shadow: 0 6px 18px rgba(20, 48, 31, .14); font-size: .8rem; white-space: nowrap;
}

.update-bar {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60;
  display: flex; align-items: center; gap: 12px; width: max-content; max-width: calc(100% - 32px);
  background: var(--g900); color: #fff; padding: 10px 12px 10px 16px; border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .25); font-weight: 600; font-size: .92rem;
}
.update-bar .btn { background: #fff; color: var(--g800); border-color: #fff; }

/* ---------- gun filter, scoring ---------- */
.div-chips { margin: -6px 0 16px; }
button.chip { font: inherit; font-size: .85rem; font-weight: 600; cursor: pointer; }
.pen-note.hf-note { color: var(--muted); }
.scoring-note { font-size: .88rem; color: var(--g800); background: var(--g100); border-radius: 10px; padding: 8px 12px; }
.pf-row select { width: auto; margin: 0; padding: 8px 32px 8px 10px; }
.link-btn { border: 0; background: none; padding: 0; font: inherit; font-weight: 700; color: var(--g600); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }

/* ---------- home: range day card ---------- */
.day-links { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.range-day-card { margin-bottom: 16px; border-left: 5px solid var(--g500); display: flex; flex-direction: column; gap: 10px; }
.range-day-card.today { border-left-color: var(--gold); background: linear-gradient(90deg, var(--gold-bg), #fff 60%); }
.rd-head { display: flex; align-items: center; gap: 12px; }
.rd-icon { font-size: 1.8rem; }
.rd-title { flex: 1; min-width: 0; }
.rd-title h3 { margin: 0; }
.rd-note { margin: 0; }
.rd-items { display: flex; flex-wrap: wrap; gap: 6px; }
.range-day-card .btn.primary { align-self: flex-start; }

/* ---------- range day plan ---------- */
.plan-intro { margin-top: -6px; max-width: 720px; }
.plan-page { max-width: 720px; }
.plan-list { list-style: none; counter-reset: plan; margin: 0 0 10px; padding: 0; }
.plan-list li { counter-increment: plan; display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--g100); }
.plan-list li::before { content: counter(plan); font-weight: 800; color: #fff; background: var(--g700); border-radius: 999px; min-width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center; font-size: .78rem; }
.plan-name { flex: 1; font-weight: 600; min-width: 0; }
.plan-btns { display: inline-flex; gap: 2px; }
.plan-btns .icon-btn { color: var(--g700); font-size: 1.05rem; }
.plan-btns .icon-btn:disabled { opacity: .3; cursor: default; background: none; }
.plan-add { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 8px; }

/* ---------- record: plan progress & shooting order ---------- */
.plan-box { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line); display: flex; flex-direction: column; gap: 8px; }
.plan-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; font-weight: 700; color: var(--g800); }
.order-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.order-chip.done { background: var(--g100); border-color: var(--g200); color: var(--g700); }
.order-chip.active { background: var(--g600); border-color: var(--g600); color: #fff; }

/* ---------- goals ---------- */
.goal { background: #fff; border: 1px dashed var(--g200); border-radius: 10px; padding: 8px 10px; }
.goal-line-text { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: .88rem; }
.goal-met { color: var(--under); font-weight: 700; }
.goal-bar { height: 6px; background: var(--g100); border-radius: 999px; margin-top: 6px; overflow: hidden; }
.goal-bar span { display: block; height: 100%; background: var(--g500); border-radius: 999px; }
.goal-form { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.goal-form input { width: 110px; margin: 0; padding: 8px 10px; }
.trend-chart .goal-line { stroke: var(--g400); stroke-width: 1.5; }
.trend-chart .goal-label { font: 700 11px system-ui, sans-serif; fill: var(--g700); }

/* ---------- standings ---------- */
ol.improved { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 8px; }
ol.improved li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
ol.improved li::marker { font-weight: 800; color: var(--g700); }

/* ---------- dry fire timer ---------- */
.dry-banner { background: #fff4d6; border: 2px solid #e0b12b; color: #5e4708; border-radius: 12px; padding: 10px 14px; margin-bottom: 16px; font-size: .95rem; }
.timer-page { display: grid; grid-template-columns: 1.2fr 1fr; gap: 16px; align-items: start; }
.timer-card { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 28px 18px; transition: background .12s; }
.timer-display { font-family: Oswald, system-ui, sans-serif; font-weight: 600; font-size: clamp(4rem, 18vw, 7.5rem); line-height: 1; color: var(--g900); font-variant-numeric: tabular-nums; }
.timer-status { font-weight: 700; color: var(--muted); min-height: 1.5em; }
.timer-start { min-width: 200px; min-height: 64px !important; font-size: 1.35rem; border-radius: 16px; }
.timer-card.flash-start { background: #d6f5dd; }
.timer-card.flash-par { background: #ffe9b8; }

/* ---------- settings: gun types ---------- */
.settings-page { max-width: 720px; }
.gun-list { list-style: none; margin: 8px 0 12px; padding: 0; }
.gun-list li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--g100); font-weight: 600; }
.gun-add { display: flex; gap: 8px; }
.gun-add input { margin: 0; flex: 1; }

/* ---------- admin ---------- */
.admin-signin { max-width: 460px; }
.form-error { color: var(--over); font-weight: 600; margin: 0 0 10px; }
code.uid { display: inline-block; background: var(--g50); border: 1px solid var(--line); border-radius: 6px; padding: 2px 6px; font-size: .85em; word-break: break-all; user-select: all; }
.admin-event { margin-bottom: 16px; }
.admin-day-note { align-self: center; font-size: .9rem; color: var(--muted); padding-top: 10px; }
.admin-summary { display: flex; flex-wrap: wrap; gap: 6px; }
.admin-table th.center, .admin-table td.center { text-align: center; }
.admin-table tr.warn td { background: #fff4e5; }
.warn-text { color: #a1520b !important; font-weight: 700; }
.check-cell { display: inline-flex; flex-direction: column; align-items: center; gap: 2px; margin: 0; cursor: pointer; }
.check-cell input { width: 26px; height: 26px; margin: 0; accent-color: var(--g600); cursor: pointer; }
.admin-actions { margin-top: 12px; }
.row-btns { white-space: nowrap; }
.row-btns .icon-btn[data-edit-member] { color: var(--g700); font-size: 1.1rem; }
.rename-form { display: flex; gap: 6px; align-items: center; }
.rename-form input { margin: 0; flex: 1; min-width: 0; }
tr.editing td { background: var(--g50); }
tr.editing p { margin: 6px 0 0; }
.admin-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; padding: 4px 2px 0; }
.admin-link { font-size: .82rem; color: var(--muted); text-decoration: none; }
.admin-link:hover { color: var(--g700); text-decoration: underline; }
.admin-line { font-size: .88rem; font-weight: 600; text-decoration: none; color: var(--g800); background: var(--g100); border-radius: 8px; padding: 6px 10px; align-self: flex-start; }

/* ---------- video tutorials ---------- */
.videos { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.video { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.video .video-thumb, .video iframe { width: 100%; aspect-ratio: 16 / 9; border: 0; border-radius: 10px; display: block; }
.video.short .video-thumb, .video.short iframe { aspect-ratio: 9 / 16; width: min(100%, 260px); margin: 0 auto; }
.video-thumb { position: relative; background: #000 center / cover no-repeat; cursor: pointer; padding: 0; }
.video-thumb .play {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 64px; height: 46px; border-radius: 12px; background: rgba(204, 0, 0, .92); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 1.3rem; box-shadow: 0 4px 14px rgba(0, 0, 0, .35);
}
.video-thumb:hover .play { background: #e00; }
.video a { align-self: flex-end; }
.video-fields { margin: 4px 0 12px; }
.video-rows { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.video-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 6px; align-items: center; }
.video-row input { margin: 0; }
.video-row input.bad { border-color: var(--over); }
.video-status { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; font-size: .82rem; font-weight: 600; color: var(--g700); min-height: 0; }
.video-status:empty { display: none; }
.video-status img { width: 64px; height: 36px; object-fit: cover; border-radius: 4px; }
.clip-badge { position: absolute; left: 8px; bottom: 8px; background: rgba(0, 0, 0, .78); color: #fff; font-size: .76rem; font-weight: 700; padding: 3px 8px; border-radius: 6px; }
.clip-fields { grid-column: 1 / -1; display: flex; gap: 8px; }
.clip-fields label { display: flex; align-items: center; gap: 6px; margin: 0; font-size: .82rem; font-weight: 600; color: var(--muted); }
.clip-fields input { width: 84px; margin: 0; padding: 8px 10px; }
.clip-fields input.bad { border-color: var(--over); }
.vid-pill { color: #b00 !important; font-weight: 700; }

/* ---------- tools ---------- */
.tools-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.tool-card { display: flex; gap: 14px; align-items: flex-start; text-decoration: none; color: inherit; transition: transform .15s, box-shadow .15s; }
.tool-card:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(20, 48, 31, .12); }
.tool-card h3 { margin-bottom: 4px; }
.tool-card p { margin: 0; font-size: .92rem; }
.tool-icon { font-size: 2rem; line-height: 1; }
.tool-form { max-width: 820px; margin-bottom: 16px; }
.tool-results { max-width: 820px; display: flex; flex-direction: column; gap: 16px; }
.zero-stats { margin: 0; }
.zero-targets { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.zero-target { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; }
.zero-target figcaption { font-weight: 800; font-size: .85rem; color: var(--g800); }
.zero-target svg { width: 100%; height: auto; border-radius: 8px; border: 1px solid var(--line); display: block; }
.zero-target .off-arrow { font: 700 13px system-ui, sans-serif; }
.zero-readout { display: flex; flex-direction: column; align-items: center; font-size: .78rem; font-weight: 700; color: var(--text); text-align: center; line-height: 1.3; }
.swatch-text { display: inline-flex; align-items: center; gap: 5px; font-weight: 700; }
.swatch-text::before { content: ''; width: 14px; height: 0; border-top: 3px solid var(--c); flex: none; }
.swatch-text.dashed::before { border-top-style: dashed; }
.compare-note { display: flex; flex-direction: column; gap: 4px; font-size: .9rem; }
.path-chart { min-height: 220px; }
.path-chart .los-line { stroke: #8a9a8f; stroke-width: 1.5; }
.path-chart .los-label { font: 600 11px system-ui, sans-serif; fill: var(--muted); }
.path-chart .end-label { font: 700 11px system-ui, sans-serif; fill: var(--text); paint-order: stroke; stroke: #fff; stroke-width: 3px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .82rem; font-weight: 600; color: var(--muted); margin-top: 6px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.bal-table td, .bal-table th { white-space: nowrap; }
.bal-table td.subsonic { color: #a1520b; }
.tool-note { max-width: 820px; margin: 0; }

/* ---------- shared bits used by the phone layout ---------- */
.tabbar, .header-settings, .mobile-only { display: none; }
.big-input { font-family: Oswald, system-ui, sans-serif; font-size: 1.6rem !important; font-weight: 600; padding: 8px 12px; letter-spacing: .02em; }
.table .sub { display: block; font-size: .78rem; color: var(--muted); font-weight: 400; }
.record-form { scroll-margin-top: 80px; }
.record-page { max-width: 640px; display: flex; flex-direction: column; gap: 16px; }
.item-info { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; font-size: .9rem; color: var(--muted); }
.item-info a { margin-left: auto; font-weight: 600; text-decoration: none; }
.pick-card label { margin-bottom: 10px; }
.mini-title { margin: 16px 0 6px; font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.entry-list { list-style: none; margin: 0; padding: 0; }
.entry-list li { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--g100); }
.entry-list li:last-child { border-bottom: 0; }
.entry-list .who { flex: 1; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry-list .t { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- phones ---------- */
@media (max-width: 720px) {
  body { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }

  /* compact top bar; main navigation moves to the bottom tab bar */
  .site-header { position: sticky; top: 0; padding-top: env(safe-area-inset-top); }
  .header-inner { min-height: 54px; flex-wrap: nowrap; padding-top: 0; padding-bottom: 0; }
  .brand svg { width: 28px; height: 28px; }
  .brand-name { font-size: 1.12rem; }
  .brand small { font-size: .64rem; }
  .nav { display: none; }
  .header-settings { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; margin-right: -8px; border-radius: 12px; color: #d4eadb; }
  .header-settings.active { background: rgba(255, 255, 255, .14); color: #fff; }

  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr);
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: rgba(255, 255, 255, .97); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid var(--line); box-shadow: 0 -4px 16px rgba(20, 48, 31, .08);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .tabbar a {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    min-height: 60px; color: var(--muted); text-decoration: none; font-size: .7rem; font-weight: 700;
    -webkit-tap-highlight-color: transparent;
  }
  .tabbar svg { width: 25px; height: 25px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
  .tabbar a.active { color: var(--g600); }
  .tab-record-btn {
    display: flex; align-items: center; justify-content: center; width: 54px; height: 54px; margin-top: -24px;
    border-radius: 50%; background: linear-gradient(135deg, var(--g700), var(--g500)); color: #fff;
    box-shadow: 0 6px 16px rgba(31, 90, 55, .4); border: 4px solid #fff;
  }
  .tab-record-btn svg { width: 26px; height: 26px; stroke-width: 2.2; }
  .tabbar a.tab-record.active { color: var(--g700); }

  main { padding-top: 16px; }
  h1 { font-size: 1.55rem; }
  .page-head { margin-bottom: 14px; }
  .page-head .actions .btn.primary { order: -1; }
  .mobile-only { display: inline-flex; }
  .card { padding: 14px; }
  .grid.items, .grid.items.wide { grid-template-columns: 1fr; }
  .form-row, .form-row.three { grid-template-columns: 1fr; }
  .form-row.three { grid-template-columns: 1fr 1fr 1fr; gap: 0 8px; }
  .day-nav { width: 100%; }
  .day-nav input { flex: 1; }
  .stat-card { padding: 12px; }
  .stat-card .value { font-size: 1.45rem; }
  .stats-row { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .stats-row .stat-card .label { font-size: .66rem; }
  .stats-row .stat-card.gold { grid-column: 1 / -1; }

  /* thumb-sized controls */
  input, select, textarea { padding: 12px; font-size: 16px; } /* 16px stops iOS from zooming in */
  .btn { min-height: 44px; }
  .btn.sm { min-height: 38px; }
  .icon-btn { width: 40px; height: 40px; font-size: 1.4rem; }
  .pen-grid { grid-template-columns: 1fr; padding: 4px 12px 2px; }
  .step { width: 48px; height: 46px; font-size: 1.4rem; }
  .stepper input { width: 46px; font-size: 1.1rem; }
  .record-form .btn.block { min-height: 52px; font-size: 1.05rem; }

  .table { font-size: .88rem; }
  .table td, .table th { padding: 8px 3px; }
  .table .rank { width: 28px; }
  .table .pen-note { white-space: normal; }
  .scroll { max-height: none; }
  .toast { bottom: calc(84px + env(safe-area-inset-bottom)); }
  .update-bar { bottom: calc(80px + env(safe-area-inset-bottom)); }
  .site-footer { padding-bottom: 12px; }
  .target-card .target-svg { max-width: 240px; }
  .targets { grid-template-columns: repeat(var(--cols-sm, 1), minmax(0, 1fr)); gap: 8px; }
  .tgt figcaption small { display: none; }
  .timer-page { grid-template-columns: 1fr; }
  .zero-targets { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .bal-table { font-size: .82rem; }
  .timer-start { width: 100%; }
  .day-links .btn { flex: 1; }
  .tgt-dist-input input { width: 52px; padding: 8px 4px; }
  .targets.multi .mark-body { transform: scale(1.7); } /* small targets: keep X's and shot numbers readable */
  .history-head .who-label { width: 100%; }
  .progress-grid { grid-template-columns: 1fr; }
  .history-stats { grid-template-columns: repeat(2, 1fr); }
  .mini-stats .value { font-size: 1.1rem; }
}
