:root {
  --ink: #1f2933;
  --muted: #6b7280;
  --paper: #fffaf0;
  --panel: #ffffff;
  --line: rgba(31, 41, 51, 0.1);
  --coral: #f9735b;
  --green: #81a969;
  --blue: #5c9fc8;
  --gold: #e7b84a;
  --lavender: #9b8ad7;
  --shadow: 0 18px 48px rgba(62, 45, 32, 0.12);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  width: 100%;
  min-width: 320px;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  touch-action: manipulation;
}

body {
  margin: 0;
  width: 100%;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(249, 115, 91, 0.18), transparent 32rem),
    radial-gradient(circle at bottom right, rgba(92, 159, 200, 0.2), transparent 30rem),
    #f5efe6;
}

button,
input,
select {
  font: inherit;
  font-size: 16px;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: default;
}

.app-shell {
  position: relative;
  width: min(100vw, 430px);
  min-height: 100vh;
  margin: 0 auto;
  padding: clamp(12px, 4vw, 18px) clamp(12px, 4vw, 16px) 94px;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255, 250, 240, 0.94), rgba(255, 252, 246, 0.98)),
    repeating-linear-gradient(0deg, rgba(31, 41, 51, 0.025), rgba(31, 41, 51, 0.025) 1px, transparent 1px, transparent 26px);
}

.screen {
  display: none;
  animation: lift 0.2s ease-out;
}

.screen.is-active {
  display: block;
}

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

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

.eyebrow {
  margin: 0 0 4px;
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(25px, 7vw, 28px);
  line-height: 1.08;
  letter-spacing: 0;
}

h2 {
  font-size: 18px;
  line-height: 1.2;
  letter-spacing: 0;
}

.icon-button {
  display: inline-grid;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 16px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 8px 18px rgba(31, 41, 51, 0.06);
}

.icon-button.filled {
  color: white;
  border-color: transparent;
  background: var(--ink);
}

.admin-dot {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  border: 0;
  border-radius: 50%;
  background: rgba(31, 41, 51, 0.16);
}

.admin-dot:hover {
  background: rgba(31, 41, 51, 0.34);
}

svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.15;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.hero {
  position: relative;
  min-height: clamp(198px, 56vw, 224px);
  margin: 0 0 14px;
  border: 1px solid rgba(129, 169, 105, 0.2);
  border-radius: 28px;
  overflow: hidden;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.74), rgba(255, 245, 224, 0.88)),
    radial-gradient(circle at 18% 25%, rgba(231, 184, 74, 0.25), transparent 8rem);
  box-shadow: var(--shadow);
}

.hero-art {
  position: absolute;
  right: clamp(-58px, -12vw, -34px);
  bottom: clamp(-70px, -16vw, -54px);
  width: clamp(270px, 80vw, 310px);
  max-width: 88%;
  pointer-events: none;
  filter: drop-shadow(0 24px 28px rgba(81, 57, 34, 0.12));
}

.hero-copy {
  position: relative;
  z-index: 1;
  width: min(62%, 250px);
  padding: clamp(18px, 5vw, 22px) clamp(14px, 4vw, 18px);
}

.hero-copy p {
  color: var(--muted);
  font-weight: 800;
}

.hero-copy strong {
  display: block;
  margin-top: 8px;
  font-size: clamp(30px, 9vw, 36px);
  line-height: 1.02;
  letter-spacing: 0;
}

.check-panel,
.date-tools,
.chart-section,
.list-section,
.rule-panel,
.add-member {
  margin-top: 14px;
  padding: clamp(14px, 4vw, 16px);
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.84);
  box-shadow: 0 12px 28px rgba(62, 45, 32, 0.08);
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.section-heading.compact {
  align-items: center;
}

.section-heading.compact span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.member-picker {
  display: grid;
  gap: 9px;
}

.member-picker label {
  color: var(--green);
  font-size: 14px;
  font-weight: 900;
}

