:root {
    color-scheme: dark;
    --bg: #071319;
    --panel: #0b1e25;
    --line: #254047;
    --text: #e9f6ef;
    --muted: #a8c4bd;
    --lime: #b7ed81;
    --teal: #7bdac1;
    font: 16px/1.5 "Inter", "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif
}

* {
    box-sizing: border-box
}

body {
    margin: 0;
    background: radial-gradient(ellipse at 50% -25%, #1a3c3a, transparent 60%), var(--bg);
    color: var(--text)
}

button {
    font: inherit;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent
}

button:focus-visible,
a:focus-visible {
    outline: 2px solid #e8ffbf;
    outline-offset: 3px
}

button:disabled {
    opacity: .42;
    cursor: default
}

[hidden] {
    display: none !important
}

.wrap {
    max-width: 1264px;
    margin: auto;
    padding: 8px clamp(10px, 3.2vw, 38px) 0
}

.mast {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px
}

.brand {
    display: flex;
    gap: 11px;
    align-items: center;
    font-size: 16px;
    font-weight: 850;
    letter-spacing: .06em
}

.mark {
    position: relative;
    display: block;
    width: 33px;
    height: 33px;
    border-radius: 10px;
    background: #15392f;
    border: 1px solid #326353
}

.actions {
    display: flex;
    gap: 8px
}

.small,
.secondary {
    background: #0c2128;
    border: 1px solid #355055;
    color: var(--text);
    border-radius: 9px;
    padding: 8px 12px;
    font-weight: 700;
    font-size: 14px
}

.small:hover,
.secondary:hover {
    background: #19373b
}

.small[aria-pressed=true] {
    color: var(--lime)
}

.cabinet {
    border: 1px solid #315251;
    border-radius: 17px;
    overflow: hidden;
    background: #091b21;
    box-shadow: 0 20px 65px #0006
}

.hud {
    height: 57px;
    display: grid;
    grid-template-columns: minmax(135px, 1fr) 1.55fr minmax(108px, 1fr);
    gap: 18px;
    padding: 0 20px;
    align-items: center;
    background: #0b2228
}

.hud-title {
    font-weight: 800;
    font-size: 14px;
    white-space: nowrap
}

.hud-title span {
    color: var(--teal);
    margin-right: 8px;
    font: 700 13px ui-monospace, monospace
}

.attempt {
    text-align: right;
    font-size: 13px;
    color: var(--muted);
    white-space: nowrap;
    font-variant-numeric: tabular-nums
}

.progress-line {
    display: flex;
    gap: 10px;
    align-items: center;
    color: #cbf4b1;
    font: 700 13px ui-monospace, monospace
}

.track {
    position: relative;
    flex: 1;
    height: 6px;
    border-radius: 8px;
    background: #284143;
    overflow: hidden
}

.track b {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, #4fcda8, #c8f088);
    border-radius: 8px;
    transform-origin: 0 50%;
    transform: scaleX(0)
}

.progress-line output {
    width: 4ch;
    text-align: right
}

.viewport {
    position: relative;
    height: clamp(380px, 43vw, 535px);
    isolation: isolate;
    background: #103837;
    overflow: hidden
}

.viewport:focus {
    outline: none
}

.viewport.playing {
    touch-action: none;
    cursor: crosshair
}

.viewport.playing * {
    touch-action: none
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
    position: absolute;
    inset: 0;
    touch-action: none
}

.overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
    text-align: center;
    background: radial-gradient(ellipse at 50% 53%, #051c21ed 0%, #08242b9e 45%, #05151d40 83%);
    overflow: auto
}

.launch-message {
    color: #fae4b8;
    font-size: 14px;
    margin: 16px 0 0
}

.hero {
    width: min(100%, 760px);
    margin: auto
}

.hero h1,
.hero h2 {
    margin: 0;
    font-weight: 950;
    line-height: 1;
    text-shadow: 0 3px 15px #031f20, 0 1px 1px #ebfff088;
    letter-spacing: .015em
}

.hero h1 {
    font-size: clamp(27px, 7.25vw, 86px);
    white-space: nowrap;
    color: #ecffe5
}

.hero h2 {
    font-size: clamp(28px, 5.5vw, 42px)
}

.roman {
    color: #b9eb93;
    font: 700 clamp(11px, 2vw, 15px)/1.8 ui-monospace, monospace;
    letter-spacing: .27em;
    margin: 4px 0 0
}

.lead {
    margin: 8px 0;
    font-size: clamp(14px, 2vw, 16px);
    color: #d9eee7
}

.hero-actions {
    display: flex;
    justify-content: center;
    gap: 9px;
    flex-wrap: wrap
}

.primary {
    border: 1px solid #d7ffa8;
    border-radius: 10px;
    background: #b9ed83;
    color: #152a20;
    font-weight: 900;
    padding: 11px 24px;
    min-width: 152px;
    box-shadow: 0 4px 0 #4d8655, 0 0 28px #9ae66c28
}

.primary:hover {
    background: #d0ffa3
}

.primary:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 #4d8655
}

