* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --sky: #dff4ff;
    --grass: #4fae54;
    --grass-dark: #32783a;
    --soil: #8a5a35;
    --soil-dark: #5e3922;
    --cream: #fffaf0;
    --yellow: #ffd34e;
    --orange: #f49b32;
    --red: #d7473f;
    --text: #243028;
    --muted: #637068;
    --panel: #ffffff;
    --border: #c8d8c9;
}

html,
body {
    margin: 0;
    min-height: 100%;
}

body {
    font-family: Arial, Helvetica, sans-serif;

    color: var(--text);

    background:
        linear-gradient(
            180deg,
            #ccefff 0,
            #edf9ff 240px,
            #d9efc8 600px,
            #c6e4ad 100%
        );
}

button {
    font: inherit;
}


/* ======================================================
   WRAPPER
====================================================== */

.game-shell {
    width: min(1000px, 100%);
    margin: 0 auto;
    padding: 14px;
}


/* ======================================================
   HEADER
====================================================== */

.game-header {
    text-align: center;
    padding: 10px 0 16px;
}

.game-header h1 {
    margin: 0;

    font-size:
        clamp(30px, 7vw, 54px);

    color: #285f30;

    text-shadow:
        0 2px 0 rgba(255,255,255,.8);
}

.tagline {
    margin: 7px 0 14px;

    color: #4c6251;

    font-weight: bold;
}

.header-buttons {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
}

.header-buttons button {
    min-height: 42px;

    border: 1px solid #91af95;

    border-radius: 9px;

    padding: 9px 14px;

    background:
        rgba(255,255,255,.8);

    color: #294c2d;

    cursor: pointer;
}


/* ======================================================
   PANELS
====================================================== */

.panel,
.game-panel {
    background:
        rgba(255,255,255,.94);

    border:
        1px solid var(--border);

    border-radius: 18px;

    box-shadow:
        0 6px 20px
        rgba(52,83,55,.12);
}


/* ======================================================
   START SCREEN
====================================================== */

.start-screen {
    max-width: 650px;

    margin: 30px auto;

    padding: 34px 22px;

    text-align: center;
}

.hero-icons {
    display: flex;
    justify-content: center;
    align-items: center;

    gap: 18px;

    font-size:
        clamp(52px, 12vw, 90px);
}

.hero-icons .versus {
    font-size:
        clamp(22px, 6vw, 38px);

    font-weight: 900;

    color: var(--orange);
}

.start-screen h2 {
    margin: 18px 0 10px;

    font-size: 30px;
}

.start-screen p {
    max-width: 500px;

    margin: 10px auto;

    line-height: 1.6;
}


/* ======================================================
   BUTTONS
====================================================== */

.primary-button,
.search-button {
    border: 0;

    border-radius: 12px;

    background:
        linear-gradient(
            #ffd75d,
            #f5a92e
        );

    color: #3c2a08;

    font-weight: 900;

    cursor: pointer;

    box-shadow:
        inset 0 -3px 0
        rgba(113,65,8,.18);
}

.primary-button {
    margin-top: 18px;

    padding: 15px 24px;

    min-height: 52px;
}

.search-button {
    width: 100%;

    padding: 15px 12px;

    min-height: 54px;
}

.primary-button:active,
.search-button:active {
    transform: translateY(1px);
}

button:disabled {
    opacity: .45;

    cursor: default;
}


/* ======================================================
   STATS
====================================================== */

.stats {
    display: grid;

    grid-template-columns:
        repeat(5, 1fr);

    gap: 7px;

    margin-bottom: 8px;
}

.stat {
    min-width: 0;

    padding: 10px 5px;

    text-align: center;

    background:
        rgba(255,255,255,.9);

    border:
        1px solid var(--border);

    border-radius: 10px;
}

.stat span {
    display: block;

    margin-bottom: 3px;

    color: var(--muted);

    font-size: 10px;

    font-weight: bold;

    letter-spacing: .6px;
}

.stat strong {
    display: block;

    font-size: 20px;
}


/* ======================================================
   PROGRESS
====================================================== */

.progress-wrap {
    height: 9px;

    margin-bottom: 12px;

    overflow: hidden;

    background: #bcd3bb;

    border-radius: 20px;
}

.progress-bar {
    width: 0%;
    height: 100%;

    background:
        linear-gradient(
            90deg,
            #65b94f,
            #d0c83b
        );

    transition:
        width .25s ease;
}


/* ======================================================
   GAME PANEL
====================================================== */

.game-panel {
    padding: 18px;
}

.level-heading {
    text-align: center;
}

.level-heading h2 {
    margin: 0 0 5px;

    color: var(--grass-dark);
}

.level-heading p {
    margin: 0 0 15px;

    color: var(--muted);
}


/* ======================================================
   BOARD
====================================================== */

.board {
    display: grid;

    grid-template-columns:
        repeat(10, 1fr);

    gap: 4px;

    width: min(720px, 100%);

    margin: 0 auto;

    padding: 7px;

    border-radius: 12px;

    background:
        var(--soil-dark);

    border:
        3px solid #70462b;

    user-select: none;
}

.square {
    position: relative;

    min-width: 0;

    aspect-ratio: 1;

    padding: 0;

    border:
        1px solid rgba(62,37,19,.4);

    border-radius: 5px;

    background:
        linear-gradient(
            145deg,
            #a96d3f,
            #80502e
        );

    cursor: pointer;

    display: grid;

    place-items: center;

    font-size:
        clamp(15px, 4.2vw, 30px);

    overflow: hidden;
}

