@import url('https://fonts.googleapis.com/css2?family=Comic+Neue:wght@400;700;900&display=swap');

:root {
    --bg: #ffffff;
    --fg: #000000;
    --card-start: #fff8b7;
    --card-end: #f0bf2f;
    /* Chat FAB + observer bubbles (keep bottom calc in sync with FAB size / offset) */
    --chat-fab-bottom-offset: 40px;
    --chat-fab-right-offset: 40px;
    --chat-fab-size: 151.2px;
    --observer-bubble-fab-gap: 8px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    padding: 0 2rem 0;
    background: var(--bg);
    color: var(--fg);
    font-family: 'Comic Neue', 'Chalkboard SE', 'Comic Sans MS', sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 1.5rem;
}

/* Subpage “← future brian” control — must match projects/best-color/index.html (see .cursorrules). */
.bc-header {
    position: relative;
    z-index: 10;
    width: min(980px, 100%);
    margin-inline: auto;
    text-align: center;
    padding-top: clamp(2rem, 6vw, 3.25rem);
    padding-inline: 0.5rem;
    margin-bottom: clamp(0.25rem, 1vw, 0.5rem);
}

.bc-back {
    display: inline-block;
    margin-bottom: 1rem;
    padding: 0.4rem 0.75rem;
    border: 3px solid var(--fg);
    border-radius: 10px;
    background-color: #ffffff;
    opacity: 1;
    color: var(--fg);
    text-decoration: none;
    font-weight: 700;
    font-size: 0.95rem;
    box-shadow: 4px 4px 0 var(--fg);
    transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.bc-back:hover,
.bc-back:focus-visible {
    transform: translate(2px, 2px);
    box-shadow: 2px 2px 0 var(--fg);
}

.bc-title {
    margin: 0;
    font-size: clamp(2rem, 5vw, 3.2rem);
    line-height: 1.05;
    text-transform: lowercase;
}

.site-header {
    width: min(980px, 100%);
    text-align: center;
    padding-top: clamp(2rem, 6vw, 3.25rem);
    padding-bottom: 0.25rem;
}

.site-header h1 {
    margin: 0;
    font-size: clamp(2.3rem, 6vw, 3.8rem);
    line-height: 1;
    text-transform: lowercase;
}

.site-header p {
    margin: 0.55rem 0 0;
    font-size: clamp(1.05rem, 2.4vw, 1.35rem);
}

.visitor-count {
    margin: 0;
    font-size: clamp(0.95rem, 2vw, 1.15rem);
    font-weight: 700;
    padding: 0.5rem 0.85rem;
    display: inline-block;
    border: 3px solid var(--fg);
    border-radius: 12px;
    background: #ffffff;
    box-shadow: 4px 4px 0 var(--fg);
}

/* Portfolio: CSS Grid — exactly 3 equal columns from 901px up (see media query). */
#portfolio-grid {
    width: min(980px, 100%);
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.35rem;
    justify-items: center;
    align-items: stretch;
}

