:root {
    color-scheme: light;
    --page: #f7fbfa;
    --paper: #ffffff;
    --ink: #243230;
    --muted: #63726f;
    --line: #d7e6e1;
    --mint: #2d8c70;
    --cyan: #62e8f6;
    --cyan-deep: #159aaa;
    --yellow: #ffd65c;
    --red: #ff6f72;
    --green: #70ddb7;
    --chassis: #10191b;
    --chassis-2: #182528;
    --chassis-line: #315056;
    font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", "Meiryo", system-ui, sans-serif;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    min-width: 0;
    margin: 0;
    color: var(--ink);
    background: var(--page);
    font-size: 16px;
    line-height: 1.75;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
canvas {
    font: inherit;
}

button {
    letter-spacing: 0;
}

.site-header,
.site-footer,
.crowd-page {
    width: min(1120px, calc(100% - 32px));
    margin: 0 auto;
}

.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 0 10px;
}

.site-logo {
    color: var(--mint);
    font-size: 0.84rem;
    font-weight: 900;
}

.site-nav,
.site-footer {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 18px;
}

.site-nav {
    color: var(--muted);
    font-size: 0.9rem;
}

.site-nav a:hover,
.site-footer a:hover,
.info-section a:hover {
    color: var(--mint);
}

.crowd-hero {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(300px, 0.9fr);
    align-items: center;
    gap: 40px;
    padding: 58px 0 40px;
}

.hero-copy {
    min-width: 0;
}

.series-label,
.stage-label,
.hero-instrument,
.status-panel span,
.stage-meta,
.center-result p {
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

.series-label {
    margin: 0;
    color: var(--mint);
    font-size: 0.78rem;
    font-weight: 900;
    letter-spacing: 0;
}

.crowd-hero h1 {
    max-width: 720px;
    margin: 9px 0 14px;
    font-size: 40px;
    line-height: 1.28;
    letter-spacing: 0;
    text-wrap: balance;
}

.crowd-hero h1 > span {
    display: inline-block;
    white-space: nowrap;
}

.crowd-hero p:last-child {
    max-width: 680px;
    margin: 0;
    color: var(--muted);
}

.hero-instrument {
    display: grid;
    gap: 18px;
    min-height: 194px;
    padding: 24px;
    border: 1px solid #274348;
    border-radius: 8px;
    background: var(--chassis);
    color: #d7f7f4;
    box-shadow: 0 18px 42px rgba(35, 77, 67, 0.12);
}

.instrument-label,
.instrument-readout {
    color: var(--cyan);
    font-size: 0.8rem;
    font-weight: 800;
}

.instrument-readout {
    align-self: end;
    color: var(--yellow);
    text-align: right;
}

.instrument-track {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 62px;
    padding: 0 16px;
    border-block: 1px solid #335159;
}

.instrument-track::before {
    position: absolute;
    top: 50%;
    right: 20px;
    left: 20px;
    height: 1px;
    background: #47676d;
    content: "";
}

.instrument-track i {
    position: relative;
    width: 13px;
    height: 13px;
    border: 2px solid #b8dcda;
    border-radius: 50%;
    background: var(--chassis);
}

.instrument-track i:nth-child(4) {
    border-color: var(--yellow);
    transform: translateY(-11px);
}

.game-shell {
    position: relative;
    padding: 18px;
    border: 1px solid #263d42;
    border-radius: 8px;
    background: var(--chassis);
    color: #e7f3f1;
    box-shadow: 0 22px 54px rgba(25, 53, 48, 0.18);
}

.game-fullscreen-open,
.game-fullscreen-close {
    min-height: 42px;
    padding: 8px 16px;
    border: 1px solid #4c7075;
    border-radius: 8px;
    background: #172529;
    color: #dff8f4;
    font-weight: 800;
    cursor: pointer;
}

.game-fullscreen-open {
    position: absolute;
    z-index: 4;
    top: 18px;
    right: 18px;
}

.game-fullscreen-close {
    position: fixed;
    z-index: 1001;
    top: 14px;
    right: 14px;
}

.mobile-play-note {
    min-height: 42px;
    margin: 0 122px 12px 0;
    padding: 8px 12px;
    border: 1px solid #315057;
    border-radius: 6px;
    color: #bed4d1;
    font-size: 0.9rem;
}

.status-panel {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 12px;
}

.status-panel div {
    display: grid;
    gap: 2px;
    min-width: 0;
    min-height: 72px;
    padding: 10px 12px;
    border: 1px solid #35545a;
    border-radius: 6px;
    background: var(--chassis-2);
}

.status-panel span {
    color: #77cfd0;
    font-size: 0.72rem;
    font-weight: 800;
}

.status-panel strong {
    overflow: hidden;
    color: #ffffff;
    font-size: 1.35rem;
    line-height: 1.25;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.crowd-stage {
    min-width: 0;
    padding: 14px;
    border: 1px solid #35545a;
    border-radius: 6px;
    background: #0c1315;
}

.stage-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 58px;
    padding: 0 2px 10px;
}

.stage-label,
.stage-progress {
    margin: 0;
}

.stage-label {
    color: #75d5d9;
    font-size: 0.7rem;
}

.stage-progress {
    font-size: 1.05rem;
    font-weight: 900;
}

.stage-meta {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
    color: #a7c4c2;
    font-size: 0.74rem;
}

.stage-meta span {
    min-width: 86px;
    padding: 4px 8px;
    border: 1px solid #35545a;
    border-radius: 4px;
    text-align: center;
}

.canvas-frame {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    min-height: 0;
    overflow: hidden;
    border: 1px solid #42656b;
    border-radius: 4px;
    background: #0b1113;
}

#crowdCanvas {
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
    cursor: crosshair;
}

