@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@400;500;700;900&family=M+PLUS+Rounded+1c:wght@800;900&display=swap');

:root {
    color-scheme: dark;
    --bg: #102510;
    --muted: #a0b791;
    --mint: #78b747;
    --line: #ffffff20
}

* {
    box-sizing: border-box
}

body {
    margin: 0;
    background: radial-gradient(ellipse at 50% 45%, #294b22, transparent 65%), var(--bg);
    color: #ecf4e8;
    font-family: 'Noto Sans JP', sans-serif;
    font-size: 14px
}

button,
input {
    font: inherit
}

button {
    cursor: pointer;
    touch-action: manipulation
}

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

button:focus-visible,
a:focus-visible,
input:focus-visible {
    outline: 3px solid #ffdc85;
    outline-offset: 4px
}

.quiet {
    border: 1px solid var(--line);
    border-radius: 30px;
    background: transparent;
    color: #c5d7b8;
    padding: 9px 14px;
    font-size: 11px
}

main {
    max-width: 1350px;
    margin: 16px auto 35px;
    padding: 0 4%;
    display: grid;
    grid-template-columns: minmax(220px, 1fr) minmax(0, 528px) minmax(220px, 1fr);
    align-items: center;
    gap: clamp(20px, 3vw, 40px)
}

.eyebrow {
    font-size: 10px;
    letter-spacing: 2px;
    color: var(--mint);
    font-weight: 700
}

h1 {
    font-size: clamp(26px, 3.1vw, 44px);
    line-height: 1.5;
    letter-spacing: -2px;
    margin: 20px 0
}

h1 span {
    font-size: .72em;
    letter-spacing: -1px
}

.intro>p {
    color: #aec49f;
    line-height: 2.2;
    letter-spacing: 2px
}

.intro-bottom {
    margin-top: 70px
}

.tag {
    font-size: 9px;
    letter-spacing: 1.7px;
    border: 1px solid #9fbb9860;
    border-radius: 3px;
    padding: 7px 10px;
    color: var(--mint)
}

.intro-bottom p {
    font-size: 11px;
    line-height: 2;
    color: var(--muted);
    margin: 22px 0
}

.outline {
    padding: 12px 17px;
    background: transparent;
    color: #d5e6d9;
    border: 1px solid #6c8f54;
    border-radius: 8px;
    font-size: 12px
}

.outline span {
    margin-left: 24px
}

.machine {
    min-width: 0;
    border: 1px solid #7a9e5c;
    padding: 14px;
    border-radius: 24px;
    background: linear-gradient(135deg, #567a37, #2e4d21);
    box-shadow: 0 30px 65px #05170370, inset 0 0 0 5px #314d23
}

.board {
    position: relative;
    background: #1a3c17;
    overflow: hidden;
    border: 1px solid #88a17f60;
    border-bottom: 0;
    border-radius: 13px 13px 0 0
}

canvas {
    display: block;
    width: 100%;
    max-width: 100%;
    height: auto
}

.board-message {
    position: absolute;
    z-index: 2;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    background: #102b13dd;
    backdrop-filter: blur(4px);
    padding: 16px
}

.board-message h2 {
    font-size: 20px
}

.board-message p {
    font-size: 12px;
    line-height: 2;
    color: #bfd0b0
}

.little-marimo {
    display: block;
    width: 70px;
    height: 70px;
    font-size: 0;
    border-radius: 50%;
    background: #4b9d2d
}

.primary {
    border: 0;
    background: var(--mint);
    color: #102a0c;
    border-radius: 8px;
    padding: 13px 22px;
    font-weight: 900
}

.board-message .primary {
    margin-top: 15px;
    min-width: 180px
}

.primary span {
    float: right;
    margin-left: 25px
}

.controls {
    background: #243d1b;
    padding: 15px;
    border-radius: 0 0 13px 13px
}

.power-label {
    display: flex;
    justify-content: space-between;
    font-size: 8px;
    letter-spacing: 1px;
    color: #a8bf96
}

.power-label b {
    font-size: 9px;
    font-weight: 400;
    letter-spacing: 0
}

.power-track {
    height: 5px;
    background: #0c1e0a;
    border-radius: 10px;
    margin: 9px 0 12px;
    overflow: hidden
}

.power-track i {
    display: block;
    width: 0;
    height: 100%;
    background: linear-gradient(90deg, #559c31, #ffd378)
}

.launch {
    width: 100%;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none
}

.guide h2 {
    font-size: 19px;
    margin: 15px 0 30px
}

.guide article {
    display: flex;
    gap: 14px;
    margin: 25px 0
}

.guide article>b {
    color: #b8d8ba;
    font: 12px monospace;
    margin-top: 4px
}

.guide h3 {
    font-size: 13px;
    margin: 0 0 8px
}

.guide article p {
    font-size: 11px;
    line-height: 1.95;
    color: var(--muted);
    margin: 0
}

.note {
    border-top: 1px solid var(--line);
    margin-top: 30px;
    padding-top: 25px;
    display: flex;
    gap: 15px;
    color: #c6d7b8
}

.note span {
    font-size: 28px
}

.note p {
    font-size: 11px;
    line-height: 2;
    margin: 0
}

footer {
    max-width: 1200px;
    margin: 30px auto;
    padding: 20px 4%;
    border-top: 1px solid var(--line);
    color: #8fa27f;
    font-size: 10px;
    display: block;
    text-align: center;
    line-height: 1.8
}

dialog {
    width: min(460px, 92vw);
    max-height: 90dvh;
    overflow: auto;
    border: 1px solid #759f83;
    border-radius: 20px;
    padding: 16px;
    background: #203a19;
    color: #edf5e6;
    box-shadow: 0 25px 90px #081c0699
}

dialog::backdrop {
    background: #081c06c9;
    backdrop-filter: blur(6px)
}

dialog h2 {
    font-size: 22px;
    margin: 8px 0
}

dialog p {
    font-size: 12px;
    color: #b7cebf;
    line-height: 1.6
}

.final-score {
    font: 900 58px monospace;
    color: var(--mint)
}

form label {
    display: block;
    font-size: 11px;
    margin: 20px 0 9px
}

.form-row {
    display: flex;
    gap: 8px
}

input {
    min-width: 0;
    flex: 1;
    background: #12290e;
    border: 1px solid #7a9d8d;
    border-radius: 8px;
    color: white;
    padding: 12px
}

.actions {
    display: flex;
    gap: 9px;
    flex-wrap: wrap;
    margin-top: 20px
}

.dialog-head {
    display: flex;
    justify-content: space-between;
    align-items: center
}

.table-scroll {
    max-height: 55vh;
    overflow: auto
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px
}

td,
th {
    padding: 12px 6px;
    border-bottom: 1px solid var(--line);
    text-align: left
}

th {
    color: #9bb9aa;
    font-size: 10px
}

td:last-child,
th:last-child {
    text-align: right;
    font-family: monospace
}

td:nth-child(2) {
    overflow-wrap: anywhere
}

#submitStatus,
#rankStatus {
    color: #ffdc85
}

button:hover:not(:disabled) {
    filter: brightness(1.1)
}

@media(min-width:1500px) {
    main {
        margin-top: 32px
    }
}

/* Switch before either side column becomes too narrow to read. */
main>*,
.guide article>div {
    min-width: 0;
}

.tag,
.intro-actions button {
    white-space: nowrap;
}

@media(max-width:1100px) {
    main {
        grid-template-columns: minmax(0, 1fr);
        max-width: 850px;
        justify-items: center;
        gap: 24px;
    }

    .intro {
        width: 100%;
        text-align: center;
    }

    h1 {
        margin: 8px 0;
        line-height: 1.3;
    }

    h1 br {
        display: none;
    }

    h1 span {
        font-size: .85em;
    }

    .intro>p {
        margin: 10px 0;
    }

    .intro-bottom {
        margin-top: 14px;
    }

    .intro-bottom p,
    .intro .tag {
        display: none;
    }

    .intro-actions {
        justify-content: center;
    }

    .guide {
        grid-column: 1;
        width: min(720px, 100%);
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 20px;
        margin-top: 0;
    }

    .guide>.eyebrow,
    .guide>h2,
    .note {
        display: none;
    }

    .guide article {
        margin: 10px 0;
    }
}

@media(max-width:700px) {
    .guide {
        grid-template-columns: minmax(0, 1fr);
        max-width: 484px;
        gap: 8px;
    }
}

@media(max-width:620px) {
    main {
        display: flex;
        flex-direction: column;
        margin: 16px auto;
        padding: 0 4%;
        gap: 22px
    }

    .intro {
        width: 100%;
        text-align: center
    }

    .intro .eyebrow {
        font-size: 8px
    }

    h1 {
        font-size: 28px;
        line-height: 1.25;
        margin: 10px 0
    }

    h1 br {
        display: none
    }

    h1 span {
        font-size: .85em
    }

    .intro>p,
    .intro-bottom p,
    .tag {
        display: none
    }

    .intro-bottom {
        margin: 12px 0 0
    }

    .intro-bottom button {
        padding: 8px 15px;
        font-size: 10px
    }

    .machine {
        width: min(484px, 100%);
        padding: 11px
    }

    .guide {
        display: block;
        max-width: 440px
    }

    .guide article {
        margin: 18px 0
    }

    .guide article p {
        font-size: 12px
    }

    footer {
        margin: 5px auto
    }

    .board-message h2 {
        font-size: 18px
    }
}

.ammo {
    display: grid;
    grid-template-columns: repeat(20, minmax(0, 1fr));
    text-align: center;
    padding: 11px 0 0;
    color: #78b747;
    font: 16px/1.3 monospace;
    letter-spacing: 0
}

.intro-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px
}

.field-hud {
    position: absolute;
    inset: 12px 16px auto;
    z-index: 1;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    pointer-events: none;
    font-variant-numeric: tabular-nums
}

.field-hud span {
    display: block;
    font-size: 9px;
    letter-spacing: 1.5px;
    color: #bfd2aa
}

.field-hud strong {
    display: block;
    font: 700 26px/1.3 monospace;
    letter-spacing: 1px;
    color: #a0d46f
}

.field-combo {
    text-align: right
}

.field-hud small {
    display: block;
    min-height: 13px;
    font-size: 10px;
    color: #f5d280
}

@media(max-width:620px) {
    .ammo {
        font-size: 12px
    }

    .intro-actions {
        justify-content: center
    }

    .field-hud {
        inset: 10px 12px auto
    }

    .field-hud strong {
        font-size: 21px
    }

    .field-hud span {
        font-size: 8px
    }

    .field-hud small {
        font-size: 9px
    }
}

.result-ad {
    width: 100%;
    min-height: 300px;
    margin: 16px 0 20px
}

.result-ad .adsbygoogle {
    min-height: 300px
}

.share-x {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    background: #111;
    color: #fff;
    border-color: #777
}

.field-surface {
    position: relative
}

.field-status {
    position: absolute;
    z-index: 1;
    top: 12px;
    left: 50.94697%;
    transform: translateX(-50%);
    width: 52%;
    max-width: calc(100% - 208px);
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    color: #c9ddb7;
    font-size: 10px;
    line-height: 1.4;
    text-align: center;
    overflow-wrap: anywhere;
    pointer-events: none
}

@media(max-width:620px) {
    .field-status {
        top: 10px;
        max-width: calc(100% - 168px);
        font-size: 9px;
        line-height: 1.3
    }
}

/* Curve center: 269 / 528 of the canvas width, including the launcher lane. */

#result h2 {
    margin-block: 6px
}

