@font-face { font-family: B; src: url(fonts/barlow-latin-500-normal.woff2) format('woff2'); font-weight: 500; }
@font-face { font-family: B; src: url(fonts/barlow-latin-700-normal.woff2) format('woff2'); font-weight: 700; }
@font-face { font-family: BC; src: url(fonts/barlow-condensed-latin-800-normal.woff2) format('woff2'); font-weight: 800; }
@font-face { font-family: JM; src: url(fonts/jetbrains-mono-latin-800-normal.woff2) format('woff2'); font-weight: 800; }

:root {
  --cream: #fbf4ea;
  --paper: #fffaf3;
  --ink: #1f2440;
  --navy: #262b52;
  --coral: #f2694e;
  --teal: #1f8a83;
  --mustard: #f4b52f;
  --muted: #8a8070;
  --tile: #efe2cf;
  --tile-hi: #fff6ea;
  --tile-lo: #d9c6ab;
  --open: #fffdf8;
  --n1: #2a6fdb; --n2: #1f8a3c; --n3: #e2483a; --n4: #3b2c9e;
  --n5: #9a2b1f; --n6: #1f8a83; --n7: #222; --n8: #777;
  --cell: min(84px, calc((100vw - 76px) / 6));
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body { font: 500 16px/1.4 B, system-ui, sans-serif; color: var(--ink); background: #e9b98f; overflow-x: hidden; }
button { font: inherit; color: inherit; cursor: pointer; }

/* The 90s desk, softly out of focus behind everything */
.desk { position: fixed; inset: -24px; background: url(art/bg-desk.webp) center / cover; filter: blur(7px) saturate(1.05); transform: scale(1.04); z-index: -2; }
.desk::after { content: ''; position: absolute; inset: 0; background: radial-gradient(ellipse at 50% 40%, rgba(251, 244, 234, .55), rgba(251, 244, 234, .82) 75%); }

.app { max-width: 1240px; margin: 0 auto; padding: 18px 16px 28px; }
.top { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-bottom: 12px; text-align: center; }
.logo { margin: 0; font: 800 clamp(34px, 6vw, 54px)/1 BC, sans-serif; letter-spacing: 4px; color: var(--navy); }
.logo i { font-style: normal; color: var(--coral); margin: 0 6px; }
.meta { display: flex; align-items: center; gap: 8px; color: var(--muted); font-weight: 700; font-size: 14px; letter-spacing: .5px; }
.chip { background: var(--paper); border: 1px solid #e6d6bf; border-radius: 999px; min-width: 38px; height: 38px; padding: 0 10px; font-weight: 700; box-shadow: 0 2px 0 #e2cfb4; }

.modes { display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; margin: 0 0 14px; }
.tabs { display: inline-flex; background: var(--paper); border-radius: 999px; padding: 4px; box-shadow: 0 2px 0 #e2cfb4; }
.tab { border: 0; background: transparent; border-radius: 999px; padding: 8px 16px; font: 800 15px/1 BC, sans-serif; letter-spacing: 1.5px; text-transform: uppercase; color: var(--muted); }
.tab.on { background: var(--navy); color: #fff; }
.levels { display: flex; gap: 8px; }
.lvl { width: 40px; height: 40px; border-radius: 12px; border: 0; background: var(--paper); box-shadow: 0 3px 0 #e2cfb4; font: 800 18px/1 JM, monospace; color: var(--navy); }
.lvl.on { background: var(--coral); color: #fff; box-shadow: 0 3px 0 #c4472f; }
.lvl.done { color: var(--mustard); }
.lvl.on.done { color: #fff; }
.lvl:disabled { opacity: .4; cursor: not-allowed; }
.stage { display: grid; grid-template-columns: 1fr auto 1fr; gap: 22px; align-items: end; }
.stage::after { content: ''; }
.stage .sweeper { justify-self: end; width: min(300px, 100%); }
.sweeper { position: relative; display: flex; flex-direction: column; align-items: center; align-self: stretch; justify-content: flex-end; min-height: 420px; }
.kid { width: 100%; max-width: 260px; height: auto; transform-origin: 50% 100%; filter: drop-shadow(0 14px 18px rgba(60, 30, 10, .25)); transition: transform .25s; }
.kid.bob { animation: bob 1.6s ease-in-out infinite; }
.kid.shake { animation: shake .45s; }
.kid.jump { animation: jump .7s ease-out; }
@keyframes bob { 50% { transform: translateY(-6px); } }
@keyframes shake { 20%, 60% { transform: translateX(-8px) rotate(-3deg); } 40%, 80% { transform: translateX(8px) rotate(3deg); } }
@keyframes jump { 40% { transform: translateY(-26px) scale(1.04); } }

.bubble { position: relative; background: #fff; border-radius: 22px; padding: 14px 18px; font-weight: 700; font-size: 17px; line-height: 1.3; box-shadow: 0 10px 30px rgba(60, 30, 10, .15); margin-bottom: 14px; max-width: 290px; min-height: 56px; opacity: 0; transform: translateY(8px) scale(.96); transition: opacity .2s, transform .2s; }
.bubble.on { opacity: 1; transform: none; }
.bubble::after { content: ''; position: absolute; left: 50%; bottom: -14px; margin-left: -12px; border: 12px solid transparent; border-top: 14px solid #fff; border-bottom: 0; }
.bubble small { display: block; font: 800 12px/1 BC, sans-serif; letter-spacing: 2px; color: var(--coral); margin-bottom: 6px; }
.bubble.tense { background: #fff1d6; }
.bubble.tense::after { border-top-color: #fff1d6; }

.play { background: var(--paper); border-radius: 26px; padding: 14px; box-shadow: 0 30px 60px rgba(60, 30, 10, .22), 0 2px 0 #f0e2cf inset; transition: background .6s, border-radius .6s, box-shadow .6s; }
.bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.counter { display: flex; align-items: center; gap: 6px; background: var(--navy); color: #ffd36b; border-radius: 12px; padding: 6px 12px; font: 800 22px/1 JM, monospace; }
.counter img { width: 24px; height: 24px; }
.counter span { font: 800 11px/1 BC, sans-serif; letter-spacing: 2px; color: #b9bce0; }
.status { flex: 1; text-align: center; font: 800 20px/1.1 BC, sans-serif; letter-spacing: 1px; color: var(--navy); text-transform: uppercase; }

.board { display: grid; grid-template-columns: repeat(6, var(--cell)); gap: 6px; width: max-content; margin: 0 auto; padding: 8px; background: #e4d3bb; border-radius: 18px; touch-action: manipulation; user-select: none; position: relative; }
.board.shake { animation: boardshake .5s; }
@keyframes boardshake { 15% { transform: translate(-7px, 3px); } 30% { transform: translate(6px, -4px); } 45% { transform: translate(-5px, -2px); } 60% { transform: translate(4px, 4px); } 80% { transform: translate(-2px, 1px); } }

.cell { width: var(--cell); height: var(--cell); border: 0; border-radius: 11px; background: linear-gradient(160deg, var(--tile-hi), var(--tile)); box-shadow: 0 4px 0 var(--tile-lo), 0 6px 10px rgba(80, 50, 20, .12); display: grid; place-items: center; position: relative; padding: 0; transition: transform .12s, box-shadow .12s, background .2s; font: 800 calc(var(--cell) * .5)/1 JM, monospace; }
.cell:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--tile-lo); }
.cell img { width: 78%; height: 78%; object-fit: contain; pointer-events: none; }
.cell.mine img { animation: drop .25s ease-out; }
@keyframes drop { from { transform: translateY(-14px) scale(1.2); opacity: 0; } }
.cell.safe { background: linear-gradient(160deg, #f7f0e3, #ece0cc); box-shadow: 0 3px 0 #dccab0; cursor: not-allowed; }
.cell.pad { background: radial-gradient(circle, var(--mustard) 0 30%, #f9d77a 31% 44%, #f7ecd6 45%); box-shadow: 0 3px 0 #dccab0; }
.cell.pad::after { content: 'START'; position: absolute; bottom: 2px; font: 800 calc(var(--cell) * .17)/1 BC, sans-serif; letter-spacing: 1px; color: var(--navy); }
.cell.rock { background: linear-gradient(150deg, #a39a8c, #7c7366); box-shadow: 0 4px 0 #5f574b, inset 0 2px 0 rgba(255, 255, 255, .25); cursor: default; border-radius: 40% 30% 45% 35%; }
.cell.open { background: var(--open); box-shadow: inset 0 0 0 1px #f0e4d2; animation: pop .28s ease-out; cursor: default; }
@keyframes pop { 0% { transform: scale(.7); } 70% { transform: scale(1.06); } }
.cell.open.n1 { color: var(--n1); } .cell.open.n2 { color: var(--n2); } .cell.open.n3 { color: var(--n3); } .cell.open.n4 { color: var(--n4); }
.cell.open.n5 { color: var(--n5); } .cell.open.n6 { color: var(--n6); } .cell.open.n7 { color: var(--n7); } .cell.open.n8 { color: var(--n8); }
.cell.flagged { background: linear-gradient(160deg, #fff0e6, #f9dccd); }
.cell.think { outline: 5px solid var(--teal); outline-offset: 1px; z-index: 2; box-shadow: 0 0 0 9px rgba(31, 138, 131, .18); }
.cell.aim { outline: 4px dashed var(--teal); outline-offset: -6px; background: #e3f4f1; }
.cell.aim-flag { outline: 4px dashed var(--coral); outline-offset: -6px; background: #fde7df; }
.cell.target { outline: 4px dashed var(--coral); outline-offset: 2px; z-index: 3; animation: pulse .5s ease-in-out infinite alternate; }
@keyframes pulse { to { transform: scale(1.08); } }
.cell.boom { background: radial-gradient(circle, #ffd36b, var(--coral) 60%, #b8321f); animation: boom .5s ease-out; z-index: 4; }
@keyframes boom { 0% { transform: scale(1); } 30% { transform: scale(1.5); } 100% { transform: scale(1); } }
.cell.reveal img { opacity: .55; }
.board.playing .cell { cursor: default; }

.meter { display: flex; gap: 12px; align-items: center; }
.meter-body { flex: 1; min-width: 0; }
.mine-buddy { flex: none; width: 64px; height: 64px; transform-origin: 50% 90%; }
.mine-buddy img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 6px 6px rgba(30, 20, 40, .25)); }
.mine-buddy.talk { animation: talk .45s ease-out; }
.mine-buddy.hot.talk { animation: talk .45s ease-out, wiggle .5s .45s ease-in-out infinite; }
.mine-buddy.wild { animation: wiggle .25s ease-in-out infinite !important; }
@keyframes talk { 0% { transform: scale(.85) translateY(4px); } 60% { transform: scale(1.12) translateY(-6px); } }
@keyframes wiggle { 25% { transform: rotate(-10deg); } 75% { transform: rotate(10deg); } }
.mine-text { margin: 0 0 6px; font-weight: 700; font-size: 16px; line-height: 1.3; color: var(--navy); }
.mine-buddy.hot + .meter-body .mine-text { color: #c4472f; }
.meter, .moves { margin-top: 12px; background: #f6ecdf; border-radius: 14px; padding: 10px 12px; }
.meter-head { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; font-weight: 700; font-size: 16px; }
.meter-head span:first-child { font: 800 12px/1 BC, sans-serif; letter-spacing: 2px; color: var(--muted); flex: none; }
.meter-head span:last-child { text-align: right; }
.meter-track { height: 12px; background: #e7d8c3; border-radius: 99px; margin-top: 8px; overflow: hidden; }
.meter-fill { height: 100%; width: 0; background: #c9b9a2; border-radius: 99px; transition: width .4s ease, background .4s; }
.meter.warm .meter-fill { background: var(--mustard); }
.meter.hot .meter-fill { background: var(--coral); }
.meter.hot .meter-head span:last-child { color: #c4472f; }
.moves ol { list-style: none; margin: 8px 0 0; padding: 0; max-height: 150px; overflow: auto; }
.moves li { padding: 7px 4px; border-top: 1px solid #eadcc8; font-size: 15px; animation: rise .3s ease-out; }
.moves li:first-child { font-weight: 700; }
.moves li b { display: inline-grid; place-items: center; min-width: 22px; height: 22px; border-radius: 6px; background: var(--navy); color: #fff; font: 800 12px/1 JM, monospace; margin-right: 6px; }
.moves li.flag b { background: var(--coral); }
.moves li.guess b { background: var(--mustard); color: var(--navy); }
.moves li.boom b { background: #b8321f; }
.actions { display: flex; gap: 10px; justify-content: center; margin-top: 14px; flex-wrap: wrap; }
.btn { border: 0; border-radius: 14px; padding: 12px 22px; font: 800 18px/1 BC, sans-serif; letter-spacing: 1.5px; text-transform: uppercase; }
.btn.primary { background: var(--coral); color: #fff; box-shadow: 0 4px 0 #c4472f; }
.btn.primary:disabled { background: #d9cbb8; box-shadow: 0 4px 0 #c2b29b; cursor: not-allowed; }
.btn.ghost { background: transparent; border: 2px solid #e1cfb6; }
.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: none; }

.result { margin: 18px auto 0; max-width: 560px; background: var(--paper); border-radius: 26px; padding: 22px 22px 18px; text-align: center; box-shadow: 0 30px 60px rgba(60, 30, 10, .22); animation: rise .4s ease-out; }
@keyframes rise { from { transform: translateY(20px); opacity: 0; } }
.result img { height: 150px; margin-top: -90px; filter: drop-shadow(0 10px 14px rgba(60, 30, 10, .25)); }
.result h2 { margin: 6px 0 4px; font: 800 34px/1 BC, sans-serif; letter-spacing: 1px; color: var(--navy); }
.result p { margin: 0 0 10px; color: #5b5346; }
.grid-share { display: inline-block; margin: 4px auto 0; font: 15px/1.1 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif; letter-spacing: 0; white-space: pre; }
.copied { color: var(--teal); font-weight: 700; margin-top: 8px; }

dialog { border: 0; border-radius: 22px; padding: 24px; max-width: 460px; box-shadow: 0 30px 80px rgba(0, 0, 0, .3); color: var(--ink); background: var(--paper); }
dialog::backdrop { background: rgba(31, 36, 64, .35); }
dialog h2 { font: 800 30px/1 BC, sans-serif; margin: 0 0 10px; color: var(--navy); }
dialog li { margin: 6px 0; }
.foot { text-align: center; color: #7d705d; font-size: 13px; margin-top: 18px; }

/* ---- The old look, for the first second: grey, square, bevelled. ---- */
body.old .desk { filter: grayscale(1) blur(9px); }
body.old .play { background: #c0c0c0; border-radius: 0; box-shadow: inset -2px -2px #808080, inset 2px 2px #fff; }
body.old .board { background: #c0c0c0; border-radius: 0; gap: 0; padding: 4px; box-shadow: inset 2px 2px #808080, inset -2px -2px #fff; }
body.old .cell { border-radius: 0; background: #c0c0c0; box-shadow: inset -3px -3px #808080, inset 3px 3px #fff; }
body.old .cell img, body.old .cell::after { opacity: 0; }
body.old .logo, body.old .status { color: #000; font-family: 'Courier New', monospace; letter-spacing: 0; }
body.old .logo i { color: #000; }
body.old .counter { background: #000; color: #f00; border-radius: 0; }
body.old .sweeper, body.old .actions, body.old .meta, body.old .foot, body.old .modes, body.old .meter { opacity: 0; }
body.waking * { transition: all 1.4s cubic-bezier(.2,.8,.2,1) !important; }

/* The REMIXED stamp: lands on the old game, then flies at you as it wakes up. */
.remixed { position: fixed; inset: 0; display: grid; place-items: center; pointer-events: none; z-index: 50; }
.remixed span { font: 800 clamp(64px, 14vw, 160px)/1 BC, sans-serif; letter-spacing: 10px; color: var(--coral); border: 10px solid var(--coral); border-radius: 22px; padding: 8px 30px 4px; background: rgba(255, 250, 243, .9); box-shadow: 0 30px 80px rgba(0, 0, 0, .25); opacity: 0; transform: scale(3) rotate(-14deg); }
.remixed.stamp span { animation: stamp .45s cubic-bezier(.2, 1.6, .4, 1) forwards; }
.remixed.fly span { animation: fly 1.1s cubic-bezier(.6, 0, .9, .4) forwards; }
@keyframes stamp { from { opacity: 0; transform: scale(3) rotate(-14deg); } to { opacity: 1; transform: scale(1) rotate(-8deg); } }
@keyframes fly { from { opacity: 1; transform: scale(1) rotate(-8deg); } 30% { opacity: 1; transform: scale(1.15) rotate(-4deg); } to { opacity: 0; transform: scale(7) rotate(0deg); filter: blur(6px); } }

@media (max-width: 760px) {
  .stage { grid-template-columns: 1fr; gap: 6px; }
  .stage::after { display: none; }
  .stage .sweeper { justify-self: center; width: auto; }
  .sweeper { min-height: 0; flex-direction: row; align-items: flex-end; justify-content: center; gap: 8px; order: -1; }
  .kid { width: 110px; }
  .bubble { margin-bottom: 30px; font-size: 15px; }
  .bubble::after { left: auto; right: -14px; bottom: 16px; border: 12px solid transparent; border-left: 14px solid #fff; border-right: 0; }
  .bubble.tense::after { border-left-color: #fff1d6; border-top-color: transparent; }
  .play { padding: 10px; }
  .logo { font-size: 30px; letter-spacing: 2px; }
  .meta { font-size: 12px; gap: 6px; }
  #mode { white-space: nowrap; }
  .chip { min-width: 34px; height: 34px; }
  .status { font-size: 16px; }
  .result img { height: 110px; margin-top: -70px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

.meter.quiet .meter-head, .meter.quiet .meter-track { display: none; }
.counter.out b { color: var(--coral); }