#crowdCanvas:focus-visible {
    outline: 3px solid rgba(98, 232, 246, 0.62);
    outline-offset: -4px;
}

.time-rail {
    position: absolute;
    right: 10px;
    bottom: 9px;
    left: 10px;
    height: 5px;
    overflow: hidden;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.12);
    pointer-events: none;
}

.time-rail span {
    display: block;
    width: 100%;
    height: 100%;
    background: var(--cyan);
    transform-origin: left center;
}

.stage-announcement {
    position: absolute;
    z-index: 6;
    top: 50%;
    left: 50%;
    display: grid;
    place-items: center;
    min-width: min(360px, calc(100% - 32px));
    min-height: 88px;
    padding: 16px 22px;
    border: 1px solid #6aaeb5;
    border-radius: 6px;
    background: rgba(10, 20, 22, 0.94);
    color: var(--cyan);
    font-size: clamp(1.25rem, 4vw, 2rem);
    font-weight: 900;
    text-align: center;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.stage-announcement.is-perfect {
    border-color: #f3cf58;
    color: var(--yellow);
}

.stage-announcement.is-miss {
    border-color: #d65f66;
    color: var(--red);
}

.center-result {
    position: absolute;
    z-index: 7;
    top: 50%;
    left: 50%;
    display: grid;
    place-items: center;
    gap: 8px;
    width: min(430px, calc(100% - 28px));
    min-height: 250px;
    padding: 24px;
    border: 1px solid #6cc7cf;
    border-radius: 8px;
    background: rgba(10, 19, 21, 0.97);
    text-align: center;
    transform: translate(-50%, -50%);
}

.stage-announcement[hidden],
.center-result[hidden] {
    display: none;
}

.center-result p {
    margin: 0;
    color: var(--cyan);
    font-size: 0.82rem;
    font-weight: 900;
}

.center-result > strong {
    color: #ffffff;
    font-size: clamp(2rem, 6vw, 3.4rem);
    line-height: 1.1;
}

.center-result > span {
    color: #bbcecc;
    font-size: 0.88rem;
}

.judgement-row {
    display: grid;
    grid-template-columns: 120px minmax(0, 1fr);
    align-items: center;
    gap: 12px;
    min-height: 52px;
    margin-top: 10px;
    padding: 8px 10px;
    border: 1px solid #315057;
    border-radius: 4px;
}

.judgement-row strong {
    color: var(--cyan);
    font-family: "SFMono-Regular", Consolas, monospace;
    font-size: 0.96rem;
}

.judgement-row strong.is-perfect {
    color: var(--yellow);
}

.judgement-row strong.is-miss {
    color: var(--red);
}

.judgement-row span {
    min-width: 0;
    color: #bdd1cf;
}

.judgement-row span.is-anomaly-copy {
    white-space: nowrap;
}

.stage-message {
    min-height: 30px;
    margin: 8px 0 0;
    color: #9fb8b5;
    text-align: center;
}

.control-row {
    display: flex;
    justify-content: center;
    gap: 10px;
    min-height: 50px;
    margin-top: 12px;
}

.primary-button,
.ghost-button {
    min-height: 46px;
    padding: 9px 22px;
    border-radius: 6px;
    font-weight: 900;
    cursor: pointer;
}

.primary-button {
    border: 1px solid #56c9d7;
    background: #1e616a;
    color: #edffff;
}

.ghost-button {
    border: 1px solid #46656a;
    background: #182528;
    color: #d6e6e3;
}

.primary-button:hover,
.primary-button:focus-visible {
    background: #277783;
}

.ghost-button:hover,
.ghost-button:focus-visible {
    border-color: #669298;
    background: #213236;
}

.primary-button:focus-visible,
.ghost-button:focus-visible,
.game-fullscreen-open:focus-visible,
.game-fullscreen-close:focus-visible {
    outline: 3px solid rgba(98, 232, 246, 0.38);
    outline-offset: 3px;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.48;
}

.result-panel {
    margin-top: 14px;
    padding: 18px;
    border: 1px solid #35545a;
    border-radius: 6px;
    background: #152124;
}

.result-panel h2,
.result-panel h3,
.result-panel p {
    margin-top: 0;
}

.result-panel h2 {
    margin-bottom: 4px;
    color: #f4ffff;
    font-size: 1.3rem;
}

.result-panel p {
    margin-bottom: 0;
    color: #b8cdca;
}

.result-panel h3 {
    margin: 18px 0 8px;
    color: #7fd2d7;
    font-size: 0.9rem;
}

#logList {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

#logList li {
    min-width: 0;
    padding: 8px 10px;
    border-left: 3px solid #5ecdd7;
    background: #0f1a1c;
    color: #bfd2d0;
    font-size: 0.82rem;
}

