/* Theme (original Floyd Tracker palette) */
:root {
    --bg: #d67999;
    --card: #a04f6b;
    --row: #c46788;
    --row-hover: #e08baf;
    --pale: #fccadf;
    --pale-2: #ffb6c1;
    --text: #ffffff;
    --muted: #ffdfdf;
    --line: rgba(255, 255, 255, 0.651);
    --line-soft: rgba(255, 255, 255, 0.25);
    --danger: #ffcccb;
    --radius: 15px;
    --radius-sm: 10px;
    --gutter: 16px;
    --header-height: 56px;
    --shadow: 2px 2px 10px rgba(0, 0, 0, 0.2);
}

*, *::before, *::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.45;
    color: var(--text);
    background: var(--bg);
}

a {
    color: var(--text);
    font-weight: 600;
}

h1, h2, h3, h4 {
    margin: 0;
    line-height: 1.2;
}

img {
    max-width: 100%;
}

/* Header */
.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 16px;
    height: var(--header-height);
    padding: 0 max(var(--gutter), calc((100% - 1200px) / 2));
    background: var(--row);
    box-shadow: var(--shadow);
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    font-weight: 700;
    font-size: 1.05rem;
    text-decoration: none;
    white-space: nowrap;
}

.brand img {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 2px solid var(--pale);
    object-fit: cover;
}

.nav-links {
    display: flex;
    gap: 4px;
    margin-left: auto;
}

.nav-link {
    padding: 7px 14px;
    border-radius: var(--radius-sm);
    color: var(--text);
    font-weight: 600;
    font-size: 0.95rem;
    text-decoration: none;
}

.nav-link:hover, .nav-link.active {
    background: var(--row-hover);
}

.menu-button {
    display: none;
    margin-left: auto;
    width: 40px;
    height: 40px;
    padding: 12px 9px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: transparent;
    cursor: pointer;
    flex-direction: column;
    justify-content: space-between;
}

.menu-button span {
    display: block;
    height: 2px;
    border-radius: 2px;
    background: var(--text);
    transition: transform 0.2s, opacity 0.2s;
}

.menu-open .menu-button span:nth-child(1) {
    transform: translateY(6px) rotate(45deg);
}

.menu-open .menu-button span:nth-child(2) {
    opacity: 0;
}

.menu-open .menu-button span:nth-child(3) {
    transform: translateY(-6px) rotate(-45deg);
}

@media (max-width: 720px) {
    .menu-button {
        display: flex;
    }

    .nav-links {
        display: none;
        position: absolute;
        top: var(--header-height);
        left: 0;
        right: 0;
        flex-direction: column;
        padding: 6px var(--gutter) 12px;
        background: var(--row);
        box-shadow: var(--shadow);
    }

    .menu-open .nav-links {
        display: flex;
    }

    .nav-link {
        padding: 12px 14px;
    }
}

/* Layout */
.page {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px var(--gutter) 40px;
}

.page-narrow {
    max-width: 760px;
}

.page-heading {
    text-align: center;
    margin-bottom: 20px;
}

.page-heading h1 {
    font-size: clamp(1.5rem, 4vw, 2rem);
}

.page-heading p, .page-heading h3 {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 0.95rem;
    font-weight: 600;
}

/* Cards */
.card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
}

.card + .card {
    margin-top: 18px;
}

.card h2 {
    font-size: 1.25rem;
    margin-bottom: 6px;
}

.card-subtitle {
    margin: 0 0 12px;
    color: var(--muted);
    font-size: 0.9rem;
}

@media (max-width: 480px) {
    .card {
        padding: 16px 14px;
    }
}

/* List rows used by several cards */
.row-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.row-list li {
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    background: var(--row);
    font-size: 0.9rem;
    text-align: left;
}

/* Buttons & inputs */
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 9px 20px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text);
    font: inherit;
    font-weight: 700;
    text-decoration: none;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: background 0.15s;
}

