/* ProjectBloom UI. Placement is controlled in scene.js. */
* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: #222e22;
    color: #443820;
    font-family: system-ui, sans-serif;
}

main {
    display: flex;
    min-height: 100dvh;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0;
}

#screen {
    position: relative;
    width: min(100vw, 318px, calc(100dvh * 0.641129));
    aspect-ratio: 318 / 496;
    overflow: hidden;
    background: #cba959;
    isolation: isolate;
}

#garden-scene,
#garden-foreground,
#harvest-effects,
#buttons {
    position: absolute;
    inset: 0;
}

#garden-scene { z-index: 1; }
#garden-foreground { z-index: 2; pointer-events: none; }
#harvest-effects { z-index: 3; pointer-events: none; }
#buttons { z-index: 5; pointer-events: none; }

#top-tools {
    position: absolute;
    z-index: 7;
    top: 7px;
    right: 7px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 5px;
}

.top-tool {
    display: grid;
    place-items: center;
    width: 29px;
    height: 29px;
    padding: 5px;
    border: 2px solid #725632;
    border-radius: 8px;
    background: #f3dfae;
    color: #443820;
    box-shadow: 0 2px 0 #48322255;
    cursor: pointer;
}

.top-tool svg {
    display: block;
    width: 100%;
    height: 100%;
}

/* Optional user-provided artwork replaces the built-in SVG. */
.top-tool .top-tool-texture {
    display: none;
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
}

.top-tool.has-texture {
    border: 0;
    padding: 0;
    background: transparent;
    box-shadow: none;
}

.top-tool.has-texture svg {
    display: none;
}

.top-tool.has-texture .top-tool-texture {
    display: block;
}

.top-tool.has-texture[aria-expanded="true"] {
    background: transparent;
    box-shadow: none;
    filter: brightness(1.13);
}

.top-tool[aria-expanded="true"] {
    background: #ffefc4;
    box-shadow: inset 0 1px 3px #76533355;
}

.top-tool:focus-visible {
    outline: 2px solid #fff6d0;
    outline-offset: 2px;
}

/* The soil mounds are permanent scene objects, not plant children. */
#garden-backdrop,
#garden-plants,
#garden-beds,
#garden-labels {
    position: absolute;
    inset: 0;
}

/* Texture strata always win across slots: labels > soil > plants. */
#garden-backdrop {
    z-index: 0;
    pointer-events: none;
}

#garden-plants {
    z-index: 1;
}

#garden-beds {
    z-index: 2;
    pointer-events: none;
}

#garden-labels {
    z-index: 3;
    pointer-events: none;
}

.plant-label-anchor {
    position: absolute;
    pointer-events: none;
    overflow: visible;
}

.texture {
    position: absolute;
    background-repeat: no-repeat;
    background-position: center bottom;
    background-size: contain;
    pointer-events: none;
}

.background-texture,
.foreground-texture {
    background-size: 100% 100%;
}

.plant {
    position: absolute;
    cursor: default;
    text-align: center;
    transform-origin: center bottom;
}

/* Growing plants are interactive only when a target action is selected. */
.plant.plant-selectable {
    cursor: pointer;
}

.plant.plant-selectable:focus-visible {
    outline: 2px solid #fff1a2;
    outline-offset: 2px;
}

.plant .texture {
    inset: 0;
}

.plant .fallback-plant {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: end center;
    padding-bottom: 8px;
    font-size: 35px;
    pointer-events: none;
}

.plant-cover {
    position: absolute;
    display: block;
    object-fit: fill;
    opacity: 1;
    pointer-events: none;
    user-select: none;
}

/* Dev-only overlay: run bloom.debugBeds() to reveal each bed's box. */
#garden-beds.debug-beds .plant-cover {
    outline: 2px dashed #d500b0;
    background: #d500b040;
}

.owner {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    max-width: 115px;
    overflow: hidden;
    padding: 2px 4px;
    border-radius: 5px;
    background: #fff3c8e8;
    font-size: 10px;
    line-height: 1.1;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
    pointer-events: none;
}

.plant-boosts {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    gap: 5px;
    min-height: 13px;
    color: #4b341c;
    font-variant-numeric: tabular-nums;
}

.plant-boost {
    display: inline-flex;
    align-items: center;
    gap: 1px;
    font-size: 10px;
    line-height: 1;
    font-weight: 800;
}

.plant-boost img,
.plant-boost-glyph {
    display: inline-block;
    width: 13px;
    height: 13px;
    object-fit: contain;
    vertical-align: middle;
    font-size: 12px;
}

.scene-button {
    position: absolute;
    display: block;
    padding: 0;
    margin: 0;
    border: 0;
    outline-offset: 3px;
    background: transparent;
    cursor: pointer;
    pointer-events: auto;
    -webkit-tap-highlight-color: transparent;
}

.scene-button img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.scene-button:active img {
    transform: translateY(2px) scale(0.96);
}

.scene-button[aria-expanded="true"] img {
    filter: brightness(1.12);
}

#panel {
    position: absolute;
    z-index: 4;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 12px;
    background: #f3dfae;
    border: 3px solid #795b39;
    border-radius: 12px;
    box-shadow: 0 5px 20px #4434;
}