@media (min-width: 601px) {
    #portfolio-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 901px) {
    #portfolio-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* get rich quick tile — same chrome as portfolio-card / Memorize Pi */
.joke-container.portfolio-card {
    position: relative;
}

/* Full-bleed control: card border/shadow come from .portfolio-card; matches Memorize Pi body */
.joke-button {
    position: relative;
    z-index: 2;
    flex: 1 1 auto;
    align-self: stretch;
    width: 100%;
    min-width: 0;
    min-height: 0;
    margin: 0;
    padding: 0;
    appearance: none;
    font: inherit;
    font-size: clamp(1.45rem, 3vw, 1.85rem);
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: lowercase;
    color: var(--fg);
    cursor: pointer;
    background: transparent;
    border: none;
    border-radius: 20px;
    box-shadow: none;
    transition: transform 0.1s ease;
    -webkit-tap-highlight-color: transparent;
}

/* After interaction: keep tile from using the portfolio press offset */
.joke-container.portfolio-card.joke-container--spent:hover,
.joke-container.portfolio-card.joke-container--spent:focus-visible {
    transform: translate(0, 0);
    box-shadow: 6px 6px 0 var(--fg);
}

/* Error tile: no black offset shadow — dead inset only on hover/focus */
.joke-container.portfolio-card:has(#joke-button.is-error):hover,
.joke-container.portfolio-card:has(#joke-button.is-error):focus-visible {
    transform: translate(0, 0);
    box-shadow:
        inset 0 0 12px #000,
        inset 0 0 28px rgba(0, 0, 0, 0.5);
}

.joke-button:hover:not(:disabled):not(.is-error),
.joke-button:focus-visible:not(:disabled):not(.is-error) {
    transform: translate(0, 0);
}

.joke-container.portfolio-card:focus-within:not(.joke-container--spent):not(:has(#joke-button.is-error)) {
    outline: 2px solid var(--fg);
    outline-offset: 3px;
}

.joke-button:focus-visible:not(:disabled):not(.is-error) {
    outline: none;
}

.joke-button:active:not(:disabled):not(.is-error) {
    transform: translate(0, 0);
}

.joke-button:disabled {
    cursor: not-allowed;
}

/* Entire tile becomes a dead error screen (card chrome replaces white + black offset shadow) */
.joke-container.portfolio-card:has(#joke-button.is-error) {
    background: #b91c1c !important;
    border: 4px solid #ff2e2e;
    color: #ffffff;
    box-shadow:
        inset 0 0 12px #000,
        inset 0 0 28px rgba(0, 0, 0, 0.5);
}

/* Button fills the tile visually — no second “frame”; text only */
#joke-button.is-error {
    cursor: pointer;
    color: #ffffff;
    background: transparent;
    background-color: transparent;
    border: none;
    border-radius: 20px;
    box-shadow: none;
    text-transform: none;
    letter-spacing: 0.03em;
    font-size: clamp(0.72rem, 2vw, 0.98rem);
    line-height: 1.25;
    text-align: center;
}

.portfolio-card {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.1rem;
    min-height: 148px;
    min-width: min(100%, 320px);
    width: min(100%, 420px);
    justify-self: center;
    padding: 1.55rem 2rem;
    border-radius: 24px;
    text-decoration: none;
    color: var(--fg);
    background: linear-gradient(135deg, var(--card-start), var(--card-end));
    border: 4px solid var(--fg);
    box-shadow: 6px 6px 0 var(--fg);
    transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.portfolio-card:hover,
.portfolio-card:focus-visible {
    transform: translate(3px, 3px);
    box-shadow: 3px 3px 0 var(--fg);
}

/* Plain white cards (no yellow gradient) — Time Wasted; Lemon Do overrides below */
.portfolio-card--plain {
    background: #ffffff;
}

/* Lemon Do — solid pale yellow */
#lemon-do-link.portfolio-card {
    color: var(--fg);
    text-shadow:
        0 1px 0 rgba(255, 255, 255, 0.92),
        0 0 1px rgba(255, 255, 255, 0.65);
    background: #fdf08a;
}

/* The Best Color — white default, smooth tint when leaderboard top winner loads (RTDB) */
#portfolio-best-color-btn {
    background-color: #ffffff;
    color: #000000;
    transition:
        background-color 0.8s ease,
        color 0.8s ease,
        transform 0.1s ease,
        box-shadow 0.1s ease;
}

/* Brian Wiki — encyclopedia-style card */
#brian-wiki-link.portfolio-card {
    background: #ffffff;
    color: #0645ad;
    font-family:
        "Linux Libertine",
        "Liberation Serif",
        Georgia,
        "Times New Roman",
        Times,
        serif;
}

#brian-wiki-link.portfolio-card .card-title {
    font-weight: 400;
    letter-spacing: 0;
    font-size: clamp(1.65rem, 3.4vw, 2.1rem);
}

.card-icon {
    font-size: clamp(2.1rem, 4vw, 2.75rem);
    line-height: 1;
}

.card-title {
    font-size: clamp(1.45rem, 3vw, 1.85rem);
    font-weight: 700;
    letter-spacing: 0.02em;
}

#chat-panel {
    --chat-panel-width: min(340px, 92vw);
    position: fixed;
    top: 0;
    right: calc(-1 * var(--chat-panel-width));
    width: var(--chat-panel-width);
    height: 100vh;
    min-height: 100vh;
    height: 100dvh;
    min-height: 100dvh;
    padding: 1rem;
    background: #ffffff;
    border: 4px solid var(--fg);
    border-right: none;
    box-sizing: border-box;
    box-shadow: 6px 6px 0 var(--fg);
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    z-index: 50;
    transition: right 0.38s cubic-bezier(0.4, 0, 0.2, 1);
}

#chat-panel.chat-panel-open {
    right: 0;
    border-right: 4px solid var(--fg);
}

