/* Word Climb Daily — the app's "Bold Pop" look: cream ground, ink outlines, hard offset shadows. */
:root {
  --cream: #FFF6E0;
  --paper: #FFFFFF;
  --ink: #111111;
  --muted: #5A554B;
  --panel: #F1E4C3;
  --cobalt: #2D5BFF;
  --pink: #FF4F9A;
  --mint: #2ED48B;
  --sun: #FFD23F;
  --alert: #D13438;
  --display: "Lilita One", "Arial Rounded MT Bold", system-ui, sans-serif;
  --body: "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  /* A tile fits the day's word (3-7 letters, --len set by daily.js) across the rails and eight rows
     above the keyboard (less the GOAL / START tags); on short phones it stops at 34px and the ladder scrolls instead. */
  --len: 5;
  --tile: min(54px, calc((100vw - 132px) / var(--len)), max(34px, calc((100svh - 470px) / 7.5)));
  --gap: max(5px, calc(var(--tile) * 0.13));
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--cream); color: var(--ink); }
body { font-family: var(--body); font-weight: 700; -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; cursor: pointer; }
.hidden { display: none !important; }

.app {
  display: flex; flex-direction: column; height: 100svh; max-width: 520px; margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) 16px max(10px, env(safe-area-inset-bottom));
}

/* ── header ─────────────────────────────────────────────────────────── */
.top { display: flex; align-items: center; gap: 10px; }
.brand { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; }
.brand .word { font-family: var(--display); font-size: 26px; letter-spacing: .5px; white-space: nowrap; }
.star { width: 26px; height: 26px; fill: var(--sun); stroke: var(--ink); stroke-width: 1.8; stroke-linejoin: round; }
.pill {
  font-family: var(--display); font-size: 16px; padding: 5px 12px; border: 2.5px solid var(--ink);
  border-radius: 999px; background: var(--pink); box-shadow: 0 3px 0 var(--ink); white-space: nowrap;
}
.chip {
  width: 40px; height: 40px; border-radius: 12px; border: none; background: var(--ink); color: var(--cream);
  font-family: var(--display); font-size: 20px; box-shadow: 0 3px 0 var(--pink);
}
.hud { margin: 8px 0 0; text-align: center; color: var(--muted); font-size: 15px; min-height: 20px; }
.hud .left { color: var(--ink); }
.hud .low { color: var(--alert); }

/* ── the ladder ─────────────────────────────────────────────────────── */
.board-wrap { flex: 1; overflow-y: auto; display: flex; justify-content: center; padding: 10px 0 6px; }
/* Room above the goal and below the ground for the GOAL / START tags; the rails still end just past the rows. */
.board { position: relative; display: flex; flex-direction: column; gap: var(--gap); padding: 30px 26px calc(var(--gap) + 36px); margin: auto 0; }
.board::before, .board::after {           /* the rails */
  content: ""; position: absolute; top: 24px; bottom: calc(var(--gap) + 26px); width: 6px; border-radius: 3px; background: var(--ink);
}
.tag {                                    /* GOAL over the top word, START under the ground */
  position: absolute; left: 50%; transform: translateX(-50%); z-index: 2; height: 22px; padding: 0 10px;
  border: 2.5px solid var(--ink); border-radius: 999px; background: var(--paper); box-shadow: 0 2px 0 var(--ink);
  font-family: var(--display); font-size: 13px; line-height: 17px; letter-spacing: 1px; white-space: nowrap;
}
.tag.goal-tag { top: 0; background: var(--sun); }
.tag.start-tag { bottom: 0; }
.board::before { left: 4px; }
.board::after { right: 4px; }
.row { position: relative; display: flex; gap: var(--gap); justify-content: center; }
.row::before {                            /* the rung behind the tiles */
  content: ""; position: absolute; left: -22px; right: -22px; top: 50%; height: 5px; margin-top: -2.5px;
  background: var(--ink); z-index: 0;
}
.row.ground::after {                      /* the ground under the start word */
  content: ""; position: absolute; left: -34px; right: -34px; bottom: calc(var(--gap) * -1 - 10px); height: 6px;
  border-radius: 3px; background: var(--ink);
}
.tile {
  position: relative; z-index: 1; width: var(--tile); height: var(--tile); display: grid; place-items: center;
  border: 3px solid var(--ink); border-radius: calc(var(--tile) * 0.2); background: var(--paper);
  box-shadow: 0 4px 0 var(--ink); font-family: var(--display); font-size: calc(var(--tile) * 0.55);
  text-transform: uppercase; line-height: 1;
}
.tile.goal { background: var(--sun); }
.tile.rung { background: var(--mint); }
.tile.changed { background: var(--pink); }
.tile.empty { background: var(--paper); }
.tile.caret { border-color: var(--cobalt); box-shadow: 0 4px 0 var(--cobalt), 0 0 0 3px rgba(45, 91, 255, .22); }
.tile.hint { background: var(--sun); border-style: dashed; }
.row.input.bad .tile { border-color: var(--alert); color: var(--alert); }