#result p {
    margin-block: .5em
}

#result form label {
    margin-block: 10px 4.5px
}

#result .result-ad {
    margin-block: 8px 10px
}

#result .actions {
    margin-top: 10px;
    row-gap: 4.5px
}

/* Keep the complete board and controls within the current viewport height. */
.machine {
    width: min(100%, 528px);
    max-width: var(--machine-fit-width, 528px);
    justify-self: center;
    scroll-margin-block: 8px;
    container-type: inline-size
}

.field-hud {
    inset: clamp(5px, 2.5cqw, 12px) clamp(6px, 3cqw, 16px) auto
}

.field-hud strong {
    font-size: clamp(12px, 5cqw, 26px)
}

.field-hud span {
    font-size: clamp(6px, 1.8cqw, 9px)
}

.field-status {
    top: clamp(5px, 2.5cqw, 12px);
    width: 52%;
    max-width: 52%;
    font-size: clamp(7px, 2cqw, 10px)
}

@media(max-height:700px) {
    .machine {
        padding: 8px
    }

    .controls {
        padding: 10px
    }

    .launch {
        padding: 10px 8px
    }

    .little-marimo {
        width: 40px;
        height: 40px
    }

    .board-message {
        padding: 10px
    }

    .board-message h2 {
        font-size: 16px;
        margin: 8px 0
    }

    .board-message p {
        font-size: 10px;
        line-height: 1.6;
        margin: 6px 0
    }

    .board-message .primary {
        padding: 10px 14px;
        margin-top: 8px;
        min-width: 0
    }
}