.chat-panel-header {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
    flex-shrink: 0;
}

.chat-panel-header-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.chat-panel-header h2 {
    margin: 0;
    font-size: 1.4rem;
    flex: 1;
    min-width: 0;
}

#live-viewer-container {
    display: none;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    font-size: 0.85rem;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: 0.02em;
    color: var(--fg);
    font-family:
        "Comic Neue",
        "Chalkboard SE",
        "Comic Sans MS",
        sans-serif;
}

.live-viewer-icon {
    display: block;
    flex-shrink: 0;
    color: var(--fg);
}

.live-red-dot {
    width: 6px;
    height: 6px;
    flex-shrink: 0;
    border-radius: 50%;
    background-color: #e5252a;
    animation: liveDotPulse 2.2s ease-in-out infinite;
}

@keyframes liveDotPulse {
    0%,
    100% {
        opacity: 1;
    }
    50% {
        opacity: 0.45;
    }
}

#live-viewer-count {
    font-variant-numeric: tabular-nums;
    min-width: 0.65em;
}

#close-chat-btn {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.65rem;
    min-height: 2.5rem;
    padding: 0.42rem 0.7rem;
    margin: 0;
    border: 3px solid var(--fg);
    border-radius: 12px;
    background: #ffffff;
    color: var(--fg);
    font-size: 0;
    line-height: 0;
    cursor: pointer;
    appearance: none;
    -webkit-tap-highlight-color: transparent;
}

#close-chat-btn .close-chat-btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    font-family:
        "Comic Neue",
        "Chalkboard SE",
        "Comic Sans MS",
        sans-serif;
    font-size: 1.35rem;
    font-weight: normal;
    line-height: 1;
    letter-spacing: 0;
    translate: 0 -0.04em;
}

#close-chat-btn:focus-visible {
    outline: 2px solid var(--fg);
    outline-offset: 2px;
}

#message-history {
    flex-grow: 1;
    flex-shrink: 1;
    flex-basis: 0;
    min-height: 0;
    overflow-y: auto;
    border: 3px solid var(--fg);
    border-radius: 12px;
    padding: 0.65rem;
    background: #ffffff;
}

.chat-message {
    margin: 0 0 0.55rem;
    line-height: 1.25;
}

.chat-message:last-child {
    margin-bottom: 0;
}

.chat-youtube-embed {
    display: block;
    width: 100%;
    max-width: 100%;
    margin: 0.45rem 0;
    aspect-ratio: 16 / 9;
    border: 3px solid var(--fg);
    border-radius: 10px;
    box-sizing: border-box;
    background: #000000;
}

#chat-alias,
#chat-input {
    flex-shrink: 0;
    width: 100%;
    border: 3px solid var(--fg);
    border-radius: 10px;
    background: #ffffff;
    padding: 0.55rem 0.65rem;
    font: inherit;
}

#chat-alias:focus,
#chat-input:focus {
    outline: none;
    box-shadow: 0 0 0 2px #f8e071;
}

/*
 * Chat FAB — layout note: Lemon Do stays in #portfolio-grid only; this control is
 * position:fixed and does not shift other cards. Lemon Do realignment is unaffected;
 * no other layout issues found beyond the FAB sizing/position work here.
 */

/* Stack grows upward; bottom edge sits just above #chat-fab top + gap. */
#observer-bubble-container {
    position: fixed;
    right: var(--chat-fab-right-offset);
    bottom: calc(
        var(--chat-fab-bottom-offset) + var(--chat-fab-size) +
            var(--observer-bubble-fab-gap)
    );
    z-index: 21;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
    max-width: min(280px, calc(100vw - 40px));
    pointer-events: none;
}

.observer-bubble {
    max-width: min(280px, calc(100vw - 40px));
    margin: 0;
    padding: 0.65rem 0.95rem;
    font-family: inherit;
    font-size: clamp(0.95rem, 2.2vw, 1.05rem);
    font-weight: 700;
    line-height: 1.35;
    letter-spacing: 0.02em;
    color: var(--fg);
    background: #ffffff;
    border: 3px solid var(--fg);
    border-radius: 14px;
    box-shadow: 4px 4px 0 var(--fg);
    text-align: left;
    text-transform: lowercase;
    opacity: 0;
    transform: translateY(20px);
    pointer-events: auto;
    cursor: pointer;
    transition:
        opacity 0.38s ease,
        transform 0.38s cubic-bezier(0.34, 1.2, 0.64, 1);
}

