:root {
    --ink: #2e3131;
    --muted: #6e7473;
    --line: #e4e9df;
    --mint: #68b89c;
    --mint-dark: #2f8a72;
    --paper: #fffefb;
    --soft: #fbfaf3;
    --coral: #ff9f8f;
    --yellow: #f3cf6b;
    --shadow: 0 18px 48px rgba(83, 75, 34, 0.12);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    color: var(--ink);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.75;
    background:
        radial-gradient(circle at 16% 18%, rgba(255, 224, 138, 0.18), transparent 28%),
        radial-gradient(circle at 88% 20%, rgba(255, 159, 143, 0.13), transparent 30%),
        #fff;
}

a {
    color: inherit;
}

.site-header,
.site-footer {
    width: min(1120px, calc(100% - 32px));
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

.site-header {
    min-height: 70px;
}

.site-logo {
    color: var(--mint-dark);
    font-size: 0.82rem;
    font-weight: 800;
    text-decoration: none;
}

.site-nav,
.site-footer {
    flex-wrap: wrap;
}

.site-nav {
    display: flex;
    gap: 14px;
    color: var(--muted);
    font-size: 0.86rem;
}

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

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

.sound-page {
    width: min(1120px, calc(100% - 32px));
    margin: 0 auto 64px;
}

.sound-hero {
    min-height: 430px;
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(320px, 0.95fr);
    align-items: center;
    gap: clamp(26px, 5vw, 70px);
    padding: 34px 0 44px;
}

.series-label {
    margin: 0 0 12px;
    color: var(--mint-dark);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.14em;
}

.hero-copy h1 {
    margin: 0;
    font-size: 3rem;
    line-height: 1.15;
}

.hero-title-line {
    display: block;
}

.hero-copy p:last-child {
    max-width: 620px;
    margin: 22px 0 0;
    color: var(--muted);
    font-size: clamp(1rem, 1.8vw, 1.12rem);
}

.timing-preview {
    position: relative;
    min-height: 300px;
}

.preview-routes {
    position: absolute;
    inset: 8% 3%;
    width: 94%;
    height: 84%;
    overflow: visible;
}

.preview-routes path {
    fill: none;
    stroke: rgba(47, 138, 114, 0.22);
    stroke-width: 2.2;
    stroke-dasharray: 7 7;
}

.preview-lane {
    position: absolute;
    left: 8%;
    right: 8%;
    top: 50%;
    height: 5px;
    border-radius: 999px;
    background: linear-gradient(90deg, transparent, rgba(47, 138, 114, 0.42), transparent);
}

.preview-ring {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 122px;
    height: 122px;
    border: 4px solid rgba(47, 138, 114, 0.5);
    border-radius: 999px;
    transform: translate(-50%, -50%);
}

.preview-ring::after {
    position: absolute;
    inset: 20px;
    border: 1px dashed rgba(47, 138, 114, 0.42);
    border-radius: inherit;
    content: "";
}

.preview-note {
    position: absolute;
    left: 16%;
    top: 50%;
    display: grid;
    place-items: center;
    width: 78px;
    height: 78px;
    border: 1px solid rgba(255, 159, 143, 0.35);
    border-radius: 999px;
    background: #fff;
    color: #d88445;
    font-size: 2.8rem;
    font-weight: 900;
    box-shadow: 0 16px 30px rgba(216, 132, 69, 0.16);
    transform: translate(-50%, -50%);
    animation: previewMove 3.4s ease-in-out infinite;
}

.game-shell {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.86);
    box-shadow: var(--shadow);
    padding: clamp(18px, 3vw, 32px);
}

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

.status-panel div {
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--soft);
    padding: 12px;
}

.status-panel span {
    display: block;
    color: var(--mint-dark);
    font-size: 0.72rem;
    font-weight: 800;
}

