/* The [hidden] attribute must always win over component display rules. */
[hidden] { display: none !important; }

/* ============================================================================
 * Wānaka FC Academy — Attendance. Club palette: gold #CAB670, black #231F20.
 * Dark brand chrome + light, high-contrast body for sunlight readability.
 * State colours (present/absent) are semantic green/red for at-a-glance clarity
 * and accessibility (colour + icon), layered over the gold/black identity.
 * ========================================================================== */
:root {
  --gold: #CAB670;
  --gold-deep: #b6a052;
  --ink: #231F20;          /* club black */
  --ink-soft: #3a3536;
  --present: #1f7a3d;
  --present-bg: #e6f4ea;
  --absent: #c0392b;
  --absent-bg: #fdecea;
  --bg: #f6f5f1;           /* warm off-white */
  --card: #ffffff;
  --line: #e3e0d6;
  --muted: #7c766b;
  --radius: 16px;
  --shadow: 0 2px 10px rgba(35,31,32,.06);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink); background: var(--bg);
  font-size: 18px; line-height: 1.4;
  padding-bottom: 120px;
}

/* ---- top bar ---- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  background: var(--ink); color: #fff;
  padding: max(10px, env(safe-area-inset-top)) 14px 10px;
  box-shadow: 0 2px 12px rgba(0,0,0,.25);
}
.brand { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.crest { width: 38px; height: 38px; border-radius: 8px; flex: 0 0 auto; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.brand-name { font-weight: 800; letter-spacing: .06em; font-size: 16px; color: var(--gold); }
.brand-sub { font-size: 12px; color: #cbc7bf; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  background: rgba(255,255,255,.12); color: #fff; border: 0;
  width: 42px; height: 42px; border-radius: 10px; display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.sync { font-size: 12px; font-weight: 700; padding: 6px 10px; border-radius: 20px; white-space: nowrap; }
.sync.ok { background: rgba(202,182,112,.2); color: var(--gold); }
.sync.pending { background: var(--gold); color: var(--ink); }
.sync.offline { background: var(--absent); color: #fff; }

/* ---- layout ---- */
main { padding: 16px; max-width: 640px; margin: 0 auto; }
.view-title { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 4px 2px 12px; font-weight: 700; }
.muted { color: var(--muted); }
.stack > * + * { margin-top: 12px; }
.spacer { height: 16px; }