.observer-bubble.bubble-visible {
    opacity: 1;
    transform: translateY(0);
}

#chat-fab {
    position: fixed;
    left: auto;
    top: auto;
    bottom: var(--chat-fab-bottom-offset);
    right: var(--chat-fab-right-offset);
    z-index: 20;
    box-sizing: border-box;
    width: var(--chat-fab-size);
    height: var(--chat-fab-size);
    padding: 0;
    margin: 0;
    border: 4px solid var(--fg);
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 4px 4px 0 var(--fg);
    color: var(--fg);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    appearance: none;
    -webkit-tap-highlight-color: transparent;
    opacity: 1;
    transition:
        right 0.8s ease-out,
        opacity 0.8s ease-out,
        transform 0.2s ease,
        box-shadow 0.2s ease;
}

#chat-fab .chat-fab-icon {
    display: block;
    flex-shrink: 0;
    pointer-events: none;
    width: calc(144px * 0.9 * 0.8);
    height: calc(48px * 0.9 * 0.8);
}

/* Hide FAB off-screen until reveal (slide in when class is removed). */
.fab-hidden {
    right: calc(-1 * (var(--chat-fab-size) + 48px)) !important;
    opacity: 0 !important;
}

#chat-fab:hover {
    transform: translate(2px, 2px);
    box-shadow: 2px 2px 0 var(--fg);
}

#chat-fab:focus-visible {
    outline: none;
    transform: translate(2px, 2px);
    box-shadow:
        2px 2px 0 var(--fg),
        0 0 0 3px #f8e071;
}

.site-footer {
    width: 100%;
    margin-top: auto;
    padding: 1.25rem 2rem 1.75rem;
    background: var(--bg);
    box-sizing: border-box;
    display: flex;
    justify-content: center;
    align-items: center;
}

.site-footer-inner {
    width: min(980px, 100%);
    margin: 0 auto;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 0.65rem 0.85rem;
}

.site-footer-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.55rem 1.1rem;
    border-radius: 999px;
    border: 4px solid var(--fg);
    font-weight: 700;
    text-decoration: none;
    color: var(--fg);
    background: #ffffff;
    box-shadow: 4px 4px 0 var(--fg);
    transition: transform 0.1s ease, box-shadow 0.1s ease;
    font-size: clamp(0.9rem, 2.2vw, 1.05rem);
    letter-spacing: 0.02em;
    text-transform: lowercase;
    text-align: center;
}

.site-footer-link--icon {
    padding: 0.5rem 0.65rem;
}

.site-footer-x-icon {
    display: block;
    flex-shrink: 0;
}

.site-footer-link:hover,
.site-footer-link:focus-visible {
    transform: translate(2px, 2px);
    box-shadow: 2px 2px 0 var(--fg);
    outline: none;
}

/* —— Donate / Ko-fi embed (pages/donate.html) —— */
body.donate-page {
    padding-top: clamp(1.25rem, 4vw, 2rem);
    padding-bottom: 2rem;
    gap: 0;
}

.donate-header {
    width: min(980px, 100%);
    margin: 0 auto;
    padding: 0 0 1.25rem;
}