.button:hover, .button:active {
    background: var(--row-hover);
}

.button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.button-primary {
    background: var(--row);
}

.text-input {
    width: 100%;
    min-height: 46px;
    padding: 10px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--row-hover);
    color: var(--text);
    font: inherit;
    box-shadow: var(--shadow);
}

.text-input::placeholder {
    color: var(--line);
}

.text-input:focus, .button:focus-visible, .nav-link:focus-visible {
    outline: 2px solid var(--pale);
    outline-offset: 2px;
}

/* Messages */
.status-message {
    text-align: center;
    color: var(--muted);
}

.error-message {
    color: var(--danger);
    text-align: center;
    font-weight: 600;
    margin: 10px 0 0;
}

/* Ko-fi widget */
.kofi-section {
    display: flex;
    justify-content: center;
    margin-top: 24px;
}

/* Challenge rows, used by the floyd page and the my challenges panel */
.challenge-list {
    list-style: none;
    margin: 8px 0 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 5px;
}

.challenge-row {
    display: flex;
    align-items: center;
    gap: 7px;
    min-width: 0;
    padding: 4px 9px;
    border-radius: var(--radius-sm);
    background: var(--row);
    font-size: 0.85rem;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s;
}

.challenge-row:hover {
    background: var(--row-hover);
}

.challenge-mark {
    flex-shrink: 0;
    width: 14px;
    height: 14px;
    border: 2px solid var(--text);
    border-radius: 50%;
}

.challenge-row.done .challenge-mark {
    border-color: var(--pale-2);
    background: var(--pale-2);
}

.challenge-row.done .challenge-mark::after {
    content: "✓";
    display: block;
    color: var(--card);
    font-size: 10px;
    font-weight: 900;
    line-height: 10px;
    text-align: center;
}

.challenge-row.untracked .challenge-mark {
    border-style: dashed;
}

.challenge-row.done .challenge-name {
    opacity: 0.75;
}

.challenge-id {
    flex-shrink: 0;
    min-width: 1.4em;
    font-weight: 800;
}

.challenge-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Popup: dialog on desktop, slide-up sheet on phones (js/sheet.js) */
.sheet {
    width: min(520px, calc(100% - 32px));
    max-height: min(80vh, 640px);
    padding: 0;
    border: none;
    border-radius: var(--radius);
    background: var(--card);
    color: var(--text);
    box-shadow: var(--shadow);
}

.sheet::backdrop {
    background: rgba(0, 0, 0, 0.45);
}

.sheet-header {
    position: sticky;
    top: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    background: var(--card);
    border-bottom: 1px solid var(--line-soft);
}

.sheet-title {
    font-size: 1.1rem;
}

.sheet-close {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text);
    font: inherit;
    cursor: pointer;
}

.sheet-body {
    padding: 4px 16px 16px;
}

.sheet-body p {
    margin: 10px 0 0;
}

.sheet-note {
    color: var(--muted);
    font-size: 0.85rem;
}

.sheet-alert {
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    background: var(--row);
    font-weight: 600;
    font-size: 0.9rem;
}

.sheet-subtitle {
    margin-top: 14px;
    font-size: 0.95rem;
}

.sheet-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 16px;
}

.sheet-back {
    margin-top: 10px;
    min-height: 34px;
    padding: 5px 12px;
}

@media (max-width: 600px) {
    .sheet {
        width: 100%;
        max-width: none;
        margin: auto 0 0;
        border-radius: var(--radius) var(--radius) 0 0;
        animation: sheet-up 0.2s ease-out;
    }
}

@keyframes sheet-up {
    from { transform: translateY(100%); }
}

/* Header button for the pinned challenges */
.my-challenges-button {
    border: 1px solid var(--line);
    background: transparent;
    font: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
}

/* Beats any page class setting display, no !important so inline display toggles (FAQs, clue details) still work */
html .hidden {
    display: none;
}
