:root {
  --bg: #f7f8f5;
  --panel: #ffffff;
  --text: #25221d;
  --muted: #706b61;
  --line: #dedbd2;
  --teal: #0f766e;
  --teal-dark: #0a5751;
  --teal-soft: #e0f2ef;
  --amber: #f0b429;
  --amber-soft: #fff4cf;
  --coral: #c75146;
  --coral-soft: #fde8e5;
  --shadow: 0 18px 45px rgba(38, 35, 29, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.app-shell {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 8px 0 22px;
}

.topbar h1,
.panel h2,
.results-band h2 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: 32px;
  line-height: 1.1;
}

.topbar p,
.results-head p {
  margin: 7px 0 0;
  color: var(--muted);
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(92px, 1fr));
  gap: 8px;
}

.summary-strip > div,
.metric-list > div {
  min-width: 92px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.72);
}

.summary-strip span,
.metric-list span {
  display: block;
  font-size: 22px;
  font-weight: 800;
  line-height: 1;
}

.summary-strip small,
.metric-list small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 0.85fr) minmax(480px, 1.5fr) minmax(260px, 0.75fr);
  gap: 14px;
  align-items: start;
}

.panel,
.results-band {
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel {
  padding: 18px;
}

.panel-title,
.results-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.panel h2,
.results-band h2 {
  font-size: 19px;
  line-height: 1.2;
}

.score-preview,
.state-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 7px 10px;
  border-radius: var(--radius);
  background: var(--amber-soft);
  color: #624507;
  font-size: 13px;
  font-weight: 700;
}

.score-preview strong {
  font-size: 20px;
  line-height: 1;
}

.state-pill {
  background: var(--teal-soft);
  color: var(--teal-dark);
}

.state-pill.running {
  background: var(--amber-soft);
  color: #6c4c08;
}

.person-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