.donate-back {
    display: inline-block;
    padding: 0.4rem 0.75rem;
    border: 3px solid var(--fg);
    border-radius: 10px;
    background: #ffffff;
    color: var(--fg);
    text-decoration: none;
    font-weight: 700;
    font-size: 0.95rem;
    box-shadow: 4px 4px 0 var(--fg);
    transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.donate-back:hover,
.donate-back:focus-visible {
    transform: translate(2px, 2px);
    box-shadow: 2px 2px 0 var(--fg);
    outline: none;
}

.donate-main {
    flex: 1;
    width: 100%;
    max-width: min(520px, 100%);
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 0 1rem;
}

/* —— Time Wasted (projects/time-wasted/time-wasted.html) —— */
body.time-wasted-page {
    padding-top: clamp(1.25rem, 4vw, 2rem);
    padding-bottom: 0;
    gap: 0;
    align-items: stretch;
    background-color: #ffffff;
}

.tw-header {
    width: min(720px, 100%);
    margin: 0 auto;
    padding: 0 0 1.5rem;
    text-align: center;
}

.tw-back {
    display: inline-block;
    margin-bottom: 1rem;
    padding: 0.4rem 0.75rem;
    border: 3px solid var(--fg);
    border-radius: 10px;
    background: #ffffff;
    color: var(--fg);
    text-decoration: none;
    font-weight: 700;
    font-size: 0.95rem;
    box-shadow: 4px 4px 0 var(--fg);
    transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.tw-back:hover,
.tw-back:focus-visible {
    transform: translate(2px, 2px);
    box-shadow: 2px 2px 0 var(--fg);
    outline: none;
}

.tw-title {
    margin: 0;
    font-size: clamp(2rem, 5.5vw, 3rem);
    line-height: 1.05;
    text-transform: lowercase;
}

.tw-tagline {
    margin: 0.5rem 0 0;
    font-size: clamp(1rem, 2.2vw, 1.2rem);
    font-weight: 700;
}

.tw-main {
    width: min(720px, 100%);
    margin: 0 auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1.75rem;
    padding: 0.25rem 0 1.5rem;
}

.tw-fact-stack {
    display: flex;
    flex-direction: column;
    gap: clamp(150px, 15vh, 260px);
}

.tw-fact-card {
    margin: 0;
    padding: 1.15rem 1.35rem 1.25rem;
    border: 3px solid var(--fg);
    border-radius: 14px;
    background: #ffffff;
    box-shadow: 5px 5px 0 var(--fg);
}

.tw-fact-text {
    margin: 0 0 1rem;
    line-height: 1.45;
    font-size: clamp(0.98rem, 2vw, 1.12rem);
}

.tw-fact-meter {
    height: 14px;
    border: 3px solid var(--fg);
    border-radius: 8px;
    background: #e8e8e8;
    overflow: hidden;
    box-shadow: inset 2px 2px 0 rgba(0, 0, 0, 0.08);
}

.tw-fact-meter-fill {
    height: 100%;
    border-radius: 4px 0 0 4px;
    background: repeating-linear-gradient(
        -45deg,
        #1a1a1a,
        #1a1a1a 4px,
        #3d3d3d 4px,
        #3d3d3d 8px
    );
    box-shadow: 2px 0 0 var(--fg);
    min-width: 6px;
}

.tw-embed-wrap {
    position: relative;
    width: 100%;
    max-width: 100%;
    margin: 0 0 1rem;
    aspect-ratio: 16 / 9;
    border: 3px solid var(--fg);
    border-radius: 12px;
    overflow: hidden;
    background: #000000;
    box-shadow: 4px 4px 0 var(--fg);
}

.tw-embed-iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

.tw-floor-shadow {
    width: 100%;
    height: 1000px;
    max-width: 100%;
    flex-shrink: 0;
    pointer-events: none;
    background: linear-gradient(
        to bottom,
        rgba(0, 0, 0, 0) 0%,
        rgba(0, 0, 0, 0.04) 35%,
        rgba(12, 12, 14, 0.55) 78%,
        rgba(18, 18, 22, 0.92) 100%
    );
}

.tw-chart-section {
    margin: 0;
    padding: 1.25rem 1.15rem 1.5rem;
    border: 3px solid var(--fg);
    border-radius: 14px;
    background: #ffffff;
    box-shadow: 5px 5px 0 var(--fg);
}

.tw-chart-heading {
    margin: 0 0 1.15rem;
    font-size: clamp(0.95rem, 2.2vw, 1.1rem);
    font-weight: 900;
    text-transform: lowercase;
    line-height: 1.35;
    letter-spacing: 0.02em;
    text-align: center;
}

.tw-chart-bars {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    justify-content: space-between;
    gap: 0.45rem;
    padding: 0 0.1rem;
}

.tw-chart-col {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: stretch;
}

.tw-chart-bar-shell {
    width: 100%;
    max-width: 88px;
    margin: 0 auto;
    height: clamp(168px, 42vw, 240px);
    border: 3px solid var(--fg);
    border-radius: 12px 12px 8px 8px;
    background: #f0f0f0;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    overflow: hidden;
    flex-shrink: 0;
}

.tw-chart-bar-shell--roman {
    border-color: #0a0a0a;
}

.tw-chart-bar {
    width: 100%;
    min-height: 0;
    padding: 0;
    box-sizing: border-box;
    flex-shrink: 0;
}

.tw-chart-bar--youtube {
    background: #cc0000;
    border-top: 2px solid rgba(0, 0, 0, 0.2);
}

.tw-chart-bar--tiktok {
    background: linear-gradient(180deg, #00f2ea 0%, #ff0050 100%);
    border-top: 2px solid rgba(0, 0, 0, 0.15);
}

.tw-chart-bar--meta {
    background: linear-gradient(
        160deg,
        #833ab4 0%,
        #e1306c 28%,
        #1877f2 62%,
        #0866ff 100%
    );
    border-top: 2px solid rgba(0, 0, 0, 0.15);
}

.tw-chart-bar.tw-chart-bar--roman {
    min-height: 1px;
    border-top: none;
    border: 2px solid #0a0a0a;
    background: linear-gradient(180deg, #8e44ad 0%, #5b2c6f 42%, #3d1a4d 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
    box-sizing: border-box;
}

.tw-chart-label-foot {
    width: 100%;
    min-height: 4.1rem;
    margin-top: 0.45rem;
    padding: 0 0.1rem;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    text-align: center;
    box-sizing: border-box;
}

.tw-chart-foot-label {
    display: block;
    font-size: clamp(0.58rem, 1.85vw, 0.72rem);
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.055em;
    line-height: 1.2;
    color: var(--fg);
}

.tw-chart-foot-sublabel {
    display: block;
    margin-top: 0.2rem;
    font-size: clamp(0.5rem, 1.65vw, 0.64rem);
    font-weight: 800;
    line-height: 1.25;
    color: #333;
    text-transform: none;
    letter-spacing: 0.02em;
}

.tw-counter-status {
    margin: 0;
    min-height: 1.25em;
    font-size: 0.95rem;
    font-weight: 700;
    color: #8b0000;
    text-align: center;
}

.tw-counter-section {
    margin: 0;
    padding: 1.5rem 1.15rem 1.75rem;
    border: 4px solid var(--fg);
    border-radius: 18px;
    background: #ffffff;
    box-shadow: 6px 6px 0 var(--fg);
}

.tw-counter-unified {
    text-align: center;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.tw-counter-heroblock {
    flex: 1 1 auto;
    padding-bottom: 1.35rem;
}

.tw-counter-hero-title {
    margin: 0 0 0.65rem;
    font-size: clamp(0.95rem, 2.4vw, 1.15rem);
    font-weight: 900;
    text-transform: lowercase;
    line-height: 1.3;
    letter-spacing: 0.02em;
}

.tw-counter-subblock {
    flex: 0 0 auto;
    margin-top: 0;
    padding-top: 1.35rem;
    border-top: 2px solid rgba(0, 0, 0, 0.1);
}

.tw-counter-subtitle {
    margin: 0 0 0.55rem;
    font-size: clamp(0.68rem, 1.75vw, 0.82rem);
    font-weight: 800;
    text-transform: lowercase;
    letter-spacing: 0.05em;
    line-height: 1.35;
    color: rgba(0, 0, 0, 0.72);
}

.tw-counter-subtitle em {
    font-style: normal;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.tw-counter {
    margin: 0;
}

.tw-counter--primary .tw-counter-raw {
    display: block;
    font-variant-numeric: tabular-nums;
    font-size: clamp(2.65rem, 12vw, 5rem);
    font-weight: 900;
    line-height: 1;
    word-break: break-all;
}

.tw-counter--primary .tw-counter-breakdown {
    margin: 0.6rem 0 0;
    font-size: clamp(0.95rem, 2.8vw, 1.2rem);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    line-height: 1.35;
}

.tw-counter--secondary .tw-counter-raw {
    display: block;
    font-variant-numeric: tabular-nums;
    font-size: clamp(1.15rem, 4.5vw, 2rem);
    font-weight: 800;
    line-height: 1.05;
    word-break: break-all;
    color: rgba(0, 0, 0, 0.82);
}

.tw-counter--secondary .tw-counter-breakdown {
    margin: 0.4rem 0 0;
    font-size: clamp(0.72rem, 2vw, 0.9rem);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    line-height: 1.35;
    color: rgba(0, 0, 0, 0.65);
}

@media (max-width: 520px) {
    .tw-chart-bars {
        flex-wrap: wrap;
        justify-content: center;
        row-gap: 1rem;
        column-gap: 0.3rem;
    }

    .tw-chart-col {
        flex: 1 1 42%;
        max-width: 48%;
        min-width: 0;
    }

    .tw-chart-bar-shell {
        max-width: 100%;
        height: clamp(150px, 48vw, 200px);
    }

    .tw-chart-label-foot {
        min-height: 3.85rem;
    }

    .tw-chart-foot-label {
        font-size: clamp(0.52rem, 2.4vw, 0.66rem);
    }

    .tw-chart-foot-sublabel {
        font-size: clamp(0.46rem, 2.1vw, 0.58rem);
    }
}

@media (max-width: 600px) {
    body {
        padding-left: 1.25rem;
        padding-right: 1.25rem;
    }

    .site-header {
        padding-top: clamp(1.5rem, 5vw, 2.5rem);
    }

    .site-footer {
        padding: 1.1rem 1.25rem 1.5rem;
    }

    .site-footer-inner {
        flex-direction: row;
        gap: 0.55rem 0.75rem;
    }

    .site-footer-link {
        width: auto;
        max-width: none;
        padding: 0.5rem 1rem;
    }

    .site-footer-link--icon {
        padding: 0.45rem 0.55rem;
    }
}

/* --- The Best Color: hex lookup stats (background + text color set in JS) --- */
/* Reserve vertical space for input + gap + full stats card (≈4 lines + win rate). */
body.best-color-page .bc-hex-search-container {
    min-height: 16rem;
}

#search-result-display.search-result-display {
    min-height: 5.5rem;
    padding: 1rem 1.1rem;
    border: 3px solid rgba(0, 0, 0, 0.35);
    border-radius: 14px;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.25),
        3px 3px 0 rgba(0, 0, 0, 0.12);
    font-size: 0.95rem;
    font-weight: 700;
    line-height: 1.55;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    align-items: stretch;
    transition: background-color 0.15s ease, color 0.15s ease;
}

#search-result-display.search-result-display .hex-search-snapped-label {
    font-family:
        "Nunito",
        system-ui,
        -apple-system,
        "Segoe UI",
        Roboto,
        sans-serif;
    font-size: 0.68rem;
    font-weight: 800;
    text-transform: lowercase;
    letter-spacing: 0.06em;
    opacity: 0.88;
    margin: 0;
}

#search-result-display.search-result-display .hex-search-snapped-hex {
    font-family: ui-monospace, monospace;
    font-size: 1.05rem;
    word-break: break-all;
}

#search-result-display.search-result-display .hex-search-snapped-name {
    font-family:
        "Nunito",
        system-ui,
        -apple-system,
        "Segoe UI",
        Roboto,
        sans-serif;
    font-size: 0.9rem;
    text-transform: lowercase;
}

#search-result-display.search-result-display .hex-search-snapped-stats,
#search-result-display.search-result-display .hex-search-snapped-rate {
    font-family: ui-monospace, monospace;
    font-size: 0.82rem;
}

