:root{
    --text: #fff7ec;
    --text-muted: #c9bde6;
    --accent: #ffd23f;
    --accent-text: #2a2140;
    --font: "Trebuchet MS", "Segoe UI", Arial, sans-serif;
    /* The canvas layout's shape (LAYOUT in Renderer.js). */
    --layout-width: 400;
    --layout-height: 560;
}

*{
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html{
    touch-action: manipulation;
}

body{
    min-height: 100dvh;
    /* The board bought in the shop sets these (main.js). */
    background: var(--page-bottom, #1d1730) linear-gradient(180deg, var(--page-top, #3b2d5c), var(--page-bottom, #1d1730)) no-repeat;
    color: var(--text);
    font-family: var(--font);
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
}

.noscript{
    padding: 24px;
    font-size: 18px;
}

.noscript a{
    color: var(--accent);
}

.app{
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding:
        max(10px, env(safe-area-inset-top))
        max(12px, env(safe-area-inset-right))
        max(10px, env(safe-area-inset-bottom))
        max(12px, env(safe-area-inset-left));
    user-select: none;
    -webkit-user-select: none;
}

.top{
    width: min(100%, 520px);
    display: flex;
    align-items: center;
    gap: 8px;
}

.round{
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    font-size: 20px;
    line-height: 1;
    color: var(--text);
    text-decoration: none;
    background: rgba(255, 255, 255, .1);
    border: 0;
    border-radius: 50%;
    cursor: pointer;
}

.score{
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1.05;
}

.score__value{
    font-size: 36px;
    font-weight: bold;
    color: var(--accent);
    text-shadow: 0 3px 0 #c98b00;
}

.score__best{
    font-size: 14px;
    color: var(--text-muted);
}

/* A size container, so the screen can fit it in both directions. */
.stage{
    flex: 1;
    min-height: 0;
    width: 100%;
    display: grid;
    place-items: center;
    container-type: size;
}

.screen{
    position: relative;
    width: min(100cqw, 100cqh * var(--layout-width) / var(--layout-height), 520px);
    aspect-ratio: var(--layout-width) / var(--layout-height);
    touch-action: none;
    -webkit-touch-callout: none;
}

.game-canvas{
    display: block;
    width: 100%;
    height: 100%;
}

/* The menu and the game over screen, over the board. */
.panel{
    position: absolute;
    inset: 0;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 20px;
    text-align: center;
    border-radius: 20px;
    background: rgba(29, 23, 48, .9);
    animation: fade-in .3s ease-out;
}

.panel[hidden]{
    display: none;
}

@keyframes fade-in{
    from{ opacity: 0; }
}

.panel__title{
    font-size: clamp(40px, 12cqw, 54px);
    line-height: 1;
    color: var(--accent);
    text-shadow: 0 4px 0 #c98b00;
}

.panel__heading{
    font-size: clamp(30px, 9cqw, 42px);
    font-weight: bold;
    color: var(--accent);
    text-shadow: 0 3px 0 #c98b00;
}

.panel__score{
    font-size: 60px;
    font-weight: bold;
    line-height: 1;
}

.panel__text{
    font-size: 18px;
}

.panel__earned{
    font-size: 22px;
    font-weight: bold;
    color: var(--accent);
}

.panel__help{
    font-size: 14px;
    color: var(--text-muted);
}

.panel__help[hidden]{
    display: none;
}

.panel__links{
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-top: 4px;
}

.panel__links .button{
    min-height: 40px;
    padding: 0 14px;
    font-size: 15px;
}

.button{
    min-height: 48px;
    padding: 0 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font: bold 17px var(--font);
    color: var(--text);
    text-decoration: none;
    background: rgba(255, 255, 255, .14);
    border: 0;
    border-radius: 999px;
    cursor: pointer;
}

.button[hidden]{
    display: none;
}

.button--accent{
    color: var(--accent-text);
    background: var(--accent);
}

.button--big{
    min-height: 56px;
    min-width: 200px;
    font-size: 21px;
}

.button--shop{
    color: var(--accent-text);
    background: #7fe3ff;
}

.button:active,
.round:active{
    transform: scale(.94);
}

.button:focus-visible,
.round:focus-visible,
.powerup:focus-visible{
    outline: 3px solid var(--accent);
    outline-offset: 2px;
}

/* ---------- Daily challenge ---------- */

.daily{
    width: min(100%, 300px);
    padding: 10px 14px;
    border-radius: 16px;
    background: rgba(255, 255, 255, .08);
    border: 2px solid rgba(127, 227, 255, .4);
}

.daily--done{
    border-color: #8fd16a;
}

.daily__title{
    font-size: 13px;
    font-weight: bold;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: #7fe3ff;
}

.daily__goal{
    margin: 2px 0 6px;
    font-size: 17px;
    font-weight: bold;
}

.daily__bar{
    height: 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .12);
    overflow: hidden;
}

.daily__fill{
    display: block;
    height: 100%;
    width: 0;
    border-radius: inherit;
    background: linear-gradient(90deg, #7fe3ff, #8fd16a);
    transition: width .4s;
}

.daily__reward{
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-muted);
}

/* ---------- Coins, wallet, toast ---------- */

/* A small gold coin, drawn in CSS so it looks the same everywhere (emoji coins differ per phone). */
.coin-icon{
    display: inline-block;
    width: 1em;
    height: 1em;
    margin-right: .3em;
    vertical-align: -.15em;
    border-radius: 50%;
    background: radial-gradient(circle at 50% 50%, #fff3a0 0 30%, #ffd23f 32% 100%);
    box-shadow: inset 0 -.1em 0 #c98b00, 0 0 0 .06em #c98b00;
}

.wallet{
    flex-shrink: 0;
    padding: 6px 12px;
    font-size: 17px;
    font-weight: bold;
    border-radius: 999px;
    background: rgba(255, 255, 255, .1);
}

.toast{
    position: absolute;
    left: 50%;
    top: 12px;
    z-index: 3;
    width: max-content;
    max-width: calc(100% - 24px);
    padding: 10px 16px;
    font-weight: bold;
    text-align: center;
    color: var(--accent-text);
    background: var(--accent);
    border-radius: 18px;
    transform: translateX(-50%);
    box-shadow: 0 6px 20px rgba(0, 0, 0, .3);
    pointer-events: none;
}

.toast[hidden]{
    display: none;
}

/* ---------- Power-ups ---------- */

.powerups{
    flex-shrink: 0;
    width: min(100%, 520px);
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.powerup{
    min-height: 54px;
    padding: 4px 8px;
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    column-gap: 6px;
    font: bold 13px/1.2 var(--font);
    text-align: left;
    color: var(--text);
    background: rgba(255, 255, 255, .1);
    border: 2px solid transparent;
    border-radius: 16px;
    cursor: pointer;
}

.powerup:disabled{
    opacity: .4;
    cursor: default;
}

.powerup--armed{
    border-color: #ff4757;
    background: rgba(255, 71, 87, .25);
    animation: armed 1s ease-in-out infinite;
}

@keyframes armed{
    50%{ transform: scale(1.04); }
}

.powerup__icon{
    grid-row: span 2;
    font-size: 26px;
}

.powerup__tag{
    color: var(--accent);
}

/* ---------- Shop ---------- */

.shop{
    width: min(560px, calc(100% - 24px));
    max-height: calc(100dvh - 24px);
    margin: auto;
    padding: 0;
    display: none;
    flex-direction: column;
    color: var(--text);
    background: #2a2140;
    border: 0;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .5);
    font-family: var(--font);
}

.shop[open]{
    display: flex;
}

.shop::backdrop{
    background: rgba(10, 8, 20, .6);
}

.shop__header{
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 16px 8px 20px;
}

.shop__title{
    flex: 1;
    font-size: 26px;
    color: var(--accent);
}

.shop__wallet{
    font-size: 20px;
    font-weight: bold;
}

.shop__close{
    width: 40px;
    height: 40px;
    font-size: 18px;
    color: var(--text);
    background: rgba(255, 255, 255, .1);
    border: 0;
    border-radius: 50%;
    cursor: pointer;
}

.shop__tabs{
    display: flex;
    gap: 6px;
    padding: 4px 16px 12px;
    overflow-x: auto;
    scrollbar-width: none;
}

.shop__tab{
    flex-shrink: 0;
    min-height: 38px;
    padding: 0 14px;
    font: bold 15px var(--font);
    color: var(--text-muted);
    background: rgba(255, 255, 255, .08);
    border: 0;
    border-radius: 999px;
    cursor: pointer;
}

.shop__tab[aria-selected="true"]{
    color: var(--accent-text);
    background: var(--accent);
}

.shop__grid{
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
    padding: 0 16px 16px;
    overflow-y: auto;
}

.shop-card{
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 10px;
    text-align: center;
    border-radius: 16px;
    background: rgba(255, 255, 255, .07);
    border: 2px solid transparent;
}

.shop-card--worn{
    border-color: var(--accent);
}

.shop-card__picture{
    width: 96px;
    height: 96px;
    display: grid;
    place-items: center;
    font-size: 54px;
    border-radius: 12px;
    overflow: hidden;
    background: rgba(255, 255, 255, .08);
}

.shop-card__picture canvas{
    width: 96px;
    height: 96px;
}

.shop-card__name{
    font-weight: bold;
}

.shop-card__text{
    font-size: 13px;
    color: var(--text-muted);
}

.shop-card__button{
    width: 100%;
    min-height: 38px;
    margin-top: auto;
    font: bold 15px var(--font);
    color: var(--text);
    background: rgba(255, 255, 255, .14);
    border: 0;
    border-radius: 999px;
    cursor: pointer;
}

.shop-card__button--buy{
    color: var(--accent-text);
    background: var(--accent);
}

.shop-card__button:disabled{
    cursor: default;
    opacity: .5;
}

.shop-card--worn .shop-card__button:disabled{
    opacity: 1;
    color: var(--accent);
    background: transparent;
}