.status-panel strong {
    display: block;
    margin-top: 2px;
    font-size: clamp(1.1rem, 2.7vw, 1.6rem);
    line-height: 1.2;
}

.mode-selector {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    width: min(100%, 360px);
    margin: 0 auto 18px;
    padding: 4px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--soft);
}

.mode-button {
    min-width: 0;
    width: 100%;
    appearance: none;
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 9px 12px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font: inherit;
    font-size: 0.88rem;
    font-weight: 800;
    line-height: 1.3;
    transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.mode-button:hover:not(:disabled) {
    border-color: rgba(47, 138, 114, 0.28);
    background: rgba(104, 184, 156, 0.12);
    color: var(--mint-dark);
}

.mode-button:focus-visible {
    position: relative;
    z-index: 1;
    outline: 3px solid rgba(47, 138, 114, 0.28);
    outline-offset: 2px;
}

.mode-button[aria-pressed="true"],
.mode-button.is-selected,
.mode-button[data-selected="true"] {
    border-color: var(--mint-dark);
    background: var(--mint-dark);
    color: #fff;
    box-shadow: 0 5px 12px rgba(47, 138, 114, 0.2);
}

.mode-button[aria-pressed="true"]:hover:not(:disabled),
.mode-button.is-selected:hover:not(:disabled),
.mode-button[data-selected="true"]:hover:not(:disabled) {
    border-color: #26755f;
    background: #26755f;
    color: #fff;
}

.mode-button:disabled {
    cursor: default;
    opacity: 0.48;
}

.beat-stage {
    --target-size: 96px;
    --note-size: 72px;
    --note-font-size: 2.6rem;
    position: relative;
    width: 100%;
    min-height: 340px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background:
        linear-gradient(90deg, rgba(243, 207, 107, 0.08) 1px, transparent 1px),
        linear-gradient(rgba(243, 207, 107, 0.08) 1px, transparent 1px),
        var(--paper);
    background-size: 34px 34px;
    touch-action: manipulation;
}

.beat-stage.is-size-large {
    --target-size: 116px;
    --note-size: 84px;
    --note-font-size: 3rem;
}

.beat-stage.is-size-normal {
    --target-size: 96px;
    --note-size: 72px;
    --note-font-size: 2.6rem;
}

.beat-stage.is-size-hard {
    --target-size: 58px;
    --note-size: 44px;
    --note-font-size: 1.6rem;
}

.beat-stage.is-size-small {
    --target-size: 74px;
    --note-size: 56px;
    --note-font-size: 2rem;
}

.beat-hit-button {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    appearance: none;
    border: 0;
    background: transparent;
    color: var(--ink);
    cursor: pointer;
    font: inherit;
    padding: 0;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.beat-hit-button:disabled {
    cursor: default;
}

.beat-hit-button:focus-visible {
    outline: 3px solid rgba(47, 138, 114, 0.28);
    outline-offset: -4px;
}

.trajectory-layer {
    position: absolute;
    z-index: 1;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: visible;
    pointer-events: none;
}

.trajectory-path {
    fill: none;
    stroke: rgba(47, 138, 114, 0.18);
    stroke-width: 4;
    stroke-linecap: round;
    stroke-dasharray: 12 12;
    vector-effect: non-scaling-stroke;
}

.trajectory-path.is-current {
    stroke: rgba(47, 138, 114, 0.62);
    stroke-width: 5;
    stroke-dasharray: 14 9;
}

.beat-stage.is-ready .note-signal {
    opacity: 0.72;
}

.beat-stage.is-finishing .beat-hit-button,
.beat-stage.is-result .beat-hit-button {
    display: none;
}

.stage-progress {
    position: absolute;
    z-index: 3;
    top: 20px;
    left: 50%;
    width: min(90%, 560px);
    margin: 0;
    transform: translateX(-50%);
    color: var(--mint-dark);
    font-size: clamp(0.9rem, 2vw, 1.05rem);
    font-weight: 900;
    text-align: center;
}

.stage-difficulty {
    position: absolute;
    z-index: 3;
    top: 50px;
    left: 50%;
    margin: 0;
    border: 1px solid rgba(47, 138, 114, 0.2);
    border-radius: 999px;
    padding: 3px 10px;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.9);
    color: var(--mint-dark);
    font-size: 0.78rem;
    font-weight: 900;
    line-height: 1.35;
    white-space: nowrap;
}

.beat-stage.is-size-normal .stage-difficulty {
    border-color: rgba(47, 124, 210, 0.22);
    color: #2878cd;
}

.beat-stage.is-size-small .stage-difficulty {
    border-color: rgba(216, 132, 69, 0.28);
    color: #c56f2e;
}

.stage-difficulty[hidden] {
    display: none;
}

.beat-lane {
    position: absolute;
    left: 8%;
    right: 8%;
    top: 50%;
    height: 4px;
    border-radius: 999px;
    background: linear-gradient(90deg, transparent, rgba(47, 138, 114, 0.28), transparent);
}

.target-ring {
    position: absolute;
    z-index: 2;
    left: 50%;
    top: 50%;
    width: var(--target-size);
    height: var(--target-size);
    border: 3px solid rgba(47, 138, 114, 0.45);
    border-radius: 999px;
    transform: translate(-50%, -50%);
}

.target-ring::after {
    position: absolute;
    inset: 16px;
    border: 1px dashed rgba(47, 138, 114, 0.38);
    border-radius: inherit;
    content: "";
}

.note-signal {
    position: absolute;
    z-index: 3;
    left: 10%;
    top: 50%;
    display: grid;
    place-items: center;
    width: var(--note-size);
    height: var(--note-size);
    border: 1px solid rgba(255, 159, 143, 0.28);
    border-radius: 999px;
    background: #fff;
    color: #d88445;
    font-size: var(--note-font-size);
    font-weight: 900;
    box-shadow: 0 14px 28px rgba(216, 132, 69, 0.14);
    transform: translate(-50%, -50%);
    pointer-events: none;
    transition: none;
}

.note-signal[hidden] {
    display: none;
}

.beat-message {
    position: absolute;
    left: 50%;
    bottom: 24px;
    z-index: 3;
    display: grid;
    gap: 4px;
    justify-items: center;
    width: min(90%, 560px);
    transform: translateX(-50%);
    color: var(--muted);
    font-weight: 700;
    line-height: 1.3;
    pointer-events: none;
    text-align: center;
}

.beat-judgement {
    color: var(--ink);
    font-size: clamp(2.25rem, 7vw, 4.6rem);
    font-weight: 900;
    letter-spacing: 0;
    line-height: 0.95;
    text-shadow: 0 4px 0 rgba(255, 255, 255, 0.9);
}

.beat-detail {
    color: var(--muted);
    font-size: clamp(0.88rem, 2vw, 1rem);
    font-weight: 800;
}

.beat-judgement[hidden] {
    display: none;
}

.beat-stage.is-hit .beat-message {
    animation: judgementPop 0.34s cubic-bezier(0.2, 0.8, 0.25, 1.25);
}

.beat-stage.is-perfect {
    border-color: rgba(20, 169, 102, 0.62);
    box-shadow: inset 0 0 0 3px rgba(68, 215, 139, 0.18);
}

.beat-stage.is-perfect .beat-judgement {
    color: #0c9b5b;
    text-shadow:
        0 4px 0 #d9ffec,
        0 0 22px rgba(32, 200, 119, 0.28);
}

.beat-stage.is-perfect .target-ring {
    border-color: #20b96d;
    box-shadow:
        0 0 0 12px rgba(48, 211, 126, 0.16),
        0 0 34px rgba(25, 183, 105, 0.34);
    animation: perfectRingPop 0.36s ease;
}

.beat-stage.is-perfect .target-ring::after {
    border-color: rgba(12, 155, 91, 0.7);
}

.beat-stage.is-perfect .note-signal {
    border-color: rgba(255, 190, 45, 0.64);
    background: #fff8c7;
    color: #dc7727;
}

.beat-stage.is-good {
    border-color: rgba(43, 126, 220, 0.58);
    box-shadow: inset 0 0 0 3px rgba(76, 154, 239, 0.16);
}

.beat-stage.is-good .beat-judgement {
    color: #2475cf;
    text-shadow:
        0 4px 0 #e3f1ff,
        0 0 20px rgba(44, 127, 220, 0.25);
}

.beat-stage.is-good .target-ring {
    border-color: #3c8ce4;
    box-shadow:
        0 0 0 9px rgba(77, 155, 239, 0.14),
        0 0 28px rgba(48, 129, 220, 0.27);
    animation: goodRingPop 0.32s ease;
}

.beat-stage.is-good .target-ring::after {
    border-color: rgba(36, 117, 207, 0.62);
}

.beat-stage.is-miss {
    border-color: rgba(218, 70, 92, 0.6);
    box-shadow: inset 0 0 0 3px rgba(232, 91, 112, 0.14);
}

.beat-stage.is-miss .beat-judgement {
    color: #d43f5a;
    text-shadow:
        0 4px 0 #ffe3e8,
        0 0 18px rgba(212, 63, 90, 0.22);
}

.beat-stage.is-miss .target-ring {
    border-color: #df4f68;
    box-shadow:
        0 0 0 8px rgba(229, 79, 104, 0.12),
        0 0 24px rgba(210, 57, 83, 0.22);
    animation: missRingShake 0.32s ease;
}

.beat-stage.is-miss .target-ring::after {
    border-color: rgba(212, 63, 90, 0.6);
}

.stage-announcement,
.stage-result {
    position: absolute;
    z-index: 4;
    inset: 0;
    display: grid;
    align-content: center;
    justify-items: center;
    width: 100%;
    padding: 54px clamp(18px, 4vw, 36px) 28px;
    text-align: center;
}

.stage-announcement {
    color: var(--mint-dark);
    font-size: clamp(2.2rem, 8vw, 5rem);
    font-weight: 900;
    line-height: 1.1;
}

.stage-result {
    gap: 8px;
}

.stage-result span {
    color: var(--ink);
    font-size: clamp(1rem, 2.5vw, 1.35rem);
    font-weight: 800;
    line-height: 1.45;
}

.stage-result span:first-child {
    color: var(--mint-dark);
    font-size: clamp(2rem, 7vw, 4.2rem);
    font-weight: 900;
    line-height: 1.1;
}

.stage-announcement[hidden],
.stage-result[hidden],
.primary-button[hidden],
.log-title[hidden] {
    display: none;
}

.control-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    margin-top: 18px;
}

