:root {
  --bg0: #2a1014;
  --bg1: #4a1c24;
  --cream: #fbf6ee;
  --cream-2: #f4e6d4;
  --ink: #3b241c;
  --muted: #7d5c52;
  --bloom: #8d3140;
  --gold: #c9923a;
  --gold-2: #f0d7a4;
  --ember: #e08a3a;
  --line: #ead9c8;
  --block: #5c2830;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--cream);
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  background:
    radial-gradient(900px 420px at 50% -10%, rgba(255, 196, 140, 0.22), transparent 55%),
    radial-gradient(700px 380px at 110% 8%, rgba(180, 60, 80, 0.18), transparent 50%),
    linear-gradient(180deg, #5a242c 0%, var(--bg0) 38%, #1c0c10 100%);
  overflow-x: clip;
  touch-action: manipulation;
}

button, input { font: inherit; }

h1, h2, .clue-text {
  font-family: Palatino, "Iowan Old Style", Georgia, serif;
  font-weight: 500;
}

h1 { font-size: 2.1rem; line-height: 1.05; margin: 0.1rem 0; }

h2 { font-size: 1.35rem; margin: 0.2rem 0 0.4rem; color: var(--bloom); }

.boot {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  font-family: Palatino, Georgia, serif;
  font-size: 1.4rem;
}

.gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.gate-card, .paper {
  background: var(--cream);
  color: var(--ink);
  border-radius: 22px;
  box-shadow: 0 16px 40px rgba(20, 4, 8, 0.28);
}

.gate-card {
  width: min(420px, 100%);
  padding: 28px 22px 22px;
  text-align: center;
}

.seal-big {
  width: 84px;
  height: 84px;
  margin: 0 auto 8px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #f8e4e2;
  font-size: 32px;
  background: radial-gradient(circle at 35% 30%, #d46a74, #7d2433 68%);
  box-shadow: inset 0 0 0 6px rgba(255, 220, 180, 0.28), 0 10px 24px rgba(0, 0, 0, 0.25);
}

.eyebrow {
  margin: 0;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 0.72rem;
}

.on-paper { color: var(--bloom); }

.lede, .greeting, .progress, .hint, .save {
  color: var(--muted);
  line-height: 1.4;
}

.greeting { margin: 0.2rem 0; font-family: Palatino, Georgia, serif; font-size: 1.15rem; color: var(--gold-2); }
.progress { margin: 0.35rem 0 0; font-size: 0.92rem; color: var(--gold-2); }
.lede { margin: 0 0 16px; }

.username {
  position: absolute;
  left: -9999px;
  height: 0;
  opacity: 0;
}

.field {
  display: block;
  text-align: left;
  font-size: 0.85rem;
  margin-bottom: 6px;
}

input[type="password"] {
  width: 100%;
  min-height: 48px;
  font-size: 16px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
  margin-bottom: 12px;
}

.btn, .check {
  width: 100%;
  min-height: 48px;
  border: 0;
  border-radius: 999px;
  background: var(--bloom);
  color: #fffaf4;
  cursor: pointer;
}

.check.ready { box-shadow: 0 0 0 3px rgba(201, 146, 58, 0.45); }

.btn:active, .check:active, .door:active { transform: translateY(1px); }

.form-error, .problem {
  min-height: 1.2em;
  color: #8d3140;
  margin: 10px 0 0;
}

.problem {
  background: #f8e4c8;
  color: #6a2c24;
  border-radius: 12px;
  padding: 10px 12px;
}

.page {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 18px 14px 48px;
}

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

.lock, .reset-practice, .jump {
  background: transparent;
  color: var(--gold-2);
  border: 1px solid rgba(240, 215, 164, 0.45);
  border-radius: 999px;
  min-height: 40px;
  padding: 6px 14px;
  text-decoration: none;
  cursor: pointer;
}

.jump { display: inline-block; margin: 12px 0; font-size: 0.92rem; }

.preview {
  background: var(--gold-2);
  color: var(--ink);
  border-radius: 14px;
  padding: 10px 12px;
  line-height: 1.4;
}

.sky {
  position: relative;
  height: 560px;
  margin: 6px 0 18px;
}

.door {
  --rot: 0deg;
  position: absolute;
  width: 58px;
  height: 72px;
  padding: 0;
  border: 0;
  border-radius: 12px 12px 9px 9px;
  background: linear-gradient(180deg, #fffaf4, #efd8c4);
  color: var(--ink);
  box-shadow: 0 8px 16px rgba(40, 10, 14, 0.25);
  transform: rotate(var(--rot));
  cursor: pointer;
}

.door .num {
  font-family: Palatino, Georgia, serif;
  font-size: 1.15rem;
}

.door .wax {
  display: block;
  width: 16px;
  height: 16px;
  margin: 8px auto 2px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #d46a74, #7d2433);
}

.door.is-future {
  background: linear-gradient(180deg, #6d343c, #4a2228);
  color: #f6e4da;
  box-shadow: none;
}

.door.is-future .wax { background: #3a1a20; }

.door.is-today:not(.is-open) {
  animation: glow 2.6s ease-in-out infinite;
}

.door.is-open {
  background: linear-gradient(180deg, #8c3040, #5c2030);
  color: var(--gold-2);
}

.door.is-open .wax { opacity: 0.45; }

.door.is-solved .num { text-shadow: 0 0 8px rgba(240, 179, 90, 0.9); }

.door.is-birthday {
  width: 74px;
  height: 90px;
  z-index: 4;
  background: linear-gradient(180deg, #f8e7c2, #e7c27a);
  box-shadow: 0 0 0 2px var(--gold-2), 0 12px 24px rgba(60, 20, 16, 0.35);
}

.door.is-birthday .num { font-size: 1.45rem; }

.door.is-birthday::after {
  content: "♥";
  position: absolute;
  top: 5px;
  right: 7px;
  font-size: 12px;
  color: #a84555;
}

.door.is-birthday.is-open {
  background: linear-gradient(180deg, #fff6df, #e7c27a);
  color: #3b241c;
  box-shadow: 0 0 0 2px var(--gold-2), 0 0 16px rgba(240, 200, 120, 0.75);
}

.door.shake { animation: shake 0.35s ease; }

.paper { padding: 16px; margin-bottom: 16px; }

.clue-card { min-height: 72px; }

.kicker {
  margin: 0;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.72rem;
  color: var(--bloom);
}

.clue-text { font-size: 1.55rem; line-height: 1.25; margin: 6px 0 8px; }

.birthday-line {
  margin: 0 0 8px;
  color: var(--bloom);
  font-family: Palatino, Georgia, serif;
  font-size: 1.2rem;
}

.clue-img {
  display: block;
  width: min(100%, 320px);
  border-radius: 14px;
  margin: 8px 0;
}

.player { width: min(100%, 320px); margin: 8px 0; }

.status { min-height: 1.2em; }

.tries { color: var(--muted); font-size: 0.92rem; }

.board-scroll {
  overflow: auto;
  max-width: 100%;
  padding-bottom: 4px;
}

#grid {
  --cell: 34px;
  --cols: 16;
  display: grid;
  grid-template-columns: repeat(var(--cols), var(--cell));
  gap: 3px;
  width: max-content;
  padding: 3px;
  background: var(--block);
  border-radius: 8px;
}

.cell, .block {
  width: var(--cell);
  height: var(--cell);
  position: relative;
}

.cell {
  background: #fffaf4;
  border-radius: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  font-family: Palatino, Georgia, serif;
  font-size: calc(var(--cell) * 0.52);
  user-select: none;
}

.cell .num {
  position: absolute;
  top: 1px;
  left: 2px;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  font-size: 8px;
  line-height: 1;
  color: #8d6a60;
}

.cell.in-word { background: #f8ddd6; }
.cell.selected { outline: 2px solid var(--gold); outline-offset: -2px; z-index: 1; }
.cell.locked {
  background: #f0b35a;
  color: #3a2012;
  box-shadow: inset 0 0 8px rgba(160, 60, 20, 0.35);
}

.cell.burn { animation: burn 1.15s ease; }

.hint { font-size: 0.88rem; margin: 10px 0 0; }
.save { min-height: 1.2em; margin: 4px 0 0; font-size: 0.85rem; }

.mini {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 12px 0;
  color: var(--ink);
  cursor: pointer;
}

.mini.solved { color: #8a5a20; }

.lists .hint { margin-top: 0; }

.reset-practice { margin-top: 4px; }

#keycatch {
  position: fixed;
  top: 0;
  left: 0;
  width: 40px;
  height: 40px;
  opacity: 0;
  font-size: 16px;
  border: 0;
  padding: 0;
  background: transparent;
  color: transparent;
}

.burst {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 30;
}

.floater {
  position: absolute;
  bottom: -12px;
  color: #f0b7c0;
  font-size: 22px;
  animation: float 1.8s ease-in forwards;
}

:focus-visible { outline: 2px solid var(--gold-2); outline-offset: 2px; }
#keycatch:focus { outline: none; }

@keyframes glow {
  0%, 100% { box-shadow: 0 8px 16px rgba(40, 10, 14, 0.25); }
  50% { box-shadow: 0 0 0 3px rgba(240, 215, 164, 0.95), 0 8px 18px rgba(40, 10, 14, 0.28); }
}

@keyframes shake {
  0%, 100% { transform: rotate(var(--rot)); }
  30% { transform: rotate(var(--rot)) translateX(-3px); }
  70% { transform: rotate(var(--rot)) translateX(3px); }
}

@keyframes burn {
  0% { background: #fffaf4; transform: scale(1); }
  40% { background: #ffb15a; color: #fff8ee; transform: scale(1.08); box-shadow: 0 0 16px #ff7a3c; }
  100% { background: #f0b35a; color: #3a2012; transform: scale(1); }
}

@keyframes float {
  to { transform: translateY(-105vh) rotate(18deg); opacity: 0; }
}

@media (min-width: 900px) {
  .board-scroll { display: flex; justify-content: center; }
  .page { padding: 32px 22px 72px; }
  .sky { height: 320px; }
  .door { width: 64px; height: 78px; }
  .door.is-birthday { width: 82px; height: 98px; }
  .paper { padding: 20px; }
  .clue-text { font-size: 1.8rem; }
  .check { width: auto; min-width: 180px; padding: 0 18px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .door.is-today, .cell.burn, .floater, .door.shake { animation: none !important; }
}
