:root {
  --ink: #14181c;
  --ink-soft: #2a323a;
  --mist: #e8ece8;
  --paper: #f3f5f2;
  --line: rgba(20, 24, 28, 0.12);
  --copper: #b56a2b;
  --copper-deep: #8a4a16;
  --pine: #1f4d3a;
  --pine-soft: #2f6b52;
  --bone: #f7f4ee;
  --danger: #9b2c2c;
  --ok: #1f6b45;
  --shadow: 0 18px 50px rgba(20, 24, 28, 0.08);
  --font-display: "Fraunces", "Times New Roman", serif;
  --font-body: "Manrope", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--font-body);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(181, 106, 43, 0.14), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(31, 77, 58, 0.12), transparent 50%),
    linear-gradient(180deg, #f7f8f5 0%, var(--mist) 45%, #dfe5df 100%);
  background-attachment: fixed;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.045;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  z-index: 0;
}

a { color: var(--pine); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--copper-deep); }

.wrap {
  position: relative;
  z-index: 1;
  width: min(1100px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.5rem 0 4rem;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 2rem;
  animation: rise 0.7s ease both;
}

.brand {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 1;
  color: var(--ink);
  text-decoration: none;
}

.brand span {
  display: block;
  margin-top: 0.35rem;
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-soft);
  opacity: 0.7;
}

.nav-link {
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-soft);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  padding-bottom: 2px;
}
.nav-link:hover { border-color: var(--copper); color: var(--copper-deep); }

.hero {
  display: grid;
  gap: 1.25rem;
  margin-bottom: 2.5rem;
  animation: rise 0.85s ease both;
}

.hero h1 {
  margin: 0;
  max-width: 16ch;
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 7vw, 4.4rem);
  font-weight: 550;
  line-height: 0.95;
  letter-spacing: -0.02em;
}

.hero p {
  margin: 0;
  max-width: 42ch;
  font-size: 1.05rem;
  line-height: 1.55;
  color: var(--ink-soft);
}

.bank-plane {
  position: relative;
  margin: 0.5rem 0 2.5rem;
  padding: clamp(1.5rem, 4vw, 2.5rem) 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  animation: rise 1s ease both;
}

.bank-kicker {
  margin: 0 0 0.75rem;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--pine);
}

.bank-value {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(3rem, 10vw, 6.5rem);
  font-weight: 600;
  line-height: 0.9;
  letter-spacing: -0.03em;
  color: var(--ink);
}

.bank-value em {
  font-style: normal;
  color: var(--copper);
}

.bank-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
  margin-top: 1.25rem;
  font-size: 0.95rem;
  color: var(--ink-soft);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 600;
}
.pill strong { color: var(--ink); font-weight: 700; }
.pill.ok { color: var(--ok); }
.pill.off { color: var(--danger); }

.grid-2 {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 2rem;
}
@media (max-width: 820px) {
  .grid-2 { grid-template-columns: 1fr; }
}

.section-title {
  margin: 0 0 1rem;
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 550;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 2rem;
}
@media (max-width: 700px) {
  .metrics { grid-template-columns: 1fr; }
}

.metric {
  padding: 1.1rem 0;
  border-top: 1px solid var(--line);
  animation: rise 1.05s ease both;
}
.metric .label {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
  opacity: 0.75;
}
.metric .num {
  margin-top: 0.45rem;
  font-family: var(--font-display);
  font-size: 2.4rem;
  line-height: 1;
  color: var(--ink);
}
.metric .hint {
  margin-top: 0.4rem;
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}
th, td {
  padding: 0.85rem 0.5rem;
  text-align: left;
  border-bottom: 1px solid var(--line);
}
th {
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
  font-weight: 700;
}
td.place {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 600;
}
td.money { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--copper-deep); }

.note {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  color: var(--ink-soft);
  line-height: 1.55;
  white-space: pre-wrap;
}

.footer {
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  font-size: 0.85rem;
  color: var(--ink-soft);
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

/* Admin */
.panel {
  background: rgba(247, 244, 238, 0.72);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: clamp(1.2rem, 3vw, 1.8rem);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  animation: rise 0.7s ease both;
}

.panel h2 {
  margin: 0 0 1rem;
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 550;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}
@media (max-width: 700px) {
  .form-grid { grid-template-columns: 1fr; }
}

label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

input[type="text"],
input[type="number"],
input[type="password"],
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 3px;
  padding: 0.7rem 0.8rem;
  font: inherit;
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: normal;
  text-transform: none;
}
textarea { min-height: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(181, 106, 43, 0.35);
  border-color: var(--copper);
}

