@import url("https://fonts.googleapis.com/css2?family=Raleway:wght@400;500;600;700;800;900&display=swap");

:root {
  --blue: #39C2DD;
  --navy: #00343C;
  --beige: #F2E6D0;
  --offwhite: #F5F0EA;
  --coolgrey: #E2E6E7;
  --nearwhite: #FAFAFA;
  --white: #FFF;
  --darkgrey: #979797;
  --ink-muted: rgba(0, 52, 60, .7);
  --blue-soft: rgba(57, 194, 221, .14);
  --ok: #1A9C6B;
  --warn: #C0703A;
  --radius: 12px;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: "Raleway", Calibri, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  background: var(--offwhite);
  color: var(--navy);
}
main { flex: 1 0 auto; }

h1, h2, h3 { line-height: 1.15; margin: 0 0 .6em; font-weight: 800; }
h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); font-weight: 900; }
h2 { font-size: 1.5rem; }
p { margin: 0 0 1em; }

a { color: var(--navy); text-decoration: underline; text-decoration-color: var(--blue); text-decoration-thickness: 2px; text-underline-offset: 3px; }
a:hover { background: var(--blue-soft); }

:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }

img { max-width: 100%; height: auto; }

/* Header */
.site-header { background: var(--navy); color: var(--white); }
.site-header__inner {
  max-width: 1120px; margin: 0 auto; padding: 0 24px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 28px;
}
.brand { display: flex; align-items: baseline; gap: 12px; padding: 16px 0; color: var(--white); text-decoration: none; }
.brand:hover { background: none; }
.wordmark { color: var(--blue); font-weight: 700; font-size: 1.7rem; letter-spacing: -.5px; text-transform: lowercase; }
.brand__sub { font-weight: 600; color: var(--white); }
.site-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 0 24px; margin-left: auto; }
.site-nav a {
  color: var(--white); font-weight: 600; text-decoration: none;
  padding: 22px 0 14px; border-bottom: 4px solid transparent;
}
.site-nav a:hover { background: none; border-bottom-color: var(--blue-soft); }
.site-nav a[aria-current="page"] { border-bottom-color: var(--blue); }
.site-nav a:focus-visible, .brand:focus-visible { outline-offset: -2px; }
.site-nav .greeting { font-weight: 500; color: var(--white); opacity: .85; }
.site-nav form { margin: 0; }
@media (max-width: 719px) {
  .site-header__inner { padding: 0 16px; }
  .brand { padding: 12px 0 0; width: 100%; }
  .site-nav { margin-left: 0; width: 100%; gap: 0 18px; }
  .site-nav .greeting { width: 100%; padding-top: 6px; }
  .site-nav a { padding: 12px 0 10px; }
  .site-nav form { padding: 8px 0 12px; }
}

/* Footer */
.site-footer { flex-shrink: 0; margin-top: 48px; }
.site-footer__text { max-width: 1120px; margin: 0 auto; padding: 0 24px 24px; color: var(--ink-muted); font-size: .875rem; }
.site-footer__bar { height: 20px; background: var(--blue); }

/* Layout */
.page { max-width: 1120px; margin: 0 auto; padding: 40px 24px; }
.page--wide { max-width: 1440px; }
@media (max-width: 719px) { .page { padding: 28px 16px; } }

.kicker {
  display: flex; align-items: center; gap: 12px;
  margin: 0 0 14px; font-size: .8rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 2px;
}
.kicker::before { content: ""; width: 28px; height: 4px; background: var(--blue); flex: none; }

/* Card */
.card { background: var(--white); border-top: 6px solid var(--blue); padding: 32px; }
.card--narrow { max-width: 440px; margin: 0 auto; }
.card h1 { font-size: clamp(1.6rem, 3.5vw, 2.1rem); }
@media (max-width: 719px) { .card { padding: 24px 18px; } }

