:root {
    --ink: #2b2236;
    --soft: #6d6378;
    --sand: #fbf4ea;
    --sand-2: #f3e2c7;
    --rock: #c76f4c;
    --rock-dark: #8a3b2c;
    --dusk: #6b3a6e;
    --cactus: #5aa469;
    --cactus-dark: #3f7f4d;
    --sun: #f2b33d;
    --sun-dark: #c98a17;
    --stone: #a99c92;
    --stone-dark: #857870;
    --tile: 58px;
    --font: 'Baloo 2', 'Trebuchet MS', sans-serif;
}

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

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

body {
    font-family: var(--font);
    color: var(--ink);
    background: var(--sand);
    overflow-x: hidden;
}

/* dusk over the badlands, the same landscape as the home page */
.scene {
    position: fixed;
    inset: 0 0 auto 0;
    height: 300px;
    z-index: 0;
    pointer-events: none;
}

.scene svg { width: 100%; height: 100%; display: block; }

.scene::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -60px;
    height: 60px;
    background: linear-gradient(#e9b98a, var(--sand));
}

.home-link {
    position: fixed;
    top: 12px;
    left: 14px;
    z-index: 20;
    font-weight: 700;
    font-size: 15px;
    color: #fff;
    text-decoration: none;
    padding: 6px 14px;
    border-radius: 999px;
    background: rgba(42, 26, 61, .45);
    border: 1px solid rgba(255, 255, 255, .25);
    white-space: nowrap;
}

.home-link:hover, .sound-btn:hover { background: rgba(42, 26, 61, .7); }

.sound-btn {
    position: fixed;
    top: 12px;
    right: 14px;
    z-index: 20;
    font: 700 15px/1 var(--font);
    color: #fff;
    padding: 7px 14px 6px;
    border-radius: 999px;
    background: rgba(42, 26, 61, .45);
    border: 1px solid rgba(255, 255, 255, .25);
    cursor: pointer;
}

.dig {
    position: relative;
    z-index: 1;
    max-width: 920px;
    margin: 120px auto 30px;
    background: var(--sand);
    border-radius: 26px;
    box-shadow: 0 18px 50px rgba(42, 26, 61, .25), 0 0 0 4px rgba(255, 255, 255, .6);
    padding: 18px 22px 20px;
}

.head { display: flex; align-items: center; gap: 14px; margin-top: -64px; }

.pip { width: 120px; height: 100px; flex: 0 0 auto; filter: drop-shadow(0 4px 6px rgba(42, 26, 61, .25)); animation: bob 3s ease-in-out infinite; }

@keyframes bob { 50% { transform: translateY(-4px); } }

.title-wrap { padding-top: 46px; }

h1 { font-size: clamp(34px, 6vw, 48px); font-weight: 800; line-height: .95; letter-spacing: -.5px; }
h1 span { color: var(--rock); }
.tag { color: var(--soft); font-size: 16px; }

.grade-row { display: flex; align-items: center; gap: 10px; margin: 14px 0 6px; flex-wrap: wrap; }
.grade-label { font-weight: 800; color: var(--rock-dark); }

.grades { display: flex; flex-wrap: wrap; gap: 6px; }

/* pebbles */
.grade {
    font: 800 15px/1 var(--font);
    min-width: 38px;
    height: 36px;
    padding: 0 8px;
    color: var(--rock-dark);
    background: #fff;
    border: 2px solid #ecd6bb;
    border-radius: 14px 16px 13px 15px;
    cursor: pointer;
    box-shadow: 0 3px 0 #ecd6bb;
    transition: transform .1s;
}

.grade:hover { transform: translateY(-2px); }

.grade[aria-checked="true"] {
    color: #fff;
    background: var(--rock);
    border-color: var(--rock-dark);
    box-shadow: 0 3px 0 var(--rock-dark);
}

.status { font-size: 15px; color: var(--soft); min-height: 22px; }
.status b { color: var(--ink); }

.play {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 22px;
    margin-top: 10px;
    align-items: start;
}

.board-wrap { display: flex; flex-direction: column; align-items: center; }

.board { display: grid; gap: 7px; }

