:root {
  --ink: #2c4a3e; --ink2: #4f6b5f; --cream: #fffaf0; --paper: #fff4dc; --orange: #f39a26; --orange2: #e2761a;
  --flesh: #ffc861; --flesh2: #ffb547; --mint: #3d9a7d; --mint2: #2f8166; --mintl: #cdeedd; --red: #c8432b;
  --gold: #f6c343;
  font-size: clamp(12px, min(2.1vh, 1.5vw) + 5px, 21px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  font-family: "Trebuchet MS", "Avenir Next", "Segoe UI", system-ui, sans-serif; color: var(--ink);
  background: #f5dfb4 url(img/bg_wide.jpg) center / cover no-repeat; touch-action: manipulation; user-select: none; -webkit-user-select: none;
}
@media (max-aspect-ratio: 4/5) { body { background-image: url(img/bg_tall.jpg); } }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
#app { position: fixed; inset: 0; display: flex; flex-direction: column; }
kbd { display: inline-block; min-width: 1.5em; padding: .05em .35em; border: 2px solid var(--ink); border-bottom-width: 3px; border-radius: .35em; background: #fff; font: 700 .8em/1.3 inherit; text-align: center; }

/* top bar */
#top { flex: none; display: flex; align-items: center; gap: .5rem; padding: .35rem .6rem; height: 2.9rem; }
.logo { display: flex; align-items: center; gap: .4rem; border: 0; background: none; padding: 0; font-weight: 800; font-size: 1.15rem; letter-spacing: .01em; white-space: nowrap; }
.logo svg { width: 2.1rem; height: 2.1rem; flex: none; }
.logo b { color: var(--orange2); }
.logo span { text-shadow: 0 0 6px #fff8e6, 0 0 3px #fff8e6, 0 0 2px #fff8e6; }
#modeTag { font-size: .75rem; font-weight: 700; background: var(--cream); border: 2px solid var(--ink); border-radius: 99px; padding: .12rem .6rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
#modeTag:empty { display: none; }
.tb { margin-left: auto; display: flex; gap: .35rem; flex: none; }
.ib { width: 2.25rem; height: 2.25rem; border-radius: 50%; border: 2.5px solid var(--ink); background: var(--cream); display: grid; place-items: center; padding: 0; box-shadow: 0 3px 0 var(--ink); }
.ib svg { width: 62%; height: 62%; }
.ib:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.ib .slash { display: none; }
.ib.off .slash { display: inline; }
.ib.off .wave { display: none; }

/* play area */
#play {
  flex: 1; min-height: 0; display: grid; gap: .5rem; padding: .2rem .8rem .7rem;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  grid-template-areas: "wheel prog" "wheel nine" "wheel found" "entry found" "ctrls fin";
  max-width: 1300px; width: 100%; margin: 0 auto;
}
#play.hidden { visibility: hidden; }
.card { background: rgba(255, 250, 240, .93); border: 2.5px solid var(--ink); border-radius: 1rem; box-shadow: 0 4px 0 rgba(44, 74, 62, .85); }
.muted { color: var(--ink2); font-weight: 600; font-size: .8em; }
#prog { grid-area: prog; padding: .45rem .8rem .4rem; }
.pl { font-size: 1rem; font-weight: 700; }
.pl b { font-size: 1.35rem; color: var(--orange2); }
.bar { position: relative; height: .8rem; border-radius: 99px; background: #f1e2c3; border: 2px solid var(--ink); margin: .3rem 0 .15rem; overflow: visible; }
.fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: 99px; background: linear-gradient(90deg, var(--flesh), var(--orange)); transition: width .4s cubic-bezier(.3, 1.4, .5, 1); }
.mk { position: absolute; top: -4px; bottom: -4px; width: 3px; background: var(--ink); border-radius: 2px; }
.bands { position: relative; height: 1.1rem; font-size: .7rem; font-weight: 700; color: var(--ink2); }
.bands span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
.bands span.got { color: var(--mint2); }
.bands span.got::before { content: "\2713 "; }
#nine { grid-area: nine; padding: .4rem .7rem; display: flex; align-items: center; gap: .6rem; }
.nl { font-size: .75rem; font-weight: 800; line-height: 1.1; width: 4.6rem; flex: none; }
#slots { display: flex; gap: .18rem; flex: 1; justify-content: center; min-width: 0; }
#slots i { flex: 1; max-width: 1.9rem; aspect-ratio: 1 / 1.1; border-radius: .35rem; border: 2px solid var(--ink); background: #fff; display: grid; place-items: center; font-style: normal; font-weight: 800; font-size: 1rem; text-transform: uppercase; }
#slots i.h { background: var(--mintl); }
#slots.done i { background: var(--gold); animation: pop .5s both; }
#slots.done i:nth-child(2) { animation-delay: .04s } #slots.done i:nth-child(3) { animation-delay: .08s } #slots.done i:nth-child(4) { animation-delay: .12s }
#slots.done i:nth-child(5) { animation-delay: .16s } #slots.done i:nth-child(6) { animation-delay: .2s } #slots.done i:nth-child(7) { animation-delay: .24s }
#slots.done i:nth-child(8) { animation-delay: .28s } #slots.done i:nth-child(9) { animation-delay: .32s }
.sm { flex: none; border: 2px solid var(--ink); border-radius: 99px; background: var(--mintl); font-weight: 800; font-size: .8rem; padding: .25rem .65rem; box-shadow: 0 2px 0 var(--ink); }
.sm span { display: inline-block; min-width: 1.2em; background: var(--ink); color: #fff; border-radius: 99px; font-size: .75em; padding: 0 .3em; }
.sm:disabled { opacity: .45; }
#wheelBox { grid-area: wheel; position: relative; min-height: 0; display: grid; place-items: center; }
#wheel { position: relative; width: 300px; height: 300px; }
#wheel svg.base { position: absolute; inset: 0; width: 100%; height: 100%; filter: drop-shadow(0 5px 0 rgba(44, 74, 62, .8)); }
#wheel.spin svg.base { animation: spin .5s ease; }
@keyframes spin { from { transform: rotate(-60deg); } }
.tile {
  position: absolute; left: 0; top: 0; border-radius: 50%; border: .2em solid var(--ink); background: var(--cream); color: var(--ink);
  display: grid; place-items: center; font-weight: 800; text-transform: uppercase; padding: 0; line-height: 1;
  transition: transform .45s cubic-bezier(.35, 1.4, .5, 1), background .12s; box-shadow: 0 .18em 0 var(--ink);
}
.tile.c { background: var(--mint); color: #fff; }
.tile.used { background: #f2dcae; color: rgba(44, 74, 62, .35); box-shadow: 0 .05em 0 var(--ink); }
.tile.c.used { background: #9fcdbd; color: rgba(255, 255, 255, .6); }
.tile.press { animation: tap .18s; }
@keyframes tap { 50% { scale: .88; } }
#robin { position: absolute; right: .4rem; bottom: .3rem; width: min(26%, 7.5rem, 45%); z-index: 0; opacity: .95; pointer-events: none; transition: transform .3s; }
#robin.cheer { animation: hop .6s; }
@keyframes hop { 30% { transform: translateY(-18%) rotate(-6deg); } 60% { transform: translateY(0) rotate(4deg); } }
#entry { grid-area: entry; display: flex; justify-content: center; min-width: 0; }
#word { min-height: 2.6rem; min-width: 60%; max-width: 100%; padding: .2rem .9rem; display: flex; align-items: center; justify-content: center; gap: .1rem; background: rgba(255, 250, 240, .93); border: 2.5px solid var(--ink); border-radius: 99px; font-weight: 800; font-size: 1.5rem; letter-spacing: .08em; text-transform: uppercase; }
#word .ph { font-size: .9rem; letter-spacing: 0; font-weight: 600; color: var(--ink2); text-transform: none; }
#word b.cl { color: var(--mint2); }
#word.shake { animation: shake .35s; border-color: var(--red); }
#word.good { background: var(--mintl); }
@keyframes shake { 20% { transform: translateX(-8px); } 40% { transform: translateX(7px); } 60% { transform: translateX(-5px); } 80% { transform: translateX(3px); } }
#ctrls { grid-area: ctrls; display: flex; justify-content: center; gap: .5rem; }
.btn { border: 2.5px solid var(--ink); border-radius: .9rem; background: var(--cream); font-weight: 800; font-size: 1rem; padding: .45rem .9rem; box-shadow: 0 4px 0 var(--ink); display: inline-flex; align-items: center; justify-content: center; gap: .35rem; min-height: 2.6rem; }
.btn svg { width: 1.2em; height: 1.2em; }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.btn.go { background: var(--orange); color: #fff; text-shadow: 0 2px 0 rgba(0, 0, 0, .18); }
.btn.ghost { background: var(--cream); }
.btn.big { font-size: 1.35rem; padding: .65rem 1.4rem; width: 100%; }
#bEnter { min-width: 6.5rem; }
#found { position: relative; grid-area: found; min-height: 0; display: flex; flex-direction: column; padding: .45rem .7rem; }
.fh { display: flex; justify-content: space-between; align-items: baseline; font-weight: 800; font-size: .9rem; margin-bottom: .25rem; }
#fl { position: relative; z-index: 1; flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-wrap: wrap; align-content: flex-start; gap: .25rem; padding-bottom: .2rem; touch-action: pan-y; }
#fl .w { padding: .12rem .5rem; border-radius: 99px; background: #fff; border: 2px solid #e3cf9f; font-weight: 700; font-size: .85rem; text-transform: uppercase; letter-spacing: .03em; }
#fl .w.n9 { background: var(--gold); border-color: var(--ink); }
#fl .w.new { animation: pop .5s; border-color: var(--mint); }
#fl .w.flash { animation: flash .7s; }
#fl .w.bonus { border-style: dashed; }
#fl .empty { color: var(--ink2); font-size: .85rem; }
@keyframes pop { 0% { transform: scale(.3); } 60% { transform: scale(1.15); } 100% { transform: scale(1); } }
@keyframes flash { 30%, 70% { background: #ffe2a8; transform: scale(1.12); } }
#fin { grid-area: fin; display: flex; justify-content: flex-end; align-items: center; }
.sm2 { font-size: .85rem; min-height: 2.3rem; padding: .3rem .8rem; }
#toast { position: fixed; left: 50%; top: 3.4rem; transform: translate(-50%, -10px); background: var(--ink); color: #fff; font-weight: 700; padding: .4rem 1rem; border-radius: 99px; opacity: 0; transition: .2s; pointer-events: none; z-index: 30; white-space: nowrap; font-size: .95rem; }
#toast.on { opacity: 1; transform: translate(-50%, 0); }
#toast.g { background: var(--mint2); }

/* overlays */
.ov { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; grid-template-rows: minmax(0, 1fr); grid-template-columns: minmax(0, 1fr); padding: .8rem; background: rgba(44, 74, 62, .35); }
.ov.hide { display: none; }
#start { background: rgba(255, 244, 220, .35); }
.panel { background: var(--cream); border: 3px solid var(--ink); border-radius: 1.3rem; box-shadow: 0 6px 0 var(--ink); padding: 1rem 1.2rem; max-width: 34rem; width: 100%; max-height: 100%; display: flex; flex-direction: column; gap: .6rem; }
.panel h1 { margin: 0; font-size: 2.1rem; line-height: 1.05; text-align: center; }
.panel h1 b, .panel h2 b { color: var(--orange2); }
.panel h2 { margin: 0; font-size: 1.45rem; }
.panel p { margin: 0; }
.intro { text-align: center; font-size: .95rem; line-height: 1.35; }
.startp { max-width: 46rem; flex-direction: row; gap: 1.2rem; align-items: center; }
.sl, .sr { flex: 1; display: flex; flex-direction: column; gap: .6rem; align-items: center; min-width: 0; }
.mascot { width: 8.5rem; height: auto; }
.mascot.sm { width: 5rem; flex: none; }
.sub { font-size: .85rem; font-weight: 700; color: var(--ink2); text-align: center; }
.row2 { display: flex; gap: .5rem; width: 100%; }
.row2 .btn { flex: 1; font-size: .9rem; }
.keys { display: flex; flex-wrap: wrap; gap: .35rem .8rem; justify-content: center; font-size: .78rem; font-weight: 600; }
.streak { font-weight: 800; font-size: .9rem; color: var(--orange2); text-align: center; min-height: 1em; }
.scroll { overflow-y: auto; min-height: 0; flex: 1 1 auto; touch-action: pan-y; }
.helpp ul { margin: 0; padding-left: 1.2rem; line-height: 1.4; font-size: .92rem; }
.helpp li { margin-bottom: .25rem; }
.confp { max-width: 26rem; text-align: center; }
.resp { max-width: 44rem; height: 100%; max-height: 40rem; }
.rh { display: flex; gap: .8rem; align-items: center; flex: none; }
.rh p { font-size: .92rem; font-weight: 600; }
.nineAns { margin-top: .2rem !important; }
.nineAns b { background: var(--gold); border: 2px solid var(--ink); border-radius: .4rem; padding: 0 .35rem; letter-spacing: .08em; text-transform: uppercase; }
#ansList { border-top: 2px dashed #e3cf9f; padding-top: .4rem; }
.ag { margin-bottom: .45rem; }
.ag h3 { margin: 0 0 .2rem; font-size: .8rem; color: var(--ink2); }
.ag div { display: flex; flex-wrap: wrap; gap: .22rem; }
.ag span { padding: .06rem .42rem; border-radius: 99px; font-size: .8rem; font-weight: 700; text-transform: uppercase; border: 2px solid #e3cf9f; background: #fff; color: #9a8a6a; }
.ag span.f { background: var(--mintl); border-color: var(--mint); color: var(--ink); }
.ag span.n9 { background: var(--gold); border-color: var(--ink); color: var(--ink); }
.foot { flex: none; }

/* phone portrait */
@media (max-aspect-ratio: 4/5) {
  #play { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto minmax(0, 1fr) auto auto minmax(4.5rem, .55fr) auto;
    grid-template-areas: "prog" "nine" "wheel" "entry" "ctrls" "found" "fin"; gap: .4rem; padding: .1rem .6rem .5rem; }
  #fin { justify-content: center; }
  .startp { flex-direction: column; gap: .7rem; }
  .logo span { font-size: 1rem; }
}
/* short frames (store page 794x447, 640x360, phone landscape) */
@media (max-height: 560px) and (min-aspect-ratio: 4/5) {
  :root { font-size: clamp(11px, 2.6vh + 2px, 16px); }
  #top { height: 2.5rem; padding: .25rem .6rem; }
  .ib { width: 2rem; height: 2rem; }
  #play { gap: .35rem; padding: .1rem .6rem .45rem; }
  .startp .mascot { width: 6rem; }
  .panel h1 { font-size: 1.7rem; }
  .panel { padding: .7rem .9rem; gap: .45rem; }
  .btn { min-height: 2.3rem; padding: .3rem .7rem; }
  .btn.big { font-size: 1.15rem; padding: .45rem 1rem; }
  #word { min-height: 2.2rem; font-size: 1.25rem; }
  .resp { max-height: none; }
}
@media (max-height: 400px) and (min-aspect-ratio: 4/5) {
  .startp .mascot { width: 4.2rem; }
  .intro { font-size: .85rem; }
  .keys { display: none; }
  #robin { display: none; }
  .mascot.sm { width: 3.6rem; }
}
@media (max-width: 380px) { .logo span { display: none; } }