.hero-actions .secondary {
    padding: 10px 14px
}

.ticker {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 18px;
    flex-wrap: wrap;
    padding: 10px 12px;
    background: #0b2228;
    color: #bfd4cf;
    font-size: 13px
}

.ticker span {
    display: inline-flex;
    align-items: center;
    gap: 7px
}

.ticker i {
    display: inline-grid;
    place-items: center;
    width: 22px;
    height: 22px;
    background: #19393d;
    border: 1px solid #315052;
    color: #b8eb98;
    border-radius: 5px;
    font-style: normal;
    font-weight: 800
}

.stage-section {
    margin-top: 20px;
    scroll-margin-top: 10px
}

.stage-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 9px
}

.stage-head h2 {
    margin: 0;
    font-size: 18px;
    letter-spacing: .03em
}

.stage-head output {
    color: var(--muted);
    font: 700 13px ui-monospace, monospace
}

.stages {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px
}

.stage {
    --accent: #a4e585;
    position: relative;
    text-align: left;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 9px;
    min-height: 53px;
    padding: 8px 10px;
    border: 1px solid #294349;
    border-radius: 9px;
    background: #0b1f26;
    color: var(--text)
}

.stage:hover {
    background: #123139;
    border-color: #5b8473
}

.stage[aria-pressed=true] {
    border-color: var(--accent);
    background: #16332e
}

.stage[data-rank="1"] {
    --accent: #77dcce
}

.stage[data-rank="2"] {
    --accent: #f4ae88
}

.stage b {
    font: 800 16px ui-monospace, monospace;
    color: var(--accent)
}

.stage span {
    font-weight: 750;
    font-size: 14px
}

.stage small {
    font: 650 12px ui-monospace, monospace;
    color: var(--muted)
}

footer {
    text-align: center;
    color: var(--muted);
    margin: 17px 0 12px;
    font-size: 13px
}

footer a {
    color: #aee6bf;
    text-decoration: none
}

footer a:hover {
    text-decoration: underline
}

@media(max-width:850px) {
    .stages {
        grid-template-columns: repeat(2, minmax(0, 1fr))
    }
}

@media(max-width:520px) {
    .mast {
        margin-bottom: 9px
    }

    .brand {
        font-size: 14px;
        gap: 7px
    }

    .mark {
        width: 29px;
        height: 29px
    }

    .small {
        font-size: 12px;
        padding: 7px 8px
    }

    .actions {
        gap: 5px
    }

    .cabinet {
        border-radius: 12px
    }

    .viewport {
        height: clamp(310px, 101vw, 405px)
    }

    .hud {
        height: 46px;
        padding: 0 10px;
        grid-template-columns: minmax(102px, auto) 1fr auto;
        gap: 9px
    }

    .hud-title {
        font-size: 12px
    }

    .hud-title span {
        margin-right: 4px;
        font-size: 11px
    }

    .attempt,
    .progress-line {
        font-size: 11px
    }

    .ticker {
        padding: 8px 5px;
        gap: 9px;
        font-size: 11px
    }

    .ticker i {
        height: 18px;
        width: 18px
    }

    .stage-section {
        margin-top: 15px
    }

    .stage span {
        font-size: 12px
    }

    .stage {
        gap: 5px;
        padding: 6px 7px;
        min-height: 45px
    }

    .stage small {
        font-size: 11px
    }
}

@media(max-height:520px) and (orientation:landscape) {
    .wrap {
        padding-top: 5px
    }

    .mast {
        margin-bottom: 5px
    }

    .hud {
        height: 34px
    }

    .viewport {
        height: calc(100svh - 99px);
        min-height: 230px
    }

    .ticker {
        font-size: 11px;
        padding: 4px
    }

    .hero h1 {
        font-size: 42px
    }

    .hero h2 {
        font-size: 28px
    }

    .lead {
        margin: 7px 0 10px
    }
}

