:root {
  --coral: #d96b57;
  --teal: #2f6f6d;
  --ink: #2d3f5e;
  --gold: #f2c14e;
  --canvas: #f6efe0;
  --card: #fffdf7;
  --text: #3b3128;
  --muted: #8d8069;
  --line: #e6dabc;
  --danger: #b3412f;
  --time: #7c6f58;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--canvas);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  min-height: 100vh;
  min-height: 100dvh;
}

button { font-family: inherit; cursor: pointer; }

#app { max-width: 520px; margin: 0 auto; }

:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ---------- Lanyard strap header ---------- */

.strap {
  position: sticky;
  top: 0;
  z-index: 40;
  background: linear-gradient(180deg, #357571 0%, #2f6f6d 55%, #2a6361 100%);
  box-shadow: 0 3px 10px rgba(38, 78, 76, 0.3);
  padding: calc(10px + env(safe-area-inset-top, 0px)) 14px 12px;
}

.strap::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.06) 0 5px, rgba(255, 255, 255, 0) 5px 11px);
  pointer-events: none;
}

.strap::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 5px;
  border-bottom: 2px dashed rgba(253, 246, 227, 0.28);
}

.strap-inner {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
}

.strap-title {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 19px;
  letter-spacing: 0.02em;
  color: #fdf6e3;
  flex-shrink: 0;
}

.counter {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
}

.counter-num {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #fdf6e3;
  font-size: 16px;
  font-weight: 800;
}

.counter-open .counter-num { border: 3px solid var(--coral); color: var(--coral); }
.counter-confirmed .counter-num { border: 3px solid var(--ink); color: var(--ink); }

.counter-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(253, 246, 227, 0.85);
}

.badge-add {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 8px 16px;
  background: var(--gold);
  color: #4a3a15;
  border: none;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.01em;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.08);
}

.badge-add:active { filter: brightness(0.95); }

.badge-hole {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.75);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* ---------- Views ---------- */

#views { padding-bottom: calc(104px + env(safe-area-inset-bottom, 0px)); }

.view { padding: 18px 16px 12px; }

.view-title {
  margin: 2px 0 2px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
}

.view-sub { margin: 0 0 18px; font-size: 13px; color: var(--muted); }

/* ---------- Board lanes ---------- */

.lane { margin-bottom: 30px; }

.lane-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }

.lane-dot { width: 10px; height: 10px; border-radius: 3px; }
.lane-open .lane-dot { background: var(--coral); }
.lane-filled .lane-dot { background: var(--teal); }
.lane-confirmed .lane-dot { background: var(--ink); }

.lane-title {
  margin: 0;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.lane-count {
  margin-left: auto;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 9px;
}

/* ---------- Lanyard cards ---------- */

.card {
  position: relative;
  display: block;
  width: 100%;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 15px 16px 14px;
  margin-bottom: 12px;
  box-shadow: 0 2px 6px rgba(96, 74, 40, 0.08);
  color: var(--text);
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 6px;
  background: var(--stripe, var(--coral));
}

.card::after {
  content: '';
  position: absolute;
  top: 6px;
  left: 21px;
  width: 2px;
  height: 10px;
  background: var(--stripe, var(--coral));
}

.card:active { transform: scale(0.985); }

.status-open { --stripe: var(--coral); }
.status-filled { --stripe: var(--teal); }
.status-confirmed { --stripe: var(--ink); }

.clip-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 5px 0 9px;
}

.hole {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--canvas);
  border: 1px solid rgba(0, 0, 0, 0.12);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.35);
}

.status-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.status-open .status-label { color: var(--coral); }
.status-filled .status-label { color: var(--teal); }
.status-confirmed .status-label { color: var(--ink); }

.card-role { display: block; font-size: 17px; font-weight: 700; line-height: 1.25; }
.card-time { display: block; margin-top: 4px; font-size: 13.5px; font-weight: 600; color: var(--time); }
.card-name { display: block; margin-top: 3px; font-size: 14px; font-weight: 600; color: var(--teal); }
.card-name em { font-style: italic; color: var(--muted); font-weight: 500; }

/* ---------- Empty states ---------- */

.empty {
  text-align: center;
  padding: 20px 14px;
  border: 1.5px dashed var(--line);
  border-radius: 14px;
  background: rgba(255, 253, 247, 0.55);
}

.empty p { margin: 0 0 12px; font-size: 14px; color: var(--muted); }
.empty-lane { padding: 16px 14px; }
.empty .badge-add { margin-left: auto; margin-right: auto; }

/* ---------- Form ---------- */

