:root {
    --bg: #ffffff;
    --fg: #1a1a1a;
    --muted: #5f5f5f;
    --tile: #efefe6;
    --tile-selected: #5a594e;
    --tile-selected-fg: #ffffff;
    --border: #1a1a1a;
    --yellow: #f9df6d;
    --green: #a0c35a;
    --blue: #b0c4ef;
    --purple: #ba81c5;
    --group-fg: #1a1a1a;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #121212;
        --fg: #ececec;
        --muted: #a5a5a5;
        --tile: #2c2c28;
        --tile-selected: #d8d6c8;
        --tile-selected-fg: #121212;
        --border: #ececec;
    }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--fg);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    line-height: 1.4;
}

main, .site-header, .site-footer {
    max-width: 620px;
    margin: 0 auto;
    padding: 0 16px;
}

.site-header { text-align: center; padding-top: 24px; }
.logo-link { display: inline-block; line-height: 0; }
.logo { width: 80px; height: auto; margin-bottom: 4px; }
.site-header h1 { margin: 0; font-size: 1.6rem; }
.tagline { margin: 4px 0 0; color: var(--muted); font-size: 0.9rem; }

.intro { text-align: center; margin: 20px 0 16px; }

.solved, .board { display: grid; gap: 8px; }
.solved { margin-bottom: 8px; }
.board { grid-template-columns: repeat(4, 1fr); }

.tile {
    aspect-ratio: 1.6;
    border: 0;
    border-radius: 6px;
    background: var(--tile);
    color: var(--fg);
    font: inherit;
    font-weight: 700;
    font-size: clamp(0.7rem, 2.8vw, 1rem);
    text-transform: uppercase;
    padding: 4px;
    cursor: pointer;
    overflow-wrap: anywhere;
    transition: background 0.1s, transform 0.1s;
}
.tile:active { transform: scale(0.96); }
.tile.selected { background: var(--tile-selected); color: var(--tile-selected-fg); }
.tile.shake { animation: shake 0.3s; }

@keyframes shake {
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

.group {
    border-radius: 6px;
    padding: 12px;
    text-align: center;
    color: var(--group-fg);
    animation: pop 0.25s;
}
.group.yellow { background: var(--yellow); }
.group.green { background: var(--green); }
.group.blue { background: var(--blue); }
.group.purple { background: var(--purple); }
.group h3 { margin: 0; font-size: 1rem; text-transform: uppercase; }
.group .words { margin: 2px 0 0; text-transform: uppercase; }
.group .explanation { margin: 6px 0 0; font-size: 0.85rem; }
.group a { color: inherit; font-size: 0.85rem; }

@keyframes pop {
    from { transform: scale(0.95); opacity: 0.5; }
}

.mistakes { text-align: center; margin: 20px 0 12px; }
.dots { display: inline-flex; gap: 6px; vertical-align: middle; }
.dot { width: 14px; height: 14px; border-radius: 50%; background: var(--tile-selected); }

.buttons { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }

button:not(.tile) {
    font: inherit;
    font-weight: 600;
    padding: 10px 18px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--fg);
    cursor: pointer;
}
button.primary { background: var(--fg); color: var(--bg); }
button:disabled { opacity: 0.4; cursor: default; }

.toast {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--fg);
    color: var(--bg);
    padding: 10px 16px;
    border-radius: 6px;
    font-weight: 600;
    z-index: 10;
}

.result { text-align: center; margin-top: 24px; }
.result h2 { margin: 0 0 12px; }
.share-grid { font-size: 1.4rem; line-height: 1.2; margin: 0 0 16px; }
.next { color: var(--muted); }

.empty { text-align: center; padding: 48px 0; }

.site-footer {
    margin-top: 48px;
    padding-bottom: 24px;
    font-size: 0.75rem;
    color: var(--muted);
    text-align: center;
}
.site-footer a { color: inherit; }

.site-header h1 a { color: inherit; text-decoration: none; }
.site-nav { display: flex; justify-content: center; gap: 16px; margin-top: 10px; font-size: 0.9rem; flex-wrap: wrap; }
.site-nav a { color: var(--muted); }
.site-nav a.current { color: var(--fg); font-weight: 600; }

.page-title { text-align: center; margin: 24px 0 16px; font-size: 1.25rem; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 20px 0 8px; }
.stat { display: grid; }
.stat strong { font-size: 1.5rem; }
.stat span { font-size: 0.75rem; color: var(--muted); }
.rank { margin: 12px 0 8px; }

.inline-form { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin: 8px 0; }
.inline-form input, .panel input {
    font: inherit;
    padding: 9px 12px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--fg);
    min-width: 0;
    flex: 1 1 200px;
    max-width: 280px;
}

