/*
Filename: style.css
Last Edit Date: 2026-11-30 EST
Purpose: The look of Packwords: a dark, moonlit page with the towers of letter tiles, the round's numbers, the found-word list and the pack window.
*/

:root {
  --bg: #0f1624;
  --panel: #19233a;
  --line: #2b3a59;
  --ink: #e8edf7;
  --muted: #93a2bf;
  --accent: #7fb2ff;
  --gold: #ffd166;
  --good: #7be0a4;
  --bad: #ff8a8a;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.4 system-ui, "Segoe UI", sans-serif; }
body { min-height: 100vh; -webkit-user-select: none; user-select: none; }
.hidden { display: none !important; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; background: #0b111d; border-bottom: 1px solid var(--line); }
.top h1 { margin: 0; font-size: 1.35rem; letter-spacing: .03em; }
.version { color: var(--muted); font-size: .75rem; font-weight: 400; }

.btn { border: 1px solid var(--accent); background: transparent; color: var(--accent); padding: 8px 14px; border-radius: 10px; font: inherit; font-weight: 600; cursor: pointer; }
.btn:hover:not(:disabled) { background: rgba(127, 178, 255, .15); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.big { background: var(--accent); color: #0b111d; padding: 12px 28px; font-size: 1.1rem; }
.btn.big:hover:not(:disabled) { background: #a4c8ff; }

.game { max-width: 560px; margin: 0 auto; padding: 12px 12px 28px; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stats div { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; text-align: center; }
.stats .label { display: block; color: var(--muted); font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; }
.stats b { font-size: 1.4rem; font-variant-numeric: tabular-nums; }
.stats b.low { color: var(--bad); }

.current { min-height: 2.2rem; margin-top: 10px; text-align: center; font: 700 1.6rem "Courier New", ui-monospace, monospace; letter-spacing: .12em; color: var(--ink); }
.current.good { color: var(--good); }
.message { min-height: 1.3rem; text-align: center; font-size: .95rem; color: var(--muted); }
.message.good { color: var(--good); }
.message.bad { color: var(--bad); }

.board-wrap { position: relative; margin: 6px auto 0; display: flex; justify-content: center; padding: 10px 0; background: linear-gradient(180deg, #131d31, #0f1624); border: 1px solid var(--line); border-radius: 16px; touch-action: none; }
.board { position: relative; touch-action: none; }
.trail-layer { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 3; overflow: visible; }
.trail-layer polyline { fill: none; stroke: var(--gold); stroke-width: 6; stroke-linecap: round; stroke-linejoin: round; opacity: .75; }

.tile { position: absolute; left: 0; top: 0; width: var(--t); height: var(--t); display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #31456e, #223357); border: 2px solid #4a6393; border-radius: 22%; color: var(--ink);
  font: 700 calc(var(--t) * .5) "Segoe UI", system-ui, sans-serif; text-transform: uppercase; pointer-events: none; z-index: 2;
  transition: transform .28s cubic-bezier(.3, .8, .4, 1), opacity .2s ease, background .1s ease; }
.tile.on { background: linear-gradient(160deg, #ffd166, #f0a93a); border-color: #fff3c9; color: #1b1405; }
.tile.pop { animation: pop .25s ease-out forwards; }
@keyframes pop { to { transform: scale(0); opacity: 0; } }

.overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(8, 12, 22, .82); border-radius: 16px; z-index: 5; padding: 14px; }
.overlay.hidden { display: none; }
.overlay-card { text-align: center; max-width: 340px; }
.overlay-card h2 { margin: 0 0 8px; font-size: 1.6rem; }
.overlay-card p { margin: 0 0 16px; color: var(--ink); }

.found-wrap h2 { margin: 16px 0 6px; font-size: .85rem; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.found { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; max-height: 150px; overflow-y: auto; }
.found li { display: inline-flex; align-items: baseline; gap: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; font-size: .95rem; }
.found li span { color: var(--gold); font-size: .8rem; }
.found li em { color: var(--good); font-size: .7rem; font-style: normal; text-transform: uppercase; }
.found li.new { border-color: var(--good); }

.notes { margin: 16px 0 0; text-align: center; color: var(--muted); font-size: .8rem; }

.dialog { position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; background: rgba(5, 8, 15, .75); padding: 14px; }
.dialog-card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 16px; width: min(440px, 100%); max-height: 86vh; display: flex; flex-direction: column; gap: 10px; }
.dialog-card h2 { margin: 0; font-size: 1.2rem; }
.pack-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; columns: 2; column-gap: 18px; }
.pack-list li { display: flex; justify-content: space-between; gap: 8px; padding: 3px 0; break-inside: avoid; border-bottom: 1px solid var(--line); }
.pack-list li span { color: var(--muted); font-size: .75rem; }
.pack-list li.none { color: var(--muted); columns: 1; border: 0; }

/* The player's name in the header, and the name / recovery-code windows. */
.top-right { display: flex; align-items: center; gap: 12px; }
.player { color: var(--muted); font-size: .85rem; }
.player b { color: var(--ink); }
.link { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; text-decoration: underline; cursor: pointer; }
.row { display: flex; gap: 8px; }
.field { width: 100%; padding: 10px 12px; margin: 4px 0; border-radius: 10px; border: 1px solid var(--line); background: #0f1624; color: var(--ink); font: inherit; -webkit-user-select: text; user-select: text; }
.field:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.hint { color: var(--muted); font-size: .85rem; margin: 6px 0 10px; }
.alt { margin: 12px 0 0; text-align: center; font-size: .9rem; }
.code { margin: 8px 0; padding: 14px; text-align: center; font: 700 2rem "Courier New", ui-monospace, monospace; letter-spacing: .15em; color: var(--gold); background: #0f1624; border: 1px dashed var(--gold); border-radius: 12px; -webkit-user-select: text; user-select: text; }
.dialog-card .message { min-height: 1.2rem; text-align: left; }

/* The leaderboard window: two switches (which board, which time) and the top ten. */
.seg { display: flex; gap: 0; }
.seg-btn { flex: 1; padding: 7px 10px; background: transparent; color: var(--muted); border: 1px solid var(--line); font: inherit; font-weight: 600; cursor: pointer; }
.seg-btn:first-child { border-radius: 10px 0 0 10px; }
.seg-btn:last-child { border-radius: 0 10px 10px 0; border-left: 0; }
.seg-btn.on { background: var(--accent); color: #0b111d; border-color: var(--accent); }
.board-list { list-style: none; margin: 0; padding: 0; }
.board-list li { display: grid; grid-template-columns: 2.2rem 1fr auto; gap: 8px; padding: 6px 4px; border-bottom: 1px solid var(--line); }
.board-list li b { color: var(--gold); }
.board-list li.me, .board-me { background: rgba(127, 178, 255, .14); border-radius: 8px; }
.board-list li.none { display: block; color: var(--muted); border: 0; }
.board-me { margin: 0; padding: 8px 10px; font-size: .95rem; }
.board-me:empty { display: none; }

/* The gold letter: it falls in all gold and loses a fifth of its gold from the top with each word made without it. */
.tile.gold { background: linear-gradient(180deg, #31456e 0, #223357 var(--gp, 0%), #ffd166 var(--gp, 0%), #f0a93a 100%); border-color: #ffe08a; box-shadow: 0 0 10px rgba(255, 209, 102, .6); text-shadow: 0 1px 2px rgba(0, 0, 0, .75); }
.tile.gold.on { border-color: #fff; box-shadow: 0 0 0 3px #fff3c9, 0 0 12px rgba(255, 209, 102, .8); }
.found li em.gold { color: var(--gold); }

.banner.progress { color: var(--accent); border-color: var(--accent); }
.banner.earned { color: #1b1405; background: linear-gradient(90deg, #f0a93a, #ffd166, #f0a93a); border-color: #fff3c9; text-shadow: none; }
/* A big message across the board for a couple of seconds (the gold letter fading). */
.banner { position: absolute; left: 0; right: 0; top: 42%; z-index: 4; padding: 14px 10px; text-align: center; font-size: 1.6rem; font-weight: 800; color: var(--gold); background: rgba(8, 12, 22, .82); border-top: 2px solid var(--gold); border-bottom: 2px solid var(--gold); text-shadow: 0 2px 6px rgba(0, 0, 0, .8); pointer-events: none; }

/* Badges: greyed out until the whole list is found, lit up once it is. */
.badge-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; overflow-y: auto; }
.badge { display: flex; flex-direction: column; gap: 2px; text-align: left; padding: 10px; border-radius: 12px; border: 1px solid var(--line); background: #141c2e; color: #6d7a93; font: inherit; cursor: pointer; filter: grayscale(1); }
.badge b { font-size: 1rem; }
.badge span { font-size: .75rem; }
.badge i { font-style: normal; font-size: .8rem; font-variant-numeric: tabular-nums; }
.badge.lit { filter: none; color: #1b1405; background: linear-gradient(160deg, #ffd166, #f0a93a); border-color: #fff3c9; box-shadow: 0 0 12px rgba(255, 209, 102, .45); }
#badge-words h3 { margin: 10px 0 4px; font-size: .95rem; }
.badge-words { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.badge-words li { padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); font-size: .9rem; }
.badge-words li.got { color: var(--gold); border-color: var(--gold); font-weight: 700; }
.badge-tag { font-style: normal; font-size: .7rem; color: var(--gold); border: 1px solid var(--gold); border-radius: 999px; padding: 0 6px; margin-left: 4px; }

/* ── An open book ───────────────────────────────────────────────────────────────────────────────────────────────────────
   The page sits on a dimmed bookshelf; the book has a leather cover, parchment pages and a shadow down the spine. The left page holds the
   numbers and the found words, the right page the puzzle. On a narrow screen it becomes one page: numbers, puzzle, found words. */
html { background: #120b06 url("images/bookshelf.webp") repeat; background-size: 560px; }
body { background: transparent; }
body::before { content: ""; position: fixed; inset: 0; z-index: -1; background: rgba(10, 6, 3, .74); }

.book { position: relative; max-width: 1020px; margin: 18px auto 28px; padding: 16px; display: grid; grid-template-columns: 1fr 1fr; gap: 0;
  background: linear-gradient(160deg, #5a3820, #3b2412); border-radius: 14px; box-shadow: 0 14px 40px rgba(0, 0, 0, .7), inset 0 0 0 2px #7a5233; }
.book::after { content: ""; position: absolute; top: 16px; bottom: 16px; left: 50%; width: 56px; transform: translateX(-50%); pointer-events: none; z-index: 2;
  background: linear-gradient(90deg, rgba(60, 35, 10, 0), rgba(60, 35, 10, .38) 46%, rgba(30, 15, 5, .55) 50%, rgba(60, 35, 10, .38) 54%, rgba(60, 35, 10, 0)); }

.page { position: relative; min-height: 560px; padding: 22px 26px 26px; color: #3b2a17;
  background: radial-gradient(ellipse at 30% 20%, #fcf6e4, #f6ecd0 70%, #ecdfb8);
  box-shadow: inset 0 0 40px rgba(120, 80, 30, .16), 0 3px 0 #e6d8ae, 0 6px 0 #dccd9c, 0 9px 0 #cfbf88; }
.page.left { border-radius: 8px 0 0 8px; padding-right: 40px; }
.page.right { border-radius: 0 8px 8px 0; padding-left: 40px; }

/* the left page: numbers and found words as if written on the paper */
.page .stats div { background: rgba(110, 75, 35, .12); border: 1px solid #b89b66; }
.page .stats .label { color: #7a5d34; }
.page .stats b { color: #3b2a17; }
.page .stats b.low { color: #a83a2a; }
.page .found-wrap h2 { color: #7a5d34; margin-top: 22px; }
.page .found { max-height: 300px; }
.page .found li { background: rgba(255, 250, 235, .55); border-color: #b89b66; color: #3b2a17; }
.page .found li span { color: #8a5a00; }
.page .found li em { color: #2e6b3a; }
.page .found li em.gold { color: #9a6a00; }
.page .found li.new { border-color: #2e6b3a; }
.page .notes { color: #7a5d34; }

/* the right page: the puzzle */
.page .current { color: #3b2a17; }
.page .current.good { color: #2e6b3a; }
.page .message { color: #7a5d34; }
.page .message.good { color: #2e6b3a; }
.page .message.bad { color: #a83a2a; }
.page .board-wrap { background: rgba(110, 75, 35, .10); border: 1px solid #b89b66; }
.page .trail-layer polyline { stroke: #d9822b; }

@media (max-width: 820px) {
  .book { display: flex; flex-direction: column; padding: 10px; margin: 10px; }
  .book::after { display: none; }
  .page.left { display: contents; }
  .page.right { order: 2; min-height: 0; border-radius: 8px; padding: 12px; }
  .page .stats { order: 1; padding: 10px 12px; background: radial-gradient(ellipse at 30% 20%, #fcf6e4, #f6ecd0); border-radius: 8px 8px 0 0; }
  .page .found-wrap { order: 3; padding: 4px 14px 10px; background: #f6ecd0; }
  .page .notes { order: 4; margin: 0; padding: 0 14px 12px; background: #f6ecd0; border-radius: 0 0 8px 8px; }
}

/* More header buttons now: let them wrap on a small screen instead of running off the edge. */
.top { flex-wrap: wrap; }
.top-right { flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 520px) { .top-right .btn { padding: 6px 10px; font-size: .9rem; } }
.page .overlay-card h2 { color: var(--ink); }
#badge-dialog .dialog-card { width: min(600px, 100%); }
.badge { min-width: 0; overflow-wrap: anywhere; }