label,
fieldset {
  display: grid;
  gap: 7px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

fieldset {
  grid-template-columns: 1fr 1fr;
  align-content: start;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

legend {
  padding: 0 4px;
  color: var(--muted);
}

.radio-row {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--text);
  font-weight: 650;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  outline: none;
  padding: 10px 11px;
}

input[type="radio"],
input[type="checkbox"] {
  width: 20px;
  min-height: 20px;
  accent-color: var(--teal);
  padding: 0;
}

textarea {
  resize: vertical;
  min-height: 86px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.full-row,
.form-actions {
  grid-column: 1 / -1;
}

.view-tabs {
  display: inline-flex;
  gap: 6px;
  margin: 0 0 14px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.7);
}

.birthday-banner {
  display: grid;
  gap: 4px;
  width: min(620px, 100%);
  min-height: 58px;
  margin: -6px auto 16px;
  padding: 10px 18px;
  border: 1px solid rgba(240, 180, 41, 0.75);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #fff7dc, #ffffff);
  color: #5f4308;
  text-align: center;
  box-shadow: 0 12px 30px rgba(95, 67, 8, 0.12);
}

.birthday-banner[hidden] {
  display: none;
}

.birthday-banner span {
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.birthday-banner strong {
  color: var(--text);
  font-size: 18px;
  line-height: 1.2;
}

.tab-button {
  min-height: 40px;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  padding: 0 18px;
  font-weight: 850;
}

.tab-button.active {
  background: var(--teal);
  color: #fff;
  box-shadow: 0 8px 20px rgba(15, 118, 110, 0.16);
}

.app-view {
  display: none;
}

.app-view.active-view {
  display: block;
}

.database-layout {
  display: grid;
  grid-template-columns: minmax(300px, 0.72fr) minmax(560px, 1.55fr);
  gap: 14px;
  align-items: start;
}

.create-layout {
  display: grid;
  grid-template-columns: minmax(520px, 1.35fr) minmax(300px, 0.65fr);
  gap: 14px;
  align-items: start;
}

.panel-subtitle {
  max-width: 720px;
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.attendance-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.attendance-stats > div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfbf8;
}

.attendance-stats span {
  display: block;
  font-size: 24px;
  font-weight: 850;
  line-height: 1;
}

.attendance-stats small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.attendance-list {
  display: grid;
  gap: 8px;
  max-height: 540px;
  overflow: auto;
  padding-right: 4px;
}

.attendance-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
}

.attendance-item:hover {
  border-color: rgba(15, 118, 110, 0.32);
  background: #fbfffd;
}

.attendance-item.leader-today {
  border-color: rgba(240, 180, 41, 0.65);
  background: #fffaf0;
}

.attendance-presence {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  min-width: 0;
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
}

.attendance-name {
  min-width: 0;
}

.attendance-name strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attendance-name small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.attendance-tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.search-box {
  margin-bottom: 12px;
}

.daily-leader-button {
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  padding: 0 9px;
  font-size: 12px;
  font-weight: 850;
}

.daily-leader-button.active {
  border-color: rgba(240, 180, 41, 0.7);
  background: var(--amber);
  color: #2e2410;
}

.daily-leader-button:disabled {
  background: #f4f2ec;
  color: #706b61;
  opacity: 1;
}

.form-actions,
.button-group,
.control-grid {
  display: flex;
  gap: 8px;
}

.database-panel .button-group {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.database-tools {
  display: grid;
  grid-template-columns: minmax(220px, 0.85fr) minmax(360px, 1.15fr);
  gap: 10px;
  align-items: end;
  margin-bottom: 12px;
}

.database-tools .search-box {
  margin-bottom: 0;
}

.database-selection-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.selection-count {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.primary-button,
.ghost-button,
.danger-button,
.stop-button,
.table-action {
  min-height: 40px;
  border-radius: var(--radius);
  padding: 0 14px;
  font-size: 14px;
  font-weight: 800;
}

.primary-button {
  background: var(--teal);
  color: #fff;
}

.primary-button:hover {
  background: var(--teal-dark);
}

.ghost-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
}

.ghost-button:hover {
  border-color: #b9b4a8;
}

.toggle-button.active {
  border-color: rgba(15, 118, 110, 0.48);
  background: var(--teal-soft);
  color: var(--teal-dark);
}

.danger-button,
.stop-button {
  background: var(--coral-soft);
  color: #8f2e26;
}

.stop-button {
  background: var(--amber);
  color: #2e2410;
}

.table-wrap {
  position: relative;
  min-width: 0;
  min-height: 360px;
  max-height: 520px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
}

th,
td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #fbfbf8;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

td {
  font-size: 14px;
}

.select-col {
  width: 48px;
  text-align: center;
}

.database-select-checkbox {
  width: 18px;
  height: 18px;
  accent-color: var(--teal);
}

tbody tr:hover {
  background: #fbfbf8;
}

.name-cell strong,
.member-name {
  display: block;
  color: var(--text);
}

.name-cell small,
.member-meta,
.team-meta {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: var(--radius);
  background: var(--teal-soft);
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 800;
}

.tag.no {
  background: #eeeae0;
  color: var(--muted);
}

.points-badge {
  display: inline-flex;
  justify-content: center;
  min-width: 34px;
  min-height: 28px;
  padding: 5px 8px;
  border-radius: var(--radius);
  background: var(--amber-soft);
  color: #624507;
  font-weight: 850;
}

.row-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.table-action {
  min-height: 32px;
  min-width: 70px;
  padding: 0 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  font-size: 12px;
}

.table-action.delete {
  background: var(--coral-soft);
  color: #8f2e26;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 240px;
  color: var(--muted);
  font-weight: 750;
}

.empty-state[hidden] {
  display: none;
}

.generator-panel {
  display: grid;
  gap: 16px;
}

.generation-status {
  min-height: 82px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfbf8;
  color: var(--muted);
  font-weight: 700;
}

.generation-status.ok {
  border-color: rgba(15, 118, 110, 0.35);
  background: var(--teal-soft);
  color: var(--teal-dark);
}

.generation-status.warn {
  border-color: rgba(199, 81, 70, 0.35);
  background: var(--coral-soft);
  color: #8f2e26;
}

.control-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.metric-list {
  display: grid;
  gap: 8px;
}

.results-band {
  margin-top: 14px;
  padding: 18px;
}

.results-head {
  margin-bottom: 14px;
}

.teams-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
  min-height: 190px;
}

.teams-grid:empty {
  border: 1px dashed #c9c4b8;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.55);
}

.team-card {
  display: grid;
  gap: 12px;
  min-height: 190px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.team-card.is-changing {
  animation: lift 0.14s ease;
}

.team-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.team-top h3 {
  margin: 0;
  font-size: 18px;
}

.team-total {
  min-width: 54px;
  padding: 7px 9px;
  border-radius: var(--radius);
  background: var(--amber-soft);
  color: #624507;
  text-align: center;
  font-weight: 850;
}

.leader-box {
  padding: 10px;
  border: 1px solid rgba(15, 118, 110, 0.22);
  border-radius: var(--radius);
  background: var(--teal-soft);
}

.leader-box span {
  display: block;
  margin-bottom: 4px;
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.member-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.member-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 38px;
  padding: 8px 0;
  border-bottom: 1px solid #eeece5;
}

.member-list li:last-child {
  border-bottom: 0;
}

.mini-score {
  flex: 0 0 auto;
  min-width: 28px;
  padding: 4px 7px;
  border-radius: var(--radius);
  background: #f2f0e8;
  color: var(--muted);
  text-align: center;
  font-size: 12px;
  font-weight: 850;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  transform: translateY(18px);
  opacity: 0;
  max-width: min(360px, calc(100vw - 36px));
  padding: 12px 14px;
  border-radius: var(--radius);
  background: #25221d;
  color: #fff;
  font-weight: 750;
  box-shadow: var(--shadow);
  pointer-events: none;
  transition:
    opacity 0.18s ease,
    transform 0.18s ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.draw-active {
  overflow: hidden;
}

.draw-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: none;
  padding: clamp(14px, 2.5vw, 32px);
  background:
    radial-gradient(circle at 20% 10%, rgba(240, 180, 41, 0.18), transparent 28%),
    linear-gradient(135deg, #071817 0%, #123532 54%, #1b1710 100%);
  color: #fff;
}

.draw-overlay.show {
  display: grid;
}

.draw-stage {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: clamp(10px, 1.4vw, 18px);
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.draw-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.draw-header h2 {
  margin: 4px 0 0;
  font-size: clamp(24px, 3vw, 44px);
  line-height: 1;
}

.draw-counter {
  margin: 0;
  color: #ffe49b;
  font-weight: 850;
  text-transform: uppercase;
}

.overlay-close {
  min-height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  padding: 0 16px;
  font-weight: 850;
}

.overlay-teams-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
  grid-auto-rows: minmax(320px, 1fr);
  gap: clamp(8px, 1vw, 14px);
  align-content: stretch;
  min-height: 0;
  max-height: 100%;
  overflow: auto;
  padding-right: 4px;
  overscroll-behavior: contain;
}

.overlay-teams-grid.overlay-count-1 {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
}

.overlay-teams-grid.overlay-count-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: minmax(0, 1fr);
}

.overlay-teams-grid.overlay-count-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: minmax(0, 1fr);
}

.overlay-teams-grid.overlay-count-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-rows: minmax(0, 1fr);
}

