:root {
    color-scheme: light;
    --ink: #143b36;
    --dim: #476762;
    --line: #d9e6de;
    --pad: #f9fcf7;
    --green: #c6f471;
    --forest: #0e3c37;
    --body: "DM Sans", "Hiragino Sans", "Yu Gothic UI", "Meiryo", sans-serif;
    font-family: var(--body);
    background: #edf6ee;
    color: var(--ink)
}

* {
    box-sizing: border-box
}

html,
body {
    touch-action: manipulation
}

body {
    margin: 0;
    min-width: 280px;
    min-height: 100svh;
    background: radial-gradient(ellipse at 15% 66%, #e1f1dc 0, transparent 44%), radial-gradient(ellipse at 84% 13%, #f7faed 0, transparent 43%), #edf6ee
}

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

input {
    -webkit-user-select: text;
    user-select: text;
    -webkit-touch-callout: default
}

button {
    font: inherit;
    cursor: pointer;
    color: inherit
}

button:focus-visible,
canvas:focus-visible {
    outline: 3px solid #71a52c;
    outline-offset: 4px
}

button:disabled {
    cursor: default
}

[hidden] {
    display: none !important
}

.shell {
    width: min(1056px, calc(100% - 66px));
    margin: auto
}

#startup-notice {
    width: min(100%, 490px);
    margin: 0 auto;
    padding: 10px 13px;
    border: 1px solid #e5c88d;
    border-radius: 12px;
    background: #fff5de;
    color: #5b400f;
    font-size: 14px;
    line-height: 1.55
}

.tool {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    padding: 0 13px;
    border: 1px solid #d5e5da;
    border-radius: 12px;
    background: #f6faf3;
    font-size: 13px;
    font-weight: 800;
    white-space: nowrap
}

.tool:hover {
    background: #e0efdc
}

.sound-icon {
    width: 16px;
    height: 16px;
    position: relative;
    display: inline-block
}

.sound-icon::before {
    content: "";
    position: absolute;
    inset: 2px 5px 2px 0;
    background: currentColor;
    clip-path: polygon(0 31%, 38% 31%, 100% 0, 100% 100%, 38% 69%, 0 69%)
}

.sound-icon::after {
    content: "";
    position: absolute;
    right: 0;
    top: 3px;
    width: 6px;
    height: 10px;
    border-right: 1.7px solid currentColor;
    border-radius: 50%
}

[aria-pressed="false"] .sound-icon::after {
    border: 0;
    right: 0;
    top: 7px;
    width: 6px;
    height: 1.5px;
    background: currentColor;
    border-radius: 2px;
    transform: rotate(45deg)
}

main {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 490px) minmax(0, 1fr);
    align-items: start;
    column-gap: clamp(12px, 2vw, 24px);
    padding: 2px 0
}

.intro {
    width: min(100%, 235px);
    padding-top: 10px;
    overflow-wrap: anywhere
}

.kicker {
    font-size: 13px;
    font-weight: 900;
    letter-spacing: .18em;
    color: #3c7265;
    display: flex;
    align-items: center;
    gap: 7px;
    margin: 0 0 8px
}

.kicker::before {
    content: "";
    height: 2px;
    width: 14px;
    flex: none;
    background: #77a793;
    border-radius: 4px
}

h1 {
    margin: 0;
    font-size: clamp(25px, calc(5.5vw - 17px), 50px);
    letter-spacing: -.087em;
    line-height: 1.03;
    font-weight: 950;
    font-feature-settings: "palt"
}

h1>span {
    display: block
}

.colorful> :nth-child(1) {
    color: #b54057
}

.colorful> :nth-child(2) {
    color: #8a5b0c
}

.colorful> :nth-child(3) {
    color: #147588
}

.colorful> :nth-child(4) {
    color: #76459d
}

.marimo-title {
    color: #268763
}

.lead {
    font-size: 14px;
    font-weight: 650;
    line-height: 1.55;
    color: var(--dim);
    margin: 9px 0 0;
    letter-spacing: .035em
}

.hero-art {
    width: min(100%, 225px);
    height: auto;
    display: block;
    margin: 4px 0 0
}

.tip {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 5px 8px;
    margin: 4px 0 0;
    padding: 5px 7px;
    background: #f8fcf4b8;
    border: 1px solid #d6e6d6;
    border-radius: 16px;
    width: fit-content;
    max-width: 100%
}

.tip canvas {
    width: 68px;
    max-width: 100%;
    height: auto;
    flex: none
}