.primary-button,
.ghost-button {
    appearance: none;
    min-height: 48px;
    border-radius: 8px;
    padding: 0 22px;
    border: 0;
    font: inherit;
    font-weight: 800;
    cursor: pointer;
}

.primary-button {
    background: var(--mint-dark);
    color: #fff;
    box-shadow: 0 10px 22px rgba(47, 138, 114, 0.22);
}

.primary-button:disabled {
    cursor: default;
}

.ghost-button {
    border: 1px solid var(--line);
    background: #fff;
    color: var(--muted);
}

.sound-toggle {
    min-width: 88px;
}

.sound-toggle[aria-pressed="true"] {
    border-color: rgba(47, 138, 114, 0.48);
    background: #f3fff9;
    color: var(--mint-dark);
}

.sound-toggle[aria-pressed="false"] {
    background: #fff8f2;
    color: #815d49;
}

.result-panel {
    margin-top: 20px;
    border-top: 1px dashed #ddd4b7;
    padding-top: 18px;
}

.result-panel h2 {
    margin: 0 0 4px;
    font-size: clamp(1.25rem, 3vw, 1.7rem);
}

.result-panel p {
    margin: 0;
    color: var(--muted);
}

.log-title {
    margin: 16px 0 0;
    color: var(--muted);
    font-size: 0.9rem;
}