/* ── message, power-ups ─────────────────────────────────────────────── */
.message { min-height: 22px; margin: 6px 0 4px; text-align: center; font-size: 15px; color: var(--ink); }
.message.bad { color: var(--alert); }
.message.good { color: #1b8a59; }
.powers { display: flex; gap: 10px; margin-bottom: 10px; }
.power {
  flex: 1; position: relative; display: flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; border: 3px solid var(--ink); border-radius: 14px; background: var(--paper);
  box-shadow: 0 4px 0 var(--ink); font-family: var(--display); font-size: 18px;
}
.power:disabled { background: var(--panel); color: var(--muted); box-shadow: 0 2px 0 var(--muted); border-color: var(--muted); cursor: default; }
.power.hero, .btn.hero { background: var(--pink); }
.power.app { background: var(--cobalt); color: var(--paper); text-decoration: none; }
.badge {
  min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: var(--ink); color: var(--cream);
  font-family: var(--body); font-size: 13px; display: inline-grid; place-items: center;
}

/* ── keyboard ───────────────────────────────────────────────────────── */
.keyboard { display: flex; flex-direction: column; gap: 7px; user-select: none; }
.krow { display: flex; gap: 5px; justify-content: center; }
.key {
  flex: 1; max-width: 46px; height: 50px; border: 2.5px solid var(--ink); border-radius: 10px; background: var(--paper);
  box-shadow: 0 3px 0 var(--ink); font-family: var(--display); font-size: 20px; padding: 0; touch-action: manipulation;
}
.key.wide { flex: 1.6; max-width: 74px; font-size: 16px; }
.key.del { background: var(--ink); color: var(--cream); }
.key.go { background: var(--cobalt); color: var(--paper); }
.key:active, .power:active, .btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.key:disabled { opacity: .45; transform: none; }

/* ── modals ─────────────────────────────────────────────────────────── */
.scrim {
  position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 16px;
  background: rgba(17, 17, 17, .55);
}
.card {
  position: relative; width: 100%; max-width: 420px; max-height: calc(100svh - 32px); overflow-y: auto;
  padding: 22px 20px; border: 3px solid var(--ink); border-radius: 22px; background: var(--paper);
  box-shadow: 0 6px 0 var(--ink);
}
.card h2 { font-family: var(--display); font-weight: 400; font-size: 28px; margin: 0 0 10px; }
.card p { font-size: 16px; line-height: 1.45; margin: 0 0 10px; font-weight: 600; }
.card .small { color: var(--muted); font-size: 14px; }
.goal-word { background: var(--sun); padding: 0 4px; border-radius: 4px; }
.btn {
  display: block; width: 100%; height: 52px; margin-top: 8px; border: 3px solid var(--ink); border-radius: 16px;
  background: var(--paper); box-shadow: 0 4px 0 var(--ink); font-family: var(--display); font-size: 20px;
  text-decoration: none; text-align: center; line-height: 46px;
}
.close {
  position: absolute; top: 12px; right: 12px; z-index: 2; width: 36px; height: 36px; border-radius: 10px;
  border: none; background: var(--ink); color: var(--cream); font-size: 16px;
}
.hero-card {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; padding: 16px; margin-bottom: 12px;
  border: 3px solid var(--ink); border-radius: 18px; background: var(--pink); box-shadow: 0 4px 0 var(--ink);
}
.hero-card.failed { background: var(--panel); }
.kicker { grid-column: 1 / -1; font-size: 13px; letter-spacing: 1px; text-transform: uppercase; }
.grade { font-family: var(--display); font-size: 44px; line-height: 1.05; text-transform: uppercase; }
.stars { align-self: center; font-size: 30px; letter-spacing: 2px; color: var(--sun); -webkit-text-stroke: 1.5px var(--ink); }
.route { grid-column: 1 / -1; font-size: 15px; text-transform: uppercase; }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.fact {
  display: flex; flex-direction: column; gap: 2px; padding: 12px; border: 3px solid var(--ink); border-radius: 16px;
  background: var(--paper); box-shadow: 0 3px 0 var(--ink);
}
.fact:last-child { background: var(--mint); }
.fact .k { font-size: 12px; letter-spacing: 1px; text-transform: uppercase; }
.fact .v { font-family: var(--display); font-size: 28px; }
.fact .s { font-size: 13px; color: var(--muted); }
.fact:last-child .s { color: var(--ink); }
.path { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-bottom: 6px; }
.dot { width: 24px; height: 24px; border: 2.5px solid var(--ink); border-radius: 7px; }
.dot.c0 { background: var(--mint); }
.dot.c1 { background: var(--sun); }
.dot.c2 { background: var(--ink); }
.next { text-align: center; color: var(--muted); font-size: 14px; margin: 10px 0 4px; }
.cta { margin-top: 10px; padding: 14px; border: 3px solid var(--ink); border-radius: 16px; background: var(--cream); }
.cta p { font-size: 15px; margin: 0 0 4px; }
.cta .btn { background: var(--cobalt); color: var(--paper); }
.cta .fine { font-size: 13px; color: var(--muted); margin-top: 8px; }
.cta a { color: var(--cobalt); }

/* ── motion (off when the player asks for less) ─────────────────────── */
@keyframes pop { 0% { transform: scale(.82); } 60% { transform: scale(1.08); } 100% { transform: scale(1); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20%, 60% { transform: translateX(-7px); } 40%, 80% { transform: translateX(7px); } }
@keyframes rise { from { transform: translateY(14px); opacity: 0; } to { transform: none; opacity: 1; } }
.tile.pop { animation: pop .16s ease-out; }
.row.shake { animation: shake .32s ease-in-out; }
.row.new .tile { animation: rise .28s ease-out both; }
.card { animation: rise .25s ease-out; }
@media (prefers-reduced-motion: reduce) {
  .tile.pop, .row.shake, .row.new .tile, .card { animation: none; }
}
/* ── calendar ───────────────────────────────────────────────────────── */
.chip svg { display: block; width: 22px; height: 22px; margin: auto; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }
.fact.tap { text-align: left; cursor: pointer; }   /* the results Streak tile opens the calendar */
.facts.three { grid-template-columns: repeat(3, 1fr); gap: 8px; }
.cal .fact { padding: 10px; background: var(--paper); }
.cal .fact .v { font-size: 24px; }
.cal .fact.streak { background: var(--sun); }
.cal .fact.solved { background: var(--mint); }
.cal .fact:last-child { background: var(--paper); }
.cal .fact:last-child .s { color: var(--muted); }
.month { display: flex; align-items: center; justify-content: space-between; margin: 2px 0 10px; font-family: var(--display); font-size: 20px; }
.month .nav {
  width: 36px; height: 36px; padding: 0; border: 2.5px solid var(--ink); border-radius: 10px; background: var(--paper);
  box-shadow: 0 3px 0 var(--ink); font-family: var(--display); font-size: 22px; line-height: 1;
}
.month .nav:disabled { opacity: .3; box-shadow: none; cursor: default; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.cal-grid .dow { text-align: center; font-size: 12px; color: var(--muted); }
.day { aspect-ratio: 1; display: grid; place-items: center; border: 2px solid transparent; border-radius: 9px; font-size: 14px; }
.day.solved { background: var(--mint); border-color: var(--ink); }
.day.failed { background: var(--ink); border-color: var(--ink); color: var(--cream); }
.day.missed { background: var(--panel); }
.day.before { color: var(--muted); }
.day.future { color: var(--muted); opacity: .45; }
.day.today { background: var(--paper); border-color: var(--ink); }
.day.now { box-shadow: 0 0 0 3px var(--cobalt); }
.legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 14px; margin: 14px 0 6px; font-size: 13px; }
.legend i { display: inline-block; width: 14px; height: 14px; margin-right: 5px; vertical-align: -2px; border: 2px solid var(--ink); border-radius: 4px; }
.legend i.solved { background: var(--mint); }
.legend i.failed { background: var(--ink); }
.legend i.missed { background: var(--panel); border-color: var(--panel); }
.card .small.center { text-align: center; margin: 4px 0 0; }

/* Narrow phones: "#313" instead of "Daily #313", and a smaller wordmark, so four header items fit. */
@media (max-width: 420px) { .pill .long { display: none; } }
@media (max-width: 374px) { .brand .star { display: none; } .top .brand .word { font-size: 18px; } .top { gap: 8px; } }
@media (max-height: 640px) { .brand .word { font-size: 22px; } .key { height: 44px; } }
