:root {
    --fc-bg: #18204a;
    --fc-bg-dark: #0d1027;
    --fc-panel: #fff1c9;
    --fc-panel-2: #f6d99a;
    --fc-red: #d62828;
    --fc-red-dark: #8f1515;
    --fc-blue: #1e3a8a;
    --fc-yellow: #fcbf49;
    --fc-green: #48d860;
    --fc-black: #111111;
    --fc-white: #fffaf0;
    --fc-gray: #6d6875;
    --shadow-step: 8px;
    --pixel-border: 4px solid var(--fc-black);
    color-scheme: dark;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--fc-black);
    background:
        linear-gradient(rgba(255, 255, 255, 0.045) 2px, transparent 2px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.045) 2px, transparent 2px),
        radial-gradient(circle at 22% 20%, rgba(252, 191, 73, 0.18), transparent 28%),
        radial-gradient(circle at 80% 70%, rgba(214, 40, 40, 0.2), transparent 24%),
        var(--fc-bg);
    background-size: 24px 24px, 24px 24px, auto, auto, auto;
    font-family: "Courier New", "Microsoft YaHei", monospace;
    overflow-x: hidden;
}

a {
    color: inherit;
}

button,
input {
    font: inherit;
}

.scanline {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 10;
    background: repeating-linear-gradient(
        to bottom,
        rgba(0, 0, 0, 0.1) 0,
        rgba(0, 0, 0, 0.1) 1px,
        transparent 1px,
        transparent 5px
    );
    mix-blend-mode: multiply;
    opacity: 0.35;
}

.home-shell {
    position: relative;
    z-index: 1;
    width: min(1180px, calc(100% - 32px));
    min-height: 100vh;
    margin: 0 auto;
    padding: 34px 0 54px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
    grid-template-rows: 1fr auto;
    gap: 22px;
    align-items: stretch;
}

.nes-panel {
    background: var(--fc-panel);
    border: var(--pixel-border);
    box-shadow: var(--shadow-step) var(--shadow-step) 0 var(--fc-red-dark);
}

.clock-panel {
    min-height: 620px;
    padding: clamp(22px, 4vw, 44px);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
}

.brand-row,
.panel-title-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
}

.eyebrow,
.status-light,
.slot-label,
.clock-hint {
    margin: 0;
    color: var(--fc-blue);
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.status-light {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--fc-red-dark);
}

.status-light span {
    width: 12px;
    height: 12px;
    display: inline-block;
    background: var(--fc-green);
    border: 2px solid var(--fc-black);
    box-shadow: 2px 2px 0 var(--fc-black);
}

h1,
h2,
p {
    margin-top: 0;
}

.site-name {
    width: fit-content;
    margin: 22px 0 0;
    padding: 8px 14px;
    color: var(--fc-white);
    background: var(--fc-blue);
    border: 4px solid var(--fc-black);
    box-shadow: 5px 5px 0 var(--fc-red);
    font-size: clamp(1.8rem, 5vw, 3.6rem);
    font-weight: 900;
    letter-spacing: 0.14em;
}

h1 {
    margin: 16px 0 18px;
    color: var(--fc-red);
    font-size: clamp(2.4rem, 8vw, 6.4rem);
    line-height: 0.9;
    letter-spacing: -0.08em;
    text-shadow: 5px 5px 0 var(--fc-black);
}

.date-card {
    width: fit-content;
    max-width: 100%;
    padding: 14px 18px;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 6px;
    background: var(--fc-black);
    color: var(--fc-yellow);
    border: 4px solid var(--fc-red);
    box-shadow: 6px 6px 0 var(--fc-blue);
    font-weight: 900;
}

.date-card span:not(.date-unit) {
    min-width: 2ch;
    font-size: clamp(1.7rem, 4vw, 3rem);
}

.date-unit,
#clock-week {
    color: var(--fc-white);
    font-size: clamp(0.9rem, 2vw, 1.2rem);
}

#clock-week {
    margin-left: 10px;
}

.watch-face {
    display: grid;
    place-items: center;
    padding: 22px 0 10px;
}