.log-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 14px 0 0;
    padding: 0;
    list-style: none;
}

.log-list li {
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #fff9e8;
    padding: 4px 10px;
    color: #8a6a22;
    font-size: 0.86rem;
}

.info-section {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-top: 28px;
}

.info-section article {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.82);
    padding: 20px;
}

.info-section h2 {
    margin: 0 0 8px;
    font-size: 1.05rem;
}

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

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

.site-footer {
    border-top: 1px solid var(--line);
    padding: 26px 0 38px;
    color: var(--muted);
    font-size: 0.86rem;
}

@keyframes previewMove {
    0%, 100% {
        left: 16%;
    }
    50% {
        left: 84%;
    }
}

@keyframes judgementPop {
    0% {
        opacity: 0;
        transform: translate(-50%, 10px) scale(0.72);
    }
    70% {
        opacity: 1;
        transform: translate(-50%, -2px) scale(1.08);
    }
    100% {
        opacity: 1;
        transform: translate(-50%, 0) scale(1);
    }
}

@keyframes perfectRingPop {
    0%, 100% {
        transform: translate(-50%, -50%) scale(1);
    }
    50% {
        transform: translate(-50%, -50%) scale(1.2);
    }
}

@keyframes goodRingPop {
    0%, 100% {
        transform: translate(-50%, -50%) scale(1);
    }
    50% {
        transform: translate(-50%, -50%) scale(1.1);
    }
}

