:root {
    --bg-deep: #09070b;
    --bg-mid: #191015;
    --bg-surface: rgba(18, 14, 20, 0.82);
    --bg-surface-strong: rgba(11, 10, 17, 0.92);
    --bg-card: rgba(30, 22, 25, 0.82);
    --text: #f8f2eb;
    --muted: #d2c0b1;
    --line: rgba(255, 255, 255, 0.1);
    --accent: #ff9548;
    --accent-strong: #ffd06c;
    --accent-soft: rgba(255, 149, 72, 0.16);
    --cool: #84d4ff;
    --cool-soft: rgba(132, 212, 255, 0.18);
    --danger: #f87171;
    --shadow: 0 28px 80px rgba(0, 0, 0, 0.36);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    font-family: "IBM Plex Sans JP", sans-serif;
    background:
        radial-gradient(circle at 18% 14%, rgba(255, 142, 60, 0.24), transparent 20%),
        radial-gradient(circle at 82% 18%, rgba(117, 211, 255, 0.14), transparent 24%),
        radial-gradient(circle at 50% 120%, rgba(255, 160, 64, 0.18), transparent 32%),
        linear-gradient(180deg, #0a0810 0%, #161019 24%, #201318 54%, #0d0c14 100%);
}

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

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

button,
input {
    font: inherit;
}

canvas {
    display: block;
}

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

.site-header {
    position: sticky;
    top: 14px;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin: 18px 0 20px;
    padding: 16px 22px;
    border-radius: 999px;
    background: rgba(10, 11, 18, 0.76);
    border: 1px solid var(--line);
    backdrop-filter: blur(18px);
    box-shadow: 0 16px 42px rgba(0, 0, 0, 0.26);
}

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

.brand {
    font-size: 1.14rem;
    letter-spacing: 0.12em;
}

.site-nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 18px;
    color: rgba(248, 242, 235, 0.82);
    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;
    grid-template-columns: minmax(0, 1fr);
    gap: 22px;
    padding: 34px 0 22px;
}

.stage-copy,
.simulation-shell,
.tool-card,
.physics-card,
.related-card,
.signal-strip,
.site-footer {
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    backdrop-filter: blur(16px);
}

.stage-copy {
    position: relative;
    overflow: hidden;
    min-width: 0;
    padding: 42px 36px 42px 38px;
    border-radius: 36px;
    background: linear-gradient(180deg, rgba(23, 16, 21, 0.94), rgba(17, 14, 19, 0.86));
}

.stage-copy::after {
    content: "";
    position: absolute;
    right: -58px;
    bottom: -96px;
    width: 300px;
    height: 300px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 145, 71, 0.42), rgba(255, 145, 71, 0));
}

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

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

h1,
h2 {
    margin: 0;
}

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

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

h3 {
    margin: 0;
    font-size: 1.34rem;
}

.stage-lead,
.section-heading p,
.tool-card p,
.physics-card p,
.related-card p,
.site-footer p,
.signal-sub,
.panel-header p,
.panel-status,
.floating-hint,
.stage-stats span,
.control span,
.subheading,
.button-secondary {
    color: var(--muted);
}

.stage-lead {
    margin: 20px 0 0;
    font-size: 1.04rem;
    line-height: 1.85;
}

.stage-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 26px;
}

.stage-tags span {
    padding: 10px 14px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(248, 242, 235, 0.9);
    font-size: 0.9rem;
}

.simulation-shell {
    order: -1;
    position: relative;
    min-width: 0;
    min-height: 760px;
    border-radius: 38px;
    overflow: hidden;
    background:
        radial-gradient(circle at 48% 76%, rgba(255, 132, 61, 0.16), transparent 28%),
        radial-gradient(circle at 72% 20%, rgba(128, 210, 255, 0.12), transparent 24%),
        linear-gradient(180deg, rgba(15, 15, 22, 0.92), rgba(11, 11, 17, 0.98));
}

.simulation-shell::after {
    content: "";
    position: absolute;
    inset: auto 0 0 0;
    height: 180px;
    pointer-events: none;
    background: linear-gradient(180deg, rgba(8, 9, 15, 0), rgba(8, 9, 15, 0.48));
}

#fireCanvas {
    width: 100%;
    height: 100%;
    min-height: 760px;
    background:
        radial-gradient(circle at 50% 74%, rgba(255, 146, 70, 0.12), transparent 20%),
        radial-gradient(circle at 50% 22%, rgba(132, 212, 255, 0.08), transparent 30%),
        linear-gradient(180deg, #0b0d17 0%, #090b12 46%, #15100d 100%);
    cursor: crosshair;
    touch-action: none;
}

.panel {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 2;
    width: min(360px, calc(100% - 40px));
    padding: 18px;
    border-radius: 24px;
    background: rgba(10, 12, 20, 0.78);
    border: 1px solid rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(16px);
    box-shadow: 0 18px 38px rgba(0, 0, 0, 0.28);
}

.panel-header h2 {
    font-size: 1.42rem;
}

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

.button-grid,
.tool-grid {
    display: grid;
    gap: 10px;
}

.button-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-top: 16px;
}

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

button {
    min-height: 44px;
    padding: 0 14px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
    cursor: pointer;
    transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease, border-color 180ms ease;
}