/* Keep border-box footprint when cleared; avoid layout jump vs. filled state. */
#search-result-display.search-result-display:empty {
    visibility: hidden;
    background: transparent !important;
}

body.best-color-page #personal-stats-widget.personal-stats-widget {
    --fav-hex: #d8d8d8;
    --handle-ink: #111;
    --panel-ink: #fff;
    box-sizing: border-box;
    background: transparent;
    border: none;
    box-shadow: none;
    color: #111;
}

/* Master expanded panel: brand blue + heavy neubrutalist shadow (JS sets --personal-panel-bg) */
body.best-color-page #personal-widget-panel.personal-widget-panel {
    position: relative;
    background-color: var(--personal-panel-bg, #0088c8) !important;
    border: 3px solid #000 !important;
    border-radius: 14px;
    box-sizing: border-box;
    box-shadow: 10px 10px 0 #000 !important;
}

/* Text on blue: single contrast variable from JS */
body.best-color-page
    #personal-widget-panel.personal-widget-panel
    .personal-widget-title-row,
body.best-color-page
    #personal-widget-panel.personal-widget-panel
    .personal-widget-lv-inline,
body.best-color-page
    #personal-widget-panel.personal-widget-panel
    .personal-widget-icon--header {
    color: var(--panel-ink, #fff);
}

body.best-color-page .personal-widget-close {
    flex-shrink: 0;
    width: 2.1rem;
    height: 2.1rem;
    padding: 0;
    border: 2px solid #000;
    border-radius: 8px;
    background: #fff;
    color: #000 !important;
    font-size: 1.35rem;
    font-weight: 800;
    line-height: 1;
    cursor: pointer;
    box-shadow: 4px 4px 0 #000;
}

body.best-color-page .personal-widget-close:hover,
body.best-color-page .personal-widget-close:focus-visible {
    transform: translate(1px, 1px);
    box-shadow: 3px 3px 0 #000;
    outline: none;
}

/* Drag grip: subtle texture (non-interactive look; drag bound in JS) */
body.best-color-page .personal-widget-drag-grip {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 26px;
    border-right: 2px solid rgba(0, 0, 0, 0.35);
    background-color: rgba(0, 0, 0, 0.08);
    background-image:
        repeating-linear-gradient(
            180deg,
            rgba(0, 0, 0, 0.22) 0 2px,
            transparent 2px 6px
        ),
        repeating-linear-gradient(
            90deg,
            rgba(0, 0, 0, 0.14) 0 1px,
            transparent 1px 5px
        );
    border-radius: 11px 0 0 11px;
    pointer-events: auto;
    touch-action: none; /* no pan/zoom steal on drag handle */
    cursor: grab;
    z-index: 2;
}

body.best-color-page .personal-widget-drag-grip:active {
    cursor: grabbing;
}

/* Inner data rows: white, black border, black text, heavy offset shadow */
body.best-color-page #personal-widget-panel .personal-widget-fave-row,
body.best-color-page #personal-widget-panel .personal-vote-stat-box,
body.best-color-page #personal-widget-panel .personal-streak-line {
    background-color: #fff !important;
    border: 3px solid #000 !important;
    color: #000 !important;
    box-shadow: 8px 8px 0 #000 !important;
}

