
:root {
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    color: #4b3657;
    background: #f8eefa;
}

* {
    box-sizing: border-box;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    margin: 0;
    min-height: 0;
    background: radial-gradient(circle at 20% 8%, #fff5d8, transparent 38%), linear-gradient(155deg, #f8eefa, #e5f7ee);
}

button {
    font: inherit;
    cursor: pointer;
    touch-action: manipulation;
}

/* Main game container */

.shell {
    height: 100vh;
    height: 100dvh;
    max-height: 100dvh;
    max-width: 560px;
    margin: auto;
    display: flex;
    flex-direction: column;
    padding: clamp(6px, 1.5dvh, 14px) 12px;
    overflow: hidden;
}

/* Header */

.top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex: 0 0 auto;
    margin-bottom: clamp(4px, 1dvh, 10px);
}

.eyebrow {
    font-size: clamp(9px, 1.5dvh, 12px);
    color: #8b7092;
    letter-spacing: .1em;
    text-transform: uppercase;
}

h1 {
    font-size: clamp(19px, 3.5dvh, 30px);
    margin: 2px 0;
    color: #745080;
}

.icon-btn {
    border: 0;
    border-radius: 50%;
    width: clamp(32px, 5dvh, 46px);
    height: clamp(32px, 5dvh, 46px);
    background: #fff;
    box-shadow: 0 4px 14px #7d597222;
    font-size: 22px;
}

/* Statistics */

.stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 7px;
    flex: 0 0 auto;
}

    .stats > div {
        background: #ffffffd9;
        border: 1px solid #fff;
        border-radius: 16px;
        padding: clamp(4px, 1dvh, 10px);
        text-align: center;
        box-shadow: 0 4px 14px #7d597211;
    }

    .stats span {
        display: block;
        font-size: 10px;
        letter-spacing: .06em;
        color: #977f9e;
    }

    .stats strong {
        display: block;
        font-size: clamp(16px, 3dvh, 24px);
        color: #6c4a7b;
    }

.message {
    text-align: center;
    font-size: clamp(11px, 1.8dvh, 14px);
    margin: clamp(3px, 1dvh, 10px) 0;
    color: #7d6384;
    min-height: 0;
    flex: 0 0 auto;
}

/* Game board container */

.board-wrap {
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    padding: clamp(4px, 1dvh, 12px);
    background: #ffffff8a;
    border: 1px solid white;
    border-radius: 22px;
    box-shadow: 0 12px 28px #76577719;
    overflow: hidden;
}

/* Original flat board */

.board {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    grid-template-rows: repeat(6, minmax(0, 1fr));
    gap: clamp(2px, .7dvh, 7px);
    flex: 1;
    min-width: 0;
    min-height: 0;
    height: 100%;
    align-content: stretch;
}

    /* Layered board */

    .board.layered {
        display: block;
        position: relative;
        isolation: isolate;
        width: 100%;
        height: 100%;
        min-height: 0;
        overflow: hidden;
        border-radius: 12px;
    }

/* Standard flower tile */