.member-picker select {
  max-width: none;
  min-height: 56px;
  padding: 0 16px;
  border: 0;
  background: transparent;
  box-shadow: none;
  font-size: 18px;
  font-weight: 950;
}

.member-select-card {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 10px;
  align-items: center;
  min-height: 64px;
  padding: 8px 10px;
  border-color: rgba(129, 169, 105, 0.42);
  border: 1px solid rgba(129, 169, 105, 0.42);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(247, 242, 233, 0.9)),
    #fffdf8;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.6);
}

.picker-avatar {
  width: 44px;
  height: 44px;
  flex-basis: 44px;
  border-radius: 15px;
  font-size: 16px;
}

select,
input {
  width: 100%;
  min-height: 42px;
  border: 1px solid rgba(31, 41, 51, 0.12);
  border-radius: 14px;
  color: var(--ink);
  background: #fffdf8;
  outline: none;
}

select {
  max-width: 132px;
  padding: 0 12px;
  font-weight: 800;
}

input {
  margin-top: 7px;
  padding: 0 12px;
}

input[readonly] {
  color: var(--ink);
  background: #f7f2e9;
  font-weight: 900;
}

label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.today-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 66px;
  margin: 16px 0;
  padding: 12px 14px;
  border-radius: 18px;
  background: #f7f2e9;
}

.today-status > div {
  display: flex;
  align-items: center;
  gap: 10px;
}

.today-status p {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.today-status strong {
  min-width: 44px;
  color: var(--coral);
  font-size: 36px;
  line-height: 1;
  text-align: right;
}

.status-dot {
  width: 12px;
  height: 12px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--gold);
  box-shadow: 0 0 0 6px rgba(231, 184, 74, 0.16);
}

.status-dot.is-done {
  background: var(--green);
  box-shadow: 0 0 0 6px rgba(129, 169, 105, 0.18);
}

