@property --theme-hue {
    syntax: "<number>";
    inherits: true;
    initial-value: 210;
}

@property --theme-saturation {
    syntax: "<percentage>";
    inherits: true;
    initial-value: 100%;
}

@property --theme-control-saturation {
    syntax: "<percentage>";
    inherits: true;
    initial-value: 55%;
}

@property --theme-lightness {
    syntax: "<percentage>";
    inherits: true;
    initial-value: 50%;
}

:root {
    --theme-hue: 210;
    --theme-saturation: 100%;
    --theme-control-saturation: 55%;
    --theme-lightness: 50%;
    --theme-accent: hsl(var(--theme-hue), var(--theme-saturation), var(--theme-lightness));
    --theme-accent-soft: hsla(var(--theme-hue), var(--theme-saturation), var(--theme-lightness), 0.35);
    --theme-accent-light: hsl(var(--theme-hue), 100%, 78%);
    --theme-control-bg: hsla(var(--theme-hue), var(--theme-control-saturation), 92%, 0.85);
    transition: --theme-hue 0.65s ease, --theme-saturation 0.65s ease, --theme-control-saturation 0.65s ease, --theme-lightness 0.65s ease;
}

@font-face {
    font-family: "PixelFont";
    src: url("assets/ark-pixel-12px-monospaced-zh_tw.ttf") format("truetype");
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: "PixelFont", monospace;
    background-color: #111;
    color: #333;
    overflow-x: hidden;
    overflow-y: auto;
    line-height: 1.6;
}

body.mobile-notice-open {
    overflow: hidden;
}

body.home-page {
    overflow-y: hidden;
}

body.automata-playground {
    overflow: hidden;
}

body.automata-playground .page-panel {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

body.automata-playground .reset-card,
body.automata-playground .playground-hue-controls {
    display: flex;
}

#bg-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    image-rendering: pixelated;
}

body.automata-playground #bg-canvas {
    z-index: 25;
    pointer-events: auto;
}

.top-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 45px;
    background-color: #000;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    font-size: 1.5rem;
    z-index: 9999;
    box-shadow: 0 2px 0 #333;
}

.site-title {
    display: inline-flex;
    align-items: baseline;
    gap: 8px;
}

.site-subtitle {
    font-size: 0.7em;
    color: #d0d0d0;
}

.mobile-notice {
    display: block;
    position: static;
    width: 100%;
    padding: 0;
    background: transparent;
    color: #fff;
    border: 0;
    box-shadow: none;
    font-size: 0.9rem;
    line-height: 1.45;
    text-align: center;
}

.mobile-notice-modal[hidden] {
    display: none;
}

.mobile-notice-modal {
    position: fixed;
    inset: 0;
    z-index: 20000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(0, 0, 0, 0.72);
}

.mobile-notice-dialog {
    width: min(92vw, 420px);
    padding: 18px 16px 14px;
    background: rgba(0, 0, 0, 0.92);
    color: #fff;
    border: 2px solid #111;
    box-shadow: 0 6px 0 #333;
    display: grid;
    gap: 14px;
}

.mobile-notice-confirm {
    justify-self: center;
    min-width: 112px;
    min-height: 38px;
    padding: 0 18px;
    background: #fff;
    color: #111;
    border: 2px solid #111;
    font-family: "PixelFont", monospace;
    font-size: 0.95rem;
    cursor: pointer;
}

.bottom-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100vw;
    height: 35px;
    background-color: #000;
    z-index: 9999;
    box-shadow: 0 -2px 0 #333;
    display: flex;
    align-items: center;
    padding: 0 20px;
    justify-content: space-between;
}

.playground-hue-controls {
    position: fixed;
    left: 50%;
    bottom: 52px;
    transform: translateX(-50%);
    display: none;
    align-items: center;
    gap: 14px;
    padding: 12px 20px;
    z-index: 50;
}

.playground-hue-controls label,
.playground-hue-controls span {
    color: #111;
    font-size: 1rem;
}