.row {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: var(--tile);
    gap: 7px;
}

.row.shake { animation: shake .42s; }

@keyframes shake {
    20% { transform: translateX(-8px); }
    40% { transform: translateX(7px); }
    60% { transform: translateX(-5px); }
    80% { transform: translateX(3px); }
}

/* sandstone blocks with rock layers */
.tile {
    width: var(--tile);
    height: var(--tile);
    display: grid;
    place-items: center;
    font: 800 calc(var(--tile) * .56)/1 var(--font);
    text-transform: uppercase;
    color: var(--ink);
    border-radius: 12px;
    background:
        repeating-linear-gradient(176deg, transparent 0 9px, rgba(199, 111, 76, .08) 9px 11px),
        var(--sand-2);
    box-shadow: inset 0 -4px 0 rgba(138, 59, 44, .12);
    border: 2px solid #ecd6bb;
}

.tile.filled { border-color: var(--rock); animation: pop .12s; }
.row.current .tile.cursor { border-color: var(--rock); border-style: dashed; }

@keyframes pop { 50% { transform: scale(1.08); } }

.tile.flip { animation: flip .46s ease-in-out; }

@keyframes flip {
    0% { transform: rotateX(0); }
    50% { transform: rotateX(90deg); }
    100% { transform: rotateX(0); }
}