body.best-color-page #personal-widget-panel .personal-stat-label,
body.best-color-page #personal-widget-panel .personal-fave-empty,
body.best-color-page #personal-widget-panel .personal-vote-stat-line,
body.best-color-page #personal-widget-panel .personal-streak-line {
    color: #000 !important;
}

body.best-color-page #personal-widget-panel .personal-fave-swatch-tile {
    border: 2px solid #000 !important;
    box-shadow: none !important;
}

/* XP bar in panel header (on blue) + same track style if reused */
body.best-color-page #personal-widget-panel .personal-xp-bar {
    position: relative;
    width: 100%;
    height: 11px;
    border: 2px solid rgba(0, 0, 0, 0.85);
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.92) !important;
    box-sizing: border-box;
    overflow: hidden;
}

body.best-color-page
    #personal-widget-panel
    .personal-widget-header-xp
    .personal-xp-bar {
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.35);
}

body.best-color-page #personal-widget-panel .personal-xp-bar-fill {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    height: 100%;
    width: 0%;
    max-width: 100%;
    border-radius: 2px;
    background: #0088c8 !important;
    pointer-events: none;
    transition: width 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Legacy compact-xp (if referenced elsewhere) */
body.best-color-page .compact-xp-tracker {
    position: relative;
    display: block;
    width: 100%;
    max-width: 100%;
    margin: 0 0 0.65rem;
    padding: 0.32rem 0.55rem;
    border: 2px solid var(--fg);
    border-radius: 999px;
    background: #f4f4f6;
    box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.08);
    box-sizing: border-box;
    overflow: hidden;
}