.playground-hue-controls input[type="range"] {
    width: min(46vw, 380px);
    accent-color: var(--theme-accent);
}

.nav-back-btn {
    position: fixed;
    left: 20px;
    bottom: 48px;
    width: 128px;
    height: 45px;
    border: none;
    color: transparent;
    font-family: "PixelFont", monospace;
    font-size: 1.2rem;
    cursor: pointer;
    background: url("assets/pixtag.png") center / 100% 100% no-repeat;
    display: none;
    z-index: 40;
}

.nav-back-btn::before {
    content: attr(data-label);
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding-left: 18px;
    color: #fff;
    pointer-events: none;
}

body.automata-playground .nav-back-btn {
    display: block;
}

body.low-effects * {
    -webkit-tap-highlight-color: transparent;
}

body.low-effects #bg-canvas {
    image-rendering: auto;
}

.bgm-btn {
    cursor: pointer;
    user-select: none;
    transition: filter 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
}

.bgm-btn:hover {
    filter: brightness(0.8);
}

#bgm-icon {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    image-rendering: pixelated;
}

.bgm-text {
    display: none;
}

#left-sidebar {
    position: fixed;
    top: 70px;
    left: 0;
    width: 130px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    z-index: 30;
}

.nav-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.nav-list a {
    text-decoration: none;
    color: #fff;
    font-size: 1.3rem;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    height: 45px;
    min-width: 128px;
    padding-left: 18px;
    padding-right: 18px;
    width: 100%;
    background-image: url("assets/pixtag.png");
    background-size: 100% 100%;
    background-position: center;
    background-repeat: no-repeat;
    background-color: transparent;
    transition: padding-left 0.2s, filter 0.2s;
}

.nav-list a:hover {
    padding-left: 25px;
    filter: brightness(1.2);
}

.nav-list a.active {
    color: #8fd3ff;
    filter: brightness(0.9);
}

.lang-toggle {
    background-color: transparent;
    color: #fff;
    border: none;
    font-family: "PixelFont", monospace;
    font-size: 1.2rem;
    cursor: pointer;
    transition: color 0.2s;
    outline: none;
}

.lang-toggle:hover {
    color: var(--theme-accent);
}

.sys-status-bar {
    margin-left: auto;
    font-family: "PixelFont", monospace;
    font-size: 1.0rem;
    color: #fff;
    display: flex;
    gap: 15px;
    align-items: center;
}
.sys-status-bar a {
    color: #fff;
    text-decoration: none;
    transition: color 0.2s;
}
.sys-status-bar a:hover {
    color: var(--theme-accent);
}

.vertical-controls {
    position: fixed;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 20px;
    z-index: 30;
}

.v-slider-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    background: var(--theme-control-bg);
    width: 54px;
    min-height: 220px;
    padding: 18px 10px;
    border: 2px solid #333;
    border-radius: 4px;
    backdrop-filter: blur(2px);
    box-shadow: 4px 4px 0 var(--theme-accent-soft);
    transition: background-color 0.65s ease, box-shadow 0.65s ease;
}

.reset-card {
    display: none;
    min-height: 58px;
    padding: 14px 10px;
    justify-content: center;
}

.reset-btn {
    border: none;
    background: transparent;
    color: #111;
    font-family: "PixelFont", monospace;
    font-size: 0.82rem;
    padding: 0;
    cursor: pointer;
    width: auto;
    letter-spacing: 0.04em;
}

.v-slider-group label {
    margin-top: 15px;
    font-weight: bold;
    color: #333;
    writing-mode: vertical-rl;
    white-space: nowrap;
    letter-spacing: 2px;
    font-size: 1rem;
}

.v-slider-group span {
    margin-bottom: 10px;
    color: #000;
    font-weight: bold;
    font-size: 1.2rem;
}

input[type="range"][orient="vertical"] {
    appearance: slider-vertical;
    -webkit-appearance: slider-vertical;
    width: 15px;
    height: 100px;
    cursor: pointer;
    accent-color: var(--theme-accent);
}