.dial-ring {
    position: relative;
    width: min(58vw, 330px);
    aspect-ratio: 1;
    border: 10px solid var(--fc-black);
    background:
        radial-gradient(circle, var(--fc-panel) 0 58%, transparent 59%),
        linear-gradient(45deg, transparent 47%, rgba(17, 17, 17, 0.15) 48% 52%, transparent 53%),
        linear-gradient(-45deg, transparent 47%, rgba(17, 17, 17, 0.15) 48% 52%, transparent 53%),
        var(--fc-red);
    box-shadow: inset 0 0 0 8px var(--fc-yellow), 10px 10px 0 var(--fc-black);
}

.tick {
    position: absolute;
    color: var(--fc-black);
    font-weight: 900;
    font-size: 1.1rem;
}

.tick-12 { top: 12px; left: 50%; transform: translateX(-50%); }
.tick-3 { right: 18px; top: 50%; transform: translateY(-50%); }
.tick-6 { bottom: 12px; left: 50%; transform: translateX(-50%); }
.tick-9 { left: 18px; top: 50%; transform: translateY(-50%); }

.hand {
    position: absolute;
    left: 50%;
    bottom: 50%;
    transform-origin: 50% 100%;
    transform: translateX(-50%) rotate(0deg);
    border: 2px solid var(--fc-black);
}

.hour-hand {
    width: 12px;
    height: 28%;
    background: var(--fc-blue);
}

.minute-hand {
    width: 8px;
    height: 36%;
    background: var(--fc-red);
}

.second-hand {
    width: 4px;
    height: 42%;
    background: var(--fc-yellow);
}

.dial-dot {
    position: absolute;
    width: 22px;
    height: 22px;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    background: var(--fc-black);
    border: 4px solid var(--fc-yellow);
}

.time-display {
    align-self: flex-start;
    margin-top: 14px;
    padding: 14px 18px;
    color: var(--fc-green);
    background: var(--fc-black);
    border: 4px solid var(--fc-gray);
    box-shadow: 6px 6px 0 var(--fc-red);
    font-size: clamp(2.1rem, 8vw, 5.6rem);
    font-weight: 900;
    letter-spacing: 0.08em;
    line-height: 1;
}

.clock-hint {
    margin-top: 24px;
    color: var(--fc-red-dark);
}

.game-panel {
    padding: 22px;
    min-height: 620px;
    display: flex;
    flex-direction: column;
}

.game-panel h2 {
    margin: 0;
    color: var(--fc-black);
    font-size: 1.6rem;
}

.game-list {
    margin-top: 18px;
    display: grid;
    gap: 14px;
}

.game-item {
    display: grid;
    grid-template-columns: 52px 1fr;
    gap: 12px;
    align-items: center;
    min-height: 78px;
    padding: 12px;
    color: var(--fc-black);
    text-decoration: none;
    background: var(--fc-white);
    border: 4px solid var(--fc-black);
    box-shadow: 5px 5px 0 var(--fc-blue);
    transition: transform 120ms steps(2), box-shadow 120ms steps(2);
}

.game-item:hover,
.game-item:focus-visible {
    outline: none;
    transform: translate(3px, 3px);
    box-shadow: 2px 2px 0 var(--fc-blue);
}

.game-item.is-disabled {
    cursor: not-allowed;
    opacity: 0.75;
    filter: grayscale(0.35);
}

.game-number {
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    color: var(--fc-white);
    background: var(--fc-red);
    border: 3px solid var(--fc-black);
    font-weight: 900;
}

.game-title {
    display: block;
    font-weight: 900;
    font-size: 1.08rem;
}

.game-meta {
    display: block;
    margin-top: 6px;
    color: var(--fc-gray);
    font-size: 0.78rem;
    font-weight: 700;
}

.empty-state {
    margin: 18px 0 0;
    color: var(--fc-gray);
    font-weight: 700;
}

.login-dock {
    position: fixed;
    right: clamp(16px, 4vw, 36px);
    bottom: clamp(16px, 4vw, 34px);
    z-index: 5;
}