#panel[hidden] {
    display: none;
}

#panel-title {
    margin: 0 0 8px;
    font-size: 17px;
    font-weight: 750;
    text-align: left;
}

#panel-body {
    display: flex;
    min-height: 0;
    flex: 1;
    flex-direction: column;
}

#panel-body input {
    width: 100%;
    margin-bottom: 8px;
    padding: 8px;
}

#message {
    position: absolute;
    z-index: 6;
    top: 8px;
    right: 15%;
    left: 15%;
    padding: 5px;
    border-radius: 8px;
    background: #f8e6b9e8;
    font-size: 12px;
    text-align: center;
    opacity: 0;
    pointer-events: none;
}

/* Seed Store: compact icon + price button cards, scroll vertically. */
.seed-store-grid {
    display: grid;
    flex: 1;
    min-height: 0;
    align-content: start;
    grid-template-columns: repeat(var(--shop-columns, 2), minmax(0, 1fr));
    gap: 9px;
    overflow-y: auto;
    overscroll-behavior: contain;
    touch-action: pan-y;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    padding: 2px 3px 10px;
}

.seed-store-card {
    display: flex;
    min-width: 0;
    aspect-ratio: 0.95;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    padding: 4px;
    border: 0;
    border-radius: 0;
    background: transparent;
}

.seed-store-icon {
    display: flex;
    flex: 1;
    min-height: 0;
    width: 100%;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.seed-store-icon img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.seed-store-icon .fallback-icon {
    font-size: 39px;
    line-height: 1;
}

.seed-store-buy {
    flex: 0 0 auto;
    flex-shrink: 0;
    width: 90%;
    min-height: 29px;
    padding: 4px 6px;
    border: 0;
    border-radius: 999px;
    color: #493819;
    background: #d8b678;
    font-size: 12px;
    font-weight: 800;
    cursor: pointer;
}

.seed-store-buy:active {
    transform: translateY(1px);
}

.seed-store-buy:focus-visible {
    outline: 2px solid #2e542a;
    outline-offset: 2px;
}

/* Notebook UI: all menus use the Harvest parchment title and framed board. */
.shop-header .shop-title-block {
    flex: 0 0 auto;
    min-width: 80px;
    width: auto;
    padding: 4px 12px;
    white-space: nowrap;
}

.shop-shell .shop-board {
    padding: 8px 7px;
}

.action-shop-grid .seed-store-card {
    aspect-ratio: auto;
    min-height: 133px;
    justify-content: center;
}

.action-shop-grid .seed-store-icon {
    flex: 0 0 67px;
    height: 67px;
}

.action-shop-description {
    display: flex;
    min-height: 2.5em;
    align-items: center;
    justify-content: center;
    color: #493819;
    font-size: 11px;
    font-weight: 650;
    line-height: 1.2;
    text-align: center;
}

.action-shop-single {
    grid-template-columns: minmax(0, 1fr);
}

.action-shop-single .seed-store-card {
    width: min(100%, 190px);
    justify-self: center;
}

/* Harvest notebook: a single board, seven icons along the top edge. */
#panel.notebook-mode {
    border: 0;
    border-radius: 0;
    padding: 0;
    background: transparent;
    box-shadow: none;
}

#panel-title[hidden] {
    display: none;
}

.harvest-shell {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-height: 0;
}

.harvest-header {
    display: flex;
    flex: 0 0 41px;
    align-items: flex-end;
    gap: 2px;
    min-width: 0;
}

.harvest-title-block {
    display: flex;
    flex: 0 0 72px;
    align-items: center;
    justify-content: center;
    height: 34px;
    padding: 4px 2px;
    border: 2px solid #5a422a;
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    background: #f4dfaa;
    color: #392817;
    font-size: 14px;
    font-weight: 900;
}

.harvest-tabs {
    display: flex;
    flex: 1;
    gap: 2px;
    align-items: flex-end;
    min-width: 0;
    height: 41px;
    overflow: hidden;
}

.harvest-tab {
    position: relative;
    display: flex;
    flex: 1 1 0;
    align-items: center;
    justify-content: center;
    min-width: 0;
    height: 37px;
    padding: 2px 1px 0;
    border: 1px solid #aa8b59;
    border-bottom: 0;
    border-radius: 7px 7px 0 0;
    background: #ead3a4;
    cursor: pointer;
    transform-origin: bottom center;
}

.harvest-tab img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.harvest-tab .fallback-icon {
    font-size: 22px;
}

.harvest-tab[aria-selected="true"] {
    height: 40px;
    background: #f8ebc6;
    border-color: #5a422a;
    filter: brightness(1.04);
}

.harvest-tab[aria-selected="true"]::after {
    position: absolute;
    right: 13%;
    bottom: 0;
    left: 13%;
    height: 3px;
    border-radius: 4px;
    background: #5a422a;
    content: "";
}

.harvest-board {
    display: flex;
    flex: 1;
    min-height: 0;
    flex-direction: column;
    overflow: hidden;
    padding: 9px 7px;
    border: 3px solid #5a422a;
    border-radius: 3px 3px 9px 9px;
    background: #f8ebc6;
}

