/* The only stylesheet. Everything readable in this game is DOM on top of the canvas —
   the canvas draws the burrow and the snakes and nothing else. */

:root {
    --font: ui-rounded, -apple-system, "Trebuchet MS", sans-serif;

    --soil: #0d0805;
    --soil-lit: #3a2413;
    --frame: #4a3320;
    --frame-dark: #2a1a0f;

    --cream: #ffe9c9;
    --gold: #ffc857;
    --amber: #ffd9a0;
    --ember: #ff9f6a;
    --blood: #ff5b6e;

    /* The top inset reserves the row the home link and the mute sit in; the bottom one
       keeps the tip line clear of a gesture bar. board.js reserves matching space on the
       canvas, so the grid is never laid out under either. */
    --ng-top: calc(env(safe-area-inset-top) + 56px);
    --ng-bottom: calc(env(safe-area-inset-bottom) + 12px);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    overflow: hidden;
    /* the board is a tap target from edge to edge; a browser scroll or a pinch is never
       something this game wants */
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    background: var(--soil);
    font-family: var(--font);
}

canvas {
    position: fixed;
    inset: 0;
    z-index: 0;
    display: block;
}

/* ---------- chrome ---------- */

.home-link {
    position: fixed;
    z-index: 40;
    top: calc(env(safe-area-inset-top) + 10px);
    left: 12px;
    padding: 6px 12px;
    border-radius: 999px;
    background: rgba(20, 10, 4, .6);
    color: rgba(255, 233, 201, .85);
    font: 700 12px/1 var(--font);
    letter-spacing: .04em;
    text-decoration: none;
}

.home-link:hover {
    background: rgba(20, 10, 4, .85);
    color: var(--gold);
}

.mute {
    position: fixed;
    z-index: 40;
    top: calc(env(safe-area-inset-top) + 8px);
    right: 12px;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 2px solid var(--gold);
    border-radius: 50%;
    background: rgba(20, 10, 4, .6);
    color: var(--gold);
    cursor: pointer;
}

.mute svg {
    width: 22px;
    height: 22px;
    display: block;
    margin: auto;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
}

.mute .note-head {
    fill: currentColor;
    stroke: none;
}

.mute .slash {
    opacity: 0;
    stroke: var(--blood);
    stroke-width: 2.6;
}

.mute.off {
    border-color: rgba(255, 233, 201, .5);
    color: rgba(255, 233, 201, .5);
}

.mute.off .slash {
    opacity: 1;
}

/* ---------- HUD ---------- */

/* pointer-events:none, so nothing clickable may live in here — a nested button inherits
   it and becomes invisibly dead. The mute is a sibling for exactly that reason. */
#hud {
    position: fixed;
    z-index: 10;
    left: calc(env(safe-area-inset-left) + 12px);
    top: calc(var(--ng-top) + 8px);
    pointer-events: none;
    color: var(--cream);
    text-shadow: 0 2px 6px #000;
}

#lvl {
    font-size: clamp(13px, 3.4vw, 18px);
    font-weight: 800;
    letter-spacing: .08em;
    color: var(--gold);
}

#bar {
    margin-top: 6px;
    width: clamp(140px, 44vw, 210px);
    height: 12px;
    border-radius: 8px;
    background: var(--frame-dark);
    border: 2px solid var(--frame);
    overflow: hidden;
}

#fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #3ddc84, #ffd23f);
    /* only the colour transitions — the width is written every frame the timer moves and
       an eased width would lag the number it is reporting */
    transition: background .2s;
}

#sc {
    margin-top: 6px;
    font-size: clamp(12px, 3.1vw, 16px);
    font-weight: 700;
    opacity: .92;
}

#best {
    margin-top: 2px;
    font-size: clamp(10px, 2.7vw, 13px);
    opacity: .6;
}

#hp {
    margin-top: 5px;
    font-size: clamp(14px, 3.6vw, 18px);
    letter-spacing: .14em;
    color: var(--blood);
    text-shadow: 0 1px 4px #000;
}

#tip {
    position: fixed;
    z-index: 10;
    left: 0;
    right: 0;
    bottom: calc(var(--ng-bottom) + 58px);
    text-align: center;
    color: var(--amber);
    font-size: clamp(12px, 3.3vw, 16px);
    font-weight: 700;
    opacity: .85;
    pointer-events: none;
    text-shadow: 0 2px 8px #000;
}

/* ---------- banner ---------- */

/* One element serves both the burrow-clear and the game-over card; `.lose` is the only
   difference, so the two can never drift apart in layout. */
#ban {
    position: fixed;
    z-index: 11;
    left: 0;
    right: 0;
    top: 38%;
    text-align: center;
    pointer-events: none;
    opacity: 0;
    transition: opacity .25s;
}

#ban .card {
    display: inline-block;
    max-width: 86vw;
    padding: 18px 26px;
    border-radius: 20px;
    background: rgba(14, 7, 3, .9);
    border: 2px solid var(--frame);
    box-shadow: 0 12px 44px rgba(0, 0, 0, .75);
}

#ban b {
    display: inline-block;
    font-size: clamp(26px, 8vw, 44px);
    font-weight: 900;
    color: #fff;
    letter-spacing: .04em;
    text-shadow: 0 0 24px #ffb02e, 0 4px 0 #7a3a00;
}

#ban span {
    display: block;
    margin-top: 6px;
    font-size: clamp(13px, 3.6vw, 18px);
    color: var(--amber);
    font-weight: 700;
}

#ban.lose .card {
    background: rgba(30, 5, 5, .92);
    border-color: #7d2020;
}

#ban.lose b {
    color: #ff6a55;
    text-shadow: 0 0 22px #ff2d2d, 0 3px 0 #4a0d0d;
}

#ban.lose span {
    color: #ffb3a6;
}

/* ---------- intro ---------- */

#intro {
    position: fixed;
    inset: 0;
    z-index: 30;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 28px;
    text-align: center;
    background: radial-gradient(circle at 50% 40%, var(--soil-lit), var(--soil) 78%);
}

#intro .ico {
    font-size: clamp(38px, 12vw, 56px);
}

#intro h1 {
    margin: 0;
    font-size: clamp(22px, 7vw, 30px);
    color: var(--gold);
    letter-spacing: .05em;
    text-shadow: 0 2px 10px #000;
}

#intro p {
    margin: 0;
    max-width: 320px;
    font-size: clamp(13px, 3.8vw, 16px);
    color: var(--cream);
    line-height: 1.55;
    text-shadow: 0 1px 4px #000;
}

#intro p b {
    color: var(--ember);
}

#startBtn {
    margin-top: 8px;
    padding: 15px 44px;
    border: none;
    border-radius: 32px;
    background: linear-gradient(90deg, #3ddc84, #ffd23f);
    color: #1a1006;
    font-family: var(--font);
    font-weight: 900;
    font-size: clamp(16px, 4.4vw, 20px);
    letter-spacing: .05em;
    box-shadow: 0 6px 0 #7a5a10, 0 12px 26px rgba(0, 0, 0, .55);
    cursor: pointer;
}
