@font-face {
    font-family: 'Maged W20';
    src: url('Maged W20.ttf') format('truetype');
    font-display: swap;
}

:root {
    --bg: #000000;
    --wine: #8B2635;
    --wine-bright: #A93341;
    --yellow: #FFFF00;
    --cream: #F5E6C8;
    --link: #C8A2C8;
    --frame: #2A2A2A;
    --frame-light: #4A4A4A;
}

body.home {
    --cream: #F5A623;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--cream);
    font-family: 'Maged W20', 'Times New Roman', serif;
    min-height: 100vh;
    -webkit-font-smoothing: none;
    -moz-osx-font-smoothing: grayscale;
    font-smooth: never;
    text-rendering: optimizeSpeed;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

body {
    padding: 24px 16px 48px;
    text-align: center;
    position: relative;
}

/* CRT scanlines overlay */
/* body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9999;
    background: repeating-linear-gradient(
        to bottom,
        rgba(0, 0, 0, 0.18) 0px,
        rgba(0, 0, 0, 0.18) 1px,
        transparent 1px,
        transparent 3px
    );
    mix-blend-mode: multiply;
} */

/* Faint CRT vignette */
body::after {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9998;
    background: radial-gradient(
        ellipse at center,
        transparent 55%,
        rgba(0, 0, 0, 0.45) 100%
    );
}

.welcome {
    font-style: italic;
    font-size: 32px;
    color: var(--wine-bright);
    line-height: 1.2;
    margin-bottom: 24px;
}

.welcome .title {
    display: block;
    font-size: 44px;
    color: var(--wine);
    text-decoration: underline;
    text-decoration-color: var(--wine);
    font-style: normal;
    letter-spacing: 2px;
    margin: 4px 0;
}

.intro {
    color: var(--cream);
    font-size: 15px;
    font-style: normal;
    line-height: 1.5;
    max-width: 560px;
    margin: 12px auto 4px;
    padding: 0 12px;
    text-align: left;
}

.rule {
    border: none;
    border-top: 2px solid #555;
    margin: 16px auto;
    width: 90%;
    max-width: 900px;
}

.visitor {
    color: var(--cream);
    font-size: 16px;
    margin: 12px 0;
}

.visitor .count {
    color: #5DADE2;
    letter-spacing: 4px;
    font-weight: bold;
}

.visitor .since {
    display: block;
    font-size: 13px;
    margin-top: 2px;
}

.frame {
    margin: 24px auto;
    width: min(640px, 95%);
    padding: 8px;
    background: #2a2a2a;
    border-top: 6px solid #6a6a6a;
    border-left: 6px solid #6a6a6a;
    border-right: 6px solid #1a1a1a;
    border-bottom: 6px solid #1a1a1a;
}

.grid {
    display: grid;
    grid-template-columns: 1fr 1.2fr 1fr;
    grid-template-rows: 1fr auto;
    gap: 0;
    background: #000;
    border: 1px solid #888;
}

.cell {
    border: 1px solid #888;
    padding: 24px 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 90px;
    background: #000;
}

.cell.portrait {
    grid-row: 1 / span 2;
    grid-column: 2;
    padding: 0;
    min-height: 360px;
    overflow: hidden;
}

.cell.portrait a {
    display: block;
    width: 100%;
    height: 100%;
    line-height: 0;
}

.cell.portrait img {
    width: 100%;
    height: 100%;
    min-height: 360px;
    object-fit: cover;
    object-position: center;
    transform: scale(1.25);
    transform-origin: center;
    display: block;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    filter: contrast(1.05) saturate(1.1);
}

.grid-secret {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
}

.portrait-secret {
    grid-row: 1;
    grid-column: 1;
    min-height: 420px;
}

.portrait-secret img {
    min-height: 420px;
    transform: scale(1);
    object-fit: contain;
    background: #000;
}

.secret-gallery {
    margin: 24px auto;
    width: min(900px, 95%);
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding: 8px;
    background: #2a2a2a;
    border-top: 6px solid #6a6a6a;
    border-left: 6px solid #6a6a6a;
    border-right: 6px solid #1a1a1a;
    border-bottom: 6px solid #1a1a1a;
}

.secret-gallery img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    display: block;
    background: #000;
    border: 1px solid #888;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    filter: contrast(1.05) saturate(1.1);
}