.pickup-count {
    position: relative;
    color: #e4eedb;
    font-weight: 750
}

.pickup-dots {
    color: #f7dc8d;
    letter-spacing: .055em
}

.pickup-announcement {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap
}

.stage-record {
    display: inline-flex;
    gap: 5px;
    justify-content: flex-end;
    align-items: center;
    white-space: nowrap
}

.stage-record .pickup-mark {
    color: #f8d986;
    font-size: 12px;
    line-height: 1
}

.stage-record .stage-best {
    color: var(--muted)
}

.stage-dialog {
    width: min(680px, calc(100% - 24px));
    max-height: calc(100dvh - 30px);
    padding: clamp(12px, 3vw, 24px);
    border: 1px solid #486b67;
    border-radius: 16px;
    background: #0b2228;
    color: var(--text);
    box-shadow: 0 20px 85px #000b;
    overscroll-behavior: contain
}

.stage-dialog::backdrop {
    background: #031219bf
}

.stage-dialog .stage-section {
    margin: 0
}

.stage-header-actions {
    display: flex;
    gap: 10px;
    align-items: center
}

.stage-dialog .stages {
    grid-template-columns: repeat(4, minmax(0, 1fr))
}

#stageClose {
    display: none
}

.stage-dialog #stageClose {
    display: inline-block
}

@media(max-width:600px) {
    .stage-dialog .stages {
        grid-template-columns: repeat(2, minmax(0, 1fr))
    }
}

.game-guide {
    margin: 24px 0 0;
    padding: 18px 0 4px;
    border-top: 1px solid var(--line)
}

.game-guide h2 {
    margin: 0 0 7px;
    font-size: 18px
}

.game-guide p {
    margin: 0 0 7px;
    color: var(--muted);
    line-break: strict
}

html,
[data-game-controls],
.stage-dialog {
    touch-action: manipulation
}

[data-game-controls],
[data-game-controls] *,
.stage-dialog {
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none
}

@media (any-pointer: coarse) {

    body,
    body * {
        -webkit-user-select: none;
        user-select: none;
        -webkit-touch-callout: none
    }
}

.mast,
.mast .actions {
    flex-wrap: wrap
}

.mast .actions {
    align-items: center
}

.bgm-control {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
    font-size: 14px
}

.bgm-control input {
    width: clamp(64px, 10vw, 112px);
    min-height: 32px;
    margin: 0;
    accent-color: var(--lime)
}

.bgm-control input:focus-visible {
    outline: 2px solid #e8ffbf;
    outline-offset: 3px;
    border-radius: 4px
}

@media(max-width:520px) {
    .bgm-control {
        font-size: 12px
    }
}

.ranking-form {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin: 0 0 12px
}

.ranking-form label {
    font-size: 14px
}

.ranking-form input {
    max-width: 100%;
    width: 12em;
    padding: 7px 9px;
    border: 1px solid #486b67;
    border-radius: 9px;
    background: #0b2228;
    color: var(--text);
    font: inherit;
    -webkit-user-select: text;
    user-select: text;
    -webkit-touch-callout: default
}

.ranking-feedback,
.ranking-note {
    color: var(--muted);
    font-size: 14px
}

.ranking-feedback:empty {
    display: none
}

.ranking-feedback {
    margin: 0 0 12px
}

.ranking {
    margin: 18px 0 0;
    padding: 18px 0 4px;
    border-top: 1px solid var(--line)
}

.ranking h2 {
    margin: 0;
    font-size: 18px
}

.ranking-note {
    margin: 5px 0 10px
}

.ranking table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    font-size: clamp(12px, 2.5vw, 15px);
    font-variant-numeric: tabular-nums
}

.ranking th,
.ranking td {
    padding: 8px 6px;
    text-align: center;
    border-bottom: 1px solid var(--line)
}

.ranking th {
    color: var(--muted)
}

.ranking th:first-child {
    width: 12%
}

.ranking th:nth-child(2),
.ranking td:nth-child(2) {
    text-align: left;
    overflow-wrap: anywhere;
    white-space: pre-wrap
}

.ranking th:nth-child(3),
.ranking th:nth-child(4) {
    width: 24%
}

.stage-list-ad {
    text-align: center;
    margin-top: 16px
}

.game-over-ad {
    margin: 8px 0 12px
}

.game-over-ad,
.game-over-ad .adsbygoogle {
    min-height: 300px
}