button:hover,
.button:hover,
button:focus-visible,
.button:focus-visible {
    transform: translateY(-1px);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.22);
}

button.is-active,
button.accent,
.button-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    color: #2a1508;
    border-color: rgba(255, 208, 108, 0.36);
}

button.warning {
    background: linear-gradient(135deg, #ffb54d, #ffd577);
    color: #24150b;
}

button.danger {
    background: linear-gradient(135deg, #f97373, #fb9a86);
    color: #2b1010;
}

button.is-paused {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
    border-color: rgba(255, 255, 255, 0.12);
}

.subheading {
    margin: 16px 0 10px;
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.control-grid {
    display: grid;
    gap: 12px;
    margin-top: 14px;
}

.control {
    display: grid;
    gap: 6px;
}

.control span,
.control strong {
    font-size: 0.9rem;
}

.control strong {
    justify-self: end;
    color: #fff2de;
}

.control input[type="range"] {
    width: 100%;
    accent-color: var(--accent);
}

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

.floating-hint {
    position: absolute;
    right: 20px;
    bottom: 20px;
    z-index: 2;
    max-width: 360px;
    padding: 14px 16px;
    border-radius: 18px;
    background: rgba(9, 11, 18, 0.72);
    border: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.92rem;
    line-height: 1.65;
}

.stage-stats {
    position: absolute;
    left: 20px;
    bottom: 20px;
    z-index: 2;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.stage-stats article {
    min-width: 116px;
    padding: 12px 14px;
    border-radius: 18px;
    background: rgba(9, 11, 18, 0.72);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

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

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

.signal-strip {
    margin-top: 6px;
    padding: 24px 28px;
    border-radius: 28px;
    background: linear-gradient(135deg, rgba(23, 15, 17, 0.9), rgba(12, 16, 24, 0.88));
}

.signal-kicker,
.signal-main,
.signal-sub {
    margin: 0;
}

.signal-main {
    margin-top: 6px;
    font-size: clamp(1.45rem, 2.6vw, 2.4rem);
}

.signal-sub {
    margin-top: 10px;
    line-height: 1.8;
}

.section {
    padding-top: 28px;
}

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

.section-heading p {
    margin: 12px 0 0;
    line-height: 1.8;
}

.tool-card-grid,
.physics-grid,
.related-grid {
    display: grid;
    gap: 18px;
}

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

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

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

.tool-card,
.physics-card,
.related-card {
    min-width: 0;
    padding: 24px;
    border-radius: 30px;
    background: var(--bg-card);
}

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

.strong-card {
    background: linear-gradient(180deg, rgba(38, 24, 18, 0.9), rgba(24, 18, 18, 0.84));
}

.warm-card {
    background: linear-gradient(180deg, rgba(47, 28, 18, 0.9), rgba(26, 18, 17, 0.86));
}

.cool-card {
    background: linear-gradient(180deg, rgba(17, 28, 38, 0.9), rgba(16, 17, 27, 0.86));
}

.ember-card {
    background: linear-gradient(180deg, rgba(41, 24, 24, 0.9), rgba(22, 16, 20, 0.86));
}

.erase-card {
    background: linear-gradient(180deg, rgba(24, 24, 32, 0.9), rgba(16, 16, 24, 0.86));
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 50px;
    padding: 0 22px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.button-secondary {
    background: rgba(255, 255, 255, 0.06);
}

.feature-card {
    background: linear-gradient(180deg, rgba(38, 23, 16, 0.94), rgba(21, 17, 19, 0.9));
}

.site-footer {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    margin-top: 28px;
    padding: 24px 26px;
    border-radius: 28px;
    background: rgba(10, 11, 18, 0.78);
}

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

.site-footer p {
    margin: 8px 0 0;
    line-height: 1.7;
}

.footer-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 16px;
}

@media (max-width: 1160px) {
    .stage {
        grid-template-columns: 1fr;
    }

    .simulation-shell,
    #fireCanvas {
        min-height: 820px;
    }

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

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

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

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

    .site-nav,
    .footer-links {
        justify-content: flex-start;
    }

    .tool-card-grid,
    .physics-grid,
    .related-grid {
        grid-template-columns: 1fr;
    }

    .simulation-shell {
        min-height: auto;
        padding-bottom: 16px;
    }

    #fireCanvas {
        min-height: 460px;
        height: 58vh;
    }

    .panel,
    .floating-hint,
    .stage-stats {
        position: relative;
        top: auto;
        right: auto;
        bottom: auto;
        left: auto;
        width: auto;
        max-width: none;
        margin: 16px 16px 0;
    }

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

@media (max-width: 560px) {
    .stage-copy,
    .tool-card,
    .physics-card,
    .related-card,
    .signal-strip,
    .site-footer {
        border-radius: 24px;
    }

    .stage-copy {
        padding: 32px 22px;
    }

    .panel {
        padding: 16px;
    }

    #fireCanvas {
        min-height: 400px;
        height: 50vh;
    }

    .button-grid,
    .tool-grid {
        grid-template-columns: 1fr 1fr;
    }

    .stage-stats article {
        min-width: calc(50% - 6px);
    }
}