.pixel-button {
    min-height: 48px;
    padding: 10px 16px;
    color: var(--fc-white);
    background: var(--fc-red);
    border: 4px solid var(--fc-black);
    box-shadow: 5px 5px 0 var(--fc-black);
    cursor: pointer;
    font-weight: 900;
    text-transform: uppercase;
}

.pixel-button:hover,
.pixel-button:focus-visible {
    outline: none;
    transform: translate(2px, 2px);
    box-shadow: 3px 3px 0 var(--fc-black);
}

.pixel-button.secondary {
    color: var(--fc-black);
    background: var(--fc-yellow);
}

.login-dock small {
    display: block;
    margin-top: 4px;
    color: var(--fc-panel);
    font-size: 0.72rem;
    text-transform: none;
}

.site-footer {
    grid-column: 1 / -1;
    color: var(--fc-panel);
    font-size: 0.86rem;
    text-align: left;
}

.site-footer a {
    text-decoration: none;
}

.site-footer a:hover {
    color: var(--fc-yellow);
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(13, 16, 39, 0.82);
}

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

.modal-card {
    position: relative;
    width: min(420px, 100%);
    padding: 28px;
}

.modal-card h2 {
    margin: 8px 0 12px;
    color: var(--fc-red);
    font-size: 2rem;
    text-shadow: 2px 2px 0 var(--fc-black);
}

.modal-copy {
    color: var(--fc-blue);
    line-height: 1.7;
    font-weight: 700;
}

.modal-close {
    position: absolute;
    top: 8px;
    right: 10px;
    width: 38px;
    height: 38px;
    color: var(--fc-white);
    background: var(--fc-black);
    border: 3px solid var(--fc-red);
    cursor: pointer;
    font-size: 1.4rem;
    font-weight: 900;
}

.field-label {
    display: block;
    margin: 16px 0 8px;
    color: var(--fc-black);
    font-weight: 900;
}

.pixel-input {
    width: 100%;
    min-height: 48px;
    padding: 10px 12px;
    color: var(--fc-green);
    background: var(--fc-black);
    border: 4px solid var(--fc-gray);
    outline: none;
}

.pixel-input:focus {
    border-color: var(--fc-red);
}

.modal-actions {
    margin-top: 18px;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.game-page {
    min-height: 100vh;
    padding: 24px 16px 38px;
}

.game-shell {
    width: min(920px, 100%);
    margin: 0 auto;
    display: grid;
    gap: 18px;
}

.game-header,
.game-hud,
.game-screen,
.game-help {
    padding: 18px;
}

.game-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.game-header h1 {
    margin: 0;
    font-size: clamp(1.8rem, 6vw, 3.6rem);
}

.game-hud {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: space-between;
    font-weight: 900;
}

.game-screen {
    background: var(--fc-black);
    display: grid;
    place-items: center;
}

#game-canvas {
    width: min(100%, 560px);
    max-height: 72vh;
    background: #111827;
    border: 4px solid var(--fc-yellow);
    image-rendering: pixelated;
    touch-action: none;
}

.game-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
}

.game-help {
    color: var(--fc-blue);
    line-height: 1.7;
    font-weight: 700;
}

@media (max-width: 820px) {
    .home-shell {
        width: min(100% - 24px, 560px);
        min-height: auto;
        grid-template-columns: 1fr;
        padding: 18px 0 110px;
    }

    .clock-panel,
    .game-panel {
        min-height: auto;
    }

    h1 {
        letter-spacing: -0.05em;
    }

    .time-display {
        width: 100%;
        text-align: center;
        letter-spacing: 0.04em;
    }

    .dial-ring {
        width: min(74vw, 280px);
    }

    .site-footer {
        text-align: center;
    }
}

@media (max-width: 460px) {
    .brand-row,
    .panel-title-row,
    .game-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .clock-panel,
    .game-panel,
    .modal-card {
        padding: 18px;
    }

    .game-item {
        grid-template-columns: 44px 1fr;
    }

    .game-number {
        width: 42px;
        height: 42px;
    }

    .login-dock {
        right: 14px;
        bottom: 14px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        transition: none !important;
        animation: none !important;
    }

    .scanline {
        opacity: 0.18;
    }
}