@media(max-height:500px) and (min-aspect-ratio:1/1) {
    .machine {
        display: grid;
        grid-template-columns: minmax(0, 1fr) 150px;
        gap: 8px
    }

    .board {
        border-bottom: 1px solid #88a17f60;
        border-radius: 13px
    }

    .controls {
        align-self: stretch;
        display: flex;
        flex-direction: column;
        justify-content: center;
        border-radius: 13px;
        padding: 10px
    }

    .power-label {
        flex-wrap: wrap;
        gap: 5px
    }

    .launch {
        font-size: 11px;
        min-height: 44px
    }

    .ammo {
        font-size: 10px;
        grid-template-columns: repeat(10, minmax(0, 1fr));
        row-gap: 4px
    }

    .little-marimo {
        display: none
    }

    .board-message h2 {
        font-size: 14px
    }

    .board-message p {
        font-size: 9px
    }

    .board-message .primary {
        font-size: 12px
    }

    .primary span {
        margin-left: 10px
    }
}

.field-surface {
    container-type: inline-size
}

.launch {
    min-height: 44px
}

/* Keep viewport changes and responsive content from panning the page sideways. */
html,
body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    overscroll-behavior-x: none;
    touch-action: pan-y pinch-zoom;
}

main {
    width: 100%;
    padding-inline: clamp(12px, 4vw, 54px);
}

