:root {
  color-scheme: light;
  --bg: #f6f0e8;
  --panel: rgba(255, 253, 249, 0.88);
  --panel-strong: #fffaf2;
  --ink: #1e1a17;
  --muted: #66584b;
  --accent: #b14d24;
  --accent-dark: #7e3114;
  --line: rgba(52, 36, 27, 0.12);
  --danger: #8d2323;
  --shadow: 0 24px 70px rgba(86, 53, 32, 0.14);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: Georgia, "Times New Roman", serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(231, 174, 97, 0.45), transparent 30%),
    radial-gradient(circle at bottom right, rgba(177, 77, 36, 0.18), transparent 35%),
    linear-gradient(180deg, #fbf7f2 0%, var(--bg) 100%);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

a {
  color: inherit;
  text-decoration: none;
}

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

.shell-header,
.shell-footer,
.page-shell {
  width: min(1040px, calc(100% - 2rem));
  margin: 0 auto;
}

.shell-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 0;
}

.brand {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-decoration: none;
  text-transform: uppercase;
}

.shell-header nav a {
  text-decoration: none;
  padding: 0.6rem 1rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.5);
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

.page-shell {
  padding: 2rem 0 4rem;
  padding-bottom: calc(4rem + var(--safe-bottom));
}

.hero-card,
.panel,
.note-card {
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.hero-card {
  padding: 2.5rem;
  margin-bottom: 1.5rem;
}

.hero-big {
  text-align: center;
}

.hero-big .lead {
  margin: 0 auto 1rem;
}

.subtitle {
  color: var(--muted);
  font-size: 1rem;
}

.eyebrow {
  margin: 0 0 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--accent);
  font-size: 0.78rem;
}

h1, h2, h3, p {
  margin-top: 0;
}

.lead {
  max-width: 52rem;
  font-size: 1.15rem;
  color: var(--muted);
}

/* ── People Grid (landing) ── */

.people-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.person-card-link {
  text-decoration: none;
  display: block;
}

.person-card {
  padding: 1.5rem;
  background: var(--panel-strong);
  transition: transform 0.2s, box-shadow 0.2s;
  cursor: pointer;
}

.person-card-link:hover .person-card,
.person-card:active {
  transform: translateY(-2px);
  box-shadow: 0 12px 40px rgba(86, 53, 32, 0.2);
}

.person-emoji {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}

.person-card h2 {
  font-size: 1.3rem;
  margin-bottom: 0.25rem;
}

.person-code {
  color: var(--muted);
  font-size: 0.95rem;
  margin-bottom: 0.25rem;
}

.code-badge {
  font-weight: 700;
  font-family: monospace;
  letter-spacing: 0.1em;
  background: rgba(177, 77, 36, 0.1);
  padding: 0.1rem 0.4rem;
  border-radius: 6px;
}

.person-hint {
  font-size: 0.85rem;
  color: var(--muted);
}

/* ── Notes Grid ── */

.notes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
}

.note-card {
  padding: 1.25rem;
  background: var(--panel-strong);
}

/* ── Panels ── */

.panel {
  padding: 1.5rem;
}

.panel-narrow {
  max-width: 28rem;
}

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

.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
}

.panel-header > h1,
.panel-header > h2 {
  min-width: 0;
  flex: 1 1 auto;
  overflow-wrap: break-word;
  word-break: break-word;
}

.stack-form {
  display: grid;
  gap: 0.9rem;
}

.stack-form label {
  display: grid;
  gap: 0.35rem;
  color: var(--muted);
}

input,
textarea,
select {
  width: 100%;
  padding: 0.8rem 0.95rem;
  border: 1px solid rgba(52, 36, 27, 0.16);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.9);
  min-height: 48px;
  font-size: 16px;
}

button {
  width: fit-content;
  padding: 0.75rem 1.1rem;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  transition: background 0.2s;
  min-height: 44px;
  min-width: 44px;
}

button:hover {
  background: var(--accent-dark);
}

button:active {
  transform: scale(0.98);
}

.secondary-button {
  background: rgba(30, 26, 23, 0.78);
}

.secondary-button:hover {
  background: rgba(30, 26, 23, 0.9);
}

.danger-button {
  background: var(--danger);
}

.danger-button:hover {
  background: #6e1a1a;
}

/* ── Flash messages ── */

.flash-stack {
  display: grid;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.flash {
  padding: 0.9rem 1rem;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.85);
}

.flash-success {
  border-color: rgba(58, 124, 77, 0.28);
}

.flash-error {
  border-color: rgba(141, 35, 35, 0.24);
}

/* ── Mission cards ── */