@keyframes missRingShake {
    0%, 100% {
        transform: translate(-50%, -50%);
    }
    25% {
        transform: translate(calc(-50% - 6px), -50%);
    }
    75% {
        transform: translate(calc(-50% + 6px), -50%);
    }
}

@media (max-width: 820px) {
    .sound-hero {
        grid-template-columns: 1fr;
        min-height: 0;
        text-align: center;
    }

    .hero-copy p:last-child {
        margin-left: auto;
        margin-right: auto;
    }

    .timing-preview {
        min-height: 220px;
    }

    .status-panel {
        grid-template-columns: repeat(2, 1fr);
    }

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

@media (max-width: 540px) {
    .mode-button {
        padding-inline: 6px;
        font-size: 0.82rem;
        white-space: nowrap;
    }

    .site-header,
    .site-footer {
        align-items: flex-start;
        flex-direction: column;
    }

    .beat-stage {
        --target-size: 96px;
        --note-size: 60px;
        --note-font-size: 2.1rem;
        min-height: 300px;
    }

    .trajectory-path {
        stroke-width: 3;
    }

    .trajectory-path.is-current {
        stroke-width: 4;
    }

    .beat-stage.is-size-large {
        --target-size: 106px;
        --note-size: 72px;
        --note-font-size: 2.45rem;
    }

    .beat-stage.is-size-normal {
        --target-size: 90px;
        --note-size: 60px;
        --note-font-size: 2.1rem;
    }

    .beat-stage.is-size-hard {
        --target-size: 56px;
        --note-size: 44px;
        --note-font-size: 1.6rem;
    }

    .beat-stage.is-size-small {
        --target-size: 70px;
        --note-size: 48px;
        --note-font-size: 1.72rem;
    }

    .beat-message {
        bottom: 18px;
    }

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

@media (max-width: 820px) {
    .hero-copy h1 {
        font-size: 1.75rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .preview-note {
        animation: none;
    }

    .beat-stage.is-hit .beat-message,
    .beat-stage.is-perfect .target-ring,
    .beat-stage.is-good .target-ring,
    .beat-stage.is-miss .target-ring {
        animation: none;
    }
}