body.best-color-page .compact-xp-fill {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    height: 100%;
    width: 0%;
    max-width: 100%;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.07);
    box-sizing: border-box;
    pointer-events: none;
    transition:
        width 0.35s cubic-bezier(0.22, 1, 0.36, 1),
        background-color 0.2s ease;
    z-index: 0;
}

/* Best Color: disable double-tap zoom on vote targets (all viewports) */
body.best-color-page button.color-choice {
    touch-action: manipulation;
}

/* Best Color: narrow phones — side-by-side vote targets, thumb-friendly height */
@media (max-width: 767px) {
    body.best-color-page #matchup.matchup {
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
        align-items: stretch;
        justify-content: center;
        gap: 0.5rem;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    body.best-color-page #matchup.matchup .color-choice {
        flex: 1 1 0;
        min-width: 0;
        width: auto;
        max-width: none;
        min-height: 11.5rem;
        box-sizing: border-box;
        padding: 0.65rem 0.4rem 1.55rem;
    }

    body.best-color-page #matchup.matchup .color-choice-name {
        white-space: normal;
        overflow-wrap: anywhere;
        word-break: break-word;
        hyphens: auto;
        font-size: clamp(0.8rem, 2.8vw + 0.55rem, 1.55rem);
        line-height: 1.14;
        padding: 0.25rem 0.3rem 0.95rem;
    }

    body.best-color-page #matchup.matchup .color-choice-hex {
        max-width: calc(100% - 0.5rem);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        font-size: clamp(0.45rem, 1.8vw, 0.52rem);
    }
}

