:root {
    color-scheme: light;
    --ink: #263332;
    --muted: #667572;
    --line: #dce9e4;
    --soft-line: #edf5f2;
    --mint: #8edfc1;
    --mint-deep: #2f8f70;
    --green: #dff5e9;
    --paper: #fffefa;
    --shadow: 0 18px 45px rgba(45, 92, 78, 0.12);
    font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", "Meiryo", system-ui, sans-serif;
    color: var(--ink);
}

* { box-sizing: border-box; }
html { min-width: 0; scroll-behavior: smooth; }
body {
    min-width: 0;
    margin: 0;
    color: var(--ink);
    background: radial-gradient(circle at 50% 12%, rgba(142, 223, 193, 0.13), transparent 28rem), linear-gradient(180deg, #fff 0%, #fdfffe 48%, #f8fcfa 100%);
    font-size: 16px;
    line-height: 1.8;
}
a { color: inherit; }
button { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
button:focus-visible, a:focus-visible { outline: 3px solid rgba(36, 133, 102, 0.45); outline-offset: 3px; }

.site-header, .site-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    width: min(1120px, calc(100% - 32px));
    margin: 0 auto;
}
.site-header { padding: 18px 0 8px; }
.site-logo { color: var(--ink); font-size: 14px; font-weight: 800; letter-spacing: 0.02em; text-decoration: none; }
.site-nav { display: flex; flex-wrap: wrap; gap: 8px 18px; color: var(--muted); font-size: 0.92rem; }
.site-nav a, .site-footer a { text-decoration: none; }
.site-nav a:hover, .site-footer a:hover { color: var(--mint-deep); }

.stack-page { width: min(1120px, calc(100% - 32px)); margin: 0 auto; padding: 10px 0 42px; }
.breadcrumb { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 8px; color: var(--muted); font-size: 12px; }
.breadcrumb a { color: #315d54; text-decoration: none; }
.breadcrumb [aria-current="page"] { color: var(--ink); font-weight: 700; }
.stack-hero { padding: 12px 0 20px; }
.series-label { margin: 0 0 4px; color: var(--mint-deep); font-size: 0.78rem; font-weight: 800; letter-spacing: 0.12em; }
h1 { margin: 0; font-size: clamp(28px, 5vw, 42px); line-height: 1.2; letter-spacing: 0; }
.stack-hero > p:last-child { margin: 8px 0 0; color: #3f504d; font-size: clamp(1rem, 1.6vw, 1.12rem); }

.game-shell, .info-section article, .related-section {
    border: 1px solid var(--line);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 10px 28px rgba(42, 87, 74, 0.07);
}
.game-shell { width: min(880px, 100%); margin: 0 auto; padding: 12px; }
.game-stage {
    position: relative;
    isolation: isolate;
    width: 100%;
    height: clamp(340px, 46vw, 390px);
    overflow: hidden;
    border: 1px solid #d4e8e1;
    border-radius: 8px;
    background: #f4fbf8;
}
#game-canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; touch-action: manipulation; cursor: pointer; }
.score-bar {
    position: absolute;
    z-index: 3;
    top: 10px;
    right: 108px;
    left: 10px;
    display: flex;
    align-items: center;
    gap: clamp(8px, 2vw, 16px);
    height: 54px;
    padding: 6px 10px;
    overflow: hidden;
    border: 1px solid rgba(203, 229, 220, 0.92);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.96);
}
.score-item { display: grid; flex: 0 1 auto; min-width: 0; gap: 2px; }
.score-item > span { color: var(--muted); font-size: 10px; line-height: 1.2; white-space: nowrap; }
.score-item > div { display: flex; align-items: baseline; gap: 4px; }
.score-item strong { font-size: 20px; line-height: 1; font-variant-numeric: tabular-nums; }
.score-item small { color: var(--muted); font-size: 10px; }
.level-label { flex: 0 0 auto; margin-left: auto; padding: 6px 7px; border-radius: 999px; color: #287a68; background: #e6f7f1; font-size: 10px; font-weight: 800; letter-spacing: 0.04em; white-space: nowrap; }
.fullscreen-button {
    position: absolute;
    z-index: 4;
    top: 10px;
    right: 10px;
    min-width: 88px;
    min-height: 44px;
    padding: 7px 10px;
    border: 1px solid #c8e3da;
    border-radius: 10px;
    color: #246b5b;
    background: rgba(255, 255, 255, 0.97);
    box-shadow: 0 2px 6px rgba(23, 59, 57, 0.09);
    font-size: 13px;
    font-weight: 800;
    cursor: pointer;
    touch-action: manipulation;
}
.fullscreen-button:hover { background: #eaf8f2; }
.action-button {
    position: absolute;
    z-index: 4;
    bottom: 10px;
    left: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 11px;
    width: min(260px, calc(100% - 24px));
    min-height: 54px;
    padding: 8px 16px;
    transform: translateX(-50%);
    border: 0;
    border-radius: 10px;
    color: #fff;
    background: var(--mint-deep);
    box-shadow: 0 3px 0 #246f58;
    cursor: pointer;
    touch-action: manipulation;
}
.action-button:hover { background: #287e62; }
.action-button:active { transform: translate(-50%, 2px); box-shadow: 0 1px 0 #246f58; }
.action-button span { font-size: 17px; font-weight: 800; }
.action-button small { color: rgba(255, 255, 255, 0.86); font-size: 12px; }
.stage-message {
    position: absolute;
    z-index: 3;
    right: 8px;
    bottom: 72px;
    left: 8px;
    min-height: 20px;
    margin: 0;
    color: #53736b;
    font-size: 12px;
    line-height: 20px;
    text-align: center;
    pointer-events: none;
}
.game-over-card {
    position: absolute;
    z-index: 2;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 20px;
    color: #fff;
    background: rgba(20, 56, 52, 0.82);
    text-align: center;
    pointer-events: none;
}
.game-over-card strong { font-size: 24px; }
.game-over-card span { font-size: 14px; }

.info-section { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin: 22px auto 0; }
.info-section article { padding: 18px; }
.info-section h2, .related-section h2 { margin: 0 0 6px; color: #315d54; font-size: 1rem; line-height: 1.4; }
.info-section p, .related-section p { margin: 0; color: var(--muted); font-size: 0.9rem; line-height: 1.7; }
.related-section { margin-top: 14px; padding: 18px; }
.related-section a { color: #246f58; font-weight: 700; }
.game-comment-section { margin-top: 24px; }
.site-footer { flex-wrap: wrap; padding: 28px 0 36px; border-top: 1px solid var(--soft-line); color: var(--muted); font-size: 0.88rem; }

#game-stage:fullscreen, #game-stage.is-fullscreen-fallback {
    position: fixed;
    z-index: 10000;
    inset: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    max-width: none;
    margin: 0;
    border: 0;
    border-radius: 0;
    background: #f4fbf8;
}
html.has-fullscreen-fallback, body.has-fullscreen-fallback { overflow: hidden; }

@media (max-width: 760px) {
    .info-section { grid-template-columns: 1fr; gap: 10px; }
    .info-section article { padding: 15px 16px; }
}
@media (max-width: 640px) {
    body { font-size: 15px; }
    .site-header, .site-footer { align-items: flex-start; flex-direction: column; gap: 8px; }
    .site-header, .site-footer, .stack-page { width: min(100% - 24px, 1120px); }
    .site-header { padding-top: 14px; }
    .site-nav { gap: 8px 14px; }
    .stack-page { padding-top: 8px; }
    .stack-hero { padding: 10px 0 16px; }
    .game-shell { padding: 10px; }
    .game-stage { height: clamp(300px, 76vw, 350px); }
    .site-footer { padding: 24px 0 30px; }
}
@media (max-width: 380px) {
    .site-header, .site-footer, .stack-page { width: calc(100% - 20px); }
    .game-shell { padding: 8px; }
    .score-bar { top: 7px; right: 100px; left: 7px; padding-right: 7px; padding-left: 7px; }
    .score-bar .level-label { display: none; }
    .fullscreen-button { top: 7px; right: 7px; min-width: 86px; padding-right: 8px; padding-left: 8px; }
}
@media (max-width: 480px) and (max-height: 650px) {
    .game-stage { height: 220px; }
    .score-bar, .fullscreen-button { top: 6px; }
    .action-button { bottom: 8px; }
    .stage-message { bottom: 68px; }
}
@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
}
