:root {
  --ink:#193a37; --pine:#164744; --sand:#fbf7ed; --edge:#d8d4c6; --muted:#53655d;
  color:var(--ink); background:var(--sand);
}
body { min-height:100vh; padding-bottom:2rem; }
.game-nav,main { width:min(calc(100% - clamp(28px,7vw,92px)),1080px); margin-inline:auto; }
.game-nav { padding-block:10px; border-color:#ddd9ce; }
button { font:inherit; color:inherit; cursor:pointer; -webkit-tap-highlight-color:transparent; }
button:focus-visible,a:focus-visible { outline:3px solid #1568ae; outline-offset:3px; }
button:disabled { cursor:default; }
#help { min-height:42px; border:0; background:transparent; font-size:.91rem; font-weight:750; }
.query { display:inline-grid; place-items:center; width:1.3rem; height:1.3rem; border-radius:50%; border:1.5px solid currentColor; font-size:.8rem; margin-inline-end:.22rem; }
.hero { display:grid; grid-template-columns:1fr .94fr; min-height:196px; position:relative; isolation:isolate; overflow:hidden; background:var(--pine); color:#fff9e9; border-radius:20px; margin-block:18px; }
.hero::before { content:""; position:absolute; z-index:-1; inset:0; background-image:radial-gradient(#5a8175 1px,transparent 1px); background-size:12px 12px; opacity:.34; mask-image:linear-gradient(90deg,transparent,#000); }
.hero-copy { align-self:center; padding:clamp(20px,3.1vw,39px); }
h1,h2,h3,#lead-name,.depth,.actions { font-family:ui-rounded,"Trebuchet MS",system-ui,sans-serif; }
h1 { color:#fff9e9; font-size:clamp(2.9rem,5.3vw,4.55rem); font-weight:900; line-height:.97; margin:0; letter-spacing:-.062em; }
h1 em { display:block; color:#ffcf59; font-style:normal; }
.hero p { margin:14px 0 0; line-height:1.46; max-width:39ch; color:#e9eedf; font-weight:500; font-size:clamp(.93rem,1.5vw,1.09rem); }
.scene { position:relative; min-height:100%; overflow:hidden; clip-path:polygon(7% 0,100% 0,100% 100%,0% 100%); background:#86cdb3; }
.scene img { position:absolute; width:100%; height:100%; object-fit:cover; object-position:center 57%; }
.workbench { display:grid; grid-template-columns:minmax(0,1.64fr) minmax(265px,1fr); gap:16px; align-items:start; }
.panel { background:#fffef8; border:1px solid var(--edge); border-radius:18px; padding:clamp(16px,2vw,24px); }
.panel-head,.help-head { display:flex; align-items:center; justify-content:space-between; gap:10px; }
h2,h3,p { margin:0; }
h2 { font-size:clamp(1.4rem,2.2vw,1.8rem); line-height:1.1; letter-spacing:-.045em; }
h3 { font-size:1.17rem; line-height:1.2; letter-spacing:-.025em; }
.yard-lines { width:43px; height:8px; opacity:.8; transform:skew(-12deg); background:repeating-linear-gradient(115deg,#d1a948 0 5px,transparent 5px 9px); }
.guide,.geology p,#status { color:var(--muted); font-size:.88rem; line-height:1.4; }
.guide { margin:7px 0 13px; }
.board { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:6px; background:#315049; padding:8px; border:1px solid #324a44; border-radius:13px; direction:ltr; }
.bay { position:relative; display:grid; place-items:center; min-width:0; width:100%; height:clamp(72px,7.1vw,91px); overflow:hidden; border:2px solid transparent; border-radius:7px; background:#f1ecda; touch-action:manipulation; color:#263e38; user-select:none; }
.bay[data-level="0"] { background-color:#e2dfcc; background-image:radial-gradient(#c6c3ad .9px,transparent 1px); background-size:8px 8px; }
.bay[data-level="0"]::before { content:""; position:absolute; inset:5px; border:1px dashed #aea995; border-radius:4px; pointer-events:none; }
.bay-mark { font-size:1.35rem; line-height:1; font-weight:500; color:#777b65; }
.bay img { position:absolute; left:4%; top:5%; width:92%; height:90%; object-fit:contain; display:block; pointer-events:none; -webkit-user-drag:none; filter:drop-shadow(0 2px 1px #2d352124); }
.bay[data-level="1"] { background:#fbefc8; }
.bay[data-level="2"] { background:#fbe0bd; }
.bay[data-level="3"] { background:#d2ede1; }
.bay[data-level="4"] { background:#ffdbcb; }
.bay[data-level="5"] { background:#e9d8f7; }
.level-tag { position:absolute; inset-inline-start:4px; inset-block-start:3px; z-index:1; padding:0 4px; color:#244336; background:#fffdf1ed; border-radius:4px; font-size:.63rem; line-height:1.5; font-weight:800; }
.bay[draggable="true"] { cursor:grab; }
.bay[draggable="true"]:active { cursor:grabbing; }
.bay.tile-selected,.bay[aria-pressed="true"],.bay.drop-target { border-color:#146f67; box-shadow:inset 0 0 0 2px #fbfff1; }
.bay.can-merge { border:2px dashed #21735a; }
.bay:focus-visible { outline-color:#fff; outline-offset:-3px; box-shadow:inset 0 0 0 5px #1568ae; }
@media(hover:hover){.bay:hover {filter:brightness(1.05)}.actions button:hover:not(:disabled),#again:hover,.play-btn:hover {filter:brightness(1.06)}#help:hover {text-decoration:underline}}
.actions { display:grid; grid-template-columns:1fr 1fr; gap:10px; margin-top:13px; }
.actions button,.play-btn,#again { display:flex; align-items:center; justify-content:center; gap:.4rem; min-height:45px; border-radius:9px; line-height:1.15; font-weight:800; padding:8px 15px; }
.actions button:active:not(:disabled),#again:active,.play-btn:active {transform:translateY(2px)}
.add-btn { border:1px solid #77a28d; background:#e0eddb; color:#1d4a3d; box-shadow:0 2px #b7cbb5; }
.dig-btn,.play-btn,#again { border:1px solid #bd8d2e; background:#ffcd55; color:#332e1c; box-shadow:0 2px #b8872a; }
.actions button:disabled { border-color:#c9c5b5; box-shadow:none; color:#696c5e; background:#e8e6d9; }
.dig-arrow { font-size:1.06em; }
#status { min-height:2.8em; margin-top:10px; }
.depth { padding:3px 10px; background:#e3eee4; border-radius:9px; color:#285342; font-size:1.03rem; font-weight:800; font-variant-numeric:tabular-nums; }
.cutaway { margin-top:14px; height:clamp(134px,14vw,175px); position:relative; isolation:isolate; overflow:hidden; background:#795047; border-radius:11px; border:1px solid #9c7252; }
.seam { position:absolute; inset-inline:0; }
.soil { top:0; height:26%; background:radial-gradient(ellipse at 15% 72%,#b68153 0px 2.2px,transparent 3px) 0 0/24px 17px,#dfab6a; }
.clay { top:19%; height:42%; background:repeating-linear-gradient(168deg,transparent 0 17px,#c78b59 18px 20px,transparent 21px 31px),#b8774f; clip-path:polygon(0 8%,19% 4%,47% 16%,75% 0,100% 12%,100% 100%,0 100%); }
.rock { top:51%; height:42%; background:radial-gradient(ellipse at 34% 69%,#8c6658 0px 5px,transparent 6px) 0 0/39px 27px,#9d7564; clip-path:polygon(0 15%,21% 1%,53% 13%,79% 3%,100% 12%,100% 100%,0 100%); }
.fossil-bed { top:80%; height:24%; background:repeating-linear-gradient(166deg,transparent 0 21px,#744f45 22px 25px),#684a43; clip-path:polygon(0 16%,21% 1%,52% 13%,78% 0,100% 13%,100% 100%,0 100%); }
.cutaway::after { content:""; position:absolute; inset:0; pointer-events:none; opacity:.23; background-image:radial-gradient(#553c3c .8px,transparent 1px); background-size:8px 7px; }
.gauge { position:absolute; top:6px; bottom:8px; left:36%; width:11px; border-inline:1px dashed #ffeaca; }
.bore { width:100%; height:var(--depth,0%); background:#463b30; transition:height .35s ease; }
.gauge i { position:absolute; top:var(--depth,0%); left:50%; width:17px; height:12px; transform:translate(-50%,-50%); clip-path:polygon(0 0,100% 0,80% 80%,50% 100%,20% 80%); background:#ffcd55; transition:top .35s ease; }
.depth-tag { position:absolute; left:8px; font-size:.69rem; padding:1px 5px; font-weight:750; background:#fff5d8; color:#543c30; border-radius:3px; }
.top-tag { top:7px; }.base-tag { bottom:7px; }
.fossil-imprint { position:absolute; right:14%; bottom:0; width:46px; transform:rotate(5deg); opacity:.83; }
.shell {display:block;width:100%;height:auto;}
.geology { margin-block:12px; }.geology p { margin-top:3px; }
.lead { display:flex; align-items:center; gap:10px; padding-top:10px; border-top:1px dashed #c6c9bb; }
.lead img { width:69px; height:54px; object-fit:contain; background:#f9efcf; border-radius:8px; }
.sub,#roster span { display:block; color:var(--muted); font-size:.72rem; }
#lead-name {font-weight:800;line-height:1.2}
#lead-level { margin-inline-start:auto; white-space:nowrap; color:#325746; background:#edf1e3; border-radius:6px; padding:3px 6px; font-size:.75rem; font-weight:800; }
.collection { margin-block-start:16px; }
.collection h2 { font-size:1.35rem; }
#roster { display:grid; grid-template-columns:repeat(5,minmax(0,1fr)); gap:7px; padding:0; margin:14px 0 0; list-style:none; }
#roster li { display:flex; align-items:center; gap:6px; min-width:0; padding:7px; border:1px dashed #d0cdbf; border-radius:9px; background:#f6f3e9; }
#roster img { width:43%; max-width:64px; height:45px; object-fit:contain; filter:grayscale(.93); opacity:.58; }
#roster strong {display:block;font-size:.83rem; line-height:1.16; }
#roster li.unlocked { border:1px solid #c6d7bd; background:#eff4e7; }
#roster li.unlocked img { opacity:1; filter:none; }
.win { display:flex; align-items:center; gap:18px; background:#fff0c2; border:1px solid #dcba5d; border-radius:16px; padding:15px 20px; margin-top:16px; }
.win[hidden] {display:none}.win .shell { width:74px; }.win p { margin-top:3px; font-size:.9rem; }.win button { margin-inline-start:auto;white-space:nowrap; }
dialog { width:min(425px,92vw); padding:22px; background:#fffdf3; color:var(--ink); border:1px solid #c7c5b5; border-radius:17px; box-shadow:0 22px 80px #152d3255; }
dialog::backdrop { background:#172e2bb3; }
.close { border:0; border-radius:50%; width:36px; height:36px; background:#eeeadd; font-size:1.4rem; }
dialog ol {padding-inline-start:1.3rem}dialog li {margin-block:.65rem;line-height:1.47}.play-btn {width:100%}
.sr-only {position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}
@keyframes bump {0%{transform:scale(.82)}55%{transform:scale(1.08)}100%{transform:scale(1)}}
@keyframes shovel {25%{transform:translateY(-3px) rotate(-4deg)}70%{transform:translateY(1px) rotate(3deg)}}
.bay.merged img {animation:bump .35s ease-out}.digging .lead img {animation:shovel .4s ease-out}
@media(max-width:760px) {
  .workbench {grid-template-columns:minmax(0,1.4fr) minmax(210px,1fr);gap:10px}
  .hero {margin-block:12px}.panel {padding:14px}.bay {height:65px}.board {gap:4px;padding:6px}.lead img {width:52px}
  #roster li {flex-direction:column;align-items:flex-start;gap:0}#roster img {width:70%;height:40px}
}
@media(max-width:620px) {
  .game-nav {padding-block:4px}.hero {grid-template-columns:1.16fr 1fr;min-height:120px;border-radius:14px}
  .hero-copy {padding:15px 0 15px 16px}h1 {font-size:clamp(1.85rem,7.5vw,2.9rem)}
  .hero p {font-size:.77rem;line-height:1.35;margin-top:7px;max-width:26ch}
  .scene img {object-fit:contain;background:linear-gradient(to bottom,#7fceb0 50%,#e9ab57 50%)}
  .workbench {grid-template-columns:1fr;gap:12px}.bay {height:clamp(53px,14.7vw,78px)}
  .board {gap:5px;padding:6px}.panel {border-radius:13px;padding:14px}.guide {font-size:.8rem; margin:5px 0 9px}
  .actions {margin-top:9px}.actions button {min-height:43px}#status {margin-top:8px;font-size:.81rem;min-height:1.4em}
  .cutaway {height:122px}.collection {margin-top:12px}#roster {grid-template-columns:repeat(3,minmax(0,1fr))}
  #roster li {align-items:center;text-align:center}.win {gap:8px;flex-wrap:wrap}.win .shell {width:55px}.win div {flex:1;min-width:135px}
}
@media(prefers-reduced-motion:reduce){*,*::before,*::after {animation:none!important;transition:none!important;scroll-behavior:auto!important}}