.tile {
    min-width: 0;
    min-height: 0;
    aspect-ratio: auto;
    border: 2px solid #fff;
    border-radius: clamp(5px, 1.4dvh, 13px);
    background: linear-gradient(145deg, #fff, #fff5f8);
    box-shadow: 0 4px 0 #decddd, 0 6px 9px #75577722;
    font-size: clamp(20px, min(9vw, 4.2dvh), 46px);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform .13s, background .13s, box-shadow .13s, opacity .13s;
    user-select: none;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
}

    .tile:active:not(:disabled) {
        transform: translateY(3px);
        box-shadow: 0 1px 0 #decddd;
    }

    .tile.hinted {
        background: #fff0ac;
        outline: 3px solid #f4b84a;
        outline-offset: -2px;
    }

    .tile.empty {
        visibility: hidden;
        pointer-events: none;
    }

/* Positioned tiles in layered mode */

.board.layered .tile.positioned {
    position: absolute;
    /*
       JavaScript positions tiles using a
       6.6-unit coordinate system.

       Width and height reserve enough space
       for the overlapping offsets.
    */

    width: 14.6%;
    height: 14.6%;
    margin: 0;
    padding: 0;
    border-radius: clamp(7px, 1.5dvh, 13px);
    box-shadow: 0 3px 0 #d9c2d9, 0 6px 9px #76577735;
    z-index: 1;
}

    /* Different layer colors */

    .board.layered .tile.positioned[style*="--depth: 0"] {
        background: linear-gradient(145deg, #fff, #fff5f8);
    }

    .board.layered .tile.positioned[style*="--depth: 1"] {
        background: linear-gradient(145deg, #fffdf0, #ffe8f3);
        box-shadow: 0 4px 0 #d8bbd7, 0 7px 11px #76577740;
    }

    .board.layered .tile.positioned[style*="--depth: 2"] {
        background: linear-gradient(145deg, #ffffff, #e8f8ff);
        box-shadow: 0 5px 0 #b9c9df, 0 9px 13px #76577750;
    }

/* Tiles underneath other tiles */

.board.layered .tile.blocked {
    filter: brightness(.87) saturate(.75);
    cursor: default;
    pointer-events: none;
}

.board.layered .tile.positioned:not(.blocked) {
    cursor: pointer;
}

    .board.layered .tile.positioned:not(.blocked):active {
        transform: translateY(2px) scale(.97);
    }

/* Tray heading */

.tray-title {
    display: flex;
    justify-content: space-between;
    flex: 0 0 auto;
    margin: clamp(4px, 1dvh, 10px) 5px clamp(2px, .5dvh, 6px);
    font-size: 12px;
    letter-spacing: .08em;
    font-weight: 750;
    color: #80648a;
}

/* Seven-slot collection tray */

.tray {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 5px;
    flex: 0 0 auto;
    padding: clamp(4px, .7dvh, 9px);
    background: #dfcde7;
    border-radius: 18px;
    min-height: 0;
}

.slot {
    aspect-ratio: auto;
    height: clamp(28px, 5.5dvh, 48px);
    border-radius: 10px;
    background: #ffffff69;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(22px, 3.8dvh, 38px);
    min-width: 0;
}

    .slot.filled {
        background: white;
        box-shadow: 0 3px 5px #74577722;
    }

/* Action buttons */

.actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 7px;
    flex: 0 0 auto;
    margin-top: clamp(5px, 1dvh, 12px);
}

    .actions button,
    .primary {
        border: 0;
        background: #fff;
        border-radius: 15px;
        padding: clamp(6px, 1.3dvh, 13px) 3px;
        color: #70537c;
        font-weight: 750;
        box-shadow: 0 4px 13px #76577718;
    }

        .actions button:disabled {
            opacity: .4;
            cursor: not-allowed;
        }

/* Footer */

.footer {
    text-align: center;
    flex: 0 0 auto;
    margin-top: clamp(4px, .8dvh, 10px);
    font-size: 10px;
    color: #9a819f;
}

/* Modal overlay */

.overlay {
    position: fixed;
    inset: 0;
    background: #48354a85;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 100;
}

.hidden {
    display: none;
}

.dialog {
    background: #fffafc;
    border-radius: 25px;
    padding: 30px 22px;
    text-align: center;
    max-width: 350px;
    width: 100%;
    box-shadow: 0 20px 80px #34213944;
}

.modal-icon {
    font-size: 56px;
}

.dialog h2 {
    color: #79518b;
}

.dialog p {
    color: #8a7491;
}

.primary {
    background: #a96cc0;
    color: white;
    padding: 14px 30px;
    width: 100%;
}

/* Desktop and tablet */

@media (min-width: 560px) {
    .tile {
        font-size: 36px;
    }

    .slot {
        font-size: 34px;
    }
}

/* Narrow phones */

@media (max-width: 360px) {
    .board {
        gap: 4px;
    }

    .tile {
        border-radius: 9px;
    }

    .shell {
        padding: 8px;
    }

    .tray {
        gap: 3px;
        padding: 6px;
    }
}

/* Short mobile screens */

@media (max-height: 580px) {
    .eyebrow,
    .footer {
        display: none;
    }

    .message {
        margin: 3px 0;
    }

    .stats span {
        font-size: 9px;
    }
}