.day-row {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
@media (max-width: 700px) {
  .day-row { grid-template-columns: 1fr; }
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.btn {
  appearance: none;
  border: 0;
  cursor: pointer;
  border-radius: 3px;
  padding: 0.85rem 1.25rem;
  font: inherit;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 0.82rem;
  transition: transform 0.15s ease, background 0.15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--ink); color: var(--bone); }
.btn-primary:hover { background: var(--copper-deep); }
.btn-secondary { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn-danger { background: var(--danger); color: #fff; }

.flash {
  margin: 0 0 1rem;
  padding: 0.85rem 1rem;
  border-left: 3px solid var(--pine);
  background: rgba(31, 77, 58, 0.08);
  color: var(--pine);
  font-weight: 600;
}
.flash.error {
  border-color: var(--danger);
  background: rgba(155, 44, 44, 0.08);
  color: var(--danger);
}

.calc-live {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
}
.calc-live .big {
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 3.2rem);
  margin: 0.25rem 0 0.75rem;
}
.muted { color: var(--ink-soft); font-size: 0.9rem; }
.formula {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 0.85rem;
  background: rgba(20, 24, 28, 0.04);
  padding: 0.65rem 0.8rem;
  border-radius: 3px;
  margin: 0.75rem 0;
}

.empty-state {
  padding: 3rem 0;
  animation: rise 0.8s ease both;
}
.empty-state h1 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 6vw, 3.4rem);
  margin: 0 0 0.75rem;
}
.empty-state p { color: var(--ink-soft); max-width: 40ch; line-height: 1.55; }

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* —— Public page —— */
.page-public {
  min-height: 100dvh;
  overflow-x: hidden;
  background:
    radial-gradient(900px 480px at 8% -8%, rgba(181, 106, 43, 0.18), transparent 55%),
    radial-gradient(800px 420px at 100% 5%, rgba(31, 77, 58, 0.14), transparent 52%),
    linear-gradient(165deg, #f8f7f2 0%, #e7ebe6 42%, #d8e0d9 100%);
}
.wrap-public {
  width: min(740px, calc(100% - 1.5rem));
  min-height: 100dvh;
  padding: 1.1rem 0 1.25rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.wrap-compact {
  width: min(720px, calc(100% - 1.5rem));
  padding: 1rem 0 2.5rem;
}
.topbar-compact {
  margin-bottom: 1rem;
  flex: 0 0 auto;
}
.topbar-compact .brand {
  font-size: clamp(1.55rem, 4vw, 2.15rem);
  color: var(--copper-deep);
}

.public-fit {
  flex: 0 1 auto;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.stage-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0 0 1rem;
}
.stage-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 0.84rem;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.5);
}
.stage-tab em {
  font-style: normal;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--pine);
}
.stage-tab:hover { border-color: var(--copper); color: var(--copper-deep); }
.stage-tab.is-active {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--bone);
}
.stage-tab.is-active em { color: rgba(247, 244, 238, 0.75); }

.public-hero {
  margin: 0 0 1.15rem;
  padding: 0 0 1.1rem;
  border-bottom: 1px solid var(--line);
}
.public-hero h1 {
  margin: 0;
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.bank-huge {
  margin: 0.35rem 0 0.5rem;
  font-family: var(--font-display);
  font-size: clamp(2.7rem, 8vw, 4rem);
  font-weight: 650;
  line-height: 0.95;
  letter-spacing: -0.03em;
}
.bank-huge em { font-style: normal; color: var(--copper-deep); }
.bank-huge span {
  font-size: 0.42em;
  font-weight: 550;
  color: var(--ink-soft);
}
.one-line {
  margin: 0;
  font-size: 1rem;
  line-height: 1.4;
  color: var(--ink-soft);
}

.prize-section { margin: 0 0 0.85rem; }
.prize-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.4rem 1rem;
  margin-bottom: 0.65rem;
}
.prize-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 600;
}
.prize-head p {
  margin: 0;
  font-size: 0.86rem;
  color: var(--ink-soft);
}

