:root {
  --pink: #f7c8d8;
  --pink-deep: #d96b93;
  --shu: #d43d2a;
  --ink: #33302e;
  --muted: #8a837e;
  --line: #e5ddd8;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Hiragino Sans", sans-serif;
  color: var(--ink);
  background: #fffaf8;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
}
header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  /* Extra top room so the title clears the iPhone status-bar blur. */
  padding: calc(env(safe-area-inset-top) + 28px) 16px 4px;
  background: #fffaf8;
}
header h1 { font-size: 20px; margin: 0; }
#whoami { color: var(--muted); font-size: 14px; }
main {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 4px 16px 8px;
}
.view {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.view[hidden] { display: none; }
#view-register, #view-admin { overflow-y: auto; }
h2 { font-size: 16px; margin: 22px 0 8px; }
.error { color: #b3261e; min-height: 1.2em; }
.note { color: var(--muted); font-size: 13px; text-align: center; margin: 6px 0 2px; }

/* --- Check-in: today's calendar page + stamp --- */
#today-status { text-align: center; margin: 2px 0 8px; color: var(--muted); font-size: 14px; }
#today-card {
  position: relative;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  text-align: center;
  padding: 12px 12px 14px;
  box-shadow: 0 2px 10px rgba(51, 48, 46, 0.05);
}
#today-ym { font-size: 15px; color: var(--muted); letter-spacing: 0.12em; }
#today-day {
  font-size: clamp(84px, 27vw, 118px);
  line-height: 1.02;
  font-weight: 800;
}
#today-week { font-size: 17px; font-weight: 600; }
#my-total { margin-top: 4px; font-size: 15px; color: var(--muted); }
#stamp {
  position: absolute;
  right: 12px;
  bottom: 12px;
  width: 86px;
  height: 86px;
  border: 3px solid var(--shu);
  border-radius: 50%;
  color: var(--shu);
  display: grid;
  place-content: center;
  text-align: center;
  transform: rotate(-10deg);
  background: rgba(255, 255, 255, 0.45);
  box-shadow: inset 0 0 0 2px rgba(212, 61, 42, 0.3);
}
#stamp[hidden] { display: none; }
#stamp .stamp-word { font-size: 21px; font-weight: 800; line-height: 1.1; }
#stamp-date { font-size: 12px; font-weight: 700; }
#stamp.pop { animation: stamp-in 0.32s ease-out; }
@keyframes stamp-in {
  0% { transform: scale(2.6) rotate(-26deg); opacity: 0; }
  55% { transform: scale(0.94) rotate(-9deg); opacity: 1; }
  100% { transform: scale(1) rotate(-10deg); opacity: 1; }
}
#press {
  display: block;
  width: min(46vw, 168px);
  height: min(46vw, 168px);
  margin: 14px auto 8px;
  border: none;
  border-radius: 50%;
  background: var(--pink);
  color: var(--ink);
  font-size: 30px;
  font-weight: 700;
  box-shadow: 0 6px 0 var(--pink-deep);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  flex: none;
}
#press:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--pink-deep); }
#press:disabled { opacity: 0.55; }
#press-result { text-align: center; min-height: 1.4em; font-size: 16px; margin: 2px 0; }

/* --- Mini month calendar --- */
#month-cal {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 8px 10px 10px;
  margin-top: 6px;
}
.cal-row { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-head { font-size: 11px; color: var(--muted); text-align: center; padding-bottom: 2px; }
.cal-head .fri { color: var(--pink-deep); font-weight: 700; }
.cal-cell { text-align: center; padding: 1.5px 0; }
.cal-cell .num {
  display: inline-grid;
  place-items: center;
  width: 25px;
  height: 25px;
  border-radius: 50%;
  font-size: 13px;
}
.cal-cell.fri .num { color: var(--pink-deep); font-weight: 600; }
.cal-cell .num.today { border: 2px solid var(--ink); font-weight: 800; }
.cal-cell .num.stamped {
  background: var(--shu);
  color: #fff;
  font-weight: 700;
  transform: rotate(-8deg);
}
.cal-cell .num.stamped.today { border-color: var(--shu); }

#logout {
  align-self: center;
  border: none;
  background: none;
  color: var(--muted);
  font-size: 13px;
  text-decoration: underline;
  padding: 6px 8px;
}

input, select, button { font-size: 16px; }
input, select {
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
button {
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}
#register-form { display: flex; gap: 8px; }
#register-form input { flex: 1; }
#claim-list { display: flex; flex-wrap: wrap; gap: 8px; }
#claim-list button { border-radius: 999px; }

/* --- Points table (dates as rows, members as columns) --- */
.row { display: flex; gap: 18px; align-items: center; margin-bottom: 10px; flex: none; }
.table-wrap {
  flex: 1;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overscroll-behavior: contain;
}
table { border-collapse: separate; border-spacing: 0; font-size: 13px; white-space: nowrap; }
th, td {
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  padding: 5px 8px;
  text-align: center;
  background: #fff;
}
thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: #fff5f8;
  font-weight: 700;
}
thead tr.totals td {
  position: sticky;
  top: 30px;
  z-index: 3;
  background: #fff5f8;
  font-weight: 700;
}
th:first-child, td:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  text-align: left;
  font-weight: 600;
}
thead th:first-child { z-index: 4; }
thead tr.totals td:first-child { z-index: 4; }
td.hit { color: var(--shu); font-weight: 700; }

#settings-form { display: grid; gap: 10px; max-width: 420px; }
#settings-form label { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
#settings-form input, #settings-form select { width: 170px; }
.admin-row {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 14px;
}
.admin-row .grow { flex: 1; }
.admin-row button { padding: 5px 10px; font-size: 13px; }
.counted-on { background: var(--pink); border-color: var(--pink-deep); }

#tabbar {
  display: flex;
  background: #fff;
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  flex: none;
}
#tabbar[hidden] { display: none; }
#tabbar button {
  flex: 1; border: none; border-radius: 0; background: none;
  padding: 14px 0; font-size: 15px; color: var(--muted);
}
#tabbar button.active { color: var(--ink); font-weight: 700; }