.check-button {
  display: flex;
  width: 100%;
  min-height: 64px;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 0;
  border-radius: 21px;
  color: white;
  background: linear-gradient(135deg, var(--coral), #f0a64b);
  box-shadow: 0 16px 24px rgba(249, 115, 91, 0.28);
  font-size: 18px;
  font-weight: 900;
}

.check-button.is-done,
.check-button:disabled {
  background: linear-gradient(135deg, var(--green), #5c9fc8);
  box-shadow: 0 14px 22px rgba(92, 159, 200, 0.18);
  opacity: 0.9;
}

.check-button.is-waiting {
  color: rgba(31, 41, 51, 0.64);
  background: linear-gradient(135deg, #cbd5df, #aeb8c3);
  box-shadow: none;
  opacity: 1;
}

.check-button svg {
  width: 24px;
  height: 24px;
}

.button-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 10px;
}

.soft-button {
  display: flex;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 16px;
  color: var(--ink);
  background: #fffdf8;
  font-size: 14px;
  font-weight: 850;
}

.soft-button:disabled {
  color: rgba(31, 41, 51, 0.38);
  background: rgba(255, 253, 248, 0.54);
}

.soft-button svg {
  width: 18px;
  height: 18px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 14px;
}

.metric-grid article {
  min-height: 86px;
  padding: 13px 10px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 10px 22px rgba(62, 45, 32, 0.07);
}

.metric-grid span {
  display: block;
  min-height: 18px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.metric-grid strong {
  display: block;
  margin-top: 8px;
  font-size: clamp(23px, 7vw, 27px);
  line-height: 1;
  letter-spacing: 0;
}

.member-strip,
.group-list,
.rank-list,
.stat-table {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.person-pill,
.group-row,
.rank-row,
.stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 58px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fffdf8;
}

.identity {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
}

.avatar {
  display: inline-grid;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  place-items: center;
  border-radius: 14px;
  color: white;
  background: var(--blue);
  font-size: 15px;
  font-weight: 900;
  line-height: 1;
  text-align: center;
}

.identity strong,
.rank-row strong,
.stat-row strong {
  overflow: hidden;
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.identity div span,
.rank-row .identity div span,
.stat-row .identity div span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.rank-number {
  display: inline-grid;
  min-width: 42px;
  height: 30px;
  place-items: center;
  border-radius: 999px;
  color: #5b3b10;
  background: rgba(231, 184, 74, 0.22);
  font-size: 12px;
  font-weight: 950;
}

.count-badge {
  min-width: 54px;
  padding: 7px 10px;
  border-radius: 999px;
  color: var(--ink);
  background: rgba(231, 184, 74, 0.18);
  font-size: 13px;
  font-weight: 900;
  text-align: center;
}

.date-tools {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.segmented {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 5px;
  border-radius: 17px;
  background: #f3eadf;
}

.segmented button {
  min-height: 38px;
  border: 0;
  border-radius: 13px;
  color: var(--muted);
  background: transparent;
  font-weight: 900;
}

.segmented button.is-selected {
  color: var(--ink);
  background: #fffdf8;
  box-shadow: 0 8px 16px rgba(62, 45, 32, 0.08);
}

.bar-chart {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(22px, 1fr);
  align-items: end;
  gap: 8px;
  min-height: 162px;
  margin-top: 14px;
  padding: 12px 4px 2px;
  overflow-x: auto;
}

.bar {
  display: grid;
  grid-template-rows: 1fr auto;
  min-width: 22px;
  height: 140px;
  align-items: end;
  gap: 6px;
}

.bar span {
  display: block;
  width: 100%;
  min-height: 5px;
  border-radius: 10px 10px 4px 4px;
  background: linear-gradient(180deg, var(--blue), var(--green));
}

.bar small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-align: center;
}

.rank-podium {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: stretch;
  gap: 9px;
  min-height: 206px;
  margin-top: 12px;
}

.podium-card {
  position: relative;
  overflow: hidden;
  display: grid;
  min-height: 178px;
  align-content: start;
  justify-items: center;
  gap: 7px;
  padding: 12px 7px 13px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.84);
  box-shadow: 0 12px 28px rgba(62, 45, 32, 0.08);
  text-align: center;
}

.podium-card::before {
  position: absolute;
  inset: 0;
  z-index: 0;
  content: "";
  opacity: 0.9;
}

.podium-card > * {
  position: relative;
  z-index: 1;
}

.podium-card-1 {
  min-height: 198px;
  border-color: rgba(231, 184, 74, 0.45);
  background: linear-gradient(180deg, rgba(255, 243, 198, 0.96), rgba(255, 255, 255, 0.92));
  box-shadow: 0 18px 34px rgba(183, 130, 36, 0.16);
}

.podium-card-1::before {
  background:
    radial-gradient(circle at 50% 5%, rgba(255, 210, 96, 0.42), transparent 40%),
    linear-gradient(180deg, rgba(255, 248, 222, 0.72), transparent 70%);
}

.podium-card-2 {
  border-color: rgba(133, 154, 170, 0.34);
  background: linear-gradient(180deg, rgba(236, 245, 250, 0.96), rgba(255, 255, 255, 0.9));
}

.podium-card-2::before {
  background: radial-gradient(circle at 50% 2%, rgba(162, 185, 200, 0.26), transparent 42%);
}

.podium-card-3 {
  border-color: rgba(198, 125, 86, 0.34);
  background: linear-gradient(180deg, rgba(255, 235, 220, 0.96), rgba(255, 255, 255, 0.9));
}

.podium-card-3::before {
  background: radial-gradient(circle at 50% 2%, rgba(229, 155, 101, 0.25), transparent 42%);
}

.podium-icon {
  width: 58px;
  height: 58px;
  object-fit: contain;
  filter: drop-shadow(0 8px 10px rgba(86, 64, 38, 0.14));
}

.podium-card-1 .podium-icon {
  width: 68px;
  height: 68px;
}

.podium-avatar {
  width: 36px;
  height: 36px;
  flex-basis: 36px;
  border: 2px solid rgba(255, 255, 255, 0.8);
  border-radius: 13px;
  box-shadow: 0 8px 16px rgba(65, 48, 35, 0.1);
}

.podium-card strong {
  max-width: 100%;
  overflow: hidden;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.podium-card > span:not(.avatar):not(.medal) {
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  line-height: 1.35;
}

.medal {
  display: inline-grid;
  min-width: 38px;
  height: 26px;
  padding: 0 8px;
  place-items: center;
  border-radius: 999px;
  color: white;
  background: linear-gradient(135deg, var(--coral), #e7b84a);
  box-shadow: 0 8px 16px rgba(213, 95, 75, 0.2);
  font-size: 12px;
  font-weight: 950;
}

.rule-panel {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.rule-panel p {
  margin-top: 8px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.rule-chip {
  flex: 0 0 auto;
  padding: 8px 10px;
  border-radius: 999px;
  color: #5b3b10;
  background: rgba(231, 184, 74, 0.22);
  font-size: 12px;
  font-weight: 900;
}

.add-member {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 10px;
}

.admin-panel[hidden] {
  display: none;
}

.group-row.is-admin {
  display: grid;
  grid-template-columns: 1fr;
  align-items: stretch;
}

.member-admin-tools {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: end;
  margin-top: 8px;
}

.member-admin-tools input {
  min-height: 38px;
}

.mini-button {
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 13px;
  color: var(--ink);
  background: #fffdf8;
  font-size: 13px;
  font-weight: 900;
}

.delete-button {
  display: inline-grid;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  place-items: center;
  border: 0;
  border-radius: 14px;
  color: #b94b3a;
  background: rgba(249, 115, 91, 0.12);
}

.delete-button svg {
  width: 17px;
  height: 17px;
}

.tabbar {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  width: min(100vw, 430px);
  margin: 0 auto;
  padding: 10px 12px max(10px, env(safe-area-inset-bottom));
  border-top: 1px solid rgba(31, 41, 51, 0.08);
  background: rgba(255, 250, 240, 0.9);
  backdrop-filter: blur(18px);
}

.tabbar button {
  display: grid;
  min-height: 58px;
  place-items: center;
  gap: 3px;
  border: 0;
  border-radius: 18px;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
  font-weight: 900;
}

.tabbar button.is-active {
  color: var(--ink);
  background: white;
  box-shadow: 0 12px 22px rgba(62, 45, 32, 0.1);
}

.tabbar svg {
  width: 22px;
  height: 22px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 92px;
  z-index: 10;
  max-width: min(360px, calc(100vw - 32px));
  padding: 11px 14px;
  border-radius: 999px;
  color: white;
  background: rgba(31, 41, 51, 0.92);
  box-shadow: 0 14px 28px rgba(31, 41, 51, 0.2);
  font-size: 14px;
  font-weight: 850;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 10px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.join-gate {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(31, 41, 51, 0.28);
  backdrop-filter: blur(14px);
}

.join-gate[hidden] {
  display: none;
}

.join-card {
  width: min(100%, 390px);
  padding: 20px;
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 28px;
  background:
    linear-gradient(180deg, rgba(255, 253, 248, 0.96), rgba(255, 250, 240, 0.96)),
    radial-gradient(circle at top right, rgba(231, 184, 74, 0.22), transparent 14rem);
  box-shadow: 0 24px 70px rgba(31, 41, 51, 0.22);
}

.join-card img {
  display: block;
  width: min(72%, 230px);
  margin: -18px auto -4px;
  filter: drop-shadow(0 18px 22px rgba(81, 57, 34, 0.12));
}

.join-card h2 {
  margin-bottom: 16px;
  font-size: 24px;
}

.join-card label + label {
  margin-top: 10px;
}

.join-card .check-button {
  min-height: 54px;
  margin-top: 14px;
}

.join-error {
  min-height: 20px;
  margin-top: 10px;
  color: #b94b3a;
  font-size: 13px;
  font-weight: 850;
  text-align: center;
}

@media (max-width: 360px) {
  .app-shell {
    padding-right: 12px;
    padding-left: 12px;
  }

  select {
    max-width: 112px;
    padding: 0 8px;
  }
}