.tip p {
    margin: 0;
    font-size: 12px;
    font-weight: 750;
    line-height: 1.5;
    color: #315a50
}

.tip strong {
    color: #235b48
}

.machine {
    grid-column: 2;
    min-width: 0;
    background: #fbfdf8;
    border: 1px solid #d4e4d8;
    border-radius: 29px;
    padding: 10px;
    box-shadow: 0 18px 45px #174c3220, 0 1px 2px #30534212
}

.progress-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin: 0 1px 6px
}

.progress-actions {
    display: flex;
    align-items: center;
    gap: 6px
}

.progress-actions .tool {
    min-height: 36px
}

.wallet {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 850;
    color: #37594b;
    min-width: 0
}

.wallet strong {
    font-size: 19px;
    font-variant-numeric: tabular-nums;
    color: var(--ink);
    overflow-wrap: anywhere
}

.wallet-mark {
    flex: none;
    width: 19px;
    height: 19px;
    border-radius: 50%;
    border: 2px solid #86ac53;
    background: radial-gradient(circle at 35% 30%, #efffc5, #b7e478 63%, #8fba58);
    box-shadow: 0 1px 1px #43613738
}

.shop-trigger {
    background: #e6f3d4;
    border-color: #ccdcbf;
    min-height: 36px;
    padding: 0 13px
}

.shop-trigger:disabled {
    opacity: .56
}

.result-reward {
    display: block;
    margin: 7px 0;
    color: #295a37;
    font-size: 14px;
    font-weight: 900;
    padding: 6px;
    background: #e3f2d2;
    border-radius: 10px
}

.overlay .overlay-secondary {
    width: 100%;
    margin-top: 9px;
    min-height: 40px
}

#ready,
#finished {
    margin-inline: auto
}

#ready {
    position: relative;
    z-index: 1
}

#finished {
    width: min(100%, 360px);
    padding-top: 16px;
    padding-bottom: 14px
}

.overlay>ins.adsbygoogle {
    display: block;
    min-height: 300px;
    margin-top: 12px
}

#finished>ins.adsbygoogle {
    margin-bottom: 12px
}

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

.result-actions button {
    min-height: 45px;
    padding: 6px;
    font-size: 15px;
    white-space: nowrap
}

#shop {
    width: min(490px, calc(100% - 24px));
    padding: 19px;
    max-height: min(90vh, 650px);
    max-height: min(90dvh, 650px);
    overflow: hidden
}

#shop[open] {
    display: flex;
    flex-direction: column
}

.shop-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 36%) minmax(0, 1fr);
    align-items: center;
    gap: 6px;
    margin-bottom: 5px
}

#shop-title,
.shop-head .shop-balance {
    margin: 0
}

.shop-balance {
    text-align: center;
    overflow-wrap: anywhere
}

.shop-head form {
    justify-self: end
}

.shop-head .tool {
    min-height: 35px
}

.shop-list {
    display: grid;
    gap: 8px;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    margin-inline: -7px;
    padding: 7px
}

.shop-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 9px;
    align-items: center;
    border: 1px solid #dae7d7;
    background: #eff6e9;
    border-radius: 14px;
    padding: 10px
}

.shop-item h3 {
    margin: 0;
    font-size: 15px
}

.shop-item .shop-effect {
    margin: 4px 0 0;
    font-size: 13px;
    line-height: 1.4
}

.shop-item .shop-level {
    display: block;
    font-size: 12px;
    font-weight: 850;
    margin-top: 3px;
    color: #386352
}

#shop .shop-item button {
    min-width: 82px;
    font-size: 13px;
    padding: 6px 8px;
    min-height: 39px
}

.shop-item button:disabled {
    background: #e2eadb;
    color: #456253;
    border-color: #cedcc9;
    box-shadow: none;
    transform: none
}

#shop-status {
    margin: 8px 0 0;
    min-height: 1.75em
}

.hud {
    display: grid;
    grid-template-columns: 1fr 1.05fr 1fr;
    gap: 7px;
    margin-bottom: 7px
}

.stat {
    border: 1px solid #e1ebe2;
    background: #f3f8f0;
    border-radius: 16px;
    text-align: center;
    min-width: 0;
    padding: 6px 4px 5px
}

.stat.time {
    background: #e7f3dd;
    border-color: #dbeace
}

.stat.urgent {
    background: #ffe9dc;
    border-color: #f8d8c8;
    color: #9a412d
}