.table-shell {
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.28);
}
.prize-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}
.prize-table thead th {
  padding: 0.7rem 0.55rem;
  text-align: left;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--ink-soft);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.prize-table tbody td {
  padding: 0.72rem 0.55rem;
  border-bottom: 1px solid rgba(20, 24, 28, 0.07);
  vertical-align: middle;
}
.prize-table tbody tr:last-child td { border-bottom: 0; }
.prize-table tbody tr:nth-child(even) { background: rgba(20, 24, 28, 0.025); }
.prize-table tbody tr:hover { background: rgba(181, 106, 43, 0.07); }
.place-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.85rem;
  height: 1.85rem;
  border-radius: 999px;
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 650;
  background: rgba(20, 24, 28, 0.06);
  color: var(--ink);
}
.row-gold .place-badge {
  background: rgba(181, 106, 43, 0.2);
  color: var(--copper-deep);
}
.row-silver .place-badge {
  background: rgba(90, 104, 112, 0.14);
  color: #3d4a52;
}
.row-bronze .place-badge {
  background: rgba(140, 90, 48, 0.14);
  color: #6b4520;
}
.col-share {
  font-weight: 700;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}
.col-coins {
  font-family: var(--font-display);
  font-size: 1.28rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  color: var(--copper-deep);
  white-space: nowrap;
}
.col-rub {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--pine);
  white-space: nowrap;
}
.col-rub.is-muted {
  color: var(--ink-soft);
  font-weight: 600;
  text-transform: none;
}
.starter-section .prize-table thead th:nth-child(2),
.starter-section .prize-table thead th:nth-child(3),
.starter-section .col-coins,
.starter-section .col-rub { text-align: right; }
.starter-note {
  margin: 0 0 0.85rem;
  font-size: 0.98rem;
  line-height: 1.45;
  color: var(--ink-soft);
  max-width: 46ch;
}
.starter-note-bottom {
  margin: 0.9rem 0 0;
  padding-top: 0.75rem;
  border-top: 1px solid var(--line);
  font-weight: 600;
  color: var(--pine);
}
.row-gold .col-coins { font-size: 1.4rem; }
.prize-table thead th:nth-child(3),
.prize-table.has-rub thead th:nth-child(4),
.col-coins,
.col-rub { text-align: right; }
.col-place { width: 3.8rem; }
.col-share { width: 4.2rem; }

.status-row { margin: 0.15rem 0 0.35rem; }
.status-box {
  display: grid;
  gap: 0.25rem;
  padding: 0.85rem 0;
  border-top: 1px solid var(--line);
}
.status-box strong { font-size: 0.98rem; }
.status-box span {
  font-size: 0.92rem;
  line-height: 1.4;
  color: var(--ink-soft);
}
.status-box.is-on strong { color: var(--ok); }
.status-box.is-off strong { color: var(--danger); }

.howto {
  margin: 0.15rem 0 0;
  padding-top: 0.55rem;
  border-top: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 0.84rem;
  line-height: 1.4;
}
.howto summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--ink);
  list-style: none;
}
.howto summary::-webkit-details-marker { display: none; }
.howto summary::after { content: " ▾"; color: var(--copper); }
.howto[open] summary::after { content: " ▴"; }
.howto p { margin: 0.4rem 0 0; }

.page-public .footer-compact {
  margin-top: 0.75rem;
  padding-top: 0;
  border-top: 0;
  font-size: 0.8rem;
}

@media (max-width: 560px) {
  .wrap-public { justify-content: flex-start; padding-top: 0.85rem; }
  .prize-table thead th:nth-child(2),
  .col-share { display: none; }
}

@media (max-height: 700px) {
  .bank-huge { font-size: clamp(2.2rem, 6vw, 3rem); }
  .prize-table tbody td { padding: 0.5rem 0.45rem; }
  .status-box { padding: 0.55rem 0; }
}

/* Admin openings archive */
.openings-list { display: grid; gap: 0.65rem; }
.opening-item {
  border: 1px solid var(--line);
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.45);
  padding: 0.65rem 0.85rem;
}
.opening-item summary {
  cursor: pointer;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1rem;
  align-items: baseline;
  justify-content: space-between;
  list-style: none;
  font-size: 0.95rem;
}
.opening-item summary::-webkit-details-marker { display: none; }
.opening-item summary span {
  color: var(--ink-soft);
  font-size: 0.85rem;
}
.opening-body { margin-top: 0.75rem; padding-top: 0.65rem; border-top: 1px solid var(--line); }
