:root {
  --navy: #1e5631;   /* main brand colour: header, buttons, big numbers (infield green) */
  --green: #2e7d32;
  --red: #c62828;
  --amber: #e08c00;
  --gray-bg: #f4f6f8;
  --border: #dbe1e8;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--gray-bg);
  color: #1e2430;
}

.container { max-width: 1000px; margin: 0 auto; padding: 0 1.25rem; }

.topbar { background: var(--navy); color: #fff; padding-top: env(safe-area-inset-top); }
@media (display-mode: standalone) { body { -webkit-tap-highlight-color: transparent; } }
.topbar-inner {
  max-width: 1000px; margin: 0 auto; padding: 0.75rem 1.25rem;
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .5rem;
}
.brand { color: #fff; font-weight: 700; text-decoration: none; font-size: 1.1rem; }
.topbar nav a { color: #e4efe6; text-decoration: none; margin-left: 1rem; font-size: 0.92rem; }
.topbar nav a:hover { color: #fff; text-decoration: underline; }
.topbar .who { color: #b4cdb9; margin-left: 1rem; font-size: 0.9rem; }

main.container { padding-top: 1.5rem; padding-bottom: 3rem; }

h1 { margin-top: 0; }

.hero { text-align: center; padding: 3rem 1rem; }
.hero-text { max-width: 36rem; margin: 0.5rem auto 0; font-size: 1.05rem; color: #3a4252; }
.hero-contact { margin-top: 1.5rem; }
.hero-contact a { color: var(--navy); }
.hero-actions { margin-top: 1.5rem; display: flex; gap: 1rem; justify-content: center; }

.card {
  background: #fff; border: 1px solid var(--border); border-radius: 8px;
  padding: 1.25rem 1.5rem; margin-bottom: 1.5rem;
}
.card.narrow { max-width: 420px; margin: 2rem auto; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 1rem; text-align: center; }
.stat-num { font-size: 2rem; font-weight: 700; color: var(--navy); }
a.stat-link { display: block; color: inherit; text-decoration: none; transition: transform .12s, box-shadow .12s, border-color .12s; }
a.stat-link:hover { border-color: var(--navy); box-shadow: 0 4px 12px rgba(30,86,49,.12); transform: translateY(-2px); }
a.stat-link:focus-visible { outline: 3px solid var(--navy); outline-offset: 2px; }

table { width: 100%; border-collapse: collapse; margin-top: 0.5rem; }
th, td { text-align: left; padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--border); font-size: 0.93rem; }
th { color: #56606f; font-weight: 600; text-transform: uppercase; font-size: 0.75rem; letter-spacing: .03em; }

.badge { display: inline-block; padding: 0.15rem 0.55rem; border-radius: 999px; font-size: 0.75rem; font-weight: 600; }
.badge-open, .badge-confirmed, .badge-approved, .badge-filled, .badge-gameon { background: #e3f4e5; color: var(--green); }
.badge-pending { background: #fdf0d9; color: var(--amber); }
.badge-declined, .badge-cancelled { background: #fbe4e4; color: var(--red); }

form.inline-form { display: flex; flex-wrap: wrap; gap: 0.9rem; align-items: flex-end; margin-bottom: 0.5rem; }
form.inline-form label { display: flex; flex-direction: column; font-size: 0.82rem; color: #56606f; gap: 0.25rem; }

label { display: block; margin-bottom: 0.9rem; font-size: 0.9rem; color: #33394a; }
select, input[type=text], input[type=email], input[type=password], input[type=date],
input[type=time], input[type=number], input[type=file] {
  display: block; width: 100%; padding: 0.5rem 0.6rem; margin-top: 0.3rem;
  border: 1px solid var(--border); border-radius: 6px; font-size: 0.95rem;
}

/* A bare file input (import page) needs the same gap below it as a labelled field has. */
input[type=file] { margin-bottom: 0.9rem; }

.btn {
  display: inline-block; margin-bottom: 0.9rem; background: var(--navy); color: #fff; border: none;
  padding: 0.55rem 1.1rem; border-radius: 6px; font-size: 0.92rem; cursor: pointer; text-decoration: none;
}
.btn:hover { opacity: 0.92; }
.btn-secondary { background: #fff; color: var(--navy); border: 1px solid var(--navy); }

.btn-link { background: none; border: none; color: var(--navy); text-decoration: underline; cursor: pointer; font-size: 0.85rem; padding: 0; }
.btn-danger { color: var(--red); }
.row-actions form { display: inline-block; margin-right: 0.6rem; }

.flash { padding: 0.7rem 1rem; border-radius: 6px; margin-bottom: 1rem; font-size: 0.92rem; }
.flash-success { background: #e3f4e5; color: var(--green); }
.flash-error { background: #fbe4e4; color: var(--red); }
.flash-info { background: #e4efe6; color: var(--navy); }

.muted { color: #7a8494; font-size: 0.88rem; }
.error-list { color: var(--red); font-size: 0.9rem; }

.site-footer { border-top: 1px solid var(--border); padding: 1.25rem 0; color: #8a93a3; font-size: 0.85rem; }
/* ==== Kebab (overflow) menu on the games table ==== */
.kebab { position: relative; display: inline-block; }
.kebab-toggle { background: none; border: 1px solid transparent; border-radius: 6px; width: 34px; height: 34px; font-size: 1.35rem; line-height: 1; cursor: pointer; color: var(--navy); }
.kebab-toggle:hover, .kebab.open .kebab-toggle { background: #fff; border-color: var(--border); }
.kebab-menu { position: absolute; right: calc(100% + 4px); top: 0; z-index: 20; min-width: 150px; background: #fff; border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 6px 18px rgba(30,86,49,.15); padding: 0.25rem 0; }
.kebab-menu form { display: block; margin: 0; }
.kebab-item { display: block; width: 100%; text-align: left; padding: 0.55rem 0.9rem; background: none; border: 0; font: inherit; font-size: 0.92rem; color: #1e2430; text-decoration: none; cursor: pointer; }
.kebab-item:hover { background: var(--gray-bg); }
.kebab-item.danger { color: var(--red); }
.js .kebab-menu { display: none; }
.js .kebab.open .kebab-menu { display: block; }
td.row-actions { text-align: right; white-space: nowrap; }

/* ==== Filter button + panel (games table) ==== */
.table-head { position: relative; }
.table-head h2 { margin: 0.2rem 0 0.6rem; padding-right: 7rem; }
/* "Add a game" button that reveals the form */
details.add-game > summary { list-style: none; cursor: pointer; user-select: none; }
details.add-game > summary::-webkit-details-marker { display: none; }
details.add-game .when-open { display: none; }
details.add-game[open] .when-open { display: inline; }
details.add-game[open] .when-closed { display: none; }
details.add-game[open] > summary { background: #fff; color: var(--navy); border: 1px solid var(--navy); padding: calc(0.55rem - 1px) calc(1.1rem - 1px); }
a.btn-export { position: absolute; top: 0; right: 0; margin-bottom: 0; }
details.filter > summary { position: absolute; top: 0; right: 0; list-style: none; cursor: pointer; user-select: none; margin-bottom: 0; }
details.filter > summary::-webkit-details-marker { display: none; }
.filter-panel { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.2rem 1rem; align-items: end; margin: 0.2rem 0 0.8rem; padding: 0.9rem 1rem 0.5rem; background: var(--gray-bg); border: 1px solid var(--border); border-radius: 8px; }
.filter-panel label { margin-bottom: 0.5rem; }
.filter-actions { display: flex; gap: 0.6rem; margin-bottom: 0.5rem; }
.filter-actions .btn { margin-bottom: 0; }

/* ==== Open Games table: keep every row the same height ==== */
td.nowrap { white-space: nowrap; }
.badge-row { display: inline-flex; gap: 0.3rem; flex-wrap: nowrap; }
.row-action-group { display: flex; justify-content: flex-end; align-items: center; gap: 0.5rem; min-height: 38px; white-space: nowrap; }
.row-action-group form { display: block; margin: 0; }
.row-action-group .btn { margin-bottom: 0; padding: 0.45rem 0.85rem; font-size: 0.88rem; white-space: nowrap; }

/* ==== Hamburger button (hidden on desktop) ==== */
.nav-toggle { display: none; }

/* ==== MOBILE — delete this whole block (and the .nav-toggle rule above) to restore the old phone layout ==== */
@media (max-width: 640px) {
  /* top menu -> hamburger (only collapses when JavaScript is running) */
  .topbar-inner { padding: 0.6rem 1rem; flex-wrap: wrap; }
  .nav-toggle {
    display: flex; flex-direction: column; justify-content: center; gap: 5px;
    width: 44px; height: 44px; padding: 0 10px; margin-right: -10px;
    background: none; border: 0; cursor: pointer;
  }
  .nav-toggle span { display: block; height: 2px; background: #fff; border-radius: 2px; transition: transform .15s, opacity .15s; }
  .nav-open .nav-toggle span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
  .nav-open .nav-toggle span:nth-child(2) { opacity: 0; }
  .nav-open .nav-toggle span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
  .topbar nav { width: 100%; display: flex; flex-direction: column; padding-bottom: 0.4rem; }
  .js .topbar nav { display: none; }
  .js .topbar.nav-open nav { display: flex; }
  .topbar nav a { margin-left: 0; padding: 0.8rem 0.25rem; min-height: 48px; display: flex; align-items: center; border-top: 1px solid rgba(255,255,255,.12); font-size: 1rem; }
  .topbar .who { margin: 0; padding: 0.8rem 0.25rem 0.2rem; border-top: 1px solid rgba(255,255,255,.12); font-size: 0.85rem; }

  main.container { padding-left: 1rem; padding-right: 1rem; }
  .card { padding: 1rem; }
  .card.narrow { margin: 1rem auto; }
  h1 { font-size: 1.5rem; }
  .hero { padding: 2rem 0.5rem; }
  .hero-actions { flex-wrap: wrap; }

  form.inline-form { align-items: stretch; }
  form.inline-form label { flex: 1 1 100%; }
  form.inline-form .btn { flex: 1; text-align: center; }
  body input, body select, body textarea { font-size: 16px; } /* stops iOS zoom-on-focus */

  /* tables become one card per row */
  table.stack-table, table.stack-table tbody, table.stack-table tr, table.stack-table td { display: block; width: 100%; }
  table.stack-table thead { display: none; }
  table.stack-table tr { border: 1px solid var(--border); border-radius: 8px; padding: 0.35rem 0.9rem 0.6rem; margin-bottom: 0.9rem; background: #fff; }
  table.stack-table td { border-bottom: none; padding: 0.3rem 0; font-size: 0.95rem; }
  table.stack-table td:empty { display: none; }
  table.stack-table td[data-label] { display: flex; justify-content: space-between; align-items: center; gap: 1rem; text-align: right; }
  table.stack-table td[data-label]::before { content: attr(data-label); color: #56606f; font-size: 0.78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; text-align: left; flex: none; }
  table.stack-table td.cell-title { font-weight: 700; font-size: 1.05rem; padding: 0.55rem 0 0.4rem; border-bottom: 1px solid var(--border); margin-bottom: 0.3rem; }

  /* row actions: a row of big tappable buttons */
  table.stack-table td.row-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; padding-top: 0.6rem; }
  table.stack-table td.row-actions form { display: block; margin: 0; flex: 1 1 auto; }
  table.stack-table td.row-actions .btn { display: block; width: 100%; text-align: center; margin-bottom: 0; padding: 0.8rem 1rem; min-height: 44px; }
  table.stack-table td.row-actions .btn-link,
  table.stack-table td.row-actions a.btn-link {
    display: flex; align-items: center; justify-content: center; flex: 1 1 auto; width: 100%;
    min-height: 44px; padding: 0 0.9rem; border: 1px solid var(--border); border-radius: 6px;
    background: #fff; text-decoration: none; font-size: 0.95rem;
  }
  table.stack-table td.row-actions a.btn-link { width: auto; }
  table.stack-table td.row-actions .muted { display: block; width: 100%; text-align: center; padding: 0.4rem 0; }

  /* kebab menu: on phones the actions are shown as buttons instead */
  .kebab { display: block; width: 100%; }
  .kebab-toggle { display: none; }
  .js .kebab .kebab-menu, .kebab .kebab-menu { display: flex; position: static; flex-wrap: wrap; gap: 0.5rem; min-width: 0; padding: 0; border: 0; box-shadow: none; background: none; }
  .kebab-menu form { flex: 1 1 auto; }
  .kebab-item { display: flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 0.9rem; border: 1px solid var(--border); border-radius: 6px; background: #fff; text-align: center; }
  .kebab-menu > a.kebab-item { flex: 1 1 auto; width: auto; }
  td.row-actions { text-align: left; white-space: normal; }

  .badge-row { flex-wrap: wrap; justify-content: flex-end; }
  .row-action-group { width: 100%; flex-wrap: wrap; justify-content: stretch; white-space: normal; }
  .row-action-group form { flex: 1 1 auto; }
  .row-action-group .btn { padding: 0.8rem 1rem; font-size: 0.95rem; }
}

/* Edit user: role checkboxes */
fieldset.role-checks { border: 1px solid var(--border); border-radius: 6px; padding: .5rem .9rem .3rem; margin: 0 0 .9rem; flex: 1 1 100%; }
fieldset.role-checks legend { font-size: .82rem; color: #56606f; padding: 0 .3rem; }
form.inline-form label.check, label.check { display: flex; flex-direction: row; align-items: center; justify-content: flex-start; gap: .5rem; flex: 1 1 100%; color: #33394a; font-size: .92rem; text-align: left; margin-bottom: .5rem; }
label.check input { width: auto; margin: 0; }
form.inline-form .form-actions { flex: 1 1 100%; display: flex; gap: .6rem; }

/* iOS Safari: native date/time inputs ignore width:100% and render wider than
   their container. Reset appearance and allow them to shrink. */
input[type=date], input[type=time] {
  -webkit-appearance: none;
  appearance: none;
  min-width: 0;
  max-width: 100%;
  min-height: 2.45rem;
  background-color: #fff;
  font-family: inherit;
}
input[type=date]::-webkit-date-and-time-value,
input[type=time]::-webkit-date-and-time-value { text-align: left; min-height: 1.2em; }
form.inline-form label { min-width: 0; }
