/* Farm's look; everything else is shared/game/game-ui.css (loaded first). */
:root{
    --bg: #6fbf4a;
    --title: #fff1a8;
    --outline: #4a2c12;
    --panel: rgba(40, 70, 25, .55);
    --panel-center: rgba(40, 70, 25, .7);
    --panel-edge: rgba(40, 70, 25, .2);
    --dialog: #fff8e7;
    --wood: #8a5a2e;
    --wood-dark: #5a3719;
    --paper: #fff8e7;
    --ink: #4a2c12;
    --ink-muted: #8a6a48;
    --leaf: #5fb043;
    --leaf-dark: #3f8f33;
}

/* ---------- HUD: coins and level ---------- */
.stats{
    display: flex;
    flex-direction: column;
    gap: 6px;
    pointer-events: auto;
}

.stat{
    display: flex;
    align-items: center;
    gap: 6px;
    width: max-content;
    min-width: 96px;
    padding: 3px 12px 3px 4px;
    font-size: 19px;
    font-weight: bold;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
    background: var(--paper);
    border: 2px solid var(--wood);
    border-radius: 999px;
    box-shadow: 0 3px 0 var(--wood-dark), 0 6px 12px rgba(0, 0, 0, .18);
}

.stat__icon{
    width: 28px;
    height: 28px;
}

.stat--level{
    padding-right: 10px;
}

.stat__bar{
    position: relative;
    width: 64px;
    height: 10px;
    overflow: hidden;
    background: #e8dcc0;
    border-radius: 5px;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, .2);
}