.square::after {
    content: "";

    position: absolute;

    inset: 4px;

    border:
        1px dashed
        rgba(255,255,255,.10);

    border-radius: 3px;

    pointer-events: none;
}

.square.selected {
    outline:
        3px solid var(--yellow);

    outline-offset: -2px;

    background:
        linear-gradient(
            145deg,
            #c18445,
            #99602e
        );
}

.square.selected::before {
    content: "🐦";

    position: absolute;

    z-index: 2;

    font-size:
        clamp(11px, 3vw, 21px);
}

.square.revealed {
    cursor: default;

    background: #d7b47b;

    animation:
        reveal .22s ease;
}

.square.revealed::after {
    display: none;
}

.square.worm {
    background: #d9c47d;
}

.square.golden {
    background: #ffe49b;
}

.square.redworm {
    background: #f2b0a9;
}

.square.egg {
    background: #d8ecc8;
}

.square.rock {
    background: #c9c3b6;
}

.square.empty {
    background: #b78c5d;
}

@keyframes reveal {

    from {
        transform: scale(.75);
        opacity: .3;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}


/* ======================================================
   SEARCH AREA
====================================================== */

.search-area {
    display: grid;

    grid-template-columns:
        2fr 1fr;

    gap: 8px;

    width: min(720px, 100%);

    margin: 14px auto 0;
}

.secondary-button {
    min-height: 54px;

    padding: 10px;

    border:
        1px solid #a8bca7;

    border-radius: 12px;

    background: white;

    color: #39533b;

    font-weight: bold;

    cursor: pointer;
}

.result-message {
    min-height: 52px;

    width: min(720px, 100%);

    margin: 12px auto 0;

    padding: 13px;

    border-radius: 10px;

    background: #f2f8ef;

    border:
        1px solid #cbdcc7;

    text-align: center;

    line-height: 1.45;
}


/* ======================================================
   LEGEND
====================================================== */

.legend {
    display: grid;

    grid-template-columns:
        repeat(5, 1fr);

    gap: 6px;

    margin: 12px 0;
}

.legend > div {
    min-width: 0;

    padding: 8px 4px;

    text-align: center;

    border-radius: 9px;

    background:
        rgba(255,255,255,.75);

    border:
        1px solid #c7d8c5;
}

.legend span {
    display: block;

    font-size: 23px;
}

.legend strong,
.legend small {
    display: block;
}

.legend strong {
    font-size: 11px;
}

.legend small {
    margin-top: 2px;

    color: var(--muted);

    font-size: 10px;
}


/* ======================================================
   MODALS
====================================================== */

.modal {
    position: fixed;

    inset: 0;

    z-index: 50;

    display: grid;

    place-items: center;

    padding: 16px;

    background:
        rgba(24,37,25,.75);
}

.modal.hidden,
.hidden {
    display: none;
}

.modal-card {
    position: relative;

    width: min(520px, 100%);

    max-height: 90vh;

    overflow-y: auto;

    padding: 28px 20px;

    text-align: center;

    border-radius: 18px;

    background: white;

    border:
        2px solid #8eb58d;

    box-shadow:
        0 10px 40px
        rgba(0,0,0,.25);
}

.modal-card h2 {
    margin-top: 8px;

    color: #326638;
}

.modal-card p {
    line-height: 1.55;
}

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

.close-button {
    position: absolute;

    top: 7px;
    right: 10px;

    border: 0;

    background: transparent;

    font-size: 30px;

    cursor: pointer;
}

.rules-card {
    text-align: left;
}

.rules-card h2 {
    text-align: center;
}

.rules-list {
    margin: 15px 0;

    padding: 8px 15px;

    border-radius: 10px;

    background: #f1f7ed;
}

.rules-list p {
    margin: 8px 0;
}


/* ======================================================
   VICTORY
====================================================== */

.victory-icons {
    font-size: 45px;
}

.victory-code {
    margin: 18px 0 5px;

    padding: 14px;

    border:
        2px dashed #e3a428;

    border-radius: 10px;

    background: #fff6d8;

    color: #72520b;

    font-weight: 900;

    letter-spacing: 2px;
}


/* ======================================================
   MOBILE
====================================================== */

@media (max-width: 600px) {

    .game-shell {
        padding: 8px;
    }

    .game-header {
        padding-top: 5px;
    }

    .stats {
        grid-template-columns:
            repeat(5, 1fr);

        gap: 3px;
    }

    .stat {
        padding: 7px 2px;
    }

    .stat strong {
        font-size: 16px;
    }

    .stat span {
        font-size: 8px;
    }

    .game-panel {
        padding: 10px 6px;
    }

    .board {
        gap: 2px;
        padding: 4px;
    }

    .square {
        border-radius: 3px;
    }

    .search-area {
        grid-template-columns: 1fr;
    }

    .legend {
        grid-template-columns:
            repeat(5, 1fr);

        gap: 2px;
    }

    .legend > div {
        padding: 6px 1px;
    }

    .legend span {
        font-size: 19px;
    }

    .legend strong {
        font-size: 9px;
    }

    .legend small {
        font-size: 8px;
    }
}
