:root {
  --paper: #f6efe1; --card: #fffaf0; --ink: #3a2a2a; --red: #e5484d; --blue: #2e4fa3; --green: #3c9a63; --yellow: #f5cf47; --pink: #f28aa8;
  font-size: clamp(11px, calc(min(2.1vh, 1.5vw) + 4px), 19px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--paper); color: var(--ink);
  font-family: "Trebuchet MS", "Segoe UI", "Helvetica Neue", Arial, sans-serif; touch-action: none; user-select: none; -webkit-user-select: none; }
body { background: radial-gradient(circle at 20% 10%, #fff7e6 0, transparent 40%), radial-gradient(circle at 80% 90%, #fbe6dc 0, transparent 45%), var(--paper); }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; padding: 0; }
.hide { display: none !important; }
#app { position: fixed; inset: 0; display: flex; flex-direction: column; }

/* header: paper ribbon with scalloped bottom edge */
#top { flex: 0 0 auto; height: 2.7rem; display: flex; align-items: center; gap: .5rem; padding: 0 .5rem; background: var(--red); color: #fff; position: relative; z-index: 3; }
#top::after { content: ""; position: absolute; left: 0; right: 0; bottom: -6px; height: 7px; background: radial-gradient(circle at 6px 0, var(--red) 5px, transparent 5.5px) 0 0 / 12px 7px repeat-x; }
#brand { display: flex; align-items: center; gap: .35rem; font-weight: 800; font-size: 1.15rem; letter-spacing: .02em; white-space: nowrap; }
#brand svg { width: 1.7rem; height: 1.7rem; background: #fbf7ee; border-radius: 50%; }
#modeChip { flex: 1; min-width: 0; text-align: center; font-weight: 700; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#icons { display: flex; gap: .3rem; }
.ic { width: 2.1rem; height: 2.1rem; border-radius: 50%; background: #ffffff2e; color: #fff; display: grid; place-items: center; }
.ic svg { width: 1.25rem; height: 1.25rem; }
.ic:active { transform: scale(.9); }
#bSound .x, #bMusic .x { display: none; }
#bSound.off .x, #bMusic.off .x { display: inline; } #bSound.off .w { display: none; }
#bSound.off, #bMusic.off { opacity: .6; }

#main { flex: 1; min-height: 0; display: flex; }
#stage { position: relative; flex: 0 0 44%; overflow: hidden; margin: .6rem 0 .5rem .5rem; border-radius: 1rem; border: .22rem solid #fffaf0; box-shadow: 0 .25rem .8rem #7a4a3030; background: #f4dccb; }
#bg { position: absolute; inset: 0; background-size: cover; background-position: center 70%; }
#room { position: absolute; inset: 0; width: 100%; height: 100%; display: none; }
#stage.inroom #room { display: block; } #stage.inroom #bg { display: none; }
#dollWrap { position: absolute; left: 0; right: 0; bottom: 1%; top: 4%; display: flex; justify-content: center; pointer-events: none; }
#doll { height: 100%; width: 100%; filter: drop-shadow(0 4px 0 #00000022); transition: transform .25s; }
#stage.inroom #dollWrap { left: 30%; top: 22%; }
#doll.bop { animation: bop .3s; }
@keyframes bop { 40% { transform: scale(1.03, .97); } }
#you { position: absolute; left: 50%; bottom: .4rem; transform: translateX(-50%); background: var(--blue); color: #fff; font-weight: 800; font-size: .75rem; padding: .15rem .6rem; border-radius: 1rem; box-shadow: 0 2px 0 #1a2d63; white-space: nowrap; }
#hint { position: absolute; left: .5rem; right: .5rem; top: .4rem; text-align: center; font-size: .78rem; font-weight: 700; color: var(--ink); background: #fffaf0e0; border-radius: .8rem; padding: .2rem .5rem; }
#task { position: absolute; left: .4rem; top: 2.1rem; max-width: 60%; display: flex; flex-direction: column; gap: .2rem; }
#task .tt { font-weight: 800; font-size: .8rem; background: var(--blue); color: #fff; border-radius: .6rem; padding: .15rem .5rem; align-self: flex-start; }
#task .rq { font-size: .72rem; font-weight: 700; background: #fffaf0e8; border-radius: .6rem; padding: .12rem .45rem; display: flex; gap: .3rem; align-items: center; }
#task .rq i { font-style: normal; width: 1rem; height: 1rem; border-radius: 50%; border: 2px solid #c9b8a4; display: inline-grid; place-items: center; font-size: .65rem; flex: 0 0 auto; }
#task .rq.ok i { background: var(--green); border-color: var(--green); color: #fff; }
#task .rq.ok { color: #23663f; }
#bJudge { position: absolute; right: .5rem; bottom: .5rem; }
#fx { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.spark { position: absolute; width: 1rem; height: 1rem; animation: fly .9s ease-out forwards; }
@keyframes fly { to { transform: translate(var(--dx), var(--dy)) rotate(200deg) scale(.3); opacity: 0; } }
.flash { position: absolute; inset: 0; background: #fff; animation: fl .45s forwards; }
@keyframes fl { to { opacity: 0; } }

/* panel */
#panel { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; gap: .35rem; padding: .6rem .5rem .5rem; }
#studios { display: grid; grid-template-columns: repeat(4, 1fr); gap: .3rem; flex: 0 0 auto; }
#studios button { display: flex; align-items: center; justify-content: center; gap: .3rem; height: 2.3rem; border-radius: .7rem .7rem .3rem .3rem; font-weight: 800; font-size: .9rem; background: #fffaf0; color: var(--blue); border-bottom: .2rem solid #e6d6bf; }
#studios button svg { width: 1.2rem; height: 1.2rem; flex: 0 0 auto; }
#studios button.on { color: #fff; border-bottom-color: #00000033; }
#studios button[data-s="postac"].on { background: var(--green); }
#studios button[data-s="fryzury"].on { background: var(--pink); }
#studios button[data-s="ubieranki"].on { background: var(--red); }
#studios button[data-s="pokoj"].on { background: var(--blue); }
#cats { display: flex; flex-wrap: wrap; gap: .3rem; overflow-x: auto; flex: 0 0 auto; scrollbar-width: none; touch-action: pan-x; }
#cats::-webkit-scrollbar { display: none; }
#cats button { flex: 0 0 auto; height: 1.9rem; padding: 0 .7rem; border-radius: 1rem; background: #fffaf0; font-weight: 700; font-size: .82rem; border: 2px solid #e6d6bf; white-space: nowrap; }
#cats button.on { background: var(--yellow); border-color: #d9ae2a; }
#itemsBox { flex: 1; min-height: 0; overflow-y: auto; background: #fffaf0; border-radius: .8rem; padding: .35rem; touch-action: pan-y; box-shadow: inset 0 0 0 2px #efe1cb; }
#items { display: grid; grid-template-columns: repeat(auto-fill, minmax(4.4rem, 1fr)); gap: .35rem; }
#items button { position: relative; aspect-ratio: 1; border-radius: .7rem; background: #f7ecdc; border: 2px solid #eadbc5; display: flex; flex-direction: column; align-items: center; justify-content: center; overflow: hidden; padding: .15rem; }
#items button svg { width: 100%; flex: 1; min-height: 0; }
#items button span { font-size: clamp(.6rem, 1.1vh, .78rem); font-weight: 700; line-height: 1.05; text-align: center; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#items button.on { border-color: var(--red); background: #ffe9e4; box-shadow: 0 0 0 2px var(--red); }
#items button.kf { outline: 3px dashed var(--blue); outline-offset: 1px; }
#items button.none { font-weight: 800; color: #a08a74; font-size: .8rem; }
#items button .sw { width: 70%; aspect-ratio: 1; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 2px #00000022; flex: 0 0 auto; }
#items button.tool { background: #eef3ff; }
#items .info { grid-column: 1 / -1; font-size: .78rem; font-weight: 700; text-align: center; padding: .2rem; color: var(--blue); }
#items button:active { transform: scale(.94); }
#colors { flex: 0 0 auto; display: flex; flex-direction: column; gap: .3rem; }
#sw { display: grid; grid-template-columns: repeat(16, 1fr); gap: .25rem; }
#sw button { aspect-ratio: 1; max-height: 1.9rem; border-radius: 50%; border: 2px solid #ffffff; box-shadow: 0 0 0 1.5px #00000026; }
#sw button.on { box-shadow: 0 0 0 3px var(--ink); transform: scale(1.08); }
#sw button:disabled { opacity: .3; }
#pats { display: flex; gap: .3rem; }
#pats button { flex: 1; height: 1.7rem; border-radius: .6rem; background: #fffaf0; border: 2px solid #e6d6bf; font-size: .72rem; font-weight: 700; }
#pats button.on { background: var(--blue); color: #fff; border-color: var(--blue); }
#pats:empty { display: none; }

.big { font: inherit; font-weight: 800; font-size: 1.05rem; padding: .55rem 1.2rem; border-radius: 1.3rem; background: var(--red); color: #fff; box-shadow: 0 .22rem 0 #a52a30; text-decoration: none; display: inline-block; text-align: center; white-space: nowrap; }
.big.alt { background: #fffaf0; color: var(--blue); box-shadow: 0 .22rem 0 #d4c2a8; border: 2px solid #e6d6bf; }
.big:active { transform: translateY(2px); box-shadow: 0 1px 0 #a52a30; }

/* overlays */
.ov { position: fixed; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center; background: #3a2a2a66; padding: .6rem; }
#start { background: url(img/studio.webp) center / cover; }
#start::before { content: ""; position: absolute; inset: 0; background: #f6efe1a8; }
.card { position: relative; background: var(--card); border-radius: 1.2rem; box-shadow: 0 .4rem 1.4rem #5a2a2040; padding: 1rem; max-height: 96%; max-width: 100%; display: flex; flex-direction: column; border: .25rem solid #fff; }
.card::before { content: ""; position: absolute; left: 1rem; right: 1rem; top: -.65rem; height: .8rem; background: radial-gradient(circle at 50% 100%, var(--red) 45%, transparent 47%) 0 0 / 1.2rem .8rem repeat-x; }
.startCard { flex-direction: row; gap: 1rem; width: 50rem; align-items: center; }
.sc-left { flex: 0 0 44%; display: flex; flex-direction: column; align-items: center; }
.pick { margin: 0 0 .3rem; font-weight: 800; color: var(--blue); }
#friends { display: flex; gap: .4rem; width: 100%; }
#friends button { flex: 1; background: #f7ecdc; border-radius: .9rem; border: 2px solid #eadbc5; padding: .2rem .1rem .3rem; display: flex; flex-direction: column; align-items: center; }
#friends button svg { width: 100%; height: 13rem; }
#friends button b { font-size: .85rem; color: var(--red); }
#friends button:hover { border-color: var(--red); }
.sc-right { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .6rem; }
.logo small { display: block; color: var(--green); font-weight: 800; font-size: .9rem; text-transform: uppercase; letter-spacing: .08em; }
.logo b { display: block; font-size: 2.4rem; line-height: 1; color: var(--red); text-shadow: 2px 2px 0 #f5cf47; }
.intro { margin: 0; font-size: .92rem; line-height: 1.35; }
.btns { display: flex; gap: .6rem; flex-wrap: wrap; }
.btns .big { flex: 1; font-size: 1.25rem; padding: .7rem 1rem; }
.keys { display: flex; flex-wrap: wrap; gap: .25rem .6rem; font-size: .72rem; color: #6a5648; }
kbd { display: inline-block; font: inherit; font-weight: 800; background: #fff; border: 1.5px solid #d4c2a8; border-bottom-width: 3px; border-radius: .35rem; padding: 0 .3rem; margin-right: .15rem; color: var(--ink); }

.lvCard { width: 52rem; }
.lvCard h2 { margin: 0; color: var(--red); font-size: 1.5rem; }
.lvSub { margin: .2rem 0 .5rem; font-size: .85rem; }
#lvGrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; overflow-y: auto; min-height: 0; flex: 1; padding: .2rem; touch-action: pan-y; }
#lvGrid button { position: relative; border-radius: .8rem; overflow: hidden; background: #f7ecdc; border: 2px solid #eadbc5; text-align: left; display: flex; flex-direction: column; }
#lvGrid button .th { aspect-ratio: 16/9; background-size: cover; background-position: center; }
#lvGrid button b { font-size: .85rem; padding: .2rem .4rem 0; }
#lvGrid button em { font-style: normal; font-size: .85rem; color: #d9a93a; padding: 0 .4rem .3rem; letter-spacing: .1em; }
#lvGrid button .today { position: absolute; top: .3rem; left: .3rem; background: var(--red); color: #fff; font-size: .65rem; font-weight: 800; padding: .1rem .4rem; border-radius: .6rem; }
.foot { display: flex; gap: .5rem; justify-content: center; flex-wrap: wrap; padding-top: .6rem; flex: 0 0 auto; }

.resCard { width: 30rem; }
.resTop { text-align: center; }
#resTitle { font-weight: 800; font-size: 1.3rem; color: var(--blue); }
#stars { font-size: 2.4rem; letter-spacing: .2rem; color: #e3d6c4; line-height: 1.1; }
#stars span.on { color: #f2b70f; display: inline-block; animation: pop .4s; }
@keyframes pop { 0% { transform: scale(.2); } 70% { transform: scale(1.3); } }
#resScore { font-weight: 800; font-size: 1rem; }
#resList { overflow-y: auto; min-height: 0; margin-top: .4rem; font-size: .85rem; }
#resList div { display: flex; justify-content: space-between; gap: .5rem; padding: .18rem .3rem; border-bottom: 1px dashed #e6d6bf; }
#resList div.miss { color: #9a7f6c; }
#resList div.neg { color: var(--red); }
#resList div.msg { justify-content: center; font-weight: 800; color: var(--green); border: 0; }
.phCard { align-items: center; width: 26rem; }
#phImg { max-height: 62vh; max-width: 100%; border-radius: .6rem; min-height: 0; }
.phHint { margin: .3rem 0 0; font-size: .75rem; }

/* portrait */
@media (max-aspect-ratio: 1/1) {
  #main { flex-direction: column; }
  #stage { flex: 0 0 44%; margin: .5rem .5rem 0; }
  #panel { padding-top: .4rem; }
  #items { grid-template-columns: repeat(auto-fill, minmax(4.9rem, 1fr)); }
  #sw { grid-template-columns: repeat(8, 1fr); }
  #sw button { max-height: 2.2rem; }
  .startCard { flex-direction: column; width: 100%; gap: .5rem; }
  .sc-left { flex: 0 0 auto; width: 100%; }
  #friends button svg { height: 11rem; }
  #lvGrid { grid-template-columns: repeat(2, 1fr); }
  #brand span { display: none; }
  :root { font-size: clamp(12px, calc(1.6vh + 3px), 17px); }
}
@media (max-aspect-ratio: 1/1) and (max-width: 360px) { #brand { display: none; } }
/* short frames (store page window, phone landscape) */
@media (max-height: 560px) and (min-aspect-ratio: 1/1) {
  #top { height: 2.3rem; } .ic { width: 1.8rem; height: 1.8rem; }
  #stage { margin: .45rem 0 .35rem .35rem; flex-basis: 40%; }
  #panel { padding: .45rem .35rem .35rem; gap: .25rem; }
  #studios button { height: 1.95rem; font-size: .8rem; }
  #cats button { height: 1.65rem; font-size: .75rem; }
  #sw button { max-height: 1.5rem; }
  #pats button { height: 1.45rem; }
  #items { grid-template-columns: repeat(auto-fill, minmax(3.9rem, 1fr)); }
  #friends button svg { height: 10rem; }
  .logo b { font-size: 2rem; }
  .card { padding: .7rem; }
}
@media (max-height: 420px) and (min-aspect-ratio: 1/1) {
  #friends button svg { height: 8rem; }
  .pick { display: none; }
  .intro { font-size: .8rem; }
  .keys { display: none; }
  #task .rq { font-size: .66rem; padding: .05rem .4rem; }
  #hint { font-size: .7rem; }
  .startCard { width: 44rem; }
  #lvGrid { grid-template-columns: repeat(4, 1fr); }
}
@media (min-width: 1300px) and (min-height: 700px) { #stage { flex-basis: 40%; } }
@media (max-aspect-ratio: 1/1) { #cats { flex-wrap: wrap; overflow: visible; } #cats button { height: 1.75rem; padding: 0 .55rem; } }
