:root {
    --bg-dark: #081219;
    --bg-deep: #123642;
    --bg-soft: #f2ede3;
    --surface: rgba(255, 249, 241, 0.9);
    --surface-soft: rgba(233, 244, 246, 0.84);
    --surface-strong: rgba(255, 253, 247, 0.96);
    --ink: #1c2a33;
    --muted: #64727c;
    --line: rgba(28, 42, 51, 0.12);
    --accent: #1d7280;
    --accent-strong: #123642;
    --accent-soft: #d5863a;
    --danger: #d96868;
    --shadow: 0 28px 64px rgba(8, 18, 25, 0.2);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    font-family: "IBM Plex Sans JP", sans-serif;
    background:
        radial-gradient(circle at 12% 10%, rgba(213, 134, 58, 0.2), transparent 18%),
        radial-gradient(circle at 85% 12%, rgba(29, 114, 128, 0.2), transparent 22%),
        linear-gradient(180deg, #07111a 0%, #123542 17%, #efe6d9 17.1%, #f6f0e6 100%);
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
    background-size: 50px 50px;
    mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.82), rgba(0, 0, 0, 0.08));
}

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

button,
input {
    font: inherit;
}

canvas {
    display: block;
}

.page-shell {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding-bottom: 80px;
}

.site-header {
    position: sticky;
    top: 14px;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin: 18px 0 20px;
    padding: 16px 22px;
    border-radius: 999px;
    background: rgba(7, 17, 26, 0.76);
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(18px);
    box-shadow: 0 16px 38px rgba(0, 0, 0, 0.22);
}

.brand,
h1,
h2,
h3,
.signal-main,
.footer-title {
    font-family: "Shippori Mincho", serif;
}

.brand {
    color: #f7efe1;
    font-size: 1.14rem;
    letter-spacing: 0.08em;
}

.site-nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 18px;
    color: rgba(247, 239, 225, 0.84);
    font-size: 0.95rem;
}

.site-nav a:hover,
.site-nav a:focus-visible,
.footer-links a:hover,
.footer-links a:focus-visible {
    color: white;
}

.section,
.signal-strip,
.site-footer {
    opacity: 0;
    transform: translateY(26px);
    transition: opacity 520ms ease, transform 520ms ease;
}

.reveal.is-visible,
.site-footer.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.stage {
    display: grid;
    gap: 20px;
    padding: 34px 0 22px;
}

.stage-copy,
.signal-strip,
.rule-card,
.break-card,
.related-card,
.site-footer {
    border: 1px solid rgba(255, 255, 255, 0.58);
    background: var(--surface);
    box-shadow: var(--shadow);
    backdrop-filter: blur(14px);
}

.stage-copy {
    padding: 28px 28px 24px;
    border-radius: 32px;
    position: relative;
    overflow: hidden;
}

.stage-copy::after {
    content: "";
    position: absolute;
    inset: auto -54px -110px auto;
    width: 300px;
    height: 300px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(213, 134, 58, 0.38), rgba(213, 134, 58, 0));
}

.eyebrow,
.card-label,
.signal-kicker {
    margin: 0 0 12px;
    color: var(--accent-strong);
    font-size: 0.84rem;
    font-weight: 700;
    letter-spacing: 0.2em;
    text-transform: uppercase;
}

h1,
h2,
h3,
.brand {
    line-height: 1.14;
}

h1,
h2 {
    margin: 0;
}

h1 {
    font-size: clamp(2.7rem, 5vw, 4.8rem);
    letter-spacing: -0.04em;
}

.stage-lead,
.section-heading p,
.rule-card p,
.break-card p,
.related-card p,
.signal-sub,
.site-footer p,
.panel-header p,
.panel-status,
.floating-hint,
.stage-stats span {
    color: var(--muted);
}

.stage-lead {
    margin: 18px 0 0;
    max-width: 760px;
    font-size: 1.04rem;
    line-height: 1.8;
}

.stage-tags,
.footer-links {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.stage-tags {
    margin-top: 22px;
    position: relative;
    z-index: 1;
}

.stage-tags span,
.button,
.panel button {
    border-radius: 999px;
}

.stage-tags span {
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid rgba(18, 54, 66, 0.12);
    color: var(--accent-strong);
    font-weight: 600;
}

.simulation-shell {
    order: -1;
    position: relative;
    min-height: clamp(600px, 76vh, 820px);
    border-radius: 38px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.16);
    box-shadow: 0 32px 64px rgba(4, 9, 18, 0.32);
    background:
        radial-gradient(circle at 52% 40%, rgba(24, 70, 100, 0.82), rgba(5, 11, 20, 0.96)),
        linear-gradient(180deg, rgba(3, 8, 16, 0.96), rgba(6, 13, 24, 0.98));
}

.simulation-shell::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 14% 16%, rgba(250, 204, 21, 0.08), transparent 18%),
        radial-gradient(circle at 82% 12%, rgba(96, 165, 250, 0.12), transparent 18%);
    pointer-events: none;
}

#boidsCanvas {
    width: 100%;
    height: 100%;
}

.panel,
.floating-hint,
.stage-stats article {
    position: absolute;
    z-index: 2;
    background: rgba(5, 10, 20, 0.72);
    border: 1px solid rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(18px);
    box-shadow: 0 18px 36px rgba(0, 0, 0, 0.26);
}

.panel {
    top: 22px;
    left: 22px;
    width: min(332px, calc(100% - 44px));
    padding: 18px;
    border-radius: 24px;
    color: #f8fbff;
}

.panel-header h2 {
    margin: 0;
    font-size: 1.15rem;
    font-family: "Shippori Mincho", serif;
}