.day-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; margin-bottom: 16px; }
.day-stats div { display: grid; background: var(--tile); border-radius: 6px; padding: 10px; }
.day-stats strong { font-size: 1.3rem; }
.day-stats span { font-size: 0.75rem; color: var(--muted); }
.lead-note { text-align: center; }

.board-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.board-table th, .board-table td { padding: 8px 6px; text-align: left; border-bottom: 1px solid var(--tile); }
.board-table th { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; }
.board-table td:first-child, .board-table th:first-child { width: 2.5em; }
.board-table td:nth-child(2) { overflow-wrap: anywhere; }
.board-table tr.me td { background: var(--tile); font-weight: 700; }
.board-table tr.gap td { text-align: center; color: var(--muted); }
.fine { font-size: 0.75rem; color: var(--muted); text-align: center; }

.panel { margin: 0 0 24px; }
.panel h3 { margin: 0 0 8px; font-size: 1rem; }
.panel .inline-form { justify-content: flex-start; }
.code { font: 700 1.3rem ui-monospace, monospace; letter-spacing: 0.05em; }
.flash { padding: 10px 14px; border-radius: 6px; background: var(--tile); }
.flash.error { color: #b3261e; }

/* After the game: how everyone did, and collection log news */
.group-stats { font-size: 0.8rem; opacity: 0.85; margin: 4px 0 0; }
.log-news { margin: 12px 0 0; }
.log-new { color: #ef1020; font-weight: 700; margin: 4px 0; text-shadow: 1px 1px 0 #000; }
.log-count { margin: 6px 0 0; font-size: 0.9rem; }

/* Collection log page */
.log-total { text-align: center; color: var(--muted); margin: -8px 0 16px; }
.log-grid { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.log-slot { background: var(--tile); border-radius: 6px; padding: 10px; display: grid; gap: 2px; }
.log-slot strong { font-size: 0.95rem; }
.log-slot span { font-size: 0.78rem; color: var(--muted); }
.log-slot.got { box-shadow: inset 0 0 0 2px #c8a656; }
.log-slot:not(.got) strong { opacity: 0.6; }
.pet { cursor: help; }

/* How to play, under the board */
.about { margin: 40px 0 0; padding-top: 16px; border-top: 1px solid var(--tile); color: var(--muted); font-size: 0.9rem; }
.about h2 { font-size: 1rem; color: var(--fg); margin: 0 0 8px; }
.about p { margin: 0 0 10px; }

/* Discord sign-up */
.discord-link { display: inline-flex; align-items: center; gap: 6px; }
.discord-icon { width: 1.1em; height: 1.1em; fill: #5865f2; flex: none; }
.stack-form { display: grid; gap: 10px; justify-items: start; }
.field { display: grid; gap: 4px; width: 100%; }
.field span { font-size: 0.85rem; color: var(--muted); }
.field input, .field select {
    font: inherit;
    padding: 9px 12px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--fg);
    width: 100%;
    max-width: 480px;
}
.stack-form .field input { max-width: 480px; }
.check { display: flex; gap: 8px; align-items: center; }
.steps { margin: 0; padding-left: 1.3em; display: grid; gap: 4px; }
.panel .hint { font-size: 0.8rem; color: var(--muted); margin: 0; }

/* The hidden attribute must win over display rules like .inline-form's flex. */
[hidden] { display: none !important; }

.made-by { margin-top: 10px; display: inline-flex; align-items: center; gap: 4px; }
.made-by-icon { width: 0.9em; height: 0.9em; fill: #d4af37; flex: none; }

/* Archive */
.archive-note { color: var(--muted); font-size: 0.9rem; margin: 0 0 16px; }
.archive-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.archive-item {
    display: grid; grid-template-columns: 4em 1fr auto; gap: 10px; align-items: center;
    padding: 10px 14px; border-radius: 8px; background: var(--tile); color: inherit; text-decoration: none;
    border-left: 6px solid transparent;
}
.archive-item:hover, .archive-item:focus-visible { outline: 2px solid var(--border); outline-offset: -2px; }
.archive-number { font-weight: 700; }
.archive-date { color: var(--muted); font-size: 0.9rem; }
.archive-status { font-size: 0.85rem; text-align: right; }
.archive-item.won { border-left-color: var(--green); }
.archive-item.lost { border-left-color: var(--purple); }
.archive-item.going { border-left-color: var(--yellow); }
.archive-item.todo .archive-status { color: var(--muted); }
.archive-pages { display: flex; justify-content: center; gap: 16px; margin: 20px 0; font-size: 0.9rem; }
.archive-flag { display: block; color: var(--muted); font-size: 0.8rem; margin-top: 2px; }
.archive-links { margin-top: 16px; }