footer {
    padding-inline: clamp(12px, 4vw, 48px);
}

/* Anchor the game itself at the viewport center, independently of side content. */
.intro h1 span {
    display: inline-block;
    white-space: nowrap;
}

@media(min-width:1101px) {
    main {
        display: block;
        position: relative;
        max-width: none;
        padding-inline: 24px;
    }

    .machine {
        margin-inline: auto;
    }

    .intro,
    .guide {
        position: absolute;
        inset-block: 0;
        display: grid;
        align-content: safe center;
        width: min(280px, calc(50% - var(--game-half-width, 264px) - 56px));
    }

    .intro {
        right: calc(50% + var(--game-half-width, 264px) + 32px);
    }

    .guide {
        left: calc(50% + var(--game-half-width, 264px) + 32px);
        width: min(260px, calc(50% - var(--game-half-width, 264px) - 56px));
    }

    .intro h1 span {
        font-size: min(.72em, 2.2vw);
    }
}

.stage-picker {
    width: min(280px, 100%);
    text-align: left
}

#welcome {
    justify-content: flex-start;
    overflow-y: auto;
    overscroll-behavior-y: contain
}

#welcome > * {
    flex-shrink: 0
}

.welcome-ad {
    width: 100%;
    height: 300px;
    margin-top: 16px
}

.welcome-ad .adsbygoogle {
    display: block;
    width: 100%;
    height: 300px
}