.stat-label {
    display: block;
    font-size: 12px;
    letter-spacing: .095em;
    color: var(--dim);
    font-weight: 850;
    line-height: 1.15
}

.stat strong {
    display: block;
    font-size: 28px;
    font-weight: 950;
    line-height: 1.04;
    letter-spacing: .005em;
    margin-top: 2px;
    font-variant-numeric: tabular-nums
}

.stat small {
    font-size: 12px;
    margin-left: 3px;
    font-weight: 850
}

.pond {
    position: relative;
    border-radius: 19px;
    overflow: hidden;
    isolation: isolate;
    background: #0b3434
}

.game-board {
    display: block;
    width: 100%;
    height: auto;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    outline-offset: -4px !important
}

.track {
    position: absolute;
    z-index: 2;
    left: 15px;
    right: 15px;
    top: 11px;
    height: 4px;
    border-radius: 9px;
    background: #b6ecbd31;
    pointer-events: none;
    overflow: hidden
}

.track span {
    display: block;
    height: 100%;
    width: 100%;
    border-radius: 9px;
    background: #bff486;
    transform-origin: left
}

.urgent-track span {
    background: #ffae8f
}

.veil {
    position: absolute;
    z-index: 3;
    inset: 0;
    display: grid;
    place-items: center;
    background: #092e3082;
    padding: 20px;
    overflow: auto
}

.overlay {
    text-align: center;
    width: min(100%, 320px);
    background: #f6fbef;
    color: var(--ink);
    padding: 16px 19px;
    border-radius: 24px;
    box-shadow: 0 14px 35px #061f2763;
    border: 1px solid #ffffffd9
}

.overlay h2 {
    margin: 0;
    font-size: 25px;
    letter-spacing: -.035em;
    line-height: 1.25
}

.overlay p {
    margin: 8px 0 16px;
    font-size: 13px;
    color: #406657;
    line-height: 1.65;
    font-weight: 700
}

.veil.counting-down {
    background: transparent
}

.veil.has-ad {
    display: block;
    padding: 8px;
    touch-action: manipulation;
    overflow-anchor: none
}

.start-countdown {
    display: grid;
    place-items: center;
    width: clamp(96px, 32vw, 132px);
    aspect-ratio: 1;
    border-radius: 50%;
    background: #f6fbef
}

.start-countdown strong {
    font-size: clamp(60px, 12vw, 88px);
    font-weight: 900;
    line-height: 1;
    color: #25644a;
    font-variant-numeric: tabular-nums
}

.overlay-logo {
    width: 66px;
    height: 47px;
    display: block;
    margin: -3px auto 6px
}

.primary {
    min-height: 45px;
    padding: 8px 16px;
    border-radius: 13px;
    background: #c6f471;
    color: #21452f;
    border: 1px solid #a9d559;
    box-shadow: 0 3px 0 #9bc857;
    font-weight: 950;
    font-size: 16px;
    letter-spacing: .04em
}

.primary:hover {
    background: #d7fa9b
}

.primary:active {
    transform: translateY(2px);
    box-shadow: 0 1px 0 #9bc857
}

.overlay .primary {
    width: 100%
}

.result-score {
    display: block;
    font-size: 44px;
    line-height: 1.05;
    margin: 8px 0 4px;
    font-weight: 950;
    font-variant-numeric: tabular-nums
}

.result-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    margin: 12px 0 14px
}

.result-info div {
    border-radius: 10px;
    background: #e6efde;
    padding: 6px 4px;
    font-size: 11px;
    line-height: 1.4;
    font-weight: 800
}

.result-info b {
    display: block;
    font-size: 18px
}

.result-record {
    margin: 3px 0 6px !important
}

.controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding: 6px 1px 0
}

.chain-readout {
    font-size: 13px;
    font-weight: 900;
    color: #396054;
    padding-left: 4px;
    white-space: nowrap
}

.chain-readout strong {
    font-size: 17px;
    margin: 0 2px;
    font-variant-numeric: tabular-nums
}

.control-group {
    display: flex;
    gap: 5px
}

.control {
    min-height: 34px;
    padding: 3px 10px;
    border-radius: 10px;
    border: 1px solid #dfe9dc;
    background: #f4f8ee;
    font-size: 12px;
    font-weight: 850;
    white-space: nowrap
}

.control:not(:disabled):hover {
    background: #e4f1dc
}

.control:disabled {
    color: #526e60;
    background: #f4f8ee;
    opacity: .66
}

