/* The Number - assumption-busting guessing game.
   Studio-light portal theme with a dark monospace console as the centrepiece. */
#tn-wrapper {
    --tn-bg: #f8f8f6;
    --tn-surface: #ffffff;
    --tn-border: #e3e3df;
    --tn-text: #1a1a18;
    --tn-muted: #5c5c58;
    --tn-accent: #0E8F86;          /* terminal teal */
    --tn-accent-2: #14B8A6;
    --tn-accent-soft: #E2F5F2;
    --tn-accent-line: #BFE7E2;
    --tn-grad: linear-gradient(120deg, #0E8F86 0%, #14B8A6 55%, #6D5CF6 100%);
    --tn-ok: #15A06B;
    --tn-warn: #D97706;
    --tn-err: #DC2626;
    --tn-track: #ECECE8;
    /* console palette */
    --tn-con-bg: #0d1117;
    --tn-con-text: #d7e0ea;
    --tn-con-dim: #7d8794;
    --tn-con-green: #5ad19b;
    --tn-con-red: #ff8e8e;
    --tn-con-amber: #f5c469;
    --tn-con-cyan: #6fd3e0;

    background: var(--tn-bg);
    color: var(--tn-text);
    min-height: 80vh;
    font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
#tn-wrapper * { box-sizing: border-box; }

.tn-screen { display: none; }
.tn-screen.on { display: block; }
.tn-wrap { max-width: 760px; margin: 0 auto; padding: 1.75rem 1.25rem 3rem; }

/* ---- intro hero ---- */
.tn-card {
    background: var(--tn-surface);
    border: 1px solid var(--tn-border);
    border-radius: 16px;
    padding: 2.25rem;
    box-shadow: 0 8px 30px rgba(0,0,0,0.05);
    text-align: center;
}
.tn-hero-title {
    font-size: 2.4rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin: 0 0 0.6rem;
}
.tn-hero-tag { color: var(--tn-muted); font-size: 1.05rem; line-height: 1.55; margin: 0 0 1.6rem; }
.tn-byline { margin-top: 1.6rem; font-size: 0.78rem; color: var(--tn-muted); }
.tn-byline a { color: var(--tn-accent); text-decoration: none; }
.tn-credit {
    margin: 0.6rem auto 0; max-width: 30rem;
    font-size: 0.72rem; line-height: 1.5; color: var(--tn-muted);
}
.tn-credit a { color: var(--tn-accent); text-decoration: none; }
.tn-credit a:hover { text-decoration: underline; }

/* ---- result footer ---- */
.tn-footer {
    margin-top: 2rem; padding-top: 1.25rem; border-top: 1px solid var(--tn-border);
    text-align: center; font-size: 0.78rem; color: var(--tn-muted);
}
.tn-footer p { margin: 0.35rem 0; }
.tn-footer .tn-credit { margin-left: auto; margin-right: auto; }
.tn-footer a { color: var(--tn-accent); text-decoration: none; }
.tn-footer a:hover { text-decoration: underline; }

/* ---- buttons ---- */
.tn-btn {
    border: none; cursor: pointer; font-weight: 700;
    border-radius: 10px; padding: 0.8rem 1.4rem; font-size: 0.95rem;
    transition: transform 0.08s ease, box-shadow 0.15s ease;
}
.tn-btn:active { transform: translateY(1px); }
.tn-btn-primary { background: var(--tn-grad); color: #fff; box-shadow: 0 6px 18px rgba(14,143,134,0.3); }
.tn-btn-secondary { background: var(--tn-surface); color: var(--tn-text); border: 1px solid var(--tn-border); }
.tn-hero-cta { margin-top: 0.4rem; }
.tn-hero-cta span { margin-left: 0.3rem; }

/* ---- game HUD ---- */
.tn-hud {
    display: flex; align-items: center; justify-content: space-between;
    gap: 0.75rem; flex-wrap: wrap; margin-bottom: 0.85rem;
}
.tn-hud-left { display: flex; align-items: baseline; gap: 0.6rem; }
.tn-level-pill {
    font-family: var(--fm, monospace); font-weight: 800; font-size: 0.78rem;
    color: #fff; background: var(--tn-accent); padding: 0.2rem 0.55rem; border-radius: 6px;
}
.tn-level-name { font-weight: 700; font-size: 1.05rem; }
.tn-hud-right { display: flex; align-items: center; gap: 0.7rem; flex-wrap: wrap; }
.tn-rank {
    font-size: 0.75rem; font-weight: 700; color: var(--tn-accent);
    background: var(--tn-accent-soft); border: 1px solid var(--tn-accent-line);
    padding: 0.25rem 0.6rem; border-radius: 99px;
}
.tn-stat { font-size: 0.82rem; color: var(--tn-muted); }
.tn-stat b { color: var(--tn-text); font-variant-numeric: tabular-nums; }
.tn-icon-btn {
    background: none; border: 1px solid var(--tn-border); border-radius: 8px;
    width: 32px; height: 32px; cursor: pointer; font-size: 0.9rem; line-height: 1;
}

/* ---- console ---- */
.tn-console {
    position: relative;
    background: var(--tn-con-bg);
    border-radius: 14px;
    padding: 1rem 1.1rem 0.9rem;
    box-shadow: 0 12px 36px rgba(13,17,23,0.28);
    font-family: var(--fm, "Consolas", "SF Mono", "Courier New", monospace);
}
.tn-log {
    min-height: 210px; max-height: 320px; overflow-y: auto;
    font-size: 0.92rem; line-height: 1.6; color: var(--tn-con-text);
    padding-bottom: 0.5rem;
}
.tn-line { white-space: pre-wrap; word-break: break-word; }
.tn-line-prompt { color: #fff; font-weight: 600; margin-bottom: 0.3rem; }
.tn-line-guess  { color: var(--tn-con-cyan); }
.tn-line-hint   { color: var(--tn-con-amber); }
.tn-line-win    { color: var(--tn-con-green); font-weight: 700; }
.tn-line-sys    { color: var(--tn-con-dim); font-style: italic; }
.tn-line-find   { color: var(--tn-con-cyan); font-weight: 700; }
.tn-line-reveal { color: var(--tn-con-green); font-weight: 700; }
.tn-line-alert  { color: var(--tn-con-red); font-weight: 700; }
.tn-line-glitch {
    color: var(--tn-con-red); font-weight: 700; letter-spacing: 0.04em;
    text-shadow: 1px 0 rgba(111,211,224,0.7), -1px 0 rgba(255,142,142,0.7);
    animation: tn-glitch 0.85s steps(2, end) 1;
}
@keyframes tn-glitch {
    0%   { opacity: 0.35; transform: translateX(-2px); }
    20%  { opacity: 1;    transform: translateX(2px); }
    40%  { transform: translateX(-1px); }
    60%  { transform: translateX(1px); }
    100% { transform: translateX(0); }
}
@media (prefers-reduced-motion: reduce) {
    .tn-line-glitch { animation: none; }
}

.tn-input-row {
    display: flex; align-items: center; gap: 0.5rem;
    border-top: 1px solid rgba(255,255,255,0.08); padding-top: 0.7rem;
}
.tn-caret { color: var(--tn-con-green); font-weight: 800; }
.tn-input {
    flex: 1; background: transparent; border: none; outline: none;
    color: #fff; font-family: inherit; font-size: 1rem; caret-color: var(--tn-con-green);
}
.tn-enter {
    background: var(--tn-accent); color: #fff; border: none; border-radius: 7px;
    padding: 0.4rem 0.9rem; font-weight: 700; cursor: pointer; font-family: inherit;
}
.tn-enter:hover { background: var(--tn-accent-2); }

.tn-controls { display: flex; gap: 0.6rem; margin-top: 0.8rem; }
.tn-ghost-btn {
    background: none; border: 1px solid var(--tn-border); color: var(--tn-muted);
    border-radius: 8px; padding: 0.45rem 0.85rem; font-size: 0.82rem; cursor: pointer;
}
.tn-ghost-btn:hover { border-color: var(--tn-accent); color: var(--tn-accent); }
.tn-finish-btn { margin-left: auto; font-weight: 700; }

/* ---- burst badge ---- */
.tn-burst {
    position: absolute; top: 12px; right: 12px;
    background: var(--tn-grad); color: #fff; font-family: "Inter", sans-serif;
    font-weight: 800; font-size: 0.78rem; letter-spacing: 0.02em;
    padding: 0.35rem 0.7rem; border-radius: 99px;
    box-shadow: 0 6px 18px rgba(14,143,134,0.4);
    animation: tn-pop 0.3s ease, tn-fade 1.6s ease forwards;
}
@keyframes tn-pop { from { transform: scale(0.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes tn-fade { 0%,70% { opacity: 1; } 100% { opacity: 0; transform: translateY(-6px); } }

/* ---- result ---- */
.tn-result-head { text-align: center; margin-bottom: 1.4rem; }
.tn-score-ring {
    width: 132px; height: 132px; border-radius: 50%; margin: 0 auto 0.8rem;
    display: grid; place-items: center;
    background: conic-gradient(var(--tn-accent) 0deg, var(--tn-track) 0);
}
.tn-score-ring::before {
    content: ""; grid-area: 1/1; width: 104px; height: 104px;
    background: var(--tn-surface); border-radius: 50%;
}
.tn-score-num {
    grid-area: 1/1; font-size: 2.4rem; font-weight: 800; color: var(--tn-text);
    font-variant-numeric: tabular-nums;
}
.tn-result-sub { color: var(--tn-muted); font-size: 0.92rem; margin: 0.2rem 0; }
.tn-result-rank {
    display: inline-block; font-weight: 800; color: var(--tn-accent);
    background: var(--tn-accent-soft); border: 1px solid var(--tn-accent-line);
    padding: 0.3rem 0.8rem; border-radius: 99px; font-size: 0.9rem;
}

.tn-report {
    background: var(--tn-surface); border: 1px solid var(--tn-border);
    border-radius: 14px; padding: 0.4rem 1rem; margin-bottom: 1.25rem;
}
.tn-report-head {
    font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.1em;
    font-weight: 800; color: var(--tn-muted); padding: 0.8rem 0 0.5rem;
}
.tn-report-row {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.7rem 0; border-top: 1px solid var(--tn-border);
}
.tn-report-icon {
    flex-shrink: 0; width: 26px; height: 26px; border-radius: 50%;
    display: grid; place-items: center; font-weight: 800; font-size: 0.85rem;
    background: var(--tn-track); color: var(--tn-muted);
}
.tn-report-row.bonus .tn-report-icon { background: var(--tn-accent-soft); color: var(--tn-accent); }
.tn-report-row.ok .tn-report-icon { background: #E7F6EF; color: var(--tn-ok); }
.tn-report-row.revealed .tn-report-icon { background: #FFF1E0; color: var(--tn-warn); }
.tn-report-row.locked .tn-report-icon { background: var(--tn-track); color: var(--tn-muted); }
.tn-report-row.locked .tn-report-name { color: var(--tn-muted); }
.tn-report-body { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.tn-report-name { font-weight: 700; font-size: 0.9rem; }
.tn-report-lesson { font-size: 0.84rem; color: var(--tn-text); }
.tn-report-lesson.tn-blur { filter: blur(5px); user-select: none; pointer-events: none; }
.tn-report-note { font-size: 0.76rem; color: var(--tn-muted); }
.tn-report-pts { font-weight: 800; color: var(--tn-accent); font-variant-numeric: tabular-nums; }

.tn-nudge { text-align: center; color: var(--tn-muted); font-size: 0.88rem; margin: 1rem 0; }
.tn-result-actions { display: flex; gap: 0.7rem; justify-content: center; flex-wrap: wrap; }

#the-number-leaderboard { margin: 1.25rem 0; }

/* ---- responsive ---- */
@media (max-width: 560px) {
    .tn-hero-title { font-size: 1.9rem; }
    .tn-wrap { padding: 1.25rem 1rem 2.5rem; }
    .tn-console { padding: 0.85rem 0.85rem 0.8rem; }
    .tn-hud-right { gap: 0.5rem; }
}