.stage-picker label {
    display: block;
    font-size: 11px;
    color: #c9ddb7;
    margin-bottom: 5px
}

.stage-picker select,
.ranking-stage select {
    width: 100%;
    min-width: 0;
    border: 1px solid #789b60;
    border-radius: 8px;
    background: #132f16;
    color: #ecf4e8;
    font: inherit;
    font-size: 14px;
    padding: 9px
}

.stage-picker select:focus-visible,
.ranking-stage select:focus-visible {
    outline: 3px solid #ffdc85;
    outline-offset: 3px
}

.board-message {
    gap: 8px
}

.board-message h2,
.board-message>p {
    margin: 0
}

.board-message .little-marimo {
    width: 40px;
    height: 40px;
    flex-shrink: 0
}

.board-message .primary {
    margin-top: 4px
}

.ranking-stage {
    display: block;
    font-size: 12px;
    margin: 12px 0
}

.ranking-stage select {
    display: block;
    margin-top: 6px
}

#resultStage {
    color: #a0d46f;
    font-weight: 700
}

.ranking-hint {
    font-size: 11px
}

@media(max-height:500px) {
    .stage-picker label {
        font-size: 9px;
        margin-bottom: 3px
    }

    .stage-picker select {
        font-size: 11px;
        padding: 6px
    }

    .board-message {
        gap: 5px
    }

    .board-message>p {
        font-size: 9px
    }

    .board-message .primary {
        min-height: 36px;
        padding: 7px 14px
    }

    .board-message h2 {
        font-size: 14px
    }

    .board-message .little-marimo {
        display: none
    }
}

/* Long-pressing the board must not select text or open the touch callout. */
.machine,
.machine * {
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    -webkit-user-drag: none;
}

.machine input,
.machine textarea,
.machine select,
.machine option,
.machine [contenteditable="true"] {
    -webkit-user-select: text;
    user-select: text;
    -webkit-touch-callout: default;
}

/* Rounded moss-green lettering with a small marimo and a pond bubble. */
.intro .marimo-title {
    font-family: 'M PLUS Rounded 1c', 'Hiragino Maru Gothic ProN', 'Noto Sans JP', sans-serif;
    font-size: 0;
    line-height: 1.2;
    letter-spacing: 0;
}

.intro .marimo-title .marimo-title-main {
    position: relative;
    display: inline-block;
    padding: 0 12px 0 44px;
    font-size: clamp(42px, 4.1vw, 58px);
    font-weight: 900;
    line-height: 1.35;
    letter-spacing: .06em;
    color: #8dc650;
    background: linear-gradient(165deg, #c3e698 10%, #8dc650 40%, #4e942f 85%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    -webkit-text-stroke: .6px #86b958;
    filter: drop-shadow(0 3px 0 #0a230f);
}

.marimo-title-main::before {
    content: '';
    position: absolute;
    left: 1px;
    top: 50%;
    width: 32px;
    height: 32px;
    transform: translateY(-50%);
    border-radius: 48% 52% 51% 49%;
    background: radial-gradient(circle at 32% 28%, #95c65b, #4b922b 55%, #245c21);
    border: 1px solid #639d3b;
    box-shadow: 0 0 0 2px #366b2855, 0 3px 8px #071d0b66;
}

.intro .marimo-title .marimo-title-sub {
    display: inline-block;
    font-size: clamp(20px, 2.1vw, 29px);
    font-weight: 800;
    line-height: 1.5;
    letter-spacing: .03em;
    color: #c2d9ac;
}

@media(max-width:620px) {
    .intro .marimo-title .marimo-title-main {
        font-size: 30px;
        padding-inline: 30px 8px;
        letter-spacing: .04em;
    }

    .marimo-title-main::before {
        width: 22px;
        height: 22px;
    }

    .marimo-title-main::after {
        width: 4px;
        height: 4px;
    }

    .intro .marimo-title .marimo-title-sub {
        font-size: 17.5px;
        margin-left: 6px;
    }
}