.pixel-panel {
    background-color: rgba(255, 255, 255, 0.85);
    border: 4px solid #333;
    box-shadow: 6px 6px 0 var(--theme-accent);
    backdrop-filter: blur(3px);
    transition: box-shadow 0.65s ease;
}

.page-panel {
    position: relative;
    margin: 80px auto;
    width: 90%;
    max-width: 700px;
    padding: 20px 30px;
    text-align: center;
    display: none;
    z-index: 20;
}

.page-panel.active {
    display: block;
}

#page-home {
    margin: calc(100vh - 430px) auto 0;
}

#page-home.pending-reveal {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(40px);
}

#page-home.initial-reveal {
    visibility: visible;
    pointer-events: auto;
    animation: homeCardReveal 0.95s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

@keyframes homeCardReveal {
    from {
        opacity: 0;
        transform: translateY(40px);
    }

    to {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
    }
}

.page-panel h1 {
    font-size: 2.5rem;
    color: #222;
    letter-spacing: 2px;
    margin-bottom: 10px;
}

.page-panel p.intro {
    font-size: 1.2rem;
    font-weight: normal;
}

.home-intro {
    max-width: 40rem;
    margin: 0 auto;
    color: #1d1d1d;
    line-height: 1.95;
    text-align: justify;
    text-wrap: pretty;
}

.intro-signature {
    display: inline-block;
    font-size: 1.38em;
    line-height: 0.9;
    color: var(--theme-accent);
    vertical-align: -0.04em;
}

.card-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
    margin-top: 20px;
    text-align: left;
}

.pixel-card {
    border: 2px solid #333;
    padding: 15px;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 4px 4px 0 var(--theme-accent-soft);
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 140px;
    transition: transform 0.2s, border-color 0.2s, box-shadow 0.65s ease;
}

.bio-text {
    margin-bottom: 0;
    line-height: 1.9;
}

.intro-lead {
    margin: 0 0 1.5rem;
    font-size: 1.08rem;
    line-height: 1.95;
    color: #222;
    text-align: justify;
}

.intro-sections {
    display: grid;
    gap: 18px;
    text-align: left;
}

.intro-section {
    font-size: 1.14rem;
    color: #222;
}

.intro-topic {
    display: inline-block;
    margin-right: 0.6rem;
    color: var(--theme-accent);
    font-size: 1.1em;
}

.pixel-card:hover {
    transform: translateY(-5px);
    border-color: var(--theme-accent);
}

.pixel-card h3 {
    color: #111;
    margin-bottom: 8px;
    font-size: 1.5rem;
}

.pixel-card p {
    font-size: 1.1rem;
    font-weight: normal;
    color: #444;
    margin-bottom: 40px;
}

.btn-black {
    background-color: #222;
    color: #fff;
    padding: 5px 15px;
    text-decoration: none;
    position: absolute;
    bottom: 15px;
    right: 15px;
    font-family: "PixelFont", monospace;
    font-size: 1.2rem;
    border: 2px solid #000;
    transition: all 0.1s;
}

.btn-black-static {
    position: static;
    align-self: flex-end;
    margin-top: auto;
}

.btn-black:active {
    transform: translate(2px, 2px);
}

@media (max-width: 800px) {
    #left-sidebar {
        top: 50px;
        flex-direction: row;
        flex-wrap: wrap;
        width: 100%;
        gap: 5px;
        padding: 5px;
    }

    .nav-list {
        flex-direction: row;
        gap: 5px;
    }

    .nav-list a {
        width: 85px;
        height: 35px;
        font-size: 1.1rem;
        min-width: 85px;
        padding-left: 10px;
        padding-right: 10px;
    }

    .vertical-controls {
        transform: translateY(-50%) scale(0.8);
        right: 5px;
    }

    .v-slider-group {
        min-height: 200px;
    }

    #page-home {
        margin: 28vh auto 0;
    }

    .home-intro {
        max-width: none;
        font-size: 1.08rem;
        line-height: 1.85;
        text-align: left;
    }

    .intro-signature {
        font-size: 1.24em;
    }
}