.harvest-grid {
    display: grid;
    flex: 1;
    min-height: 0;
    align-content: start;
    grid-template-columns: repeat(var(--harvest-columns, 3), minmax(0, 1fr));
    gap: 8px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    touch-action: pan-y;
    -webkit-overflow-scrolling: touch;
    padding: 2px 3px 8px;
    scrollbar-width: thin;
}

.harvest-card {
    display: flex;
    min-width: 0;
    aspect-ratio: 0.82;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2px;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}

.harvest-card img,
.harvest-card .fallback-icon {
    display: block;
    width: 100%;
    flex: 1;
    min-height: 0;
    object-fit: contain;
    text-align: center;
    font-size: 38px;
}

/* Harvest cards preserve both the rolled points and the boosted ceiling. */
.harvest-card .plant-boosts {
    margin-top: 2px;
}

.harvest-score {
    flex: 0 0 auto;
    min-width: 34px;
    margin-top: 2px;
    padding: 2px 6px;
    border-radius: 999px;
    background: #d8b678;
    color: #493819;
    font-size: 12px;
    font-weight: 800;
    text-align: center;
    white-space: nowrap;
}

.empty-harvests {
    padding: 12px 4px;
    color: #5a422a;
    font-size: 13px;
    text-align: center;
}

/* Pull-up, glow and a slow fade on harvest; no image assets required. */
.harvest-ghost {
    position: absolute;
    pointer-events: none;
    transform-origin: center bottom;
    isolation: isolate;
}

.harvest-ghost .plant-texture {
    z-index: 1;
}

/* Attached to the flying sprite, above its texture and glow. */
.harvest-ghost .owner {
    z-index: 4;
}

.harvest-glow {
    position: absolute;
    z-index: 0;
    top: 14%;
    bottom: 13%;
    left: -15%;
    right: -15%;
    border-radius: 50%;
    background: radial-gradient(ellipse, #fff9b9bd 0%, #eaff9b85 35%, #fff4a400 75%);
    filter: blur(8px);
    opacity: 0.85;
    pointer-events: none;
    animation: harvest-glow-pulse 1350ms ease-in-out infinite alternate;
}

@keyframes harvest-glow-pulse {
    from { transform: scale(.85); opacity: .55; }
    to { transform: scale(1.13); opacity: 1; }
}

.harvest-sparkle {
    position: absolute;
    z-index: 3;
    width: 35px;
    height: 15px;
    border-radius: 50%;
    border: 3px solid #fff6b6;
    pointer-events: none;
    opacity: 0;
}

/* Leaderboard and future Twitch connection status share the notebook layout. */
.leaderboard-title {
    flex-basis: 73px;
    font-size: 13px;
}

.leaderboard-list {
    flex: 1;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    padding: 2px 3px 8px;
}

.leaderboard-help {
    margin: 4px 2px 9px;
    color: #765c36;
    font-size: 11px;
    text-align: center;
}

.leaderboard-entry {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 5px;
    border-bottom: 1px solid #d8c292;
    font-size: 13px;
}

.leaderboard-entry:last-child {
    border-bottom: none;
}

.leaderboard-rank {
    flex: 0 0 26px;
    color: #866b3f;
    font-weight: 800;
}

.leaderboard-owner {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 750;
}

.leaderboard-entry .harvest-score {
    margin-top: 0;
    font-size: 13px;
}

.utility-body {
    display: flex;
    flex: 1;
    min-height: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    padding: 2px 3px 9px;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    font-size: 12px;
}

.utility-body strong {
    margin-top: 6px;
}

.utility-body label {
    font-weight: 750;
}

.utility-body input {
    width: 100%;
    min-height: 30px;
    margin: 0;
    border: 1px solid #bba174;
    border-radius: 5px;
    background: #fff7df;
    color: #493819;
}

.utility-body .settings-save {
    width: 100%;
    min-height: 30px;
    margin-bottom: 4px;
}

.utility-status,
.utility-credit {
    margin: 1px 0 5px;
    line-height: 1.5;
}

.utility-credit {
    font-weight: 750;
}

.utility-loading {
    padding: 12px;
    text-align: center;
    font-size: 12px;
}

/* Confirmed Bits rewards are durable credits, never invisible lost exchanges. */
.bits-pending {
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-size: 11px;
    color: #493819;
    background: #fff3c8;
    border-radius: 7px;
}
.bits-pending-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 4px;
}
.bits-pending-row .seed-store-buy {
    width: auto;
    min-height: 25px;
    font-size: 10px;
}
.seed-store-buy:disabled {
    cursor: not-allowed;
    opacity: 0.72;
}

/* Small, explicitly marked off-site policy links in the Settings panel. */
.settings-legal-links {
    display: flex;
    flex-wrap: wrap;
    gap: 7px 12px;
    margin-top: 3px;
    font-size: 11px;
}
.settings-legal-links a {
    color: #4e4636;
    font-weight: 650;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.settings-legal-links a:focus-visible {
    outline: 2px solid #644b27;
    outline-offset: 2px;
}