/* Notices */
.notice { background: var(--coolgrey); color: var(--navy); border-left: 6px solid var(--navy); padding: 12px 16px; margin: 0 0 1em; }
.notice--ok { background: var(--white); border-left-color: var(--ok); }
.notice--error { background: var(--white); border-left-color: var(--warn); font-weight: 600; }

/* Buttons */
.btn, button.btn, a.btn {
  text-decoration-line: none;
  display: inline-block; font: inherit; font-weight: 700; line-height: 1.2;
  padding: 13px 24px; border: 2px solid var(--navy); border-radius: 0; cursor: pointer;
  background: var(--navy); color: var(--white); text-decoration: none; text-align: center;
}
.btn:hover { background: var(--blue); border-color: var(--blue); color: var(--navy); }
.btn--primary { background: var(--navy); color: var(--white); border-color: var(--navy); }
.btn--primary:hover { background: var(--blue); border-color: var(--blue); color: var(--navy); }
a.btn--ghost, button.btn--ghost, .btn--ghost { background: transparent; color: var(--navy); border: 2px solid currentColor; }
.btn--ghost:hover { background: var(--blue-soft); color: var(--navy); border-color: currentColor; }

.btn.btn--ghost-light, button.btn--ghost-light { color: var(--white); border-color: var(--white); background: transparent; }
.btn.btn--ghost-light:hover, button.btn--ghost-light:hover { background: var(--blue); border-color: var(--blue); color: var(--navy); }
.btn--small { padding: 6px 12px; font-size: .875rem; }
.btn--danger { background: var(--warn); border-color: var(--warn); color: var(--white); }
.btn--danger:hover { background: var(--navy); border-color: var(--navy); color: var(--white); }
.btn--block { display: block; width: 100%; }

/* Forms */
.field { margin: 0 0 20px; }
.field label, label.field__label { display: block; font-weight: 700; margin-bottom: 6px; }
.field__hint { display: block; font-size: .875rem; color: var(--ink-muted); margin-top: 4px; font-weight: 400; }
.form-row { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: flex-end; margin: 0 0 20px; }
.form-row .field { margin: 0; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="search"], input[type="date"], input[type="datetime-local"], input[type="file"], select, textarea {
  font: inherit; color: var(--navy); background: var(--white);
  border: 2px solid var(--navy); border-radius: 0; padding: 10px 12px; max-width: 100%;
}
.field input:not([type="checkbox"]):not([type="radio"]), .field select, .field textarea { width: 100%; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
input::placeholder { color: var(--ink-muted); }

/* Hero (calendar) */
.hero { background: var(--navy); color: var(--white); }
.hero__inner { max-width: 1120px; margin: 0 auto; padding: 48px 24px 56px; }
.hero .kicker { color: var(--blue); }
.hero h1 { color: var(--white); margin-bottom: 14px; font-size: clamp(1.7rem, 6vw, 2.8rem); }
.hero__lead { max-width: 56ch; font-size: 1.15rem; margin-bottom: 24px; }
.hero__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; }
.countdown { display: inline-block; margin: 0; background: var(--blue); color: var(--navy); font-weight: 700; padding: 13px 20px; }
.hero a.btn--ghost { color: var(--white); border-color: var(--white); }
.hero a.btn--ghost:hover { background: var(--blue); border-color: var(--blue); color: var(--navy); }
@media (max-width: 719px) { .hero__inner { padding: 32px 16px 40px; } }

