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

:root{
  --bg:#f5f7fb;
  --bg-soft:#eef4ff;
  --panel:#ffffff;
  --panel-strong:#f8fbff;
  --text:#172033;
  --muted:#63708a;
  --blue:#2563eb;
  --blue-dark:#1d4ed8;
  --teal:#0f766e;
  --amber:#d97706;
  --line:#d9e2f1;
  --line-strong:#b9c8dd;
  --shadow:0 20px 50px rgba(37, 99, 235, .12);
  --shadow-soft:0 12px 28px rgba(23, 32, 51, .08);
  --radius:22px;
}

*{ box-sizing:border-box; }

html, body{
  margin:0;
  min-height:100%;
  color:var(--text);
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background:
    radial-gradient(900px 520px at 8% -8%, rgba(37,99,235,.16), transparent 62%),
    radial-gradient(850px 520px at 92% 0%, rgba(20,184,166,.14), transparent 58%),
    linear-gradient(180deg, #fbfdff 0%, var(--bg) 55%, #edf3fb 100%);
  overflow-x:hidden;
}

body::before{
  content:"";
  position:fixed;
  inset:0;
  pointer-events:none;
  background-image:
    linear-gradient(rgba(37,99,235,.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(37,99,235,.05) 1px, transparent 1px);
  background-size:48px 48px;
  mask-image:linear-gradient(180deg, rgba(0,0,0,.65), transparent 78%);
}

header, main, .container{ position:relative; z-index:2; }

.container{
  max-width:1180px;
  margin:0 auto;
  padding:30px 20px;
}

.hero{
  border-bottom:1px solid var(--line);
  background:rgba(255,255,255,.78);
  backdrop-filter:blur(18px);
  box-shadow:0 8px 30px rgba(99,112,138,.08);
}

.hero-grid{
  display:grid;
  grid-template-columns:minmax(0, 1fr) minmax(280px, 360px);
  gap:28px;
  align-items:center;
  padding-top:42px;
  padding-bottom:42px;
}

.eyebrow{
  margin:0 0 10px;
  color:var(--blue);
  font-size:12px;
  font-weight:900;
  letter-spacing:.16em;
  text-transform:uppercase;
}

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

h1{
  margin-bottom:14px;
  font-size:clamp(42px, 8vw, 86px);
  line-height:.94;
  letter-spacing:-.07em;
}

h2{
  margin-bottom:0;
  font-size:clamp(28px, 4vw, 42px);
  line-height:1;
  letter-spacing:-.04em;
}

.muted{ color:var(--muted); }

.hero-copy{
  max-width:720px;
  margin-bottom:0;
  font-size:18px;
  line-height:1.7;
}

.status-panel{
  border:1px solid rgba(37,99,235,.16);
  border-radius:var(--radius);
  background:
    linear-gradient(145deg, rgba(255,255,255,.94), rgba(248,251,255,.86)),
    radial-gradient(520px 180px at 0% 0%, rgba(37,99,235,.10), transparent 70%);
  box-shadow:var(--shadow);
  padding:22px;
}

.progress{
  margin:0 0 8px;
  font-size:28px;
  font-weight:900;
  letter-spacing:-.04em;
}

.row{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  margin-top:14px;
}

button, a.button{
  appearance:none;
  border:1px solid transparent;
  color:#fff;
  background:linear-gradient(180deg, var(--blue), var(--blue-dark));
  border-radius:999px;
  padding:11px 18px;
  font-weight:900;
  letter-spacing:.01em;
  cursor:pointer;
  text-decoration:none;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  box-shadow:0 12px 22px rgba(37,99,235,.22);
  transition:transform .14s ease, box-shadow .14s ease, background .14s ease;
}

button:hover, a.button:hover{
  transform:translateY(-2px);
  box-shadow:0 16px 28px rgba(37,99,235,.26);
}

button.secondary, a.button.secondary{
  color:var(--text);
  background:#fff;
  border-color:var(--line-strong);
  box-shadow:var(--shadow-soft);
}

button.danger{
  color:#fff;
  background:linear-gradient(180deg, #e11d48, #be123c);
  box-shadow:0 12px 22px rgba(190,18,60,.20);
}

button.danger:hover{
  box-shadow:0 16px 28px rgba(190,18,60,.26);
}

button:disabled, a.button[aria-disabled="true"]{
  opacity:.55;
  pointer-events:none;
}

.section-heading{
  display:flex;
  justify-content:space-between;
  align-items:end;
  gap:22px;
  margin:18px 0 18px;
}

.section-heading > .muted{
  max-width:330px;
  margin-bottom:4px;
  text-align:right;
}

/* =========================
   PUZZLE BOARD
========================= */
.gallery{
  display:grid;
  grid-template-columns:repeat(auto-fit, minmax(280px, 1fr));
  gap:16px;
  margin:0;
  padding:0 0 36px;
  list-style:none;
}

.card{
  position:relative;
  isolation:isolate;
  overflow:hidden;
  min-height:176px;
  border:1px solid var(--line);
  border-radius:20px;
  background:linear-gradient(180deg, rgba(255,255,255,.94), rgba(248,251,255,.92));
  box-shadow:var(--shadow-soft);
  padding:20px;
  display:grid;
  grid-template-columns:1fr auto;
  grid-template-areas:
    "index badge"
    "name name"
    "label label"
    "button button";
  align-content:start;
  gap:10px;
}

.card::before{
  content:"";
  position:absolute;
  inset:0;
  z-index:-1;
  background:
    linear-gradient(90deg, rgba(37,99,235,.12), transparent 38%),
    radial-gradient(480px 160px at 100% 0%, rgba(20,184,166,.12), transparent 65%);
  opacity:.95;
}

.card-meta-puzzle{
  border-color:rgba(217,119,6,.30);
}


.card-introduction-puzzle{
  border-color:rgba(20,184,166,.32);
}

.card-introduction-puzzle::before{
  background:
    linear-gradient(90deg, rgba(20,184,166,.16), transparent 40%),
    radial-gradient(480px 160px at 100% 0%, rgba(37,99,235,.12), transparent 65%);
}

.card-meta-puzzle::before{
  background:
    linear-gradient(90deg, rgba(217,119,6,.16), transparent 40%),
    radial-gradient(480px 160px at 100% 0%, rgba(37,99,235,.12), transparent 65%);
}

.card-index{
  grid-area:index;
  color:var(--blue);
  font-size:13px;
  font-weight:900;
  letter-spacing:.13em;
}

.puzzle-name{
  grid-area:name;
  margin:2px 0 0;
  font-size:24px;
  line-height:1.05;
  letter-spacing:-.035em;
}

.card-label{
  grid-area:label;
  margin:0 0 6px;
  color:var(--muted);
  font-weight:700;
}

.badge{
  grid-area:badge;
  justify-self:end;
  align-self:start;
  font-size:12px;
  padding:6px 10px;
  border-radius:999px;
  font-weight:900;
  border:1px solid var(--line);
  background:#fff;
}

.badge.solved{
  color:var(--teal);
  border-color:rgba(15,118,110,.22);
  background:rgba(20,184,166,.10);
}

.badge.unlocked{
  color:var(--blue-dark);
  border-color:rgba(37,99,235,.22);
  background:rgba(37,99,235,.09);
}

.card a.button{
  grid-area:button;
  justify-self:start;
  align-self:end;
  margin-top:4px;
}

/* =========================
   PUZZLE PAGES
========================= */
.page-shell{
  max-width:1080px;
}

.page-title{
  font-size:clamp(38px, 6vw, 68px);
  margin:28px 0 12px;
  letter-spacing:-.06em;
}

.page-subtitle{
  margin:0 0 22px;
  color:var(--muted);
  font-size:18px;
  line-height:1.7;
  max-width:72ch;
}

.embed-wrap{
  border-radius:var(--radius);
  overflow:hidden;
  border:1px solid var(--line);
  background:var(--panel);
  box-shadow:var(--shadow);
}

.doc-embed{
  width:100%;
  height:76vh;
  min-height:640px;
  border:0;
  display:block;
}

.answer-section{
  margin:18px 0 40px;
  border-radius:var(--radius);
  border:1px solid var(--line);
  background:rgba(255,255,255,.88);
  box-shadow:var(--shadow-soft);
  padding:18px;
}

.input{
  width:100%;
  max-width:520px;
  padding:13px 14px;
  border-radius:14px;
  border:1px solid var(--line-strong);
  background:#fff;
  color:var(--text);
  font-size:15px;
  margin-top:8px;
  outline:none;
}

.input:focus{
  border-color:rgba(37,99,235,.62);
  box-shadow:0 0 0 4px rgba(37,99,235,.12);
}

.feedback{
  margin:12px 0 0;
  font-size:15px;
  font-weight:800;
  color:var(--muted);
}

.feedback.ok{ color:var(--teal); }
.feedback.bad{ color:#be123c; }

@keyframes shake {
  0% { transform:translateX(0); }
  20% { transform:translateX(-6px); }
  40% { transform:translateX(6px); }
  60% { transform:translateX(-4px); }
  80% { transform:translateX(4px); }
  100% { transform:translateX(0); }
}
.shake { animation:shake 360ms ease; }

.no-hints-note{
  margin:12px 0 0;
  font-size:14px;
  font-weight:700;
}

/* =========================
   Celebration confetti
========================= */
#confettiLayer{
  position:fixed;
  inset:0;
  pointer-events:none;
  z-index:2147483647;
}

.confetti{
  position:fixed;
  left:0;
  top:0;
  width:10px;
  height:10px;
  border-radius:999px;
  opacity:0;
  filter:drop-shadow(0 5px 8px rgba(23,32,51,.18));
  animation:confettiBurst 1000ms cubic-bezier(.1,.9,.2,1) forwards;
}

.confetti.ribbon{
  width:16px;
  height:4px;
  border-radius:999px;
}

@keyframes confettiBurst{
  0%   { transform:translate3d(var(--x), var(--y), 0) scale(.7); opacity:0; }
  12%  { opacity:1; }
  100% { transform:translate3d(calc(var(--x) + var(--dx)), calc(var(--y) + var(--dy)), 0) rotate(var(--rot)) scale(1); opacity:0; }
}

@media (max-width:760px){
  .hero-grid{ grid-template-columns:1fr; }
  .section-heading{ display:block; }
  .section-heading > .muted{ text-align:left; max-width:100%; }
  .gallery{ grid-template-columns:1fr; }
}

/* =========================
   Accounts + leaderboard
========================= */
.account-status{
  margin:0 0 8px;
  color:var(--blue-dark);
  font-size:13px;
  font-weight:900;
  letter-spacing:.08em;
  text-transform:uppercase;
}

.auth-panel,
.admin-panel,
.leaderboard-section{
  margin:18px 0 30px;
  border:1px solid var(--line);
  border-radius:var(--radius);
  background:rgba(255,255,255,.88);
  box-shadow:var(--shadow-soft);
  padding:22px;
}

.auth-panel{
  display:grid;
  grid-template-columns:minmax(0, .9fr) minmax(280px, 1.1fr);
  gap:24px;
  align-items:start;
}

.auth-form{
  display:grid;
  gap:14px;
}

.auth-form label span{
  display:block;
  font-weight:900;
  margin-bottom:6px;
}

.auth-form .input{
  max-width:none;
  margin-top:0;
}

.leaderboard,
.admin-user-list{
  margin:0;
  padding:0;
  list-style:none;
  display:grid;
  gap:10px;
}

.leaderboard{
  counter-reset:rank;
}

.admin-user-row,
.admin-user-empty{
  border:1px solid var(--line);
  border-radius:18px;
  background:linear-gradient(180deg, rgba(255,255,255,.96), rgba(248,251,255,.92));
  padding:14px 16px;
}

.admin-user-row{
  display:flex;
  justify-content:space-between;
  gap:18px;
  align-items:center;
}

.admin-user-summary{
  display:grid;
  gap:4px;
}

.admin-user-summary strong{
  font-size:18px;
  overflow-wrap:anywhere;
}

.admin-user-summary span,
.admin-user-empty{
  color:var(--muted);
  font-weight:800;
}

.admin-user-summary .admin-current-puzzle{
  color:var(--teal);
}

.leaderboard-row,
.leaderboard-empty{
  border:1px solid var(--line);
  border-radius:18px;
  background:linear-gradient(180deg, rgba(255,255,255,.96), rgba(248,251,255,.92));
  padding:14px 16px;
}

.leaderboard-row{
  counter-increment:rank;
  display:flex;
  justify-content:space-between;
  gap:18px;
  align-items:center;
}

.leaderboard-row::before{
  content:counter(rank);
  display:inline-grid;
  place-items:center;
  flex:0 0 auto;
  width:32px;
  height:32px;
  border-radius:999px;
  color:#fff;
  background:linear-gradient(180deg, var(--blue), var(--blue-dark));
  font-weight:900;
  box-shadow:0 10px 18px rgba(37,99,235,.20);
}

.leaderboard-name{
  flex:1 1 auto;
  min-width:0;
  font-weight:900;
  overflow-wrap:anywhere;
}

.leaderboard-score{
  flex:0 0 auto;
  color:var(--teal);
  font-weight:900;
}

.leaderboard-empty{
  color:var(--muted);
  font-weight:800;
}

[hidden]{ display:none !important; }

@media (max-width:760px){
  .auth-panel{ grid-template-columns:1fr; }
  .admin-user-row{ align-items:flex-start; flex-direction:column; }
  .leaderboard-row{ align-items:flex-start; }
  .leaderboard-score{ white-space:nowrap; }
}

/* =========================
   Leaderboard dialog
========================= */
.leaderboard-dialog{
  width:min(720px, calc(100vw - 32px));
  max-height:min(760px, calc(100vh - 32px));
  border:0;
  border-radius:28px;
  padding:0;
  background:transparent;
  color:var(--text);
}

.leaderboard-dialog::backdrop{
  background:rgba(23,32,51,.42);
  backdrop-filter:blur(8px);
}

.leaderboard-window{
  border:1px solid rgba(255,255,255,.72);
  border-radius:28px;
  background:
    linear-gradient(145deg, rgba(255,255,255,.98), rgba(248,251,255,.94)),
    radial-gradient(520px 180px at 0% 0%, rgba(37,99,235,.12), transparent 70%);
  box-shadow:0 28px 80px rgba(23,32,51,.26);
  padding:24px;
}

.leaderboard-window-header{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:18px;
}

.leaderboard-window-copy{
  margin:12px 0 20px;
}

.icon-button{
  width:44px;
  height:44px;
  padding:0;
  flex:0 0 auto;
  font-size:26px;
  line-height:1;
}


/* =========================
   Account notifications
========================= */
.notification-region{
  position:fixed;
  right:20px;
  bottom:20px;
  z-index:10000;
  display:grid;
  gap:12px;
  width:min(360px, calc(100vw - 40px));
  pointer-events:none;
}

.notification{
  transform:translateY(12px);
  opacity:0;
  border:1px solid rgba(255,255,255,.72);
  border-left:5px solid var(--blue);
  border-radius:18px;
  background:rgba(255,255,255,.96);
  box-shadow:0 18px 42px rgba(23,32,51,.18);
  padding:14px 16px;
  color:var(--text);
  font-weight:900;
  line-height:1.35;
  transition:opacity .18s ease, transform .18s ease;
  pointer-events:auto;
}

.notification.ok{
  border-left-color:var(--teal);
}

.notification.info{
  border-left-color:var(--blue);
}

.notification.is-visible{
  transform:translateY(0);
  opacity:1;
}

/* =========================
   Hint requests
========================= */
.hint-request-list{
  margin-bottom:24px;
}

.hint-request-row{
  border:1px solid var(--line);
  border-radius:18px;
  background:linear-gradient(180deg, rgba(255,255,255,.96), rgba(248,251,255,.92));
  padding:14px 16px;
  display:grid;
  gap:10px;
}

.hint-request-row strong{
  font-size:18px;
  overflow-wrap:anywhere;
}

.hint-status{
  justify-self:start;
  border:1px solid var(--line-strong);
  border-radius:999px;
  padding:5px 10px;
  color:var(--muted);
  background:#fff;
  font-size:12px;
  font-weight:900;
  letter-spacing:.08em;
}

.hint-status.pending{
  color:var(--amber);
  border-color:rgba(217,119,6,.28);
  background:rgba(217,119,6,.09);
}

.hint-status.approved{
  color:var(--teal);
  border-color:rgba(15,118,110,.28);
  background:rgba(15,118,110,.09);
}

.hint-status.denied{
  color:#be123c;
  border-color:rgba(190,18,60,.28);
  background:rgba(190,18,60,.09);
}

.hint-progress,
.hint-response{
  margin:0;
  color:var(--muted);
  font-weight:700;
  line-height:1.55;
  white-space:pre-wrap;
  overflow-wrap:anywhere;
}

.hint-actions{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  align-items:flex-start;
}

.hint-response-input{
  flex:1 1 100%;
  max-width:none;
  resize:vertical;
}

.message-dialog{
  width:min(640px, calc(100vw - 32px));
  border:0;
  border-radius:28px;
  padding:0;
  background:transparent;
  color:var(--text);
}

.message-dialog::backdrop{
  background:rgba(23,32,51,.42);
  backdrop-filter:blur(8px);
}

.message-window{
  border:1px solid rgba(255,255,255,.72);
  border-radius:28px;
  background:
    linear-gradient(145deg, rgba(255,255,255,.98), rgba(248,251,255,.94)),
    radial-gradient(520px 180px at 0% 0%, rgba(37,99,235,.12), transparent 70%);
  box-shadow:0 28px 80px rgba(23,32,51,.26);
  padding:24px;
}

.message-copy{
  margin:14px 0 0;
  color:var(--muted);
  font-size:17px;
  font-weight:800;
  line-height:1.6;
  white-space:pre-wrap;
}

.hint-request-form label span{
  display:block;
  margin:14px 0 8px;
  color:var(--muted);
  font-weight:800;
  line-height:1.55;
}

.hint-request-textarea{
  max-width:none;
  resize:vertical;
}

/* =========================
   Persistent puzzle hints + time tracking
========================= */
.puzzle-hint-panel{
  margin-top:18px;
  border-top:1px solid var(--line);
  padding-top:16px;
  display:grid;
  gap:10px;
}

.puzzle-hint-panel h3{
  margin:0;
  font-size:20px;
  letter-spacing:-.02em;
}

.hint-limit-note,
.hint-history-empty{
  margin:0;
  color:var(--muted);
  font-weight:800;
  line-height:1.55;
}

.hint-history-list{
  margin:0;
  padding:0;
  list-style:none;
  display:grid;
  gap:10px;
}

.hint-history-list li{
  border:1px solid rgba(15,118,110,.24);
  border-radius:16px;
  background:rgba(20,184,166,.08);
  padding:12px 14px;
}

.hint-history-list strong{
  display:block;
  color:var(--teal);
  margin-bottom:6px;
}

.hint-history-list p{
  margin:0;
  color:var(--text);
  font-weight:800;
  line-height:1.55;
  white-space:pre-wrap;
  overflow-wrap:anywhere;
}

.admin-time-list{
  margin:8px 0 0;
  padding-left:18px;
  color:var(--muted);
  font-size:13px;
  font-weight:800;
  line-height:1.45;
}

.admin-heading-actions{
  margin:0 0 22px;
}

.public-hint-list{
  margin-bottom:24px;
}

.public-hint-form label span{
  display:block;
  margin:14px 0 8px;
  color:var(--muted);
  font-weight:800;
  line-height:1.55;
}

.public-hint-form select.input{
  max-width:none;
}

.hint-history-list li.public-hint-item{
  border-color:rgba(37,99,235,.24);
  background:rgba(37,99,235,.08);
}

.hint-history-list li.public-hint-item strong{
  color:var(--blue-dark);
}

/* =========================
   Admin window dashboard
========================= */
.admin-window-grid{
  display:grid;
  grid-template-columns:repeat(auto-fit, minmax(220px, 1fr));
  gap:16px;
}

.admin-window-card{
  min-height:150px;
  border:1px solid rgba(37,99,235,.16);
  border-radius:22px;
  color:var(--text);
  background:
    linear-gradient(145deg, rgba(255,255,255,.98), rgba(248,251,255,.92)),
    radial-gradient(420px 160px at 100% 0%, rgba(37,99,235,.12), transparent 70%);
  box-shadow:var(--shadow-soft);
  padding:20px;
  display:grid;
  align-content:start;
  justify-items:start;
  gap:10px;
  text-align:left;
}

.admin-window-card:hover{
  border-color:rgba(37,99,235,.36);
}

.admin-window-card strong{
  font-size:22px;
  line-height:1.05;
  letter-spacing:-.035em;
}

.admin-window-card span:last-child{
  color:var(--teal);
  font-weight:900;
}

.admin-window-eyebrow{
  color:var(--blue);
  font-size:12px;
  font-weight:900;
  letter-spacing:.14em;
  text-transform:uppercase;
}

.admin-dialog{
  width:min(980px, calc(100vw - 32px));
  max-height:min(820px, calc(100vh - 32px));
  border:0;
  border-radius:28px;
  padding:0;
  background:transparent;
  color:var(--text);
}

.admin-puzzles-dialog{
  width:min(1180px, calc(100vw - 32px));
}

.admin-dialog::backdrop{
  background:rgba(23,32,51,.42);
  backdrop-filter:blur(8px);
}

.admin-window{
  max-height:min(820px, calc(100vh - 32px));
  overflow:auto;
  border:1px solid rgba(255,255,255,.72);
  border-radius:28px;
  background:
    linear-gradient(145deg, rgba(255,255,255,.98), rgba(248,251,255,.94)),
    radial-gradient(520px 180px at 0% 0%, rgba(37,99,235,.12), transparent 70%);
  box-shadow:0 28px 80px rgba(23,32,51,.26);
  padding:24px;
}

.admin-window-header{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:18px;
  position:sticky;
  top:-24px;
  z-index:3;
  margin:-24px -24px 0;
  padding:24px;
  background:rgba(255,255,255,.92);
  backdrop-filter:blur(16px);
  border-bottom:1px solid var(--line);
}

.admin-window-copy{
  margin:18px 0 20px;
  line-height:1.6;
}

.admin-puzzle-gallery{
  padding-bottom:0;
}

@media (max-width:760px){
  .admin-window-card{ min-height:128px; }
  .admin-window{ padding:18px; }
  .admin-window-header{
    margin:-18px -18px 0;
    padding:18px;
  }
}

.sync-gate{
  position:fixed;
  inset:0;
  z-index:10000;
  display:grid;
  place-items:center;
  padding:24px;
  background:rgba(15,23,42,.58);
  backdrop-filter:blur(8px);
}

.sync-gate-card{
  display:grid;
  gap:8px;
  width:min(420px,100%);
  padding:24px;
  border:1px solid rgba(148,163,184,.35);
  border-radius:22px;
  background:#f8fafc;
  color:#0f172a;
  box-shadow:0 24px 80px rgba(15,23,42,.25);
  text-align:center;
}

.sync-gate-card strong{
  font-size:1.1rem;
}

.sync-gate-card span{
  color:#475569;
}