.overlay-teams-grid.overlay-count-6 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

@media (min-width: 1500px) {
  .overlay-teams-grid.overlay-count-6 {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    grid-template-rows: minmax(0, 1fr);
  }
}

/* Each card sizes its text from its own width, including grids with 5+ teams. */
.overlay-team-card {
  container-type: inline-size;
  container-name: team;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 8px;
  min-width: 0;
  min-height: 0;
  padding: clamp(10px, 0.9vw, 14px);
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.94);
  color: var(--text);
  box-shadow: 0 22px 50px rgba(0, 0, 0, 0.22);
}

.overlay-team-card .team-top,
.overlay-team-card .team-top > div,
.overlay-team-card .leader-box,
.compact-member-list,
.compact-member-list li,
.compact-member-list .member-name {
  min-width: 0;
}

.overlay-team-card .team-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  padding-bottom: 8px;
}

.overlay-team-card .team-top h3 {
  font-size: 24px;
  font-size: clamp(20px, 10cqi, 40px);
  line-height: 1.12;
  overflow-wrap: anywhere;
}

.overlay-team-card .team-meta {
  margin-top: 5px;
  font-size: 14px;
  font-size: clamp(14px, 4.8cqi, 18px);
  overflow-wrap: anywhere;
}

.overlay-team-card .team-total {
  min-width: 0;
  padding: 7px 9px;
  font-size: 20px;
  font-size: clamp(18px, 8cqi, 28px);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.overlay-team-card .leader-box {
  padding: 10px;
}

.overlay-team-card .leader-box span {
  margin-bottom: 4px;
  font-size: 14px;
}

.overlay-team-card .leader-box strong {
  display: block;
  font-size: 22px;
  font-size: clamp(18px, 8.5cqi, 32px);
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.compact-member-list {
  grid-template-columns: minmax(0, 1fr);
  gap: 4px 16px;
  min-height: 0;
  max-height: none;
  overflow: auto;
  padding-right: 4px;
  align-content: start;
  scrollbar-width: thin;
}

.compact-member-list li {
  justify-content: flex-start;
  min-height: 0;
  padding: 8px 0;
  border-bottom: 1px solid rgba(222, 219, 210, 0.65);
}

.compact-member-list .member-name {
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
  overflow-wrap: anywhere;
  font-size: 22px;
  font-size: clamp(18px, 8.5cqi, 32px);
  line-height: 1.22;
  font-weight: 820;
}

/* Two columns are useful only when the card itself can fit complete names. */
@container team (min-width: 600px) {
  .compact-member-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.mega-stop {
  width: min(560px, 100%);
  min-height: 52px;
  padding: 10px 20px;
  justify-self: center;
  border-radius: var(--radius);
  background: linear-gradient(180deg, #ffcf42, #f0a414);
  color: #221704;
  font-size: clamp(24px, 4vh, 40px);
  font-weight: 950;
  letter-spacing: 0;
  line-height: 0.96;
  white-space: normal;
  box-shadow:
    0 18px 0 #8b310d,
    0 28px 55px rgba(0, 0, 0, 0.38);
}

.mega-stop:not(:disabled):active {
  transform: translateY(10px);
  box-shadow:
    0 8px 0 #8b310d,
    0 16px 35px rgba(0, 0, 0, 0.32);
}

.mega-stop:disabled {
  background: #d8e7df;
  color: var(--teal-dark);
  box-shadow: none;
}

.mega-stop.reroll {
  background: linear-gradient(180deg, #12a394, #0b6f66);
  color: #fff;
  box-shadow:
    0 18px 0 #063f3b,
    0 28px 55px rgba(0, 0, 0, 0.38);
}

.birthday-overlay {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: none;
  place-items: center;
  padding: clamp(18px, 4vw, 48px);
  background:
    radial-gradient(circle at 20% 20%, rgba(255, 214, 98, 0.34), transparent 28%),
    radial-gradient(circle at 80% 10%, rgba(15, 118, 110, 0.28), transparent 26%),
    linear-gradient(135deg, #fff6d8 0%, #e9fbf6 52%, #fff 100%);
  color: var(--text);
}

.birthday-overlay.show {
  display: grid;
}

.birthday-stage {
  position: relative;
  display: grid;
  gap: clamp(14px, 2vw, 22px);
  width: min(980px, 100%);
  max-height: 100%;
  overflow: auto;
  padding: clamp(24px, 5vw, 58px);
  border: 1px solid rgba(240, 180, 41, 0.65);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 28px 70px rgba(37, 34, 29, 0.18);
  text-align: center;
}

.birthday-close {
  position: absolute;
  top: 16px;
  right: 16px;
  border-color: rgba(37, 34, 29, 0.12);
  background: #fff;
  color: var(--text);
}

.birthday-stage h2 {
  margin: 0;
  color: var(--teal-dark);
  font-size: clamp(44px, 9vw, 112px);
  line-height: 0.95;
}

.birthday-stage p {
  margin: 0;
  color: var(--muted);
  font-weight: 800;
}

.confetti-row {
  font-size: clamp(28px, 5vw, 58px);
  letter-spacing: 0;
}

.birthday-people {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.birthday-card {
  display: grid;
  gap: 8px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 12px 26px rgba(37, 34, 29, 0.08);
}

.birthday-emoji {
  font-size: 36px;
  line-height: 1;
}

.birthday-card strong {
  font-size: clamp(22px, 3vw, 34px);
  line-height: 1.05;
}

.birthday-card span {
  color: var(--muted);
  font-weight: 850;
}

@keyframes lift {
  from {
    transform: translateY(5px);
    opacity: 0.74;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@media (max-width: 1120px) {
  .workspace,
  .database-layout,
  .create-layout {
    grid-template-columns: 1fr 1fr;
  }

  .generator-panel {
    grid-column: 1 / -1;
  }
}

@media (min-width: 761px) and (max-width: 1100px) {
  .overlay-teams-grid.overlay-count-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: none;
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 20px, 720px);
    padding-top: 14px;
  }

  .topbar,
  .panel-title,
  .results-head {
    align-items: stretch;
    flex-direction: column;
  }

  .summary-strip {
    grid-template-columns: repeat(3, 1fr);
  }

  .workspace,
  .database-layout,
  .create-layout,
  .person-form {
    grid-template-columns: 1fr;
  }

  .database-tools {
    grid-template-columns: 1fr;
  }

  .database-selection-actions {
    justify-content: stretch;
  }

  .database-selection-actions > button {
    flex: 1 1 auto;
  }

  .workspace > *,
  .database-layout > *,
  .create-layout > * {
    min-width: 0;
  }

  table {
    min-width: 740px;
  }

  .full-row,
  .form-actions,
  .generator-panel {
    grid-column: auto;
  }

  .button-group,
  .form-actions {
    flex-wrap: wrap;
  }

  .primary-button,
  .ghost-button,
  .danger-button,
  .stop-button {
    flex: 1 1 auto;
  }

  .table-wrap {
    max-height: 440px;
  }

  .view-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }

  .attendance-stats {
    grid-template-columns: 1fr;
  }

  .attendance-item {
    grid-template-columns: 1fr;
  }

  .attendance-tags {
    justify-content: flex-start;
  }

  .draw-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .overlay-teams-grid[class*="overlay-count-"] {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: none;
    grid-auto-rows: max-content;
    align-content: start;
  }

  .overlay-team-card {
    grid-template-rows: max-content max-content max-content;
  }

  .compact-member-list {
    overflow: visible;
    grid-auto-rows: max-content;
  }

  .draw-header {
    flex-direction: row;
    align-items: center;
  }

  .draw-header > div {
    min-width: 0;
  }

  .draw-header .overlay-close {
    width: auto;
    flex-shrink: 0;
  }

  .overlay-close {
    width: 100%;
  }

.birthday-close {
    position: static;
    justify-self: stretch;
  }
}

.online-pin-overlay {
  align-items: center;
  background:
    radial-gradient(circle at 30% 20%, rgba(26, 188, 156, 0.24), transparent 34%),
    linear-gradient(135deg, rgba(10, 31, 28, 0.92), rgba(9, 14, 13, 0.96));
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 24px;
  position: fixed;
  z-index: 9999;
}

.online-pin-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
  color: var(--ink);
  display: grid;
  gap: 18px;
  max-width: 440px;
  padding: 28px;
  width: min(100%, 440px);
}

.online-pin-panel h2 {
  font-size: clamp(28px, 4vw, 44px);
  line-height: 0.96;
  margin: 0;
}

.online-pin-panel p {
  color: var(--muted);
  font-size: 15px;
  line-height: 1.45;
  margin: 0;
}

.online-pin-panel label {
  color: var(--muted);
  display: grid;
  font-size: 13px;
  font-weight: 800;
  gap: 8px;
  text-transform: uppercase;
}

.online-pin-panel input {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  font: inherit;
  font-size: 20px;
  padding: 14px;
}

.online-pin-actions {
  display: flex;
  gap: 10px;
}

.online-pin-actions > button {
  flex: 1 1 0;
}

/* Attendance history uses the existing compact operations palette. */
.history-toolbar-panel { margin-bottom: 14px; box-shadow: none; }
.history-layout { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(300px, 1fr); gap: 14px; align-items: start; }
.history-layout > .panel { box-shadow: none; }
.history-filters { display: flex; flex-wrap: wrap; align-items: end; gap: 14px; }
.history-filters > label:first-child { width: 110px; }
.history-filters .search-box { flex: 1; min-width: 190px; }
.history-summary { margin: 0 0 10px; color: var(--teal-dark); font-size: 14px; font-weight: 650; }
.history-notice { margin: 10px 0 0; font-size: 14px; line-height: 1.5; color: var(--teal-dark); overflow-wrap: anywhere; }
.history-notice:empty { display: none; }
.history-muted { color: #615c52; font-size: 13px; line-height: 1.5; }
.history-table-wrap { max-height: 620px; }
.history-table { min-width: 530px; }
.ranking-table { min-width: 260px; }
.history-table td, .ranking-table td { padding: 10px 8px; }
.history-table td, .ranking-table td, .meeting-footer { font-variant-numeric: tabular-nums; }
.history-date-cell { white-space: nowrap; }
.history-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.history-actions button { min-height: 36px; padding: 6px 9px; font-size: 13px; }
.history-names { margin: 8px 0; line-height: 1.7; white-space: normal; overflow-wrap: anywhere; }
.history-table summary { cursor: pointer; color: var(--teal-dark); font-weight: 650; }
.history-table details[open] summary { margin-bottom: 8px; }
.meeting-dialog { width: min(620px, calc(100vw - 24px)); max-height: calc(100dvh - 32px); padding: 20px; border: 1px solid var(--line); border-radius: var(--radius); color: var(--text); background: var(--panel); box-shadow: var(--shadow); }
.meeting-dialog::backdrop { background: rgb(23 32 29 / 55%); }
.meeting-dialog h2 { margin: 0; font-size: 20px; }
.meeting-dialog form { display: flex; flex-direction: column; gap: 10px; }
.meeting-dialog .panel-title { margin: 0; flex-direction: row; align-items: center; }
.meeting-dialog .search-box { margin: 0; }
.meeting-dialog .history-muted { margin: 0; }
.meeting-copy-actions { flex-wrap: wrap; }
.meeting-people { max-height: 38dvh; min-height: 100px; overflow-y: auto; border: 1px solid var(--line); border-radius: 6px; }
.history-person-row { display: flex; align-items: center; gap: 12px; min-height: 46px; padding: 9px 12px; border-bottom: 1px solid var(--line); cursor: pointer; }
.history-person-row:last-child { border-bottom: 0; }
.history-person-row:has(input:checked) { background: var(--teal-soft); }
.history-person-row input { flex: 0 0 19px; width: 19px; height: 19px; accent-color: var(--teal); }
.history-person-name { overflow-wrap: anywhere; }
.meeting-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.meeting-footer .primary-button { flex: 0 1 auto; }
#historyView :focus-visible, .meeting-dialog :focus-visible { outline: 3px solid var(--teal); outline-offset: 3px; }
#historyView ::selection, .meeting-dialog ::selection { color: var(--teal-dark); background: var(--teal-soft); }
#historyView input, .meeting-dialog input { caret-color: var(--teal); }
#historyView input::placeholder, .meeting-dialog input::placeholder { color: #706b61; opacity: 1; }
@media (max-width: 1050px) { .history-layout { grid-template-columns: 1fr; } }
@media (max-width: 760px) {
  .view-tabs { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .tab-button { padding: 8px; font-size: 14px; }
  .history-toolbar-panel .button-group { display: flex; }
  .history-filters { gap: 10px; }
  .history-summary { flex-basis: 100%; margin: 0; }
  .history-actions button { min-height: 44px; }
  .meeting-dialog { padding: 14px; }
  .meeting-dialog .panel-title button { flex: 0 0 auto; }
  .meeting-copy-actions { display: grid; grid-template-columns: 1fr; }
  .meeting-people { max-height: 32dvh; }
}
.history-person-name .history-muted, .ranking-table td .history-muted { display: block; margin-top: 3px; }
