@import url("https://fonts.googleapis.com/css2?family=Cinzel:wght@500;700&family=Jost:wght@400;500;600&family=JetBrains+Mono:wght@400;600&display=swap");

:root {
    --bg: black;
    --bg-panel: #15171d;
    --bg-row-alt: #191b22;
    --rule: #2a2d37;
    --sand: #cfa736;
    --sand-dim: #7d6a2e;
    --parchment: #e9e4d3;
    --muted: #8b8d9a;
    --obsolete: #a3564a;

    --font-display: "Cinzel", "Georgia", serif;
    --font-body: "Jost", system-ui, sans-serif;
    --font-mono: "JetBrains Mono", ui-monospace, monospace;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    * {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
    }
}

body {
    margin: 0;
    background: #050608;
    background-image:
        radial-gradient(ellipse at 20% -10%, rgba(207, 167, 54, 0.08), transparent 55%),
        radial-gradient(ellipse at 90% 0%, rgba(163, 86, 74, 0.05), transparent 45%),
        linear-gradient(to bottom, rgba(5, 6, 8, 0.72) 0%, rgba(5, 6, 8, 0.88) 100%),
        url("../static/images/background.webp");
    background-repeat: no-repeat;
    background-position: center top;
    background-size: cover;
    background-attachment: fixed;
    color: var(--parchment);
    font-family: var(--font-body);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--sand);
    text-decoration: none;
}

a:hover,
a:focus-visible {
    text-decoration: underline;
}

a[href*="tasvideos.org"] {
    color: #a870e0;
}

a[href*="tasvideos.org"]:hover,
a[href*="tasvideos.org"]:focus-visible {
    color: #c499f5;
}

a[href*="tasvideos.org"]::after {
    content: "";
    display: inline-block;
    width: 0.8em;
    height: 0.8em;
    margin-left: 3px;
    vertical-align: -0.05em;
    background-color: currentColor;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6'%3E%3C/path%3E%3Cpolyline points='15 3 21 3 21 9'%3E%3C/polyline%3E%3Cline x1='10' y1='14' x2='21' y2='3'%3E%3C/line%3E%3C/svg%3E") no-repeat center / contain;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6'%3E%3C/path%3E%3Cpolyline points='15 3 21 3 21 9'%3E%3C/polyline%3E%3Cline x1='10' y1='14' x2='21' y2='3'%3E%3C/line%3E%3C/svg%3E") no-repeat center / contain;
}

a:focus-visible,
button:focus-visible {
    outline: 2px solid var(--sand);
    outline-offset: 3px;
}

.wrap {
    max-width: 980px;
    margin: 0 auto;
    padding: 0 24px;
}

/* ---------- Hero ---------- */

.hero {
    padding: 30px 0 30px;
    border-bottom: 1px solid var(--rule);
}

.hero-grid {
    display: grid;
    align-items: center;
}

.eyebrow {
    font-family: var(--font-mono);
    font-size: 12px;
    letter-spacing: 0.28em;
    text-transform: uppercase;
    color: var(--sand);
    margin: 0 0 18px;
}

.hero h1 {
    font-family: var(--font-display);
    font-weight: 500;
    font-size: clamp(20px, 3vw, 32px);
    line-height: 1.05;
    margin: 0 0 20px;
    letter-spacing: 0.01em;
}

.hero h1 span {
    color: var(--sand);
}

.hero p.bio {
    color: var(--parchment);
    font-size: 17px;
    margin: 0;
}

/* ---------- Section shell ---------- */

section.records {
    padding: 30px 0 30px;
}

.section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 28px;
    flex-wrap: wrap;
}

.section-head h2 {
    font-weight: 500;
    font-size: 26px;
    margin: 0;
    letter-spacing: 0.02em;
}

.section-head .count {
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--muted);
}

/* ---------- Records table ---------- */

.records-table {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    background: var(--bg-panel);
    border: 1px solid var(--rule);
}

.records-table caption {
    caption-side: top;
    text-align: left;
    font-family: var(--font-body);
    font-size: 15px;
    color: var(--muted);
    padding: 0 4px 12px;
}

.records-table thead th {
    text-align: left;
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--sand);
    padding: 14px 8px;
    border-bottom: 1px solid var(--rule);
    white-space: nowrap;
}

.records-table thead th:nth-child(1) { width: 75px; }   /* Platform */
.records-table thead th:nth-child(2) { width: auto; }   /* Game */
.records-table thead th:nth-child(3) { width: 105px; }  /* Time */
.records-table thead th:nth-child(4) { width: 135px; }  /* Emulator */
.records-table thead th:nth-child(5) { width: 110px; }  /* Input File */

.records-table tbody td {
    padding: 16px 8px;
    border-bottom: 1px solid var(--rule);
    vertical-align: top;
    font-size: 14px;
}

.records-table tbody tr:last-child td {
    border-bottom: none;
}

.records-table tbody tr.record-row:nth-child(4n-3) {
    background: var(--bg-panel);
}

.records-table tbody tr.record-row:nth-child(4n-1) {
    background: var(--bg-row-alt);
}