.tile.hit, .tile.near, .tile.miss { color: #fff; box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .14); }
.tile.hit { background: var(--cactus); border-color: var(--cactus-dark); }
.tile.near { background: var(--sun); border-color: var(--sun-dark); }
.tile.miss { background: var(--stone); border-color: var(--stone-dark); }
.tile.hinted { color: rgba(138, 59, 44, .35); }

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

.btn {
    font: 800 15px/1 var(--font);
    padding: 10px 14px 9px;
    border-radius: 14px;
    cursor: pointer;
    color: var(--rock-dark);
    background: #fff;
    border: 2px solid #ecd6bb;
    box-shadow: 0 3px 0 #ecd6bb;
}

.btn:hover:not(:disabled) { border-color: var(--rock); }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #ecd6bb; }
.btn:disabled { opacity: .4; cursor: default; }
.btn.main { color: #fff; background: var(--cactus); border-color: var(--cactus-dark); box-shadow: 0 3px 0 var(--cactus-dark); }

/* field notes */
.notes {
    align-self: stretch;
    display: flex;
    flex-direction: column;
    max-height: calc(var(--tile) * 6 + 7px * 5 + 52px);
    border-radius: 16px;
    background: #fff;
    border: 2px solid #ecd6bb;
    overflow: hidden;
}

.notes-head {
    font-weight: 800;
    color: #fff;
    background: var(--rock);
    padding: 6px 14px;
}

.log {
    flex: 1;
    min-height: 120px;
    overflow-y: auto;
    padding: 10px 14px;
    font-size: 15px;
    line-height: 1.5;
    color: var(--soft);
    background: repeating-linear-gradient(transparent 0 22px, rgba(199, 111, 76, .12) 22px 23px);
}

.log p { margin: 0 0 2px; }
.log .ok { color: var(--cactus-dark); font-weight: 800; }
.log .warn { color: var(--sun-dark); font-weight: 700; }
.log .err { color: #c0473a; }
.log .dim { color: #a89aa8; }
.log .big { color: var(--cactus-dark); font-weight: 800; }
.log .mask { letter-spacing: 1px; }

/* keyboard */
.keys { margin-top: 16px; display: grid; gap: 6px; justify-items: center; }
.krow { display: flex; gap: 5px; width: 100%; max-width: 580px; justify-content: center; }

.key {
    flex: 1 1 0;
    max-width: 48px;
    height: 52px;
    font: 800 17px/1 var(--font);
    text-transform: uppercase;
    color: var(--ink);
    background: #fff;
    border: 2px solid #ecd6bb;
    border-radius: 10px;
    box-shadow: 0 3px 0 #ecd6bb;
    cursor: pointer;
    padding: 0;
    touch-action: manipulation;
}

.key.wide { max-width: 78px; flex-grow: 1.6; font-size: 13px; }
.key:active { transform: translateY(2px); box-shadow: 0 1px 0 #ecd6bb; }
.key.hit { background: var(--cactus); border-color: var(--cactus-dark); box-shadow: 0 3px 0 var(--cactus-dark); color: #fff; }
.key.near { background: var(--sun); border-color: var(--sun-dark); box-shadow: 0 3px 0 var(--sun-dark); color: #fff; }
.key.miss { background: #e3dbd4; border-color: #d3c8bf; box-shadow: 0 3px 0 #d3c8bf; color: #a3968d; }

/* result and help */
.modal {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: grid;
    place-items: center;
    padding: 16px;
    background: rgba(42, 26, 61, .5);
}

.modal[hidden] { display: none; }

.modal-card {
    width: min(460px, 100%);
    max-height: 92vh;
    overflow-y: auto;
    background: var(--sand);
    border-radius: 24px;
    padding: 22px 22px 20px;
    box-shadow: 0 24px 60px rgba(42, 26, 61, .45);
    font-size: 16px;
    line-height: 1.5;
    text-align: center;
    animation: rise .3s ease-out;
}

@keyframes rise { from { opacity: 0; transform: translateY(14px); } }

.modal-card h2 { font-size: 32px; font-weight: 800; line-height: 1.1; color: var(--rock-dark); }
.modal-card .muted { color: var(--soft); }
.modal-card p { margin: 6px 0; }
.modal-card.help { text-align: left; }

/* the dug-up word, laid out like a fossil bone */
.bone {
    position: relative;
    display: inline-block;
    margin: 18px 0 10px;
    padding: 6px 30px;
    font-size: 30px;
    font-weight: 800;
    letter-spacing: 5px;
    text-transform: uppercase;
    color: #6f5a3e;
    background: #f7ecd6;
    border-radius: 10px;
    box-shadow: inset 0 -3px 0 rgba(111, 90, 62, .15);
}

.bone::before, .bone::after {
    content: "";
    position: absolute;
    top: 50%;
    width: 30px;
    height: 46px;
    transform: translateY(-50%);
    background:
        radial-gradient(circle at 50% 26%, #f7ecd6 0 11px, transparent 12px),
        radial-gradient(circle at 50% 74%, #f7ecd6 0 11px, transparent 12px);
}

.bone::before { left: -16px; }
.bone::after { right: -16px; }
.bone.lost { color: var(--stone-dark); }

.stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    margin: 12px 0;
}

.stats div { background: #fff; border-radius: 12px; padding: 6px 2px; }
.stats b { display: block; font-size: 26px; line-height: 1.1; color: var(--rock); }
.stats span { font-size: 12px; color: var(--soft); }

.dist { display: grid; gap: 3px; margin: 6px 0 16px; font-size: 13px; text-align: left; }
.dist div { display: flex; align-items: center; gap: 6px; }
.dist i {
    font-style: normal;
    display: inline-block;
    min-width: 22px;
    padding: 0 6px;
    border-radius: 6px;
    background: #e3dbd4;
    color: var(--ink);
    text-align: right;
    font-weight: 700;
}

.dist .me i { background: var(--cactus); color: #fff; }

.row-btns { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }

.help-demo { display: flex; gap: 5px; margin: 8px 0 2px; --tile: 36px; }

@media (max-width: 760px) {
    :root { --tile: min(13vw, 54px); }
    .scene { height: 200px; }
    .dig { margin: 92px 6px 12px; padding: 12px 10px 14px; border-radius: 20px; }
    .head { margin-top: -50px; gap: 6px; }
    .pip { width: 92px; height: 76px; }
    .title-wrap { padding-top: 36px; }
    .tag { font-size: 14px; }
    .grade-row { gap: 6px; }
    .grade-label { width: 100%; }
    .grades { gap: 5px; width: 100%; }
    .grade { min-width: 0; flex: 1 0 calc(100% / 7 - 6px); height: 34px; padding: 0; }
    .play { grid-template-columns: 1fr; gap: 10px; }
    .notes { max-height: none; }
    .log { min-height: 0; max-height: 96px; font-size: 14px; }
    .krow { gap: 4px; }
    .key { height: 50px; font-size: 16px; }
}