.cell.portrait .placeholder {
    width: 100%;
    height: 360px;
    background:
        repeating-linear-gradient(45deg, #5C0A18 0 8px, #3a0610 8px 16px);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--cream);
    font-style: italic;
}

.cell a.section {
    color: var(--yellow);
    text-decoration: none;
    font-size: 28px;
    font-family: 'Maged W20', 'Times New Roman', serif;
    letter-spacing: 1px;
}

.cell a.section .key {
    color: var(--yellow);
    text-decoration: underline;
    font-size: 34px;
}

.cell a.section:hover {
    color: var(--yellow);
}

.subline {
    margin: 18px auto;
    color: var(--cream);
    font-size: 16px;
}

.subline a {
    color: var(--cream);
    text-decoration: underline;
}

.tracklist-title {
    display: inline-block;
    color: var(--cream);
    font-size: 20px;
    text-decoration: underline;
    margin-bottom: 8px;
}

.tracklist {
    list-style-position: inside;
    margin: 12px auto 16px;
    padding: 0;
    color: var(--yellow);
    font-size: 18px;
    line-height: 1.6;
    text-align: center;
    max-width: 420px;
}

.tracklist li {
    color: var(--yellow);
}

.tracklist li::marker {
    color: #F5A623;
}

.tracklist-links a {
    color: var(--yellow);
    text-decoration: underline;
}

.tales-list {
    list-style: none;
    padding-left: 0;
}

#bg-audio-play {
    position: fixed;
    bottom: 16px;
    right: 16px;
    padding: 8px 14px;
    background: var(--wine, #5a1e1e);
    color: var(--yellow, #f5d76e);
    border: 1px solid var(--yellow, #f5d76e);
    font-family: inherit;
    font-size: 14px;
    cursor: pointer;
    z-index: 100;
}

#bg-audio-play:hover {
    background: var(--yellow, #f5d76e);
    color: var(--wine, #5a1e1e);
}

.tale-num {
    color: #F5A623;
}

.tracklist-links a:hover {
    color: var(--wine-bright);
}

.tracklist-links a:visited {
    color: var(--yellow);
}

.footer {
    margin-top: 32px;
    font-size: 14px;
    color: #F5A623;
    line-height: 1.6;
}

.footer .updated {
    color: var(--yellow);
}

.footer a {
    color: var(--cream);
    text-decoration: underline;
}

.footer .small {
    font-size: 13px;
}

.member {
    margin: 18px auto;
    padding: 6px 14px;
    display: inline-block;
    border: 1px solid #444;
}

.member a {
    color: var(--cream);
    text-decoration: underline;
}

/* Lyrics + Tales page */
.page {
    max-width: 720px;
    margin: 0 auto;
    text-align: center;
}

.page h1 {
    font-style: italic;
    font-size: 44px;
    color: var(--wine);
    text-decoration: underline;
    margin: 8px 0 4px;
    letter-spacing: 2px;
}

.page .sub {
    font-style: italic;
    color: var(--wine-bright);
    font-size: 22px;
    margin-bottom: 24px;
}

.lyrics {
    color: var(--yellow);
    font-size: 22px;
    line-height: 1.8;
    white-space: pre-line;
    text-align: center;
    margin: 32px 0;
    font-family: 'Maged W20', 'Times New Roman', serif;
}

.tale {
    color: var(--yellow);
    font-size: 18px;
    line-height: 1.7;
    text-align: left;
    margin: 24px auto;
    max-width: 600px;
}

.tale h2 {
    color: var(--yellow);
    font-style: italic;
    text-align: center;
    font-size: 26px;
}

.back {
    margin: 32px 0 8px;
}

.back a {
    color: var(--yellow);
    text-decoration: underline;
    font-size: 18px;
}

/* Mobile */
@media (max-width: 640px) {
    body {
        padding: 16px 10px 32px;
    }

    .welcome {
        font-size: 22px;
        margin-bottom: 16px;
    }

    .welcome .title {
        font-size: 30px;
        letter-spacing: 1px;
    }

    .intro {
        font-size: 13px;
        padding: 0 8px;
    }

    .frame {
        width: 100%;
        padding: 6px;
        border-top-width: 4px;
        border-left-width: 4px;
        border-right-width: 4px;
        border-bottom-width: 4px;
    }

    .cell {
        padding: 10px 4px;
        min-height: 50px;
    }

    .cell.portrait {
        min-height: 220px;
    }

    .cell.portrait img {
        min-height: 220px;
        transform: scale(1.15);
    }

    .secret-gallery {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
        padding: 6px;
        border-top-width: 4px;
        border-left-width: 4px;
        border-right-width: 4px;
        border-bottom-width: 4px;
    }

    .cell a.section {
        font-size: 22px;
    }

    .cell a.section .key {
        font-size: 28px;
    }

    .tracklist-title {
        font-size: 18px;
    }

    .tracklist {
        font-size: 17px;
        max-width: 100%;
        padding: 0 8px;
    }

    .tracklist-links a {
        display: inline-block;
        padding: 4px 2px;
    }

    .page h1 {
        font-size: 32px;
    }

    .page .sub {
        font-size: 18px;
    }

    .lyrics {
        font-size: 18px;
        padding: 0 6px;
    }

    .tale {
        font-size: 16px;
        padding: 0 6px;
    }

    .footer {
        font-size: 13px;
    }

    .back a {
        font-size: 16px;
        display: inline-block;
        padding: 6px 4px;
    }
}

/* Extra-small phones */
@media (max-width: 380px) {
    .welcome .title {
        font-size: 24px;
    }

    .page h1 {
        font-size: 26px;
    }

    .cell.portrait,
    .cell.portrait img {
        min-height: 170px;
    }

    .cell a.section {
        font-size: 18px;
    }

    .cell a.section .key {
        font-size: 22px;
    }

    .cell {
        padding: 8px 2px;
    }
}
