/* Layout: one portrait screen. Wall and counter behind, brass crate in front, Toddy above it holding the next piece. */
:root {
  --night: #14102e;
  --night-2: #1d1744;
  --brass: #c99a3b;
  --gold: #fdaf1e;
  --gold-deep: #a65d0e;
  --cream: #fde3bd;
  --ink: #1a0a05;
  --danger: #ff5d4d;
  --display: "Fredoka", ui-rounded, "Trebuchet MS", system-ui, sans-serif;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; background: var(--night); color: var(--cream); }
body { overflow: hidden; font-family: var(--body); -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; touch-action: none; overscroll-behavior: none; }
#app { position: relative; height: 100%; max-width: 520px; margin: 0 auto; overflow: hidden; background: var(--night); }
#c { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#hud { position: absolute; top: 0; left: 0; right: 0; box-sizing: border-box; display: flex; flex-direction: column; gap: 4px; padding-block: max(5px, env(safe-area-inset-top, 0px)) 5px; padding-left: max(12px, env(safe-area-inset-left, 0px)); padding-right: max(12px, env(safe-area-inset-right, 0px)); pointer-events: none; background: linear-gradient(to bottom, rgba(14,10,36,.9), rgba(14,10,36,.72)); border-bottom: 1.5px solid rgba(201,154,59,.55); box-shadow: 0 3px 12px rgba(0,0,0,.35); z-index: 2; }
.row1 { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
.scorebox { min-width: 0; display: flex; flex-direction: column; }
.label { font: 600 10px var(--body); letter-spacing: .14em; text-transform: uppercase; color: var(--cream); opacity: .9; }
#score { font: 700 34px/1 var(--display); color: #fff4d6; text-shadow: 0 2px 0 var(--ink), 0 0 12px rgba(253,175,30,.35); font-variant-numeric: tabular-nums; }
#best { font: 500 12px/1.2 var(--display); color: var(--cream); opacity: .9; }
.hud-right { display: flex; align-items: center; gap: 5px; flex: none; }
.ring { width: 42px; height: 42px; border-radius: 50%; border: 2.5px solid var(--brass); background: radial-gradient(circle at 50% 40%, var(--night-2), var(--night)); display: grid; place-items: center; box-shadow: 0 2px 0 var(--ink); overflow: hidden; }
.ring img { max-width: 78%; max-height: 78%; }
#btnFull { display: grid; place-items: center; }
#btnFull, #btnSound, #btnPause { pointer-events: auto; width: 36px; height: 36px; border-radius: 11px; border: 2px solid var(--brass); background: rgba(20,16,46,.82); color: var(--cream); font: 700 17px var(--display); cursor: pointer; padding: 0; }
#btnSound.off { opacity: .55; }
#btnFull:focus-visible, #btnSound:focus-visible, #btnPause:focus-visible, .btn:focus-visible { outline: 3px solid #fff4d6; outline-offset: 2px; }
.row2 { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; height: 28px; }
#prog { display: flex; align-items: flex-end; gap: 2px; min-width: 0; flex: 1 1 auto; }
#prog img { object-fit: contain; opacity: .4; filter: grayscale(1) brightness(.9); flex: 0 1 auto; min-width: 0; }
#prog img.lit { opacity: 1; filter: none; }
#prog img.goalp { opacity: .85; filter: none; outline: 1.5px dashed var(--gold); outline-offset: 2px; border-radius: 4px; }
#goal { flex: none; font: 600 11.5px var(--body); color: var(--gold); white-space: nowrap; }
#ticket { position: absolute; left: 50%; transform: translateX(-50%); bottom: max(10px, env(safe-area-inset-bottom, 0px)); z-index: 3; pointer-events: none; width: max-content; box-sizing: border-box; height: 28px; max-width: calc(100% - 24px); display: flex; align-items: center; gap: 6px; padding: 0 10px 0 6px; border: 1.5px solid var(--gold); border-radius: 12px; background: rgba(40,28,70,.9); font: 600 12.5px/1.1 var(--body); color: var(--cream); overflow: hidden; }
#ticket[hidden] { display: flex !important; visibility: hidden; }
#ticket span { min-width: 0; white-space: nowrap; }
#ticket img { height: 22px; width: auto; flex: none; }
#ticket b { color: var(--gold); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
#banner { position: absolute; left: 0; right: 0; top: 54%; box-sizing: border-box; text-align: center; text-wrap: balance; overflow-wrap: anywhere; font: 700 24px/1.15 var(--display); color: #fff4d6; text-shadow: 0 2px 0 var(--ink), 0 0 16px rgba(253,175,30,.6); pointer-events: none; opacity: 0; transform: translateY(8px) scale(.96); transition: opacity .18s, transform .18s; z-index: 4; padding-inline: 4px; }
#banner.show { opacity: 1; transform: none; }
#banner.new { color: var(--gold); }
#banner.warn { color: var(--danger); font-size: 22px; }
#banner.chain { font-size: 30px; color: #fce25d; }
@media (prefers-reduced-motion: reduce) { #banner { transition: none; } }
#overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(10,8,28,.66); padding-block: 16px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); z-index: 5; }
.card { width: min(100%, 340px); max-height: 100%; overflow: auto; background: linear-gradient(160deg, #241c52, #15102f); border: 2px solid var(--brass); border-radius: 20px; padding: 22px 18px 18px; text-align: center; display: flex; flex-direction: column; gap: 12px; box-shadow: 0 10px 40px rgba(0,0,0,.5); }
.card h1 { margin: 0; font: 700 40px/1 var(--display); color: #fff4d6; text-shadow: 0 2px 0 var(--ink); }
.card h2 { margin: 0; font: 700 28px/1 var(--display); color: #fff4d6; }
.sub, .help { margin: 0; font: 500 14px/1.35 var(--body); color: var(--cream); opacity: .9; text-wrap: balance; }
.help { font-size: 12.5px; opacity: .7; }
.strip { display: flex; align-items: flex-end; justify-content: center; gap: 2px; padding: 6px 0 2px; }
.strip { width: 100%; }
.strip img { flex: 0 1 auto; min-width: 0; width: auto; max-width: none; object-fit: contain; }
.weeks { display: flex; flex-direction: column; gap: 8px; max-height: 48vh; overflow-y: auto; padding: 2px; }
.btn.wk { text-align: left; overflow-wrap: anywhere; }
.links { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.chip { font: 600 14px var(--display); color: var(--cream); background: rgba(20,16,46,.7); border: 1.5px solid var(--brass); border-radius: 999px; padding: 8px 14px; min-height: 40px; cursor: pointer; }
.chip:focus-visible { outline: 3px solid #fff4d6; outline-offset: 2px; }
.steps { margin: 0; padding-left: 20px; text-align: left; font: 500 14px/1.45 var(--body); display: flex; flex-direction: column; gap: 8px; }
.btn { font: 600 18px var(--display); padding: 12px 18px; border-radius: 14px; border: 2px solid var(--ink); background: var(--gold); color: var(--ink); box-shadow: 0 3px 0 var(--gold-deep); cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.btn small { font: 500 12px var(--body); opacity: .8; }
.btn.alt { background: transparent; color: var(--cream); border-color: var(--brass); box-shadow: none; }
.btn.share { background: transparent; color: var(--gold); border-color: var(--gold); box-shadow: none; }
.btn:active { transform: translateY(2px); }
.sharepic { display: block; width: auto; max-width: 100%; max-height: 58vh; margin: 0 auto; border-radius: 12px; border: 1.5px solid var(--brass); -webkit-touch-callout: default; -webkit-user-select: auto; user-select: auto; }
.medal { width: 112px; height: auto; margin: 0 auto; }
.band { font: 600 15px var(--display); letter-spacing: .12em; text-transform: uppercase; color: var(--gold); }
.final { font: 700 52px/1 var(--display); color: #fff4d6; text-shadow: 0 2px 0 var(--ink); font-variant-numeric: tabular-nums; }
#loading { position: absolute; inset: 0; display: grid; place-items: center; background: var(--night); color: var(--cream); font: 600 16px var(--display); z-index: 9; text-align: center; padding: 20px; }
@media (prefers-reduced-motion: reduce) { .btn:active { transform: none; } }
/* piece sizes (classes, because the site's CSP blocks style attributes) */
#prog .pp0{height:17px;width:17px}
#prog .pp1{height:18px;width:18px}
#prog .pp2{height:19px;width:19px}
#prog .pp3{height:20px;width:20px}
#prog .pp4{height:21px;width:21px}
#prog .pp5{height:22px;width:22px}
#prog .pp6{height:22px;width:22px}
#prog .pp7{height:23px;width:23px}
#prog .pp8{height:24px;width:24px}
#prog .pp9{height:25px;width:25px}
#prog .pp10{height:26px;width:26px}
.strip .ps0{height:14px}
.strip .ps1{height:16px}
.strip .ps2{height:18px}
.strip .ps3{height:20px}
.strip .ps4{height:22px}
.strip .ps5{height:24px}
.strip .ps6{height:25px}
.strip .ps7{height:27px}
.strip .ps8{height:29px}
.strip .ps9{height:31px}
.strip .ps10{height:33px}

/* Moonrise / Full Moon proof badge and challenge note */
.moonbadge { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 2px 10px; padding: 8px 12px; border-radius: 16px; border: 2px solid var(--ink); background: linear-gradient(180deg, #ffe08a, #fdaf1e); color: var(--ink); box-shadow: 0 3px 0 var(--gold-deep); }
.moonbadge b { font: 700 22px var(--display); letter-spacing: .04em; }
.moonbadge small { flex-basis: 100%; font: 600 12px var(--body); opacity: .85; }
.mb-moons { display: inline-flex; gap: 3px; }
.mb-moon { width: 18px; height: 18px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fffdf2, #f1c15a); border: 1.5px solid #7a4a0a; display: inline-block; }
.chal { font-weight: 600; color: var(--gold); }
.chal.won { color: #fff4d6; }

/* ===== Classy look (pictures are optional: without them the plain colours below still work) ===== */
:root { --col: clamp(520px, 56vh, 640px); }
#app { max-width: var(--col); }
.deco { display: none; }
#celeb { display: none; }

/* brass buttons */
.btn { border: 0; border-style: solid; border-width: 0 25px; border-image: url("../assets/btn_gold_v01.webp") 0 56 fill / 0 25px stretch; background: none; box-shadow: none; padding: 13px 0; color: var(--ink); text-shadow: 0 1px 0 rgba(255,235,170,.55); }
.btn.alt, .btn.share { border-image-source: url("../assets/btn_navy_v01.webp"); color: var(--cream); text-shadow: 0 1px 0 rgba(0,0,0,.5); }
.btn.share { color: var(--gold); }
.btn:active { transform: translateY(2px); filter: brightness(.95); }
.btn:hover { filter: brightness(1.07); }
.btn.alt:hover, .btn.share:hover { filter: brightness(1.2); }
#btnFull, #btnSound, #btnPause { border: 0; border-radius: 50%; background: url("../assets/btn_round_v01.webp") center / 100% 100% no-repeat; width: 38px; height: 38px; transition: transform .12s, filter .12s; }
#btnFull:hover, #btnSound:hover, #btnPause:hover { filter: brightness(1.25); transform: scale(1.06); }
.ring { border: 0; background: url("../assets/btn_round_v01.webp") center / 100% 100% no-repeat; box-shadow: none; }
.chip:hover { background: rgba(60,46,110,.85); }

/* score plate, result card frame, gold foil digits */
#hud { background: none; border: 0; border-image: url("../assets/ui_plate_v01.webp") 40 fill / 9px stretch; border-style: solid; border-width: 9px; box-shadow: 0 4px 14px rgba(0,0,0,.4); }
#hud::before { content: ""; position: absolute; inset: 0; z-index: -1; background: linear-gradient(to bottom, rgba(14,10,36,.55), rgba(14,10,36,.35)); }
.card { box-sizing: border-box; width: min(100%, 380px); border: 0; border-style: solid; border-width: 24px; border-image: url("../assets/ui_frame_v01.webp") 58 fill / 24px stretch; border-radius: 0; background: none; padding: 6px 0 2px; box-shadow: none; filter: drop-shadow(0 10px 28px rgba(0,0,0,.55)); }
.card::before { content: ""; }
#score, .final, .card h1, .card h2 { background: url("../assets/ui_foil_v01.webp") center / 220px auto; -webkit-background-clip: text; background-clip: text; color: transparent; -webkit-text-fill-color: transparent; text-shadow: none; filter: drop-shadow(0 2px 0 var(--ink)) drop-shadow(0 0 10px rgba(253,175,30,.3)); }
.moonbadge { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 0; border: 0; border-radius: 0; background: none; box-shadow: none; }
.mbrib { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 20px 66px 28px; background: url("../assets/ui_ribbon_v01.webp") center / 100% 100% no-repeat; }
.moonbadge small { color: var(--cream); opacity: .9; }

/* desktop: wide screen with a mouse. The game column stays exactly the same shape; the sides come alive */
@media (min-width: 900px) and (min-aspect-ratio: 5/4) {
  body { background: #0b0919 url("../assets/desk_bg_v01.webp") center / cover no-repeat; }
  #app { box-shadow: 0 0 0 1px rgba(201,154,59,.5), 0 0 70px rgba(0,0,0,.75); }
  .deco { display: block; position: fixed; pointer-events: none; }
  #deskvid { inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: 0; }
  #app { z-index: 1; }
  .pillar { top: 0; bottom: 0; width: 23.4vh; background: url("../assets/desk_pillar_v01.webp") center / 100% 100% no-repeat; z-index: 2; filter: drop-shadow(0 0 18px rgba(0,0,0,.6)); }
  .pl { right: calc(50% + var(--col) / 2 - 1px); }
  .pr { left: calc(50% + var(--col) / 2 - 1px); }
}
@media (min-width: 1300px) and (min-aspect-ratio: 5/4) {
  .sign { top: 0; width: 190px; height: 208px; background: url("../assets/desk_sign_v01.webp") center / contain no-repeat; right: calc(50% + var(--col) / 2 + 23.4vh + 28px); z-index: 2; }
  .keys { top: 64px; left: calc(50% + var(--col) / 2 + 23.4vh + 28px); width: 190px; box-sizing: border-box; padding: 14px 16px; border: 1.5px solid rgba(201,154,59,.7); border-radius: 14px; background: rgba(20,16,46,.72); font: 500 13px/1.3 var(--body); color: var(--cream); z-index: 2; }
  .keys b { display: block; margin-bottom: 8px; font: 600 12px var(--display); letter-spacing: .16em; text-transform: uppercase; color: var(--gold); }
  .keys ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 7px; }
  .keys li { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }
  .keys li span { margin-left: auto; opacity: .75; }
  .keys kbd { font: 600 11px var(--display); padding: 2px 7px; border: 1.5px solid var(--brass); border-bottom-width: 3px; border-radius: 6px; background: rgba(60,46,110,.7); color: #fff4d6; }
}
@media (prefers-reduced-motion: reduce) { #btnFull, #btnSound, #btnPause { transition: none; } }
.card { touch-action: pan-y; }

/* ===== Clean look (?look=clean): same game and same play-screen art, lighter menus and cards ===== */
.look-clean .btn { border: 2px solid var(--ink); border-image: none; border-radius: 14px; background: var(--gold); box-shadow: 0 3px 0 var(--gold-deep); padding: 12px 18px; text-shadow: none; }
.look-clean .btn.alt { background: transparent; color: var(--cream); border-color: var(--brass); box-shadow: none; }
.look-clean .btn.share { background: transparent; color: var(--gold); border-color: var(--gold); box-shadow: none; }
.look-clean .btn:hover { filter: brightness(1.08); }
.look-clean #btnFull, .look-clean #btnSound, .look-clean #btnPause { width: 36px; height: 36px; border: 2px solid var(--brass); border-radius: 11px; background: rgba(20,16,46,.82); }
.look-clean .ring { border: 2.5px solid var(--brass); background: radial-gradient(circle at 50% 40%, var(--night-2), var(--night)); box-shadow: 0 2px 0 var(--ink); }
.look-clean #hud { border: 0; border-image: none; border-bottom: 1.5px solid rgba(201,154,59,.55); background: linear-gradient(to bottom, rgba(14,10,36,.9), rgba(14,10,36,.72)); box-shadow: 0 3px 12px rgba(0,0,0,.35); }
.look-clean #hud::before { display: none; }
.look-clean .card { box-sizing: border-box; width: min(100%, 380px); border: 2px solid var(--brass); border-image: none; border-radius: 20px; background: linear-gradient(160deg, #241c52, #15102f); padding: 22px 18px 18px; box-shadow: 0 10px 40px rgba(0,0,0,.5); filter: none; }
.look-clean #score, .look-clean .final, .look-clean .card h1, .look-clean .card h2 { background: none; -webkit-background-clip: border-box; background-clip: border-box; color: #fff4d6; -webkit-text-fill-color: currentColor; filter: none; }
.look-clean #score { text-shadow: 0 2px 0 var(--ink), 0 0 12px rgba(253,175,30,.35); }
.look-clean .final, .look-clean .card h1 { text-shadow: 0 2px 0 var(--ink); }
.look-clean .card h2 { text-shadow: none; }
.look-clean .moonbadge { flex-direction: row; flex-wrap: wrap; justify-content: center; gap: 2px 10px; padding: 8px 12px; border: 2px solid var(--ink); border-radius: 16px; background: linear-gradient(180deg, #ffe08a, #fdaf1e); color: var(--ink); box-shadow: 0 3px 0 var(--gold-deep); }
.look-clean .mbrib { flex-direction: row; gap: 10px; padding: 0; background: none; }
.look-clean .moonbadge small { flex-basis: 100%; text-align: center; color: var(--ink); opacity: .85; }
.look-clean .pillar, .look-clean .sign { display: none !important; }
