:root {
    color-scheme: light;
    --forest-bg-deep: #0f2418;
    --forest-bg-mid: #1a3928;
    --forest-bg-soft: #2e5a3f;
    --mist: rgba(197, 234, 196, 0.24);
    --card: rgba(238, 246, 230, 0.9);
    --card-border: rgba(183, 222, 171, 0.45);
    --ink: #102117;
    --ink-quiet: #2d4738;
    --accent: #2f7b4e;
    --accent-strong: #1f5f3a;
    --contrast-scrim: rgba(7, 18, 12, 0.5);
    --glow: rgba(159, 228, 154, 0.35);
    --radius: 14px;
    --shadow: 0 12px 32px rgba(7, 23, 13, 0.22);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Trebuchet MS", "Segoe UI", sans-serif;
    color: var(--ink);
    background: linear-gradient(180deg, #bcd9bf 0%, #98c08f 35%, #6fa07a 100%);
    min-height: 100vh;
}

.app-body {
    position: relative;
    overflow-x: hidden;
}

.forest-scene {
    position: fixed;
    inset: 0;
    z-index: -2;
    pointer-events: none;
    overflow: hidden;
    background:
        radial-gradient(90% 60% at 50% 0%, rgba(210, 255, 203, 0.35), transparent 70%),
        linear-gradient(180deg, var(--forest-bg-soft), var(--forest-bg-mid) 45%, var(--forest-bg-deep));
}

.scene-static .mist-layer,
.scene-static .tree-back,
.scene-static .tree-mid,
.scene-static .firefly-layer {
    animation: none !important;
}

.scene-animated .mist-layer,
.scene-animated .tree-back,
.scene-animated .tree-mid,
.scene-animated .firefly-layer {
    animation-play-state: running;
}

.mist-layer,
.tree-layer,
.firefly-layer {
    position: absolute;
    inset: -4%;
}

.mist-layer {
    background: radial-gradient(circle at 30% 25%, var(--mist), transparent 55%),
        radial-gradient(circle at 75% 35%, rgba(196, 233, 187, 0.16), transparent 56%);
    filter: blur(6px);
    animation: drift-mist 24s linear infinite alternate;
}

.tree-layer {
    opacity: 0.26;
    background-repeat: repeat-x;
    background-size: 360px 100%;
    mix-blend-mode: multiply;
}

.tree-back {
    background-image: radial-gradient(ellipse at 50% 105%, rgba(16, 44, 25, 0.72) 30%, transparent 32%),
        radial-gradient(ellipse at 30% 100%, rgba(20, 57, 32, 0.65) 28%, transparent 31%),
        radial-gradient(ellipse at 70% 100%, rgba(18, 53, 30, 0.64) 26%, transparent 30%);
    animation: pan-trees 62s linear infinite;
}

.tree-mid {
    opacity: 0.35;
    background-image: radial-gradient(ellipse at 40% 100%, rgba(12, 42, 22, 0.84) 29%, transparent 31%),
        radial-gradient(ellipse at 80% 100%, rgba(10, 36, 19, 0.74) 25%, transparent 29%);
    animation: pan-trees 38s linear infinite reverse;
}

.firefly-layer {
    background-image:
        radial-gradient(circle, rgba(190, 255, 187, 0.5) 1px, transparent 2px),
        radial-gradient(circle, rgba(218, 255, 213, 0.55) 1px, transparent 2px);
    background-size: 180px 180px, 220px 220px;
    background-position: 0 0, 90px 60px;
    opacity: 0.22;
    animation: sparkle 12s ease-in-out infinite alternate;
}

h1,
h2,
h3 {
    margin: 0.2rem 0 0.7rem;
}

.subtitle {
    margin: 0;
}

.stage-layout {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 2rem 1rem;
    position: relative;
    z-index: 1;
}

.stage-shell {
    width: min(1080px, 100%);
    min-height: 620px;
    border: 2px solid rgba(58, 88, 62, 0.45);
    border-radius: 18px;
    background: rgba(246, 250, 241, 0.9);
    box-shadow: var(--shadow);
    backdrop-filter: blur(2px);
    padding: 1.1rem;
    display: grid;
    grid-template-columns: 86px 1fr 260px;
    grid-template-rows: auto 1fr auto;
    grid-template-areas:
        "ambient top utility"
        "ambient center right"
        "ambient bottom right";
    gap: 0.85rem;
}

.ambient-rail {
    grid-area: ambient;
    border-right: 1px dashed rgba(76, 123, 84, 0.4);
    padding-right: 0.65rem;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
}

.rail-label {
    margin: 0.15rem 0 0.3rem;
    font-size: 0.72rem;
    color: var(--ink-quiet);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.ambient-choice {
    width: 100%;
    min-height: 44px;
    border-radius: 10px;
    border: 1px solid rgba(61, 93, 76, 0.55);
    color: #08341f;
    font-size: 0.76rem;
    font-weight: 700;
    text-align: left;
    padding: 0.18rem 0.3rem;
    background: linear-gradient(180deg, #dcefdc, #cce4d1);
    display: flex;
    align-items: center;
    gap: 0.2rem;
    margin: 0.08rem 0;
}

.ambient-icon {
    width: 36px;
    height: 36px;
    object-fit: contain;
    flex: 0 0 auto;
}

.ambient-choice:nth-of-type(2) {
    background: linear-gradient(180deg, #d9eeff, #cde3f7);
}

.ambient-choice:nth-of-type(3) {
    background: linear-gradient(180deg, #eadbff, #decdf4);
}

.ambient-choice:nth-of-type(4) {
    background: linear-gradient(180deg, #f3efe7, #e6dfd2);
}

.ambient-choice.active {
    transform: translateX(3px);
    border-color: #1a6c3f;
    box-shadow: inset 0 0 0 2px rgba(206, 255, 215, 0.82);
}

.stage-top {
    grid-area: top;
    display: flex;
    justify-content: space-between;
    gap: 0.9rem;
    align-items: flex-start;
}

.stage-brand {
    color: #122a1a;
}

.utility-actions {
    grid-area: utility;
    display: flex;
    gap: 0.45rem;
    align-items: center;
}

.icon-btn {
    width: auto;
    padding: 0.2rem 0.32rem;
    background: rgba(222, 236, 223, 0.95);
    border: 1px solid rgba(83, 119, 92, 0.52);
    color: #163124;
    font-size: 0.82rem;
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    margin: 0.08rem 0;
}

.button-icon {
    width: 28px;
    height: 28px;
    object-fit: contain;
    flex: 0 0 auto;
}

.icon-text {
    max-width: 0;
    opacity: 0;
    overflow: hidden;
    white-space: nowrap;
    transition: max-width 160ms ease, opacity 160ms ease;
}

.ambient-choice:hover .icon-text,
.ambient-choice:focus-visible .icon-text,
.icon-btn:hover .icon-text,
.icon-btn:focus-visible .icon-text {
    max-width: 11rem;
    opacity: 1;
}

.stage-center {
    grid-area: center;
    display: grid;
    gap: 0.5rem;
    align-content: start;
    justify-items: center;
    padding: 0.2rem 0.8rem 0;
}

.center-message {
    text-align: center;
}

.stage-center label {
    font-weight: 700;
}

.stage-actions {
    width: min(340px, 100%);
}

.inline-settings {
    width: min(360px, 100%);
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem 0.6rem;
    align-items: center;
}

.inline-settings label {
    font-size: 0.82rem;
    color: var(--ink-quiet);
}

.stage-right {
    grid-area: right;
    background: rgba(237, 246, 233, 0.84);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 0.7rem;
    display: grid;
    gap: 0.45rem;
    align-content: start;
}

.dock-title {
    margin-bottom: 0.2rem;
    font-size: 1.02rem;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.stage-bottom {
    grid-area: bottom;
    border-top: 1px dashed rgba(90, 132, 98, 0.45);
    padding-top: 0.55rem;
}

.status-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.9rem;
}

.panel-shell {
    background: rgba(234, 245, 230, 0.82);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 0.65rem;
}

.utility-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(6, 14, 10, 0.55);
    backdrop-filter: blur(1px);
    z-index: 20;
}

.utility-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(680px, calc(100vw - 1.4rem));
    max-height: calc(100vh - 1.4rem);
    overflow: auto;
    z-index: 21;
    box-shadow: 0 20px 34px rgba(7, 23, 13, 0.3);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.55rem;
}

.modal-close {
    width: auto;
    margin: 0;
    padding: 0.45rem 0.75rem;
    background: rgba(43, 90, 58, 0.95);
}

input,
select,
button {
    width: 100%;
    margin: 0.35rem 0;
    padding: 0.55rem 0.65rem;
    border-radius: 8px;
    border: 1px solid #8ead93;
    font-size: 0.95rem;
}

button {
    background: var(--accent);
    color: #fff;
    border: none;
    cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: 2px solid #d6ffd6;
    outline-offset: 1px;
}

button:hover {
    filter: brightness(1.05);
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.button-row {
    display: grid;
    gap: 0.4rem;
}

.row {
    margin: 0.5rem 0;
}

.timer {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: #f6ffef;
    text-shadow: 0 2px 16px rgba(5, 13, 8, 0.68);
    background: var(--contrast-scrim);
    display: inline-block;
    padding: 0.12rem 0.46rem;
    border-radius: 8px;
}

.state {
    font-weight: 700;
}

.hint {
    color: var(--ink-quiet);
    font-size: 0.9rem;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.log-scene {
    position: relative;
    width: min(440px, 100%);
    justify-self: center;
    min-height: 112px;
    margin: 0.55rem auto 0.45rem;
    border-radius: 12px;
    background: linear-gradient(180deg, rgba(176, 227, 170, 0.25), rgba(57, 96, 61, 0.28));
    border: 1px solid rgba(70, 122, 72, 0.35);
    overflow: hidden;
}

.log-base {
    position: absolute;
    left: 8%;
    right: 8%;
    bottom: 14px;
    height: 26px;
    border-radius: 999px;
    background: linear-gradient(180deg, #7a5c3d, #584129);
    box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.2), inset 0 -6px 10px rgba(38, 21, 9, 0.38);
}

.log-scene-asset {
    position: absolute;
    width: 124px;
    height: 72px;
    left: 50%;
    transform: translateX(-50%);
    bottom: 18px;
    object-fit: contain;
    z-index: 1;
    pointer-events: none;
}

.scene-mushrooms {
    position: absolute;
    inset: 0;
}

.mushroom {
    position: absolute;
    bottom: 28px;
    width: 16px;
    height: 24px;
    transform-origin: bottom center;
}

.mushroom::before,
.mushroom::after {
    content: "";
    position: absolute;
    display: block;
}

.mushroom::before {
    left: 5px;
    bottom: 0;
    width: 6px;
    height: 12px;
    border-radius: 6px;
    background: #f4eed8;
}

.mushroom::after {
    left: 0;
    bottom: 10px;
    width: 16px;
    height: 11px;
    border-radius: 10px 10px 7px 7px;
}

.mushroom.sprout::after {
    background: #d39c69;
}

.mushroom.amber::after {
    background: #c98644;
}

.mushroom.bell::after {
    background: #98bc70;
}

.mushroom.moon::after {
    background: #7aa9ce;
}

.mushroom.crown::after {
    background: #b787d6;
}

.mushroom.rare::after {
    box-shadow: 0 0 8px 1px rgba(210, 255, 192, 0.75);
}

.consistency-accent {
    position: absolute;
    top: 6px;
    right: 8px;
    font-size: 0.7rem;
    color: #225330;
    background: rgba(230, 251, 224, 0.7);
    border: 1px solid rgba(85, 142, 83, 0.46);
    border-radius: 999px;
    padding: 0.16rem 0.5rem;
}

.consistency-accent.active {
    background: rgba(196, 255, 188, 0.85);
    box-shadow: 0 0 10px var(--glow);
}

.shield-body {
    color: #edf5ea;
}

.shield {
    min-height: 100vh;
    display: grid;
    place-content: center;
    text-align: center;
    gap: 0.7rem;
    padding: 1rem;
}

.scenic-surface {
    position: relative;
    z-index: 2;
}

.scenic-surface::before {
    content: "";
    position: absolute;
    inset: 16%;
    border-radius: 18px;
    background: rgba(8, 21, 12, 0.45);
    z-index: -1;
    box-shadow: 0 18px 35px rgba(0, 0, 0, 0.35);
}

.shield .timer {
    font-size: min(20vw, 8rem);
}

.shield .hint {
    color: #d4ead1;
    background: rgba(9, 23, 13, 0.66);
    border: 1px solid rgba(124, 169, 126, 0.35);
    border-radius: 8px;
    padding: 0.35rem 0.55rem;
}

@keyframes pan-trees {
    from {
        transform: translateX(0);
    }

    to {
        transform: translateX(-360px);
    }
}

@keyframes drift-mist {
    from {
        transform: translateX(-2%) translateY(0);
    }

    to {
        transform: translateX(2%) translateY(1%);
    }
}

@keyframes sparkle {
    from {
        opacity: 0.12;
    }

    to {
        opacity: 0.26;
    }
}

@media (prefers-reduced-motion: reduce) {

    .mist-layer,
    .tree-back,
    .tree-mid,
    .firefly-layer {
        animation: none !important;
    }
}

@media (max-width: 600px) {
    .stage-layout {
        padding: 0.65rem;
    }

    .stage-shell {
        grid-template-columns: 1fr;
        grid-template-rows: auto;
        grid-template-areas:
            "top"
            "ambient"
            "center"
            "right"
            "bottom"
            "utility";
        min-height: auto;
    }

    .ambient-rail {
        border-right: none;
        border-bottom: 1px dashed rgba(76, 123, 84, 0.4);
        padding-right: 0;
        padding-bottom: 0.55rem;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .rail-label {
        grid-column: 1 / -1;
    }

    .stage-top {
        flex-direction: column;
        align-items: flex-start;
    }

    .utility-actions {
        width: 100%;
    }

    .icon-btn {
        flex: 1;
    }

    .icon-text {
        max-width: 9rem;
        opacity: 1;
    }

    .utility-modal {
        width: calc(100vw - 1rem);
        max-height: calc(100vh - 1rem);
    }

    .timer {
        font-size: 1.6rem;
    }

    .tree-mid,
    .firefly-layer {
        display: none;
    }

    .scenic-surface::before {
        inset: 12%;
    }
}

@media (max-height: 620px) {

    .tree-mid,
    .firefly-layer {
        display: none;
    }
}