/* ---- buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 54px; padding: 12px 18px; border-radius: 14px; width: 100%;
  border: 2px solid var(--line); background: var(--card); color: var(--ink);
  font-size: 18px; font-weight: 700; cursor: pointer; transition: transform .05s;
}
.btn.primary { background: var(--gold); border-color: var(--gold); color: var(--ink); }
.btn.dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.ghost { background: transparent; }
.btn.big { min-height: 60px; font-size: 20px; }
.btn:active { transform: translateY(1px) scale(.996); }

/* ---- date bar ---- */
.datebar {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 12px 14px; display: flex; align-items: center; gap: 12px;
}
.datebar .nav { width: 44px; height: 44px; border-radius: 12px; border: 2px solid var(--line); background: #fff; font-size: 22px; cursor: pointer; flex: 0 0 auto; color: var(--ink); }
.datebar .datewrap { flex: 1; text-align: center; }
.datebar .dow { font-weight: 800; font-size: 18px; }
.datebar .full { font-size: 13px; color: var(--muted); }
.datebar input[type=date] { border: 0; background: transparent; text-align: center; font-weight: 700; width: 100%; padding: 2px 0; }

/* ---- group / list tiles ---- */
.tile {
  display: flex; align-items: center; gap: 14px;
  min-height: 68px; padding: 14px 16px; margin-bottom: 12px; width: 100%; text-align: left;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); font-size: 20px; font-weight: 700; cursor: pointer; color: var(--ink);
}
.tile:active { transform: translateY(1px); }
.tile .badge { width: 46px; height: 46px; border-radius: 12px; background: var(--ink); color: var(--gold);
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 15px; flex: 0 0 auto; letter-spacing: .02em; }
.tile .grow { flex: 1; min-width: 0; }
.tile .sub { font-size: 13px; color: var(--muted); font-weight: 600; margin-top: 2px; }
.tile .chev { color: var(--gold-deep); font-size: 24px; flex: 0 0 auto; }
.tile.done .badge { background: var(--present); color: #fff; }

/* ---- player rows ---- */
.player {
  display: flex; align-items: center; gap: 14px;
  min-height: 66px; padding: 12px 16px; margin-bottom: 10px; width: 100%;
  border: 2px solid var(--line); border-radius: var(--radius); background: var(--card);
  box-shadow: var(--shadow); font-size: 20px; font-weight: 700; cursor: pointer; user-select: none; color: var(--ink);
}
.player .mark {
  width: 40px; height: 40px; border-radius: 50%; flex: 0 0 auto; background: #fff;
  display: flex; align-items: center; justify-content: center; border: 2.5px solid var(--line);
}
.player .mark svg { width: 22px; height: 22px; }
.player .name { flex: 1; }
.player .state { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.player.present { border-color: var(--present); background: var(--present-bg); }
.player.present .mark { border-color: var(--present); background: var(--present); color: #fff; }
.player.present .state { color: var(--present); }
.player.absent { border-color: var(--absent); background: var(--absent-bg); }
.player.absent .mark { border-color: var(--absent); background: var(--absent); color: #fff; }
.player.absent .state { color: var(--absent); }

/* ---- inputs ---- */
textarea, input[type=text] {
  width: 100%; font-size: 17px; padding: 12px 14px; border: 2px solid var(--line);
  border-radius: 12px; background: #fff; color: var(--ink); font-family: inherit;
}
textarea { min-height: 76px; resize: vertical; }
label.field { display: block; font-weight: 700; margin: 6px 2px 6px; font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }

/* ---- quick controls on tap screen ---- */
.controls { display: flex; gap: 10px; margin-bottom: 12px; }
.controls .btn { min-height: 44px; font-size: 15px; }

/* ---- fixed action bar ---- */
.action-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; gap: 12px; align-items: stretch;
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
  background: rgba(246,245,241,.94); border-top: 1px solid var(--line);
  backdrop-filter: blur(8px);
}
.count-pill {
  flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-width: 108px; padding: 8px 16px; border-radius: 16px;
  background: var(--ink); color: var(--gold); font-weight: 800; line-height: 1.05;
}
.count-pill small { color: #cbc7bf; font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.count-pill #countNum { font-size: 22px; }
.action-bar .btn { flex: 1; margin: 0; }

/* ---- toast ---- */
.toast {
  position: fixed; left: 50%; bottom: 100px; transform: translateX(-50%);
  background: var(--present); color: #fff; padding: 14px 22px; border-radius: 30px;
  font-weight: 800; z-index: 50; box-shadow: 0 8px 24px rgba(0,0,0,.28);
  opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; max-width: 90%;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-6px); }
.toast.err { background: var(--absent); }

/* ---- history ---- */
.tabbar { display: flex; gap: 8px; margin-bottom: 14px; }
.tabbar button { flex: 1; min-height: 46px; border: 2px solid var(--line); background: #fff; border-radius: 12px; font-weight: 700; font-size: 15px; color: var(--ink); }
.tabbar button.active { background: var(--ink); color: var(--gold); border-color: var(--ink); }
table.grid { width: 100%; border-collapse: collapse; font-size: 15px; }
table.grid th, table.grid td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); }
table.grid th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.bar { height: 8px; border-radius: 6px; background: var(--line); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--present); }
.footer-note { margin-top: 22px; font-size: 13px; color: var(--muted); text-align: center; }
.empty { text-align: center; padding: 30px 16px; color: var(--muted); }
.empty .big { font-size: 15px; font-weight: 700; color: var(--ink); margin-bottom: 6px; }
.linkbtn { background: none; border: 0; color: var(--gold-deep); font-weight: 800; cursor: pointer; text-decoration: underline; font-size: 15px; padding: 0; }