#logList li.is-miss {
    border-color: var(--red);
}

.info-section {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 34px;
    padding: 50px 0 30px;
}

.info-section article {
    min-width: 0;
    padding: 24px 0;
    border-top: 1px solid var(--line);
}

.info-section h2 {
    margin: 0 0 8px;
    font-size: 1.25rem;
    line-height: 1.4;
    letter-spacing: 0;
}

.info-section p {
    margin: 0;
    color: var(--muted);
}

.info-section a {
    color: var(--mint);
    font-weight: 800;
}

.comments-stub {
    margin: 10px 0 44px;
    padding: 22px 0;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}

.comments-stub h2,
.comments-stub p {
    margin: 0;
}

.comments-stub h2 {
    font-size: 1.25rem;
}

.comments-stub p {
    margin-top: 6px;
    color: var(--muted);
}

.site-footer {
    justify-content: center;
    padding: 30px 0 40px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 0.9rem;
}

@media (max-width: 920px) {
    .crowd-hero {
        grid-template-columns: 1fr;
        gap: 22px;
        padding-top: 42px;
    }

    .hero-instrument {
        min-height: 142px;
    }

    #logList {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 640px) {
    body {
        font-size: 15px;
    }

    .site-header,
    .site-footer,
    .crowd-page {
        width: min(100% - 24px, 1120px);
    }

    .site-header {
        align-items: flex-start;
        flex-direction: column;
        gap: 7px;
    }

    .crowd-hero {
        gap: 18px;
        padding: 32px 0 24px;
    }

    .crowd-hero h1 {
        margin-top: 7px;
        font-size: 28px;
        line-height: 1.35;
    }

    .hero-instrument {
        display: none;
    }

    .game-shell {
        padding: 10px;
    }

    .game-fullscreen-open {
        top: 10px;
        right: 10px;
        min-height: 38px;
        padding: 6px 12px;
    }

    .mobile-play-note {
        min-height: 62px;
        margin: 0 92px 10px 0;
        padding: 7px 9px;
        font-size: 0.8rem;
        line-height: 1.55;
    }

    .status-panel {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 7px;
    }

    .status-panel div {
        min-height: 57px;
        padding: 7px 9px;
    }

    .status-panel strong {
        font-size: 1.1rem;
    }

    .crowd-stage {
        padding: 8px;
    }

    .stage-heading {
        align-items: flex-start;
        min-height: 64px;
    }

    .stage-meta {
        display: grid;
        gap: 4px;
    }

    .stage-meta span {
        min-width: 74px;
        padding: 2px 5px;
        font-size: 0.66rem;
    }

    .canvas-frame {
        aspect-ratio: 4 / 3;
    }

    .judgement-row {
        grid-template-columns: 88px minmax(0, 1fr);
        gap: 8px;
        min-height: 66px;
        font-size: 0.8rem;
    }

    .stage-message {
        min-height: 46px;
        font-size: 0.82rem;
        line-height: 1.5;
    }

    .control-row {
        display: grid;
        grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
    }

    .primary-button,
    .ghost-button {
        width: 100%;
        padding-inline: 10px;
    }

    .center-result {
        min-height: 210px;
        padding: 16px;
    }

    .center-result > strong {
        font-size: 2rem;
    }

    #logList,
    .info-section {
        grid-template-columns: 1fr;
    }

    .info-section {
        padding-top: 38px;
    }

    .info-section article {
        padding: 20px 0;
    }
}

@media (max-width: 340px) {
    .crowd-hero h1 {
        font-size: 26px;
    }

    .judgement-row {
        grid-template-columns: 76px minmax(0, 1fr);
    }

    .stage-announcement {
        min-width: calc(100% - 20px);
        padding-inline: 10px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}