.stat__bar i{
    position: absolute;
    inset: 0 auto 0 0;
    width: 0;
    background: linear-gradient(#9ce06c, #5fb043);
    border-radius: 5px;
    transition: width .5s ease-out;
}

.bump{
    animation: bump .35s ease-out;
}

@keyframes bump{
    40%{ transform: scale(1.15); }
}

.screen[data-phase="soon"] .stats{
    visibility: hidden;
}

.round{
    color: var(--ink);
    background: var(--paper);
    border: 2px solid var(--wood);
    box-shadow: 0 3px 0 var(--wood-dark);
}

/* ---------- The bottom bar ---------- */
.farmbar{
    position: absolute;
    left: 50%;
    bottom: max(12px, env(safe-area-inset-bottom));
    z-index: 1;
    display: flex;
    gap: 10px;
    transform: translateX(-50%);
    animation: rise .35s ease-out;
}

.farmbar[hidden]{
    display: none;
}

@keyframes rise{
    from{ transform: translate(-50%, 120%); }
}

.farmbar__button{
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    width: 86px;
    padding: 6px 4px 7px;
    font: bold 14px var(--font);
    color: var(--ink);
    background: var(--paper);
    border: 2px solid var(--wood);
    border-radius: 16px;
    box-shadow: 0 4px 0 var(--wood-dark), 0 8px 14px rgba(0, 0, 0, .2);
    cursor: pointer;
    transition: transform .1s;
}

.farmbar__button:active{
    transform: translateY(3px);
    box-shadow: 0 1px 0 var(--wood-dark);
}

.farmbar__button img{
    width: 36px;
    height: 36px;
}

.farmbar__badge,
.farmbar__count{
    position: absolute;
    top: -8px;
    right: -6px;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    font-size: 13px;
    line-height: 20px;
    color: #fff;
    background: #ff5a3c;
    border: 2px solid #fff;
    border-radius: 11px;
}

.farmbar__badge{
    animation: bump 1s ease-in-out infinite;
}

.farmbar__badge[hidden],
.farmbar__count[hidden]{
    display: none;
}

.farmbar__count{
    background: var(--leaf-dark);
}

/* ---------- Windows: seeds, barn, orders, shop, level up ---------- */
.farm-sheet{
    color: var(--ink);
    background: var(--paper);
    border: 3px solid var(--wood);
    box-shadow: 0 6px 0 var(--wood-dark), 0 20px 60px rgba(0, 0, 0, .45);
}

.farm-sheet[open]{
    animation: pop .25s cubic-bezier(.3, 1.5, .6, 1);
}

@keyframes pop{
    from{ transform: scale(.85); opacity: 0; }
}

.farm-sheet::backdrop{
    background: rgba(30, 40, 10, .45);
}

.farm-sheet .sheet__header{
    padding: 14px 14px 10px 18px;
    background: var(--wood);
    border-bottom: 3px solid var(--wood-dark);
}

.farm-sheet .sheet__title{
    color: #fff1a8;
    text-shadow: 0 2px 0 var(--wood-dark);
}

.farm-sheet .sheet__status{
    color: #f3dfb5;
}

.farm-sheet .sheet__close{
    color: var(--ink);
    background: var(--paper);
}

.sheet__empty{
    padding: 28px 24px 34px;
    color: var(--ink-muted);
    text-align: center;
}

.sheet__empty[hidden]{
    display: none;
}

.cards{
    display: grid;
    gap: 9px;
    padding: 12px 12px calc(14px + env(safe-area-inset-bottom));
    overflow-y: auto;
    list-style: none;
}

.card{
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    background: #fff;
    border: 2px solid #ecdcc0;
    border-radius: 14px;
    animation: slide-in .25s ease-out backwards;
}

.card:nth-child(2){ animation-delay: .04s; }
.card:nth-child(3){ animation-delay: .08s; }
.card:nth-child(4){ animation-delay: .12s; }
.card:nth-child(5){ animation-delay: .16s; }
.card:nth-child(6){ animation-delay: .2s; }
.card:nth-child(7){ animation-delay: .24s; }

@keyframes slide-in{
    from{ transform: translateY(10px); opacity: 0; }
}

.card--locked{
    opacity: .55;
    filter: grayscale(.6);
}

.card__icon{
    flex-shrink: 0;
    width: 52px;
    height: 52px;
    padding: 2px;
    background: #f6ecd6;
    border-radius: 12px;
}

.card__main{
    flex: 1;
    min-width: 0;
    font-size: 17px;
}

.card__main small{
    display: block;
    margin-top: 2px;
    font-size: 13px;
    color: var(--ink-muted);
}

.card__buttons{
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.pill-button{
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-width: 66px;
    padding: 7px 12px;
    font: bold 15px var(--font);
    color: #fff;
    white-space: nowrap;
    background: linear-gradient(#7ccf52, #4f9e36);
    border: 0;
    border-radius: 999px;
    box-shadow: 0 3px 0 #2f6e20;
    cursor: pointer;
}

.pill-button img{
    width: 20px;
    height: 20px;
}

.pill-button:active:not(:disabled){
    transform: translateY(2px);
    box-shadow: 0 1px 0 #2f6e20;
}

.pill-button:disabled{
    color: #8a7a68;
    background: #e5dccb;
    box-shadow: 0 3px 0 #cbbfa8;
    cursor: default;
}

.pill-button--light{
    color: var(--ink);
    background: #f6ecd6;
    box-shadow: 0 3px 0 #d8c7a4;
}

/* An order: what it needs (have / need) and what it pays. */
.order{
    flex-direction: column;
    align-items: stretch;
}

.order--ready{
    border-color: #9ce06c;
    box-shadow: 0 0 0 3px rgba(156, 224, 108, .35);
}

.order__needs{
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.need{
    display: flex;
    align-items: center;
    gap: 3px;
    padding: 2px 9px 2px 3px;
    font-weight: bold;
    color: #c0392b;
    background: #fbefe9;
    border-radius: 999px;
}

.need img{
    width: 34px;
    height: 34px;
}

.need--done{
    color: #2f7a25;
    background: #eaf7e1;
}

.order__foot{
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
}

.order__reward{
    display: flex;
    flex: 1;
    align-items: center;
    gap: 3px;
    font-size: 17px;
    font-weight: bold;
}

.order__reward img{
    width: 24px;
    height: 24px;
}

.order [data-skip]{
    min-width: 40px;
    padding: 7px 10px;
}

/* The new level. */
.levelup{
    overflow: visible;
}

.levelup__body{
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 0 22px 22px;
    text-align: center;
}

.levelup__star{
    width: 120px;
    height: 120px;
    margin-top: -60px;
    filter: drop-shadow(0 6px 10px rgba(0, 0, 0, .25));
    animation: spin-in .7s cubic-bezier(.3, 1.6, .5, 1);
}

@keyframes spin-in{
    from{ transform: scale(0) rotate(-180deg); }
}

.levelup__title{
    font-size: 34px;
    color: var(--leaf-dark);
}

.levelup__text{
    color: var(--ink-muted);
}

.levelup__list{
    display: grid;
    gap: 6px;
    width: 100%;
    margin-bottom: 8px;
    list-style: none;
}

.levelup__list li{
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 10px;
    font-weight: bold;
    background: #fff;
    border-radius: 12px;
}

.levelup__list img{
    width: 36px;
    height: 36px;
}

/* The menu (☰): the Top 50, What's new, the guide, all games, installing. */
.menu__buttons{
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 16px 14px 8px;
}

.menu__button{
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 52px;
    padding: 8px 10px;
    font: bold 16px var(--font);
    color: var(--ink);
    text-decoration: none;
    background: #fff;
    border: 2px solid #ecdcc0;
    border-radius: 14px;
    box-shadow: 0 3px 0 #d8c7a4;
    cursor: pointer;
}

.menu__button:active{
    transform: translateY(2px);
    box-shadow: 0 1px 0 #d8c7a4;
}

.menu__button[hidden]{
    display: none;
}

.menu__tip{
    padding: 6px 18px calc(16px + env(safe-area-inset-bottom));
    font-size: 13px;
    color: var(--ink-muted);
    text-align: center;
}

/* A wide screen (a phone on its side, a computer): the bar stands on the right side. */
.screen.wide .farmbar{
    left: auto;
    right: max(10px, env(safe-area-inset-right));
    top: 50%;
    bottom: auto;
    flex-direction: column;
    gap: 8px;
    transform: translateY(-40%);
    animation: none;
}

.screen.wide .farmbar__button{
    width: 78px;
    padding: 4px 4px 5px;
    font-size: 13px;
}

.screen.wide .farmbar__button img{
    width: 30px;
    height: 30px;
}

/* A phone held upright: the whole game turned a quarter, to be played on its side (src/main.js turnForPhone).
   --turn-w / --turn-h are the window's height and width. */
html.turned .app{
    inset: auto;
    top: 0;
    left: 0;
    width: var(--turn-w);
    height: var(--turn-h);
    transform-origin: 0 0;
    transform: translateX(var(--turn-h)) rotate(90deg);
}

html.turned .whats-new[open]{
    position: fixed;
    top: 50%;
    left: 50%;
    right: auto;
    bottom: auto;
    width: min(460px, calc(var(--turn-w) - 32px));
    max-height: min(620px, calc(var(--turn-h) - 32px));
    margin: 0;
    transform: translate(-50%, -50%) rotate(90deg);
}

html.turned .sheet{
    position: fixed;
    top: 50%;
    left: 50%;
    width: min(480px, calc(var(--turn-w) - 24px));
    max-height: min(680px, calc(var(--turn-h) - 24px));
    margin: 0;
    transform: translate(-50%, -50%) rotate(90deg);
}

html.turned .farm-sheet[open]{
    animation: none;
}

/* Dragging the farm doesn't select the windows' words. */
.sheet{
    user-select: none;
    -webkit-user-select: none;
}

/* A building's window: what it can make. */
.recipe{
    display: flex;
    align-items: center;
    gap: 10px;
}

.make .order__foot{
    justify-content: space-between;
}

.make .order__needs{
    flex: 1;
}

/* Today's tasks and the daily gift. */
.task{
    flex-wrap: wrap;
}

.task__bar{
    position: relative;
    flex-basis: 100%;
    height: 10px;
    overflow: hidden;
    background: #efe3c8;
    border-radius: 5px;
}

.task__bar i{
    position: absolute;
    inset: 0 auto 0 0;
    background: linear-gradient(#9ce06c, #5fb043);
    border-radius: 5px;
}

.task--claimed{
    opacity: .55;
}

.gift{
    overflow: visible;
}

.gift__body{
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 0 18px 20px;
    text-align: center;
}

.gift__box{
    width: 110px;
    height: 110px;
    margin-top: -55px;
    filter: drop-shadow(0 6px 10px rgba(0, 0, 0, .25));
    animation: gift-shake 1.2s ease-in-out infinite;
}

@keyframes gift-shake{
    0%, 60%, 100%{ transform: rotate(0); }
    70%{ transform: rotate(-8deg) scale(1.05); }
    80%{ transform: rotate(8deg) scale(1.05); }
    90%{ transform: rotate(-4deg); }
}

.notify__bell{
    margin-top: -46px;
    font-size: 72px;
    line-height: 1;
    filter: drop-shadow(0 6px 10px rgba(0, 0, 0, .25));
    animation: gift-shake 1.2s ease-in-out infinite;
}

.notify__no{
    background: transparent;
    color: var(--ink-muted);
    box-shadow: none;
    border: 0;
    text-decoration: underline;
}

.gift__title{
    font-size: 30px;
    color: var(--leaf-dark);
}

.gift__text{
    color: var(--ink-muted);
}

.gift__days{
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 5px;
    width: 100%;
    margin: 4px 0 8px;
    list-style: none;
}

.gift__days li{
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 5px 2px;
    font-size: 11px;
    font-weight: bold;
    background: #fff;
    border: 2px solid #ecdcc0;
    border-radius: 10px;
}

.gift__days img{
    width: 26px;
    height: 26px;
}

.gift__days .is-done{
    opacity: .5;
}

.gift__days .is-today{
    border-color: #ffd23f;
    box-shadow: 0 0 0 3px rgba(255, 210, 63, .45);
    transform: scale(1.08);
}

/* A swapped order's place, waiting for the next one. */
.order--waiting{
    background: #f8f1e2;
    border-style: dashed;
}

.order__wait{
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    color: var(--ink-muted);
}

.order__wait img{
    width: 34px;
    height: 34px;
    opacity: .6;
}

.order__wait b{
    color: var(--ink);
}

/* Placing a decoration: what to do, and a way out. */
.place-bar{
    position: absolute;
    top: max(12px, env(safe-area-inset-top));
    left: 50%;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: calc(100% - 260px);
    padding: 6px 6px 6px 16px;
    font: bold 15px var(--font);
    color: var(--ink);
    background: #fff8e7;
    border: 2px solid var(--wood);
    border-radius: 999px;
    box-shadow: 0 3px 0 var(--wood-dark);
    transform: translateX(-50%);
    animation: pop .25s ease-out;
}

/* Visiting a friend's farm: only the farm, its owner and the way home. */
.visit-bar{
    position: absolute;
    top: max(12px, env(safe-area-inset-top));
    left: 50%;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: calc(100% - 140px);
    padding: 6px 6px 6px 16px;
    font: bold 15px var(--font);
    color: var(--ink);
    background: #fff8e7;
    border: 2px solid var(--wood);
    border-radius: 999px;
    box-shadow: 0 3px 0 var(--wood-dark);
    transform: translateX(-50%);
    animation: pop .25s ease-out;
}

.visit-bar[hidden]{
    display: none;
}

.visit-bar__text{
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.visit-bar__home{
    flex-shrink: 0;
    padding: 8px 14px;
    font-size: 14px;
}

.screen.is-visiting .farmbar,
.screen.is-visiting .stats,
.screen.is-visiting .place-bar{
    visibility: hidden;
}

.place-bar[hidden]{
    display: none;
}

.place-bar__cancel{
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    font-size: 16px;
    color: #fff;
    background: #e5533d;
    border: 0;
    border-radius: 50%;
    cursor: pointer;
}

.shop__title{
    margin-top: 6px;
    padding: 4px 6px 0;
    font-weight: bold;
    color: var(--ink-muted);
    list-style: none;
}

/* A building's level: stars, and its upgrade. */
.stars{
    color: #f2b70b;
    letter-spacing: 1px;
}

.upgrade{
    background: #fffbea;
    border-color: #f3dd8f;
}

/* The barn's and the shop's sections: a row of tabs under the window's title (scrolls sideways if it must). */
.tabs{
    display: flex;
    flex-shrink: 0;
    gap: 6px;
    padding: 10px 12px 2px;
    overflow-x: auto;
    scrollbar-width: none;
}

.tabs::-webkit-scrollbar{
    display: none;
}

.tab{
    position: relative;
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    gap: 4px;
    padding: 5px 11px 5px 6px;
    font: bold 14px var(--font);
    color: var(--ink);
    white-space: nowrap;
    background: #fff;
    border: 2px solid #ecdcc0;
    border-radius: 999px;
    cursor: pointer;
}

.tab img{
    width: 24px;
    height: 24px;
}

.tab--on{
    color: #fff;
    background: linear-gradient(#7ccf52, #4f9e36);
    border-color: #3f8f33;
    box-shadow: 0 2px 0 #2f6e20;
}

.tab--empty{
    opacity: .5;
}

.tab__count{
    min-width: 20px;
    padding: 0 5px;
    font-size: 12px;
    line-height: 18px;
    text-align: center;
    color: var(--ink);
    background: #f6ecd6;
    border-radius: 999px;
}

.tab__dot{
    position: absolute;
    top: -3px;
    right: -3px;
    width: 12px;
    height: 12px;
    background: #e5533d;
    border: 2px solid #fff;
    border-radius: 50%;
}

/* Helping friends: the water button on a visit, the hint on the Top 50. */
.visit-bar__water{
    flex-shrink: 0;
    padding: 8px 14px;
    font-size: 14px;
    color: #fff;
    background: linear-gradient(#5ec3f2, #2f97d6);
    box-shadow: 0 3px 0 #1f6fa3;
}

.visit-bar__water[hidden]{
    display: none;
}

.visit-bar__water:disabled{
    opacity: .6;
}

.ranks__help{
    margin: 10px 12px 0;
    padding: 8px 12px;
    font-size: 14px;
    color: #1f5f8a;
    background: #e3f4fd;
    border: 2px solid #b5def5;
    border-radius: 12px;
}

.ranks__help[hidden]{
    display: none;
}

/* The truck's card at the top of the orders. */
.truck{
    background: #fff4e0;
    border-color: #f0cf96;
}

.truck__head{
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
}

.truck__head img{
    width: 34px;
    height: 34px;
}

.truck__head small{
    margin-left: auto;
    color: var(--ink-muted);
}

.help-card{
    background: #eef8fe;
    border-color: #b5def5;
}

/* The golden book: a full page shines. */
.book--full{
    background: #fff7d6;
    border-color: #f2c94c;
    box-shadow: 0 0 0 3px rgba(242, 201, 76, .3);
}

.book .card__main b{
    color: #b8860b;
}

/* The list in a window shrinks to fit and scrolls (a flex child keeps its content's height otherwise). */
.cards{
    flex: 1 1 auto;
    min-height: 0;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.stars{
    font-size: 15px;
}

/* A phone (on its side, or turned): smaller windows so they fit its short screen. */
@media (max-height: 500px), (max-width: 500px){
    .farm-sheet .sheet__header{
        padding: 8px 10px 6px 14px;
    }

    .farm-sheet .sheet__title{
        font-size: 20px;
    }

    .farm-sheet .sheet__status{
        font-size: 12px;
    }

    .farm-sheet .sheet__close{
        width: 34px;
        height: 34px;
        font-size: 15px;
    }

    .cards{
        gap: 6px;
        padding: 8px 8px calc(10px + env(safe-area-inset-bottom));
    }

    .card{
        gap: 8px;
        padding: 5px 8px;
        border-radius: 12px;
    }

    .card__icon{
        width: 40px;
        height: 40px;
        border-radius: 10px;
    }

    .card__main{
        font-size: 15px;
    }

    .card__main small{
        font-size: 12px;
    }

    .tabs{
        gap: 5px;
        padding: 6px 8px 0;
    }

    .tab{
        padding: 3px 9px 3px 4px;
        font-size: 13px;
    }

    .tab img{
        width: 20px;
        height: 20px;
    }

    .pill-button{
        min-width: 56px;
        padding: 5px 10px;
        font-size: 14px;
    }

    .pill-button img{
        width: 17px;
        height: 17px;
    }

    .need img{
        width: 26px;
        height: 26px;
    }

    .order__foot{
        margin-top: 4px;
    }

    .order__reward{
        font-size: 15px;
    }

    .menu__buttons{
        gap: 8px;
        padding: 10px 10px 4px;
    }

    .menu__button{
        min-height: 42px;
        font-size: 14px;
    }

    .gift__box,
    .levelup__star{
        width: 76px;
        height: 76px;
        margin-top: -38px;
    }

    .gift__title,
    .levelup__title{
        font-size: 24px;
    }

    .gift__text,
    .levelup__text{
        font-size: 13px;
    }

    .gift__days li{
        padding: 3px 1px;
        font-size: 10px;
    }

    .gift__days img{
        width: 20px;
        height: 20px;
    }

    .gift__body .button--big,
    .levelup__body .button--big{
        padding: 10px 28px;
        font-size: 18px;
    }

    .levelup__list li{
        padding: 4px 8px;
        font-size: 14px;
    }

    .levelup__list img{
        width: 28px;
        height: 28px;
    }
}

/* ---------- Top 50 on Farm's cream window: dark words (the shared look is for dark windows) ---------- */
.ranks .sheet__title{
    color: var(--wood-dark);
}

.ranks .sheet__status,
.ranks__rank,
.ranks__name-label{
    color: var(--ink-muted);
}

.ranks .sheet__header,
.ranks__name{
    border-bottom-color: rgba(74, 44, 18, .12);
}

.ranks__player{
    font-weight: bold;
    color: var(--ink);
}

.ranks__score{
    color: var(--leaf-dark);
}

.ranks__row{
    border-bottom-color: rgba(74, 44, 18, .08);
}

.ranks__row.is-you{
    background: rgba(255, 204, 0, .35);
}

.ranks__row.is-pickable:hover{
    background: rgba(95, 176, 67, .15);
    border-radius: 10px;
}

.ranks__you{
    color: var(--wood-dark);
}

.ranks__name-input{
    background: #ffffff;
    border: 2px solid rgba(74, 44, 18, .2);
}

.ranks__tab{
    color: var(--ink-muted);
    background: rgba(74, 44, 18, .06);
    border-color: rgba(74, 44, 18, .15);
}

.ranks .sheet__close{
    color: var(--ink);
    background: rgba(74, 44, 18, .12);
}

.ranks__name-hint{
    color: var(--leaf-dark);
}