.records-table tbody tr.record-row {
    cursor: pointer;
    user-select: none;
    transition: background-color 0.15s ease;
    scroll-margin-top: 24px;
}

.records-table tbody tr.record-row:hover {
    background: rgba(207, 167, 54, 0.08);
}

.records-table tbody tr.record-row.is-expanded {
    background: rgba(207, 167, 54, 0.12);
    border-bottom-color: transparent;
}

.cell-game .run-link {
    color: inherit;
    text-decoration: none;
    display: inline-block;
}

.cell-game .run-link:hover .name {
    color: var(--sand);
    text-decoration: underline;
}

.cell-game .name {
    font-weight: 500;
    color: var(--parchment);
}

.cell-game .branch {
    display: block;
    margin-top: 3px;
    font-size: 12px;
    color: var(--muted);
}

.breadcrumbs {
    padding: 16px 0 8px 0;
    font-size: 13px;
    color: var(--muted);
}

.breadcrumbs a {
    color: var(--sand-dim);
}

.breadcrumbs a:hover {
    color: var(--sand);
}

.breadcrumbs .sep {
    margin: 0 8px;
    color: var(--muted);
}

.badge {
    display: inline-block;
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.06em;
    padding: 3px 8px;
    border: 1px solid var(--sand-dim);
    color: var(--sand);
    border-radius: 2px;
}

.badge.obsolete-tag {
    border-color: var(--obsolete);
    color: var(--obsolete);
    margin-top: 6px;
}

.time {
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--sand);
    white-space: nowrap;
}

.emulator {
    color: var(--muted);
    font-size: 13px;
}

.links {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 12px;
}

.links a {
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--muted);
    border-bottom: 1px dotted var(--rule);
    white-space: nowrap;
}

.links a:hover,
.links a:focus-visible {
    color: var(--sand);
    border-bottom-color: var(--sand);
    text-decoration: none;
}

.links .dash {
    color: var(--rule);
    font-family: var(--font-mono);
    font-size: 11px;
}

/* ---------- Author Notes Container ---------- */

.notes-row[hidden] {
    display: none;
}

.notes-row td {
    padding: 0 !important;
    background: #111216;
    border-bottom: 1px solid var(--rule);
}

.notes-content {
    padding: 20px 24px;
    border-left: 3px solid var(--sand);
    color: var(--parchment);
    overflow-wrap: break-word;
}

.notes-media-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--rule);
}

.notes-media-item {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.notes-media-item .notes-header {
    margin-bottom: 8px;
}

.notes-media-item .youtube-embed {
    margin: 0;
    max-width: 100% !important;
}

.notes-media-item p {
    color: var(--muted);
    font-size: 14px;
    margin: 4px 0;
}

.notes-header {
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--sand);
    margin-bottom: 10px;
}

/* ---------- Notes Content Spacing & Styling ---------- */

.notes-body h1,
.notes-body h2,
.notes-body h3,
.notes-body h4,
.notes-body h5,
.notes-body h6 {
    clear: both;
    color: var(--parchment);
    margin-top: 14px;
    margin-bottom: 4px;
    letter-spacing: 0.02em;
}

.notes-body h1 {
    font-size: 20px;
}

.notes-body h2 {
    font-size: 18px;
}

.notes-body h3 {
    font-size: 16px;
}

.notes-body h4 {
    font-size: 15px;
}

.notes-body h5,
.notes-body h6 {
    font-size: 14px;
}

.notes-body p {
    margin: 6px 0;
    line-height: 1.5;
}

.notes-body ul,
.notes-body ol {
    margin: 4px 0 8px;
    padding-left: 20px;
}

.notes-body li {
    margin: 2px 0;
    line-height: 1.45;
}

.notes-body ul ul {
    margin: 2px 0;
    padding-left: 18px;
}

.notes-body blockquote {
    margin: 10px 0;
    padding: 8px 14px;
    border-left: 2px solid var(--sand-dim);
    background: rgba(0, 0, 0, 0.35);
}

.notes-body blockquote cite {
    display: block;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--sand);
    margin-bottom: 4px;
}

.notes-body code,
.notes-body pre {
    font-family: var(--font-mono);
    background: rgba(0, 0, 0, 0.45);
    border-radius: 2px;
}

.notes-body code {
    padding: 2px 5px;
    font-size: 13px;
}

.notes-body pre {
    padding: 10px;
    overflow-x: auto;
}

/* ---------- Notes Tables & Extra Elements ---------- */

.table-wrap {
    width: 100%;
    overflow-x: auto;
    margin: 14px 0;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--rule);
    border-radius: 4px;
    background: var(--bg-panel);
}

.notes-body table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    line-height: 1.45;
}

.notes-body th,
.notes-body td {
    padding: 8px 12px;
    border: 1px solid var(--rule);
    text-align: left;
    vertical-align: middle;
}

.notes-body th {
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--sand);
    background: var(--bg-row-alt);
    font-weight: 600;
    white-space: nowrap;
}

.notes-body td {
    color: var(--parchment);
}

.notes-body tbody tr:nth-child(even) {
    background: var(--bg-row-alt);
}