.panel-header p {
    margin: 8px 0 0;
    font-size: 0.9rem;
    line-height: 1.6;
}

.control {
    margin-top: 14px;
}

.control label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 6px;
    color: #edf3fb;
    font-size: 0.9rem;
}

.control input[type="range"] {
    width: 100%;
    accent-color: #f59e0b;
}

.buttons {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 18px;
}

.panel button,
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 46px;
    padding: 0 16px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease, border-color 180ms ease;
}

.panel button:hover,
.panel button:focus-visible,
.button:hover,
.button:focus-visible,
.related-card:hover,
.related-card:focus-within {
    transform: translateY(-2px);
}

.panel button {
    color: white;
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    box-shadow: 0 12px 24px rgba(18, 54, 66, 0.24);
}

.panel button.secondary,
.button-secondary {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.16);
    box-shadow: none;
}

.panel button[aria-pressed="false"] {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.16);
    box-shadow: none;
}

.button-wide {
    grid-column: span 2;
}

.panel-status {
    margin: 14px 0 0;
    font-size: 0.88rem;
    line-height: 1.6;
}

.floating-hint {
    right: 22px;
    bottom: 22px;
    max-width: 340px;
    padding: 12px 14px;
    border-radius: 18px;
    color: #dfe9f5;
    font-size: 0.88rem;
    line-height: 1.55;
}

.stage-stats {
    position: absolute;
    top: 22px;
    right: 22px;
    z-index: 2;
    width: min(280px, calc(100% - 396px));
    display: grid;
    gap: 10px;
}

.stage-stats article {
    padding: 12px 14px;
    border-radius: 18px;
    color: #f8fbff;
}

.stage-stats span {
    display: block;
    font-size: 0.8rem;
    margin-bottom: 6px;
}

.stage-stats strong {
    font-size: 1.05rem;
}

.signal-strip {
    margin-top: 14px;
    padding: 24px 28px;
    border-radius: 28px;
}

.signal-kicker {
    margin-bottom: 10px;
}

.signal-main {
    margin: 0;
    font-size: clamp(1.5rem, 2.7vw, 2.35rem);
}

.signal-sub {
    margin: 12px 0 0;
    max-width: 900px;
    line-height: 1.8;
}

.section {
    padding-top: 62px;
}

.section-heading {
    max-width: 760px;
}

.section-heading h2 {
    font-size: clamp(2rem, 3.4vw, 3rem);
    letter-spacing: -0.03em;
}

.section-heading p:last-child {
    margin: 16px 0 0;
    line-height: 1.8;
}

.rule-grid,
.break-grid,
.related-grid {
    display: grid;
    gap: 18px;
    margin-top: 24px;
}

.rule-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

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

.related-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.rule-card,
.break-card,
.related-card {
    padding: 24px;
    border-radius: 28px;
}

.strong-card {
    background: linear-gradient(180deg, rgba(233, 244, 246, 0.92), rgba(255, 249, 241, 0.88));
}

.warm-card {
    background: linear-gradient(180deg, rgba(255, 242, 223, 0.94), rgba(255, 249, 241, 0.88));
}

.accent-card,
.feature-card {
    background: linear-gradient(180deg, rgba(18, 54, 66, 0.94), rgba(29, 114, 128, 0.88));
    color: #f7fbff;
}

.accent-card p,
.feature-card p,
.feature-card .card-label {
    color: rgba(239, 246, 255, 0.84);
}

.rule-card h3,
.break-card h3,
.related-card h3 {
    margin: 0;
    font-size: 1.32rem;
}

.rule-card p,
.break-card p,
.related-card p {
    margin: 12px 0 0;
    line-height: 1.75;
}

.button {
    margin-top: 18px;
}

.button-primary {
    color: white;
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    box-shadow: 0 14px 28px rgba(18, 54, 66, 0.24);
}

.button-secondary {
    background: rgba(255, 255, 255, 0.8);
    border-color: var(--line);
}

.site-footer {
    margin-top: 72px;
    padding: 28px;
    border-radius: 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

.footer-title {
    margin: 0;
    font-size: 1.12rem;
}

.site-footer p {
    margin: 10px 0 0;
    max-width: 700px;
    line-height: 1.7;
}

@media (max-width: 1080px) {
    .stage-stats {
        width: min(240px, calc(100% - 384px));
    }

    .rule-grid,
    .related-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 860px) {
    .page-shell {
        width: min(100%, calc(100% - 24px));
    }

    .site-header,
    .site-footer {
        border-radius: 28px;
    }

    .simulation-shell {
        min-height: 920px;
    }

    .panel {
        top: auto;
        bottom: 18px;
        left: 18px;
        right: 18px;
        width: auto;
    }

    .stage-stats {
        top: 18px;
        left: 18px;
        right: 18px;
        width: auto;
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .floating-hint {
        right: 18px;
        left: 18px;
        bottom: 378px;
        max-width: none;
    }

    .break-grid,
    .related-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .site-header,
    .site-footer,
    .stage-copy,
    .signal-strip,
    .rule-card,
    .break-card,
    .related-card {
        border-radius: 24px;
    }

    .site-header {
        padding: 14px 16px;
    }

    .stage-copy {
        padding: 24px 20px 20px;
    }

    h1 {
        font-size: clamp(2.15rem, 12vw, 3.1rem);
    }

    .simulation-shell {
        min-height: 980px;
        border-radius: 28px;
    }

    .buttons,
    .stage-stats {
        grid-template-columns: 1fr;
    }

    .button-wide {
        grid-column: auto;
    }

    .floating-hint {
        bottom: 474px;
    }

    .rule-grid {
        grid-template-columns: 1fr;
    }
}