/* Door grid */
.calendar { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; grid-template-columns: repeat(2, 1fr); }
@media (min-width: 640px) { .calendar { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 1000px) { .calendar { grid-template-columns: repeat(6, 1fr); } }

.door { position: relative; aspect-ratio: 1; min-width: 0; border-radius: 0; background: var(--beige); color: var(--navy); }
.door__link, .door__face {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  justify-content: space-between; padding: 12px 14px; color: inherit; text-decoration: none; overflow: hidden;
}
.door__link:hover { background: none; outline: 3px solid var(--navy); outline-offset: 3px; }
.door__link:focus-visible { outline: 3px solid var(--navy); outline-offset: 3px; }
.door__day { font-size: clamp(2.4rem, 6vw, 3.6rem); font-weight: 900; line-height: 1; display: block; }
.door__info, .door__label { font-size: .8rem; font-weight: 600; line-height: 1.3; display: block; }
.door__icon { position: absolute; top: 12px; right: 12px; width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.door--locked { background: var(--navy); color: var(--beige); }
.door--locked .door__info { color: var(--white); opacity: .7; }
.door--open { background: var(--beige); }
.door--today { background: var(--blue); color: var(--navy); }
.door--today::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  box-shadow: none; border: 4px solid var(--navy); opacity: 1;
  animation: door-pulse 2.4s ease-in-out infinite;
}
@keyframes door-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .door--today::after { animation: none; } * { scroll-behavior: auto !important; } }
.door--answered { background: var(--white); border-top: 6px solid var(--blue); }
.door--answered .door__link { padding-top: 8px; }
.door__answer {
  font-size: .85rem; font-weight: 700; line-height: 1.25;
  display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.door--answered .door__icon { top: 8px; color: var(--ok); }

/* Puzzle */
.puzzle { display: grid; gap: 32px; grid-template-columns: 1fr; align-items: start; }
@media (min-width: 900px) { .puzzle { grid-template-columns: 3fr 2fr; } }
.puzzle__media { background: var(--white); padding: 16px; margin: 0; display: flex; justify-content: center; }
.puzzle__image { display: block; width: auto; height: auto; max-width: 100%; max-height: calc(100vh - 140px); object-fit: contain; border-radius: var(--radius); }
.puzzle__side { min-width: 0; }
@media (min-width: 900px) { .puzzle__side { position: sticky; top: 24px; } }
.puzzle__language { margin: 0 0 1em; color: var(--ink-muted); }
.puzzle__result { font-weight: 700; margin-top: 16px; padding: 12px 16px; background: var(--beige); }
.puzzle__nav { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 24px; }
.puzzle__nav .btn { flex: 1 1 auto; }

.answer-form { display: flex; flex-direction: column; gap: 8px; margin: 0 0 12px; }
.answer-form label { font-weight: 700; }
.answer-form input[type="text"] { width: 100%; font-size: 18px; padding: 14px 14px; }
.answer-form .btn { margin-top: 8px; }
.notice--ok.answer-ok { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.answer-ok__icon { width: 24px; height: 24px; flex: none; fill: none; stroke: var(--ok); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.answer-saved { color: var(--ink-muted); font-size: .9rem; }
.answer-readonly { font-weight: 700; font-size: 1.1rem; }
.answer-verdict { display: inline-block; font-weight: 800; padding: 4px 12px; background: var(--beige); }

/* Tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table, .answers-table { border-collapse: collapse; width: 100%; background: var(--white); }
.table th, .answers-table th {
  background: var(--navy); color: var(--white); text-align: left; padding: 12px 14px;
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.5px; white-space: nowrap;
}
.table td, .answers-table td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--coolgrey); vertical-align: middle; }
.table tbody tr:nth-child(odd), .answers-table tbody tr:nth-child(odd) { background: var(--white); }
.table tbody tr:nth-child(even), .answers-table tbody tr:nth-child(even) { background: var(--nearwhite); }
.table--compact th, .table--compact td { padding: 6px 10px; font-size: .9rem; }
th.sortable { cursor: pointer; }
th.sortable a { color: inherit; text-decoration: none; }
th.sortable a:hover { background: none; text-decoration: underline; text-decoration-color: var(--blue); }
th.sortable::after { content: " \2195"; opacity: .5; }
th.sortable--asc::after { content: " \25B2"; opacity: 1; color: var(--blue); }
th.sortable--desc::after { content: " \25BC"; opacity: 1; color: var(--blue); }
.table .answer-form, .answers-table .answer-form { flex-direction: row; align-items: center; gap: 8px; margin: 0; }
.table .answer-form input[type="text"], .answers-table .answer-form input[type="text"] { font-size: 1rem; padding: 6px 10px; min-width: 12rem; }
.table .answer-form .btn, .answers-table .answer-form .btn { margin-top: 0; padding: 6px 12px; font-size: .875rem; }
.answers-table .notice { margin-bottom: 8px; }

/* Tags */
.tag { display: inline-block; padding: 2px 10px; font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; background: var(--coolgrey); color: var(--navy); }
.tag--ok { background: var(--ok); color: var(--white); }
.tag--warn { background: var(--warn); color: var(--white); }
.tag--muted { background: var(--coolgrey); color: var(--ink-muted); }
.tag--override { background: var(--beige); color: var(--navy); }

/* Subnav */
.subnav { display: flex; flex-wrap: wrap; gap: 0 24px; margin: 0 0 28px; border-bottom: 2px solid var(--coolgrey); }
.subnav a { color: var(--navy); font-weight: 700; text-decoration: none; padding: 10px 0 8px; border-bottom: 4px solid transparent; margin-bottom: -2px; }
.subnav a:hover { background: none; border-bottom-color: var(--blue-soft); }
.subnav a[aria-current="page"], .subnav a.is-active, .subnav .is-active > a { border-bottom-color: var(--blue); }

/* Podium and ranking */
.podium { display: flex; align-items: flex-end; justify-content: center; gap: 12px; margin: 24px 0 40px; }
.podium__place { flex: 1 1 0; max-width: 240px; padding: 16px; text-align: center; font-weight: 700; display: flex; flex-direction: column; justify-content: flex-start; }
.podium__place::before { content: attr(data-place); font-size: 3.5rem; font-weight: 900; line-height: 1; }
.podium__place--1 { background: var(--navy); color: var(--white); min-height: 240px; }
.podium__place--1::before { color: var(--blue); }
.podium__place--2 { background: var(--blue); color: var(--navy); min-height: 190px; }
.podium__place--3 { background: var(--beige); color: var(--navy); min-height: 150px; }
.podium__place .podium__rank { font-size: 3.5rem; font-weight: 900; line-height: 1; }
.podium__place:has(.podium__rank)::before { content: none; }
.podium__name { font-size: 1.1rem; }
.podium__score { font-weight: 500; }
.ranking { list-style: none; margin: 0; padding: 0; }
.ranking li { display: flex; gap: 16px; align-items: baseline; padding: 10px 14px; background: var(--white); border-bottom: 1px solid var(--coolgrey); }
.ranking li:nth-child(even) { background: var(--nearwhite); }
table.ranking { border-collapse: collapse; width: 100%; display: table; }
table.ranking th { background: var(--navy); color: var(--white); text-align: left; padding: 12px 14px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.5px; }
table.ranking td { padding: 10px 14px; border-bottom: 1px solid var(--coolgrey); background: var(--white); }
table.ranking tr:nth-child(even) td { background: var(--nearwhite); }
@media (max-width: 639px) { .site-nav { gap: 0 14px; } }
@media (max-width: 719px) { .podium { gap: 6px; } .podium__place { padding: 10px 6px; font-size: .9rem; } }

.intro-image { display: block; border-radius: var(--radius); margin: 0 0 1.5em; }
.score { font-weight: 800; font-size: 1.2rem; }

/* Admin ranking: section spacing and per-day matrix */
.section-title { margin-top: 40px; margin-bottom: 12px; }
.matrix td, .matrix th { text-align: center; }
.matrix td:first-child, .matrix th:first-child { text-align: left; white-space: nowrap; }
.matrix__ok { color: var(--ok); font-weight: 700; }
.matrix__wrong { color: var(--warn); font-weight: 700; }
.matrix__none { color: var(--darkgrey); }