.section-title {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.85rem;
  margin: 2rem 0 1rem;
}

.mission-badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-photo {
  background: rgba(177, 77, 36, 0.15);
  color: var(--accent);
}

.badge-recurring {
  background: rgba(58, 124, 77, 0.15);
  color: #2d6a4f;
}

.badge-easy { background: rgba(58, 124, 77, 0.12); color: #2d6a4f; }
.badge-medium { background: rgba(200, 150, 0, 0.15); color: #8b6914; }
.badge-hard { background: rgba(141, 35, 35, 0.12); color: var(--danger); }

/* ── Checkbox grid ── */

.checkbox-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.3rem;
  max-height: 200px;
  overflow-y: auto;
  padding: 0.5rem;
  border: 1px solid rgba(52, 36, 27, 0.12);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.5);
  margin-bottom: 0.5rem;
}

.checkbox-grid label {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  color: var(--ink);
  font-size: 0.9rem;
  cursor: pointer;
  min-height: 44px;
  padding: 0.25rem 0;
}

.checkbox-grid input[type="checkbox"] {
  width: auto;
}

/* ── Pending badge & review link ── */

.pending-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 0.35rem;
  border-radius: 999px;
  background: var(--accent);
  color: white;
  font-size: 0.75rem;
  font-weight: 700;
}

.review-link {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.4rem 0.9rem;
  border-radius: 14px;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  background: rgba(177, 77, 36, 0.12);
  color: var(--accent);
}

.review-link:hover {
  background: rgba(177, 77, 36, 0.2);
}

/* ── Empty state ── */

.empty-state {
  text-align: center;
  padding: 2rem;
  color: var(--muted);
}

.empty-state a {
  color: var(--accent);
  text-decoration: underline;
}

/* ── Mission progress ── */

.mission-progress {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1rem;
}

.progress-bar {
  flex: 1;
  height: 8px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.3s;
}

/* ── Footer ── */

.shell-footer {
  padding: 0 0 2rem;
  color: var(--muted);
  text-align: center;
  padding-bottom: calc(2rem + var(--safe-bottom));
}

/* ── Mobile ── */

@media (max-width: 720px) {
  .shell-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .shell-header nav {
    display: flex;
    gap: 0.5rem;
  }

  .shell-header nav a {
    padding: 0.5rem 0.75rem;
  }

  .page-shell {
    padding: 1rem 0 2rem;
  }

  .shell-header,
  .shell-footer,
  .page-shell {
    width: calc(100% - 1rem);
  }

  .hero-card,
  .panel,
  .note-card {
    border-radius: 18px;
  }

  .hero-card {
    padding: 1.5rem;
  }

  h1 {
    font-size: 1.6rem;
  }

  h2 {
    font-size: 1.3rem;
  }

  h3 {
    font-size: 1.15rem;
  }

  .lead {
    font-size: 1rem;
  }

  .people-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .person-card {
    padding: 1.25rem;
  }

  .notes-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

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

  .panel-header > div {
    width: 100%;
    justify-content: flex-start;
  }

  .admin-grid {
    grid-template-columns: 1fr;
  }

  .panel-wide {
    grid-column: 1;
  }

  .mission-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .mission-badges {
    width: 100%;
  }

  .mission-badge {
    font-size: 0.7rem;
    padding: 0.15rem 0.5rem;
  }

  .section-title {
    margin: 1.5rem 0 0.75rem;
    font-size: 0.8rem;
  }

  .mission-card {
    padding: 1.25rem;
  }

  .total-points {
    font-size: 1.75rem;
  }

  .submission-preview img {
    max-height: 250px;
  }

  .podium {
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
  }

  .podium-place {
    width: 100%;
    max-width: 100%;
    order: unset !important;
  }

  .podium-block {
    height: auto !important;
    padding: 0.75rem;
  }

  .podium-place.first .podium-block {
    background: linear-gradient(135deg, #ffd700, #f0c000);
  }
  .podium-place.second .podium-block {
    background: linear-gradient(135deg, #c0c0c0, #a8a8a8);
  }
  .podium-place.third .podium-block {
    background: linear-gradient(135deg, #cd7f32, #b8722d);
  }
}

/* ── Very small screens ── */

@media (max-width: 380px) {
  h1 {
    font-size: 1.4rem;
  }
  
  h2 {
    font-size: 1.2rem;
  }
  
  h3 {
    font-size: 1.05rem;
  }
  
  .hero-card {
    padding: 1.25rem;
  }

  .mission-card {
    padding: 1rem;
  }

  .file-label {
    padding: 0.875rem 1rem;
  }

  .file-label-text {
    font-size: 0.9rem;
  }
}