.shuffle-icon {
    font-size: 14px
}

.pause-icon {
    display: inline-block;
    width: 8px;
    height: 10px;
    margin-right: 3px;
    border-left: 2px solid currentColor;
    border-right: 2px solid currentColor
}

.instructions,
.ranking {
    grid-column: 2;
    min-width: 0;
    margin-top: 9px;
    padding: 11px 13px;
    background: #fbfdf8;
    border: 1px solid #d4e4d8;
    border-radius: 16px
}

.instructions h2 {
    margin: 0 0 6px;
    font-size: 17px
}

.instructions ul {
    margin: 0;
    padding-left: 1.35em;
    font-size: 13px;
    line-height: 1.55;
    color: var(--dim)
}

.instructions li+li {
    margin-top: 4px
}

.instructions p {
    margin: 7px 0 0;
    font-size: 12px;
    line-height: 1.55;
    color: var(--dim)
}

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

.ranking p,
.ranking label {
    font-size: 13px;
    color: var(--dim)
}

.ranking form {
    display: grid;
    gap: 6px;
    margin-bottom: 10px
}

.ranking-fields {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px
}

.ranking input {
    width: 100%;
    min-width: 0;
    padding: 7px 10px;
    border: 1px solid #c8dccb;
    border-radius: 10px;
    background: #fff;
    color: var(--ink);
    font: inherit;
    font-size: 16px
}

.ranking input[readonly] {
    background: #edf5e9
}

.ranking .tool:disabled {
    opacity: .65
}

.ranking table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    font-size: 14px;
    font-variant-numeric: tabular-nums
}

.ranking th,
.ranking td {
    text-align: left;
    padding: 6px 4px;
    border-bottom: 1px solid var(--line);
    overflow-wrap: anywhere
}

.ranking th:first-child {
    width: 3em
}

.ranking th:last-child,
.ranking td:last-child {
    text-align: right
}

.ranking th:last-child {
    width: 38%
}

#ranking-message {
    margin: 0;
    min-height: 1.5em
}

#result-ranking {
    text-decoration: none
}

.footer {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    text-align: center;
    margin-top: 0;
    padding: 7px 0 10px;
    border-top: 1px solid #d6e4db;
    font-size: 12px;
    color: #506e64;
    gap: 10px
}

.footer a {
    color: #336c58;
    font-weight: 750;
    text-underline-offset: 3px
}

dialog {
    width: min(430px, calc(100% - 28px));
    border: 1px solid #d4e4d8;
    border-radius: 22px;
    padding: 24px;
    background: #f9fcf5;
    color: var(--ink);
    box-shadow: 0 14px 45px #0a2b3444
}

dialog::backdrop {
    background: #0d3a37a6
}

dialog h2 {
    font-size: 23px;
    margin: 0 0 13px
}

dialog p {
    color: var(--dim);
    font-size: 13px;
    line-height: 1.75;
    margin: 10px 0 16px
}

dialog .primary {
    min-width: 115px
}

@media(max-width:790px) {
    .shell {
        width: min(650px, calc(100% - 34px))
    }

    main {
        display: flex;
        flex-direction: column;
        align-items: center;
        padding: 8px 0
    }

    .intro {
        display: none
    }

    .machine,
    .instructions,
    .ranking {
        width: min(100%, 480px, max(300px, calc((100svh - 205px) * .907 + 28px)))
    }
}

@media(max-width:450px) {
    .shell {
        width: calc(100% - 20px)
    }

    .tool {
        font-size: 12px;
        padding: 0 7px;
        gap: 5px;
        min-height: 34px
    }

    #shop {
        padding-inline: 14px
    }

    #shop-title {
        font-size: clamp(16px, 5vw, 23px)
    }

    main {
        padding: 6px 0
    }

    .machine {
        border-radius: 20px;
        padding: 8px
    }

    .hud {
        gap: 5px;
        margin-bottom: 7px
    }

    .stat {
        border-radius: 11px;
        padding: 6px 2px
    }

    .stat-label {
        font-size: 11px
    }

    .stat strong {
        font-size: 24px
    }

    .pond {
        border-radius: 13px
    }

    .controls {
        padding-top: 7px
    }

    .track {
        top: 8px
    }

    .control {
        min-height: 40px
    }

    .footer {
        font-size: 11px
    }
}

@media(prefers-reduced-motion:reduce) {
    .primary:active {
        transform: none
    }
}
