:root {
  --s: 44px;
  --sky1: #6cbcf0; --sky2: #d4f0ff;
  --ink: #1b1c20; --cream: #fff5de;
  --hazard: #ffc400; --hazard-dk: #c78f00;
  --steel: #d6432c; --steel-dk: #8c2414; --steel-lt: #ff7a5c;
  --pole: #9aa6b2; --pole-dk: #5e6a76;
  --site: #2b3a4a; --site-dk: #1d2833;
  --v0: #d4472e; --v1: #23855a; --v2: #2c68c0; --v3: #8448bb;
  --ok: #20a35a; --bad: #e0442a;
  --stencil: "Big Shoulders Stencil Display", "Big Shoulders Stencil", "Allerta Stencil", Impact, "Arial Narrow Bold", sans-serif;
  --cond: "Barlow Condensed", "Arial Narrow", system-ui, sans-serif;
  --body: "Barlow", system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
html { background: #f3e7cf; }
[hidden] { display: none !important; }
body {
  font-family: var(--body); color: var(--ink);
  background: linear-gradient(180deg, var(--sky1) 0, var(--sky2) 700px, #f3e7cf 1200px);
  min-height: 100vh; overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; cursor: pointer; }

/* drifting clouds */
.sky { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.cloud { position: absolute; display: block; width: 120px; height: 34px; border-radius: 30px; background: #fff; opacity: .75; animation: drift 90s linear infinite; }
.cloud::before, .cloud::after { content: ""; position: absolute; background: #fff; border-radius: 50%; }
.cloud::before { width: 54px; height: 54px; left: 18px; top: -26px; }
.cloud::after { width: 40px; height: 40px; left: 60px; top: -16px; }
.c1 { top: 8%; left: -20%; animation-duration: 110s; }
.c2 { top: 22%; left: -40%; transform: scale(.7); animation-duration: 140s; animation-delay: -60s; }
.c3 { top: 4%; left: -30%; transform: scale(.55); animation-duration: 170s; animation-delay: -120s; }
@keyframes drift { to { translate: 160vw 0; } }

.app { position: relative; z-index: 1; max-width: 480px; margin: 0 auto; padding: max(10px, env(safe-area-inset-top)) 16px 28px; }

/* header */
.top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.logo { margin: 0; display: flex; align-items: center; gap: 8px; font-family: var(--stencil); font-weight: 900; font-size: 30px; line-height: .86; text-transform: uppercase; letter-spacing: .5px; color: var(--ink); }
.logo span { text-shadow: 2px 2px 0 var(--hazard); }
.logobot { width: 46px; height: auto; filter: drop-shadow(0 2px 2px #0003); animation: nod 5s ease-in-out infinite; transform-origin: 50% 90%; }
@keyframes nod { 0%, 86%, 100% { rotate: 0deg; } 90% { rotate: -9deg; } 95% { rotate: 6deg; } }
.siteinfo { display: flex; flex-direction: column; align-items: flex-end; font-family: var(--cond); font-weight: 700; font-size: 15px; line-height: 1.2; text-align: right; }
.siteinfo #siteNo { font-size: 18px; }
.link { background: none; border: 0; padding: 0; text-decoration: underline; text-underline-offset: 2px; font-family: var(--cond); font-weight: 700; color: #0b4f8a; }

/* gauges */
.gauges { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 8px 0 6px; }
.gauge { background: var(--ink); color: var(--hazard); border-radius: 10px; padding: 5px 8px 4px; text-align: center; box-shadow: inset 0 0 0 2px #ffffff14, 0 3px 0 #0003; }
.gauge b { display: block; font-family: var(--cond); font-weight: 800; font-size: 24px; line-height: 1; font-variant-numeric: tabular-nums; }
.gauge small { display: block; font-family: var(--cond); font-weight: 600; font-size: 11px; letter-spacing: .7px; white-space: nowrap; text-transform: uppercase; color: #ffe9a3; opacity: .8; }
.gauge.bump b { animation: bump .45s ease-out; }
@keyframes bump { 30% { transform: scale(1.25); color: #fff; } }

/* GuffBot's beacon */
.beacon { display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 10px 0 4px; border-radius: 17px; background: #ffffffc4; width: max-content; max-width: 100%; margin: 0 auto 4px; font-family: var(--cond); font-weight: 700; font-size: 16px; box-shadow: 0 2px 0 #0001; }
.beacon .bot { position: relative; width: 30px; height: 33px; flex: none; }
.beacon .bot img { width: 30px; position: absolute; bottom: 0; left: 0; }
.beacon .light { position: absolute; left: 50%; top: -3px; width: 12px; height: 12px; margin-left: -6px; border-radius: 50%; background: var(--lc, #20c35a); box-shadow: 0 0 8px 3px var(--lc, #20c35a); }
.beacon[data-state="clear"] { --lc: #19c45a; }
.beacon[data-state="checking"] { --lc: #ffb300; }
.beacon[data-state="checking"] .light { animation: blink .7s ease-in-out infinite; }
.beacon[data-state="unknown"] { --lc: #9aa6b2; }
.beacon[data-state="stuck"] { --lc: #ff2a10; background: #ffe2dc; color: #8c1a08; }
.beacon[data-state="stuck"] .light { animation: blink .45s steps(2) infinite; }
.beacon.alarm { animation: nope .4s; }
@keyframes blink { 50% { opacity: .3; box-shadow: 0 0 2px 1px var(--lc); } }

/* the word being spelled */
.wordbar { height: 58px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.tip { display: flex; align-items: center; gap: 6px; font-family: var(--cond); font-weight: 700; font-size: 15px; color: #23384d; background: #ffffff8c; border-radius: 10px; padding: 4px 4px 4px 10px; }
.x { border: 0; background: #1b1c2014; width: 26px; height: 26px; border-radius: 13px; font-size: 13px; line-height: 1; display: grid; place-items: center; flex: none; }
.current { display: flex; align-items: center; gap: 8px; }
.wordtiles { display: flex; gap: 3px; min-height: 34px; }
.wordtiles .wt { width: 30px; height: 34px; border-radius: 5px; display: grid; place-items: center; font-family: var(--body); font-weight: 800; font-size: 21px; background: var(--hazard); color: var(--ink); box-shadow: inset 0 -3px 0 #0002; animation: pop .18s ease-out; }
.wordtiles .wt img { width: 26px; }
.wordtiles.valid .wt { background: #7be3a2; }
.wordtiles.nope { animation: nope .35s; }
@keyframes pop { from { transform: scale(.4); } }
@keyframes nope { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
.wordmsg { font-family: var(--cond); font-weight: 600; font-size: 15px; color: #23384d; text-align: center; min-height: 18px; line-height: 18px; }

/* the site */
.siteframe { position: relative; margin: 0 auto; padding: 46px 14px 18px; width: max-content; touch-action: none; user-select: none; -webkit-user-select: none; }
.jib { position: absolute; left: -2px; right: -2px; top: 4px; height: 26px; }
.jibtruss { position: absolute; inset: 4px 0 6px 0; border-top: 4px solid var(--hazard-dk); border-bottom: 4px solid var(--hazard-dk);
  background: repeating-linear-gradient(60deg, transparent 0 9px, var(--hazard) 9px 13px, transparent 13px 22px), repeating-linear-gradient(-60deg, transparent 0 9px, var(--hazard) 9px 13px, transparent 13px 22px); }
.cab { position: absolute; left: 4px; top: -2px; width: 30px; height: 28px; border-radius: 4px 4px 2px 2px; background: var(--hazard); border: 3px solid var(--hazard-dk); }
.cab::after { content: ""; position: absolute; inset: 3px 4px 10px; background: #bfe6ff; border-radius: 2px; }
.hook { position: absolute; top: 24px; left: 50%; width: 0; height: 0; z-index: 6; pointer-events: none; }
.cable { position: absolute; left: -1.5px; top: 0; width: 3px; height: 0; background: #2a2a2a; }
.hookhead { position: absolute; left: -10px; top: 0; width: 20px; height: 22px; }
.hookhead::before { content: ""; position: absolute; left: 3px; top: 0; width: 14px; height: 8px; background: var(--hazard); border: 2px solid var(--ink); border-radius: 3px; }
.hookhead::after { content: ""; position: absolute; left: 4px; top: 8px; width: 10px; height: 10px; border: 3px solid var(--ink); border-top-color: transparent; border-left-color: transparent; border-radius: 50%; transform: rotate(45deg); }
.pole { position: absolute; top: 30px; bottom: 6px; width: 8px; border-radius: 3px; background: linear-gradient(90deg, var(--pole-dk), #d7dee5 40%, var(--pole)); }
.pole::after { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(180deg, transparent 0 calc(var(--s) - 5px), #4a545e calc(var(--s) - 5px) var(--s)); opacity: .55; }
.pole.left { left: 2px; } .pole.right { right: 2px; }
.ground { position: absolute; left: -6px; right: -6px; bottom: 0; height: 18px; border-radius: 4px;
  background: repeating-linear-gradient(-45deg, var(--hazard) 0 12px, var(--ink) 12px 24px); box-shadow: 0 3px 0 #0003; }

.board { position: relative; width: calc(var(--s) * 6); height: calc(var(--s) * 8); border-radius: 6px;
  background:
    linear-gradient(90deg, #ffffff0c 1px, transparent 1px) 0 0 / var(--s) var(--s),
    linear-gradient(180deg, #ffffff0c 1px, transparent 1px) 0 0 / var(--s) var(--s),
    linear-gradient(180deg, var(--site) 0%, var(--site-dk) 100%);
  box-shadow: inset 0 0 0 2px #0004, inset 0 10px 24px #0005; overflow: visible; }
.board.shake { animation: shake .42s cubic-bezier(.36,.07,.19,.97); }
.board.shake-big { animation: shake2 .6s cubic-bezier(.36,.07,.19,.97); }
@keyframes shake { 20% { translate: -4px 2px; } 40% { translate: 4px -2px; } 60% { translate: -3px 1px; } 80% { translate: 2px 0; } }
@keyframes shake2 { 10% { translate: -8px 4px; } 25% { translate: 8px -5px; } 40% { translate: -6px 3px; } 55% { translate: 5px -2px; } 70% { translate: -3px 1px; } 85% { translate: 2px 0; } }

.tile, .girder { position: absolute; left: 0; top: 0; width: var(--s); height: var(--s); padding: 2px; will-change: transform; transform-origin: 50% 100%; }
.p { width: 100%; height: 100%; border-radius: 7px; display: grid; place-items: center; position: relative; transition: transform .12s, box-shadow .12s, background-color .12s; }
.tile.L .p {
  font-family: var(--body); font-weight: 800; font-size: calc(var(--s) * .56); line-height: 1; color: #fff;
  text-shadow: 0 1px 0 #0003;
  background: linear-gradient(180deg, #ffffff30, transparent 50%, #00000022), var(--c);
  box-shadow: inset 0 0 0 1.5px #0002, inset 0 -3px 0 #0003, 0 2px 0 #0004;
}
.tile.v0 { --c: var(--v0); } .tile.v1 { --c: var(--v1); } .tile.v2 { --c: var(--v2); } .tile.v3 { --c: var(--v3); }
.tile.L .p span { transform: translateY(.5px); }

.tile.W .p { background:
    repeating-linear-gradient(-45deg, transparent 0 7px, #ffffff9c 7px 10px, transparent 10px 17px),
    linear-gradient(180deg, #ff9a2e, #ff6a00);
  box-shadow: inset 0 0 0 1.5px #0003, inset 0 -3px 0 #0003, 0 2px 0 #0004; }
.tile.W img { width: 92%; height: auto; margin-top: -6%; filter: drop-shadow(0 1px 1px #0006); pointer-events: none; }

.tile.B .p { background:
    linear-gradient(180deg, #0000 0 31%, #0003 31% 34%, #0000 34% 64%, #0003 64% 67%, #0000 67%),
    linear-gradient(180deg, #a3703f, #6e4522);
  box-shadow: inset 0 0 0 2px #3c240f, inset 0 -3px 0 #0004, 0 2px 0 #0004; }
.tile.B svg { width: 86%; height: 86%; overflow: visible; }
.tile.B .spark { transform-origin: center; transform-box: fill-box; animation: spark .5s steps(2) infinite; }
@keyframes spark { 50% { transform: scale(.55) rotate(30deg); opacity: .75; } }

.girder { height: var(--s); padding: 3px 1px; }
.girder svg { display: block; width: 100%; height: 100%; filter: drop-shadow(0 3px 0 #0005); }

.tile.sel .p { transform: translateY(-3px) scale(1.04); box-shadow: 0 0 0 3px var(--hazard), 0 6px 10px #0006; }
.tile.L.sel .p { background-color: #f2a516; color: var(--ink); text-shadow: none; }
.tile.lifted { z-index: 5; }
.tile.hint .p { animation: hintglow .7s ease-in-out infinite alternate; box-shadow: 0 0 0 3px #fff, 0 0 14px 4px #19c45a; }
@keyframes hintglow { to { transform: translateY(-4px) scale(1.06); } }
.tile.dim .p { filter: saturate(.5) brightness(.85); }

.chain { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 4; overflow: visible; }
.chain polyline { fill: none; stroke: var(--ink); stroke-width: 7; stroke-linecap: round; stroke-linejoin: round; opacity: .55; }
.chain polyline.top { stroke: var(--hazard); stroke-width: 3; stroke-dasharray: 6 6; opacity: 1; animation: march .6s linear infinite; }
@keyframes march { to { stroke-dashoffset: -12; } }


/* effects */
.fx { position: absolute; inset: 0; pointer-events: none; z-index: 8; }
.pts { position: absolute; font-family: var(--cond); font-weight: 800; }
.float { position: absolute; transform: translate(-50%, -50%); font-family: var(--cond); font-weight: 800; font-size: 22px; color: #fff; background: var(--ink); border-radius: 8px; padding: 1px 8px; white-space: nowrap; box-shadow: 0 3px 0 #0004; }
.dust { position: absolute; width: 10px; height: 10px; margin: -5px; border-radius: 50%; background: #e9dcc3; opacity: .9; }
.debris { position: absolute; width: 10px; height: 10px; border-radius: 2px; }
.flash { position: absolute; width: 60px; height: 60px; margin: -30px; border-radius: 50%; background: radial-gradient(circle, #fff 0 20%, #ffe066 35%, #ff7a00 55%, #ff3d0000 70%); }
.bang { position: absolute; transform: translate(-50%, -50%) rotate(-8deg); font-family: var(--stencil); font-weight: 900; font-size: 46px; color: #ffe14d; -webkit-text-stroke: 2.5px var(--ink); paint-order: stroke fill; text-shadow: 4px 4px 0 var(--steel); white-space: nowrap; }
.sign { position: absolute; left: 50%; top: 38%; transform: translate(-50%, -50%); padding: 10px 18px 8px; background: var(--hazard); border: 4px solid var(--ink); border-radius: 10px; font-family: var(--stencil); font-weight: 900; font-size: 34px; letter-spacing: 1px; white-space: nowrap; box-shadow: 0 6px 0 #0005; }
.sign::before { content: ""; position: absolute; inset: 3px; border-radius: 6px; border: 3px dashed #1b1c2055; pointer-events: none; }

/* controls */
.controls { display: grid; grid-template-columns: auto auto 1fr; gap: 8px; margin-top: 12px; }
.btn { border: 0; border-radius: 12px; padding: 12px 14px; font-family: var(--cond); font-weight: 800; font-size: 20px; letter-spacing: .4px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; box-shadow: 0 4px 0 #0005; transition: transform .08s, box-shadow .08s, filter .15s; }
.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 #0005; }
.btn:disabled { filter: grayscale(.8) opacity(.55); cursor: default; }
.btn svg { width: 22px; height: 22px; flex: none; }
.btn img { width: 24px; height: auto; margin: -4px 0 -2px; }
.btn.go { background: var(--hazard); color: var(--ink); font-size: 24px; }
.btn.go:not(:disabled) { animation: ready 1.6s ease-in-out infinite; }
@keyframes ready { 50% { box-shadow: 0 4px 0 #0005, 0 0 0 4px #ffc40077; } }
.btn.side { background: #fff; color: var(--ink); padding: 12px 12px; }
.btn.side.urge { background: #ff5a3c; color: #fff; animation: urge 1s ease-in-out infinite; }
@keyframes urge { 50% { box-shadow: 0 4px 0 #0005, 0 0 0 5px #ff5a3c55; } }
.btn.small { font-size: 16px; padding: 8px 14px; }
.btn.dark { background: var(--ink); color: #fff; }

.notice { margin: 10px 0 0; padding: 10px 12px; border-radius: 10px; background: #fff8e1; border: 2px solid var(--ink); font-family: var(--cond); font-weight: 700; font-size: 16px; text-align: center; }
.notice .row { display: flex; gap: 8px; justify-content: center; margin-top: 8px; flex-wrap: wrap; }

/* result */
.result { margin-top: 14px; background: #fff; border-radius: 14px; padding: 16px 16px 14px; border: 4px solid transparent;
  background: linear-gradient(#fff, #fff) padding-box, repeating-linear-gradient(-45deg, var(--hazard) 0 10px, var(--ink) 10px 20px) border-box; box-shadow: 0 6px 0 #0003; text-align: center; animation: rise .45s cubic-bezier(.2,1.4,.4,1); }
@keyframes rise { from { transform: translateY(30px) scale(.94); opacity: 0; } }
.result h2 { margin: 0; font-family: var(--stencil); font-weight: 900; font-size: 34px; line-height: 1; text-transform: uppercase; }
.result .big { font-family: var(--cond); font-weight: 800; font-size: 54px; line-height: 1; margin: 8px 0 2px; }
.result .vs { font-family: var(--cond); font-weight: 700; font-size: 17px; color: #384a5c; }
.result .vs b { color: var(--ink); }
.result .beat { display: inline-block; margin: 2px 0 6px; background: var(--ok); color: #fff; padding: 2px 12px; border-radius: 20px; font-family: var(--cond); font-weight: 800; font-size: 18px; }
.result .beat.over { background: #44576a; }
.result .big small { font-size: 22px; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; justify-content: center; margin: 12px 0 4px; }
.chip { font-family: var(--cond); font-weight: 800; font-size: 15px; padding: 2px 8px; border-radius: 6px; background: #e9eef3; }
.result .row { display: flex; gap: 8px; justify-content: center; margin-top: 12px; flex-wrap: wrap; }
.plan { text-align: left; margin-top: 12px; }
.plan summary { cursor: pointer; font-family: var(--cond); font-weight: 800; font-size: 17px; text-align: center; list-style: none; }
.plan summary::-webkit-details-marker { display: none; }
.plan summary::after { content: " \25BE"; }
.plan[open] summary::after { content: " \25B4"; }
.plan p { font-size: 14px; color: #44576a; margin: 8px 0; text-align: center; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 12px; }
.stats div { background: #f1f4f7; border-radius: 8px; padding: 6px 2px; }
.stats b { display: block; font-family: var(--cond); font-weight: 800; font-size: 22px; line-height: 1; }
.stats small { font-size: 11px; color: #4b5d70; }

.howto { margin-top: 16px; background: #ffffffa8; border-radius: 12px; padding: 10px 14px; font-size: 15px; line-height: 1.4; }
.howto summary { cursor: pointer; font-family: var(--cond); font-weight: 800; font-size: 18px; }
.howto ul { padding-left: 18px; margin: 8px 0 2px; }
.howto li { margin: 5px 0; }
.foot { text-align: center; font-size: 14px; color: #3c4c5c; margin-top: 16px; }
.foot a { color: #0b4f8a; }
.foot .link { display: block; margin: 8px auto 0; font-family: var(--body); font-weight: 600; font-size: 14px; color: #6a3b2b; }

/* celebration */
.party { position: fixed; inset: 0; z-index: 50; pointer-events: none; overflow: hidden; }
.party .bot { position: absolute; left: 50%; top: -260px; width: 200px; margin-left: -100px; }
.party .bot img { width: 100%; filter: drop-shadow(0 10px 12px #0005); }
.party .bot::before { content: ""; position: absolute; left: 50%; bottom: 100%; width: 4px; height: 400px; margin-left: -2px; background: #222; }
.party .title { position: absolute; left: 50%; top: 52%; transform: translate(-50%, -50%) rotate(-4deg); font-family: var(--stencil); font-weight: 900; font-size: 54px; line-height: .95; text-align: center; color: var(--hazard); -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; text-shadow: 5px 5px 0 var(--steel); white-space: nowrap; }
.party .bit { position: absolute; top: -40px; font-size: 28px; }

.guffbar-slot:empty { display: none; }
.guffbar-slot { margin-top: 14px; }

@media (max-width: 370px) {
  .logo { font-size: 25px; } .logobot { width: 38px; }
  .btn { font-size: 18px; padding: 11px 10px; }
}
@media (prefers-reduced-motion: reduce) {
  .cloud, .logobot, .btn.go:not(:disabled) { animation: none; }
}