.field { margin-bottom: 16px; }

.field > label,
.field .field-label,
.find-label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.req {
  color: var(--coral);
  font-weight: 700;
  text-transform: none;
  letter-spacing: 0;
  font-size: 11px;
  margin-left: 2px;
}

.field input,
.find-head input {
  width: 100%;
  min-height: 50px;
  padding: 12px 14px;
  font-size: 16px;
  font-family: inherit;
  color: var(--text);
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  appearance: none;
  -webkit-appearance: none;
}

.field input::placeholder,
.find-head input::placeholder { color: #b6ab97; }

.field input:focus,
.find-head input:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(47, 111, 109, 0.14);
}

.field input.invalid { border-color: var(--danger); }

.field-error { margin: 6px 2px 0; font-size: 12.5px; color: var(--danger); }

.seg { display: flex; gap: 8px; }

.seg-btn {
  flex: 1;
  min-height: 46px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.seg-btn.selected.seg-open { border-color: var(--coral); color: var(--coral); background: rgba(217, 107, 87, 0.1); }
.seg-btn.selected.seg-filled { border-color: var(--teal); color: var(--teal); background: rgba(47, 111, 109, 0.1); }
.seg-btn.selected.seg-confirmed { border-color: var(--ink); color: var(--ink); background: rgba(45, 63, 94, 0.08); }

.form-actions { display: flex; gap: 10px; margin-top: 24px; }

.btn {
  min-height: 50px;
  border: none;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 700;
}

.btn-primary { flex: 1.3; background: var(--coral); color: #fff; }
.btn-primary:active { filter: brightness(0.94); }
.btn-ghost { flex: 1; background: transparent; border: 1.5px solid var(--line); color: var(--muted); }

.btn-danger {
  width: 100%;
  margin-top: 12px;
  min-height: 48px;
  background: transparent;
  border: 1.5px solid rgba(179, 65, 47, 0.45);
  color: var(--danger);
}

.btn-danger:active { background: rgba(179, 65, 47, 0.08); }

/* ---------- Roster ---------- */

.roster-group { margin-bottom: 22px; }

.group-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 800;
  color: var(--ink);
}

.group-title::after { content: ''; flex: 1; height: 1px; background: var(--line); }

.roster-list {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}

.roster-item { border-bottom: 1px solid var(--line); }
.roster-item:last-child { border-bottom: none; }

.roster-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  padding: 13px 16px;
  background: transparent;
  border: none;
  text-align: left;
  min-height: 52px;
}

.roster-name { font-size: 16px; font-weight: 700; color: var(--text); }
.roster-role { font-size: 13px; color: var(--muted); }

.roster-actions { display: none; gap: 10px; padding: 0 12px 12px; }

.roster-item.expanded { background: rgba(242, 193, 78, 0.09); }
.roster-item.expanded .roster-actions { display: flex; }

.btn-small {
  flex: 1;
  min-height: 42px;
  padding: 6px 8px;
  line-height: 1.25;
  font-size: 14px;
  border-radius: 10px;
  border: 1.5px solid var(--line);
  background: var(--card);
  color: var(--text);
}

.btn-teal { background: var(--teal); border-color: var(--teal); color: #fff; }

/* ---------- Find ---------- */

.find-head { margin-bottom: 6px; }

.find-head input:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(47, 111, 109, 0.14);
}

.find-count { margin: 10px 2px 2px; font-size: 13px; color: var(--muted); min-height: 18px; }

#find-results { margin-top: 12px; }

/* ---------- Bottom tab bar ---------- */

.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  max-width: 520px;
  margin: 0 auto;
  display: flex;
  background: var(--card);
  border-top: 1px solid var(--line);
  padding: 8px 4px calc(8px + env(safe-area-inset-bottom, 0px));
}

.tab-btn {
  flex: 1;
  min-height: 54px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  background: transparent;
  border: none;
  color: #a3937c;
  padding: 2px 0 0;
}

.tab-clip { display: block; transition: transform 0.16s ease, filter 0.16s ease; }

.tab-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tab-btn.active { color: var(--coral); }

.tab-btn.active .tab-clip {
  transform: translateY(-6px);
  filter: drop-shadow(0 7px 5px rgba(59, 49, 40, 0.28));
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + env(safe-area-inset-bottom, 0px));
  z-index: 60;
  transform: translateX(-50%) translateY(10px);
  background: #33291f;
  color: #fdf6e3;
  font-size: 13.5px;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  max-width: 86%;
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Small screens ---------- */

@media (max-width: 359px) {
  .strap-title { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