.notes-body tbody tr:hover {
    background: rgba(207, 167, 54, 0.06);
}

.notes-body hr {
    border: none;
    border-top: 1px solid var(--rule);
    margin: 16px 0;
}

.notes-body dl {
    margin: 8px 0;
}

.notes-body dt {
    font-family: var(--font-mono);
    font-weight: 600;
    color: var(--sand);
    margin-top: 6px;
}

.notes-body dd {
    margin-left: 18px;
    margin-bottom: 6px;
    color: var(--parchment);
}

.notes-body q {
    font-style: italic;
    color: var(--parchment);
}

/* ---------- Table of Contents Card ---------- */

.toc-card {
    background: var(--bg-panel);
    border: 1px solid var(--rule);
    border-radius: 4px;
    margin: 14px 0 18px;
    overflow: hidden;
}

.toc-header {
    padding: 9px 14px;
    background: var(--bg-row-alt);
    border-bottom: 1px solid var(--rule);
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--sand);
}

.toc-body {
    padding: 10px 14px 12px;
}

.toc-body ul {
    margin: 0;
    padding-left: 20px;
    list-style: disc;
}

.toc-body ul ul {
    margin: 2px 0;
    padding-left: 18px;
    list-style: circle;
}

.toc-body ul ul ul {
    list-style: square;
}

.toc-body li {
    margin: 3px 0;
    font-size: 13px;
    line-height: 1.45;
}

.toc-body a {
    color: var(--sand);
    border-bottom: 1px dotted transparent;
    text-decoration: none;
    transition: color 0.15s ease, border-color 0.15s ease;
}

.toc-body a:hover,
.toc-body a:focus-visible {
    color: var(--parchment);
    border-bottom-color: var(--sand);
    text-decoration: none;
}

.notes-body::after {
    content: "";
    display: table;
    clear: both;
}

/* ---------- YouTube Module Embeds ---------- */

.youtube-embed {
    margin: 14px 0;
    width: 100%;
}

.youtube-embed.align-left {
    float: left;
    margin: 6px 18px 14px 0;
}

.youtube-embed.align-right {
    float: right;
    margin: 6px 0 14px 18px;
}

.youtube-embed.align-center {
    margin-left: auto;
    margin-right: auto;
    text-align: center;
}

.youtube-video {
    position: relative;
    width: 100%;
    overflow: hidden;
    border-radius: 4px;
    background: #000;
}

.youtube-video iframe {
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
}

.youtube-link {
    margin-top: 6px;
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.04em;
}

.youtube-link a {
    color: var(--muted);
    border-bottom: 1px dotted var(--rule);
}

.youtube-link a:hover,
.youtube-link a:focus-visible {
    color: var(--sand);
    border-bottom-color: var(--sand);
    text-decoration: none;
}

/* ---------- Interactive Tab Widget (%%TAB%%) ---------- */

.tabs-container {
    margin: 18px 0;
    border: 1px solid var(--rule);
    border-radius: 4px;
    background: var(--bg-panel);
    overflow: hidden;
}

.tabs-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    background: var(--bg-row-alt);
    border-bottom: 1px solid var(--rule);
    padding: 6px 6px 0;
}

.tab-btn {
    appearance: none;
    border: 1px solid transparent;
    border-bottom: none;
    border-radius: 3px 3px 0 0;
    background: transparent;
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.05em;
    padding: 8px 14px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
    user-select: none;
}

.tab-btn:hover,
.tab-btn:focus-visible {
    color: var(--parchment);
    background: rgba(207, 167, 54, 0.06);
}

.tab-btn.active {
    background: var(--bg-panel);
    color: var(--sand);
    border-color: var(--rule);
    border-bottom-color: var(--bg-panel);
    margin-bottom: -1px;
    font-weight: 600;
}

.tabs-panes {
    padding: 16px;
}

.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
}

.tab-pane > :first-child {
    margin-top: 0;
}

.tab-pane > :last-child {
    margin-bottom: 0;
}

/* ---------- Responsive: card layout on small screens ---------- */

@media (max-width: 860px) {
    .hero-grid {
        grid-template-columns: 1fr;
    }

    .records-table thead {
        display: none;
    }

    .records-table,
    .records-table tbody,
    .records-table tbody tr,
    .records-table tbody td {
        display: block;
        width: 100%;
    }

    .records-table tbody tr.record-row {
        padding: 16px;
        border-bottom: 1px solid var(--rule);
    }

    .records-table tbody td {
        border-bottom: none;
        padding: 4px 0;
    }

    .records-table tbody td[data-label]::before {
        content: attr(data-label);
        display: block;
        font-family: var(--font-mono);
        font-size: 10px;
        letter-spacing: 0.12em;
        text-transform: uppercase;
        color: var(--sand);
        margin-bottom: 4px;
    }

    .notes-content {
        padding: 16px;
    }

    .notes-media-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .youtube-embed.align-left,
    .youtube-embed.align-right {
        float: none;
        margin: 14px 0;
        max-width: 100% !important;
    }
}

/* ---------- Footer ---------- */

footer {
    padding: 32px 0 64px;
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: 12px;
    border-top: 1px solid var(--rule);
}