@font-face {
  font-family: SolaimanLipi;
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: local("SolaimanLipi"),
       url("./fonts/SolaimanLipi.woff2") format("woff2");
  unicode-range: U+0980-09FF, U+0964-0965, U+200C, U+200D, U+25CC;
}
:root { color-scheme: light; }
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
html[lang="bn"] body { font-family: SolaimanLipi, "Times New Roman", Times, serif; font-weight: 400; }
html[lang="en"] body { font-family: "Times New Roman", Times, serif; }
button, input { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
#menu {
  height: 100dvh; max-height: 100dvh; overflow: hidden;
  display: flex; flex-direction: column;
  background: #120c09; color: #ffdd9c;
}
.menu-stage {
  position: relative; flex: 1 1 auto; min-height: 0;
  display: grid; place-items: center; container-type: size;
  overflow: hidden;
}
.menu-blur {
  /* Carry the same artwork into wide-monitor side space. */
  position: absolute; inset: -24px;
  width: calc(100% + 48px); height: calc(100% + 48px);
  object-fit: cover; filter: blur(22px) brightness(.48);
  pointer-events: none;
}
.menu-frame {
  position: relative; z-index: 1;
  width: min(100cqw, calc(100cqh * 1670 / 942));
  aspect-ratio: 1670 / 942;
}
.menu-card { display: block; width: 100%; height: 100%; object-fit: contain; }
.menu-cat {
  position: absolute; z-index: 2; pointer-events: none;
  left: 32.6%; top: 67%; width: 8.1%; height: 9.6%;
}
.menu-port { display: none; }
/* Menu controls are deliberately separate from the in-game language switch. */
.menu-back {
  position: absolute; z-index: 3; top: 3%;
  left: 14px; padding: 8px 14px; border-radius: 999px;
  border: 1px solid #e6bd68; background: #24150dcc; color: #ffe6a4; text-decoration: none;
}
/* The language switch belongs only to the in-game toolbar. */
.lang-switch { position: static; right: auto; display: flex; border: 1px solid #e6bd68; border-radius: 999px; overflow: hidden; background: #24150dcc; }
.lang-switch button { margin: 0; padding: 7px 12px; border: 0; background: transparent; color: #ffe6a4; min-height: 36px; }
.lang-switch button[aria-pressed="true"] { background: #f0d7a2; color: #2a160c; }
#play {
  position: absolute; z-index: 3; left: 63%; top: 70%; transform: translate(-50%, -50%);
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: min(280px, 34%); min-height: 52px; margin: 0; padding: 8px 22px;
  border-radius: 999px; border: 3px solid #e6c36a;
  background: linear-gradient(#9a1e24, #5a0e12); color: #fff6d8;
  font-family: "Times New Roman", Times, serif; font-weight: 700;
  font-size: 22px; line-height: 1; letter-spacing: 0.01em; white-space: nowrap;
  box-shadow: 0 8px 16px #20120966, inset 0 1px 0 #f3dd9a66;
}
.play-glyph {
  width: 0; height: 0; border-style: solid;
  border-width: 8px 0 8px 14px; border-color: transparent transparent transparent #f6d78a;
}
/* The Play Game button is already painted into the user-provided image.
   Only an invisible accessible hit target is placed over the painted button.
   The existing #play click listener and all gameplay remain untouched. */
@media (min-aspect-ratio: 4/5) {
  #play {
    left: 64.2%; top: 76.95%;
    width: 34.6%; height: 14.2%;
    min-height: 0; padding: 0; margin: 0;
    border: 0; border-radius: 20%;
    background: transparent; color: transparent;
    box-shadow: none; gap: 0;
  }
  #play .play-glyph, #play #play-label { visibility: hidden; }
  #play:focus-visible {
    outline: 3px solid #fff0a3;
    outline-offset: 2px;
  }
}
.legal-footer {
  width: 100%; margin: 0; margin-top: auto; flex: 0 0 auto;
  padding: 12px 16px 14px; background: #fff; color: #6b7280;
  text-align: center; font: 13px/1.6 "Times New Roman", Times, serif;
}
.legal-footer nav { display: flex; justify-content: center; gap: 9px; flex-wrap: wrap; }
.legal-footer a { color: inherit; text-decoration: none; }
.legal-footer a:hover { text-decoration: underline; color: #176b50; }
.legal-footer p { margin: 4px 0 0; }
html:has(#game:not([hidden])), html:has(#game:not([hidden])) body { height: 100dvh; overflow: hidden; }
#game {
  height: 100dvh; max-height: 100dvh; overflow: hidden;
  display: grid; grid-template-rows: auto minmax(0, 1fr);
  background: #1a100c; color: #2a1a12;
}
.play-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; height: 40px; padding: 4px 8px; background: #24150d; }
.play-top .lang-switch { position: static; }
.play-top-left { display: flex; align-items: center; gap: 6px; }
#to-menu, #new {
  min-height: 32px; padding: 4px 10px; border-radius: 999px;
  border: 1px solid #e6bd68; background: transparent; color: #ffe6a4; font-size: 14px;
}
.stage-wrap { position: relative; min-height: 0; overflow: hidden; }
#stage { display: block; width: 100%; height: 100%; background: #24160f; }
#ask-panel {
  display: contents;
  pointer-events: none;
}
#ask-panel > * { pointer-events: auto; }
.speech {
  position: absolute; z-index: 5; display: flex; align-items: stretch;
  left: calc(var(--bubble-left, 0.63) * 100%);
  top: calc(var(--bubble-top, 0.04) * 100%);
  width: min(420px, calc(100% - var(--bubble-left, 0.63) * 100% - 16px));
  margin: 0; padding: 0; border: 0; background: transparent;
  filter: drop-shadow(0 8px 14px rgba(32, 18, 9, 0.28));
  color: #1a1f26;
}
.q-badge {
  flex: 0 0 45px; display: grid; place-items: center;
  background: #1c4f4a; color: #fff; font-size: 21px; font-weight: 700;
  border-radius: 16px 0 0 16px;
}
#status {
  margin: 0; flex: 1; padding: 10px 14px;
  background: #f7f9fc; color: #1a1f26;
  border-radius: 20px; font-size: 22px; line-height: 1.25;
}
.speech.has-badge #status { border-radius: 0 14px 14px 0; }
.speech::after {
  content: ""; position: absolute; left: -18px; top: 24px;
  border: 11px solid transparent; border-right: 20px solid #f7f9fc;
}
.speech.has-badge::after { border-right-color: #1c4f4a; }
.speech.pop { animation: bubble-in .38s cubic-bezier(.16,.84,.32,1) both; }
@keyframes bubble-in { from { opacity: 0; transform: translateY(8px) scale(.92); } to { opacity: 1; transform: none; } }
[hidden] { display: none !important; }
#categories, #hud {
  position: absolute; z-index: 3; left: 3%; right: 3%;
  top: calc(var(--desk-y, 0.62) * 100%);
}
#load-retry { width: 100%; margin-top: 8px; }
.cat-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.cat-row button, #guess button, #learn-save, #learn-again, #back, .confirm button {
  min-height: 42px; border-radius: 10px; border: 1px solid #bd9969;
  background: linear-gradient(#fff0cb, #dfbb81); color: #392417; padding: 6px 4px;
}
.answer-row { display: contents; }
#answers {
  position: absolute; z-index: 5; left: 16px; right: 16px; bottom: 14px;
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px;
  background: transparent; border: 0; box-shadow: none; pointer-events: auto;
}
#answers button {
  min-height: 58px; margin: 0; padding: 8px 10px;
  border: 1px solid #d3dde8; border-radius: 12px;
  background: #f7f9fc; color: #1c2430; font-size: 18px; line-height: 1.15;
  box-shadow: 0 6px 14px rgba(20, 16, 10, 0.18);
}
#answers button:hover, #answers button:focus-visible { background: #d7e4f2; }
#hud { color: #fff6e4; pointer-events: auto; }
#hud:not(:has(#guess:not([hidden]), #learn:not([hidden]), #learn-again:not([hidden]))) { display: none; }
#hud:has(#learn:not([hidden]), #learn-again:not([hidden])) {
  top: auto; bottom: 8px; z-index: 6; max-height: calc(100% - 12px); overflow: auto;
}
#progress {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
#credit, #learn-note { margin: 2px 4px; font-size: 12px; color: #fff6e4; text-shadow: 0 1px 2px #201209; }
.guess-line { display: none; margin: 0; }
#solved-line {
  margin: 0; padding: 8px 16px; text-align: center;
  color: #2a1a12; background: #fff6e4; border: 1px solid #c5a16c;
  border-radius: 14px; font-size: 20px; line-height: 1.3;
  text-shadow: none;
}
#guess { display: flex; gap: 4px; align-items: center; }
#back {
  position: absolute; z-index: 7; left: 8px; bottom: 8px; top: auto;
  width: 44px; height: 44px; min-width: 44px; min-height: 44px; padding: 0;
  border-radius: 50%; display: grid; place-items: center;
  font-size: 22px; line-height: 1;
  border: 1px solid #e6bd68; background: #24150dcc; color: #ffe6a4;
}
@media (min-aspect-ratio: 4/5) {
  #categories { left: max(16px, calc((100% - 720px) / 2)); right: max(16px, calc((100% - 720px) / 2)); }
  #categories .cat-row button { font-size: 18px; }
  #answers { left: max(16px, calc((100% - 920px) / 2)); right: max(16px, calc((100% - 920px) / 2)); }
  /* Answer positioning is handled by the final layered layout, including Back. */
  @media (max-height: 450px) {
    #categories .cat-row button { min-height: 42px; font-size: 15px; }
    #answers button { min-height: 42px; padding: 6px; font-size: 15px; }
  }
}
html[lang="bn"] button, html[lang="bn"] input, html[lang="bn"] .speech { font-weight: 400; }
#learn {
  display: grid; grid-template-columns: 1fr 1fr auto; gap: 6px; align-items: end;
  padding: 8px; border-radius: 12px; background: #24150de6; margin-bottom: 6px;
}
#learn label { display: grid; gap: 2px; font-size: 13px; }
#learn input { min-height: 36px; padding: 4px 8px; border-radius: 8px; border: 1px solid #e6bd68; width: 100%; }
#learn-note { grid-column: 1 / -1; }
#learn-again {
  display: block;
  width: min(320px, 100%);
  min-height: 52px;
  margin: 0 auto 8px;
  padding: 10px 20px;
  font-size: 18px;
}

.confirm {
  position: absolute; z-index: 5; left: 50%; top: 42%; transform: translate(-50%, -50%);
  width: min(280px, 88%); padding: 14px 14px 12px; text-align: center;
  border-radius: 14px; background: #fff6e4; border: 2px solid #c5a16c; color: #2a1a12;
  box-shadow: 0 12px 28px #20120966;
}
.confirm p { margin: 0 0 10px; }
.confirm div { display: flex; gap: 8px; }
.confirm button { flex: 1; }
@media (max-aspect-ratio: 4/5) {
  #menu { position: relative; }
  .menu-stage { position: absolute; inset: 0; display: block; }
  .menu-blur, .menu-card { display: none; }
  .menu-frame { width: 100%; height: 100%; aspect-ratio: auto; }
  .menu-port { display: block; width: 100%; height: 100%; object-fit: cover; object-position: center center; }
  .menu-back { top: 10px; }
  #play {
    left: 50%; top: auto; bottom: 8%; transform: translateX(-50%);
    width: min(280px, 74%); min-height: 52px; font-size: 22px;
  }
}
@media (max-aspect-ratio: 4/5) {
  #ask-panel {
    display: contents;
    left: auto; right: auto; top: auto; width: auto; max-height: none;
  }
  .speech {
    position: absolute; left: 0; right: 0; z-index: 5;
    width: fit-content; max-width: calc(100% - 24px);
    margin-left: auto; margin-right: auto;
    top: calc(var(--question-y, 0.46) * 100% + 6px);
  }
  #status { width: auto; flex: 0 1 auto; }
  .speech::after, .speech.has-badge::after {
    left: 50%; margin-left: -9px; top: -16px; bottom: auto; right: auto;
    border: 9px solid transparent;
    border-bottom: 16px solid #f7f9fc;
  }
  .q-badge { flex: 0 0 32px; font-size: 15px; border-radius: 12px 0 0 12px; }
  #status { font-size: 16px; padding: 10px 16px; border-radius: 14px; }
  #categories, #answers {
    /* Just under the speech bubble. --under-bubble is the bubble's bottom, not desk-y. */
    top: var(--under-bubble, calc(var(--question-y, 0.46) * 100% + 60px));
    bottom: auto; left: 12px; right: 12px; width: auto; z-index: 6;
  }
  .cat-row, .answer-row {
    display: flex; flex-direction: row; flex-wrap: wrap; justify-content: center;
    align-items: center; gap: 14px;
  }
  .cat-row button, #answers button, #load-retry {
    flex: 0 0 auto; width: auto; min-width: 44px; min-height: 44px; height: 44px;
    font-size: 16px; line-height: 1; padding: 0 16px; border-radius: 999px;
  }
  #answers {
    display: flex; flex-direction: column; align-items: center; gap: 14px;
    background: transparent; border: 0; box-shadow: none;
  }
  #answers button {
    border: 1px solid #d5dee8; background: #f7f9fc;
    box-shadow: 0 3px 8px rgba(20, 16, 10, 0.12);
  }
  #load-retry { margin: 8px auto 0; }
  #hud:has(#guess:not([hidden])) {
    top: calc(var(--note-bottom, 0.62) * 100% + 8px);
    bottom: auto; left: 12px; right: 12px; z-index: 6;
    padding: 0; background: transparent;
    display: flex; flex-direction: column; align-items: center; gap: 4px;
  }
  .guess-line { display: none; }
  #guess { display: grid; grid-template-columns: 1fr; gap: 8px; width: 100%; }
  #guess button { min-height: 52px; font-size: 18px; width: 100%; padding: 8px 14px; }
  #solved-line { font-size: 20px; }
  #hud:has(#guess:not([hidden])) #credit {
    margin: 0; max-width: 92%; text-align: center; font-size: 11px; line-height: 1.25;
  }
  #back { top: auto; bottom: 8px; width: 44px; height: 44px; }
}
@media (min-aspect-ratio: 4/5) {
  #hud:has(#guess:not([hidden])) {
    top: calc(var(--note-bottom, 0.52) * 100% + 10px);
    bottom: auto;
    left: calc(var(--note-left, 0.18) * 100%);
    right: auto;
    width: calc(var(--note-width, 0.64) * 100%);
    z-index: 6;
    display: flex; flex-direction: column; align-items: stretch; gap: 4px;
    background: transparent;
  }
  #hud:has(#guess:not([hidden])) #guess {
    display: grid; grid-template-columns: 1fr; gap: 8px;
    width: 100%; margin: 0;
  }
  #hud:has(#guess:not([hidden])) #guess button {
    min-height: 58px; font-size: 20px; width: 100%; padding: 10px 16px;
  }
  #solved-line { font-size: 20px; }
  #hud:has(#guess:not([hidden])) #credit {
    position: static; margin: 0; max-width: 100%; text-align: center; font-size: 11px;
    line-height: 1.2;
  }
}
@media (max-width: 520px) {
  #learn { grid-template-columns: 1fr; }
  #new { font-size: 13px; padding: 4px 8px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* In-game controls are separate from the illustrated room and short desk. */
#game .stage-wrap { background:#21130b; }
#game #categories .cat-row button, #game #answers button {
  border:1px solid #e1b66d; border-radius:999px;
  background:linear-gradient(#fff2d0,#e7c285); color:#35200f;
  box-shadow:0 3px 7px #10080445; font-weight:700;
}
#game #categories .cat-row button:hover, #game #answers button:hover { background:#ffe0a0; }
#game #categories .cat-row button:focus-visible, #game #answers button:focus-visible {
  outline:2px solid #fff1c7; outline-offset:2px;
}
#game #categories .cat-row button::before {
  content:""; display:inline-block; width:1em; height:1em; margin-right:.4em;
  background:currentColor; vertical-align:-.12em; mask-repeat:no-repeat; mask-size:contain; mask-position:center;
}
#game #categories [data-cat="character"]::before {mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='7' r='4'/%3E%3Cpath d='M4 21v-3a8 8 0 0116 0v3z'/%3E%3C/svg%3E")}
#game #categories [data-cat="object"]::before {mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='none' stroke='black' stroke-width='2' d='M12 2 22 7v10l-10 5-10-5V7z M2 7l10 5 10-5M12 12v10'/%3E%3C/svg%3E")}
#game #categories [data-cat="animal"]::before {mask-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cellipse cx='4' cy='9' rx='2.5' ry='3.5'/%3E%3Cellipse cx='9' cy='5' rx='2.5' ry='3.5'/%3E%3Cellipse cx='15' cy='5' rx='2.5' ry='3.5'/%3E%3Cellipse cx='20' cy='9' rx='2.5' ry='3.5'/%3E%3Cpath d='M12 10c-3 0-9 6-7 9s5 1 7 1 5 2 7-1-4-9-7-9z'/%3E%3C/svg%3E")}
@media (min-aspect-ratio:4/5){
  #game #categories {top:calc(var(--room-edge,.6)*100% + clamp(8px,3vh,28px));}
  #game #categories .cat-row button {min-height:clamp(42px,6vh,56px);}
  #game #answers {bottom:clamp(10px,3vh,30px);}
  #game #answers button {min-height:clamp(42px,6.5vh,58px);}
}
@media (max-aspect-ratio:4/5){
  #game .speech {top:calc(var(--question-y,.46)*100% + 8px); max-width:calc(100% - 28px);}
  #game .speech::after, #game .speech.has-badge::after {left:40%;}
  #game #categories {left:12px;right:12px;}
  #game #categories .cat-row {display:grid;grid-template-columns:1fr;gap:8px;width:min(78%,360px);margin:auto;}
  #game #categories .cat-row button {width:100%;height:44px;min-height:44px;font-size:17px;padding:0 12px;}
  #game #answers {gap:8px;}
  #game #answers .answer-row {gap:8px;flex-wrap:nowrap;width:100%;max-width:440px;}
  #game #answers button {flex:1 1 0;min-width:0;min-height:44px;height:auto;padding:6px 8px;font-size:15px;line-height:1.15;white-space:normal;}
  #game .q-badge {flex-basis:32px;}
}

/* Riddlex bilingual typography: readable Bangla without synthetic bold. */
html[lang="en"] body { font-family: "Times New Roman", Times, SolaimanLipi, serif; }
html[lang="bn"] body { font-family: SolaimanLipi, "Times New Roman", Times, serif; }
#game .lang-switch [data-set-lang="en"], #riddlex-guide [data-guide-lang="en"] {
  font-family: "Times New Roman", Times, serif; font-weight: 400;
}
#game .lang-switch [data-set-lang="bn"], #riddlex-guide [data-guide-lang="bn"],
#riddlex-guide [lang="bn"] {
  font-family: SolaimanLipi, "Times New Roman", Times, serif;
  font-weight: 400; font-synthesis: none;
}
html[lang="bn"] #game button, html[lang="bn"] #game input,
html[lang="bn"] #game #status, html[lang="bn"] #game #solved-line,
html[lang="bn"] #game .q-badge {
  font-family: SolaimanLipi, "Times New Roman", Times, serif;
  font-weight: 400; font-synthesis: none;
}
html[lang="bn"] #game #status { font-size: 24px; line-height: 1.5; overflow-wrap: anywhere; }
html[lang="bn"] #game #categories .cat-row button,
html[lang="bn"] #game #answers button { font-size: 20px; line-height: 1.35; }
html[lang="bn"] #game #solved-line { line-height: 1.5; }
@media (max-aspect-ratio:4/5) {
  html[lang="bn"] #game #status { font-size: 19px; line-height: 1.5; padding: 8px 12px; }
  html[lang="bn"] #game #categories .cat-row button { font-size: 19px; line-height: 1.35; height: auto; }
  html[lang="bn"] #game #answers button { font-size: 17px; line-height: 1.35; }
}
@media (min-aspect-ratio:4/5) and (max-height:450px) {
  html[lang="bn"] #game #status { font-size: 19px; line-height: 1.4; }
  html[lang="bn"] #game #categories .cat-row button,
  html[lang="bn"] #game #answers button { font-size: 17px; }
}

/* Approved layered layout. Static sprites, exact carved desk, live HTML controls. */
#game {grid-template-rows:clamp(47px,7vh,66px) minmax(0,1fr);isolation:isolate;border:1px solid #9b7238;border-radius:clamp(0px,1.1vw,16px);}
#game .play-top {height:auto;padding:7px clamp(10px,2vw,26px);background:linear-gradient(#392517,#24160e);z-index:5;}
#game .play-top button {font-size:clamp(12px,1.25vw,17px);padding:7px 12px;min-height:36px;}
#game .stage-wrap {--edge:72%;--actor-bottom:27.7%;background:#2b180d;isolation:isolate;}
#game .room-art {position:absolute;inset:0;z-index:0;isolation:isolate;pointer-events:none;overflow:hidden;}
.room-library {position:absolute;inset:0 0 auto;height:var(--edge);background:url("images/layered/library.webp") center top/110% auto no-repeat;z-index:-2;}
.room-library::after{content:"";position:absolute;inset:0;background:linear-gradient(180deg,#27160945,transparent 24%,#32160a10 65%,#20110b48);}
.room-logo{position:absolute;z-index:5;left:50%;top:1%;width:clamp(170px,23vw,330px);height:auto;transform:translateX(-50%);filter:drop-shadow(0 3px 2px #140700);}
.room-detective,.room-cat,.room-lamp{position:absolute;bottom:var(--actor-bottom);height:auto;object-fit:contain;object-position:center bottom;}
.room-detective{left:27%;width:39%;max-height:61%;z-index:1;filter:drop-shadow(0 3px 3px #210f0850);}
.room-cat{left:65%;width:23%;max-height:25%;z-index:2;}
.room-lamp{left:8%;width:15%;max-height:45%;z-index:1;}
.room-lens{position:absolute;bottom:calc(var(--actor-bottom) - 1.4%);width:11%;height:auto;left:16%;z-index:4;}
.room-desk{position:absolute;top:var(--edge);height:6.8%;left:0;right:0;background:linear-gradient(0deg,#1e090026,transparent 55%),url("images/layered/desk.webp") center/100% 100%;box-shadow:inset 0 3px 7px #32110050;z-index:3;}
.room-desk::after{content:"";position:absolute;left:0;right:0;bottom:-1px;height:26%;background:url("images/layered/desk-rim.webp") center/100% 100% no-repeat;box-shadow:0 5px 7px #14070070;}
.room-front{position:absolute;top:calc(var(--edge) + 6.8%);bottom:0;left:0;right:0;background:url("images/layered/desk-front.webp") center/100% 100% no-repeat;z-index:0;}
#game #stage{position:absolute;inset:0;z-index:2;pointer-events:none;background:transparent;}
#game .speech{left:64%;right:auto;top:var(--speech-top,40%);width:min(30%,420px);margin:0;min-height:48px;max-width:none;display:flex;align-items:center;justify-content:center;gap:5px;padding:10px 14px;background:#fffcf7;color:#2c2019;border-radius:18px;filter:none;box-shadow:0 5px 10px #10070033;text-align:center;}
#game #status{background:transparent;padding:0;border-radius:0;flex:0 1 auto;font-size:clamp(16px,1.85vw,24px);line-height:1.25;}
#game .q-badge{flex:0 0 auto;border-radius:9px;padding:5px;min-width:21px;background:#276c61;font-size:.9em;line-height:1.25;}
#game .speech::after,#game .speech.has-badge::after{content:"";position:absolute;pointer-events:none;left:-25px;top:auto;bottom:5px;right:auto;margin:0;width:30px;height:25px;border:0;background:#fffcf7;clip-path:polygon(100% 0,100% 65%,0 100%,65% 47%);}
#game #categories,#game #answers{position:absolute;top:calc(var(--edge) + 9.3%);bottom:7.5%;left:50%;right:auto;transform:translateX(-50%);width:min(78%,930px);margin:0;z-index:5;align-content:center;align-items:center;}
#game #categories .cat-row{width:100%;gap:clamp(8px,1.7vw,24px);}
#game #categories .cat-row button,#game #answers button{font-size:clamp(15px,1.6vw,21px);min-height:44px;padding:9px 12px;border-color:#efc676;background:linear-gradient(#fff1ca,#f4ce81);box-shadow:0 4px 7px #10070066;}
#game #answers{width:min(85%,1050px);gap:10px;}
#game #back{bottom:2.2%;left:2%;}
html[lang="bn"] #game #status{font-size:clamp(19px,1.9vw,25px);line-height:1.45;font-weight:400;}
html[lang="bn"] #game #categories .cat-row button,html[lang="bn"] #game #answers button{font-size:clamp(17px,1.75vw,23px);line-height:1.35;font-weight:400;}
@media(max-aspect-ratio:4/5){
  #game{grid-template-rows:47px minmax(0,1fr);border:0;border-radius:0;}
  #game .play-top{padding:5px 9px;}
  #game .play-top button{padding:6px 9px;font-size:13px;}
  #game .stage-wrap{--edge:58%;--actor-bottom:41.8%;}
  .room-library{background-size:auto 147%;background-position:48% top;}
  .room-logo{top:1.1%;width:min(64%,260px);}
  .room-detective{left:-7%;width:74%;max-height:52%;}
  .room-cat{left:56%;width:44%;max-height:22%;}
  .room-lamp{left:-10%;width:25%;max-height:27%;}
  .room-lens{left:0%;width:20%;}
  .room-front{background-image:url("images/layered/desk-front-mobile.webp");}
  #game .speech{top:var(--speech-top,36%);left:55%;width:42%;padding:8px;min-height:40px;border-radius:15px;}
  #game #status{font-size:clamp(14px,4.3vw,20px);line-height:1.3;}
  #game .speech::after,#game .speech.has-badge::after{left:-18px;width:23px;height:21px;bottom:4px;}
  #game #categories,#game #answers{top:calc(var(--edge) + 9.3%);bottom:7.5%;left:50%;right:auto;width:min(78%,360px);}
  #game #categories .cat-row{width:100%;gap:10px;}
  #game #categories .cat-row button{height:auto;min-height:48px;font-size:17px;padding:5px 12px;}
  #game #answers{width:min(88%,440px);bottom:10%;gap:8px;justify-content:center;}
  #game #answers .answer-row{width:100%;gap:7px;flex-wrap:nowrap;justify-content:center;}
  #game #answers button{min-width:0;min-height:44px;height:auto;font-size:15px;padding:5px 7px;line-height:1.2;}
  html[lang="bn"] #game #status{font-size:clamp(17px,4.6vw,20px);line-height:1.4;}
  html[lang="bn"] #game #answers button{font-size:17px;line-height:1.3;}
}
@media(max-aspect-ratio:4/5) and (max-height:620px){
  #game .stage-wrap{--edge:54%;--actor-bottom:45.8%;}
  .room-logo{width:55%;}
  .room-detective{max-height:48%;}
  #game #categories,#game #answers{top:calc(var(--edge) + 6.2%);bottom:4.5%;}
  #game #categories .cat-row{gap:6px;}
  #game #categories .cat-row button{min-height:44px;padding:4px 8px;font-size:15px;}
  #game #answers{bottom:9%;gap:5px;}
  #game #answers button{min-height:44px;padding:4px 6px;font-size:13px;}
  #game #back{min-width:34px;min-height:34px;width:34px;height:34px;}
  html[lang="bn"] #game #answers button{font-size:15px;}
}
@media(min-aspect-ratio:4/5) and (max-height:450px){
  #game{grid-template-rows:38px minmax(0,1fr);}
  #game .stage-wrap{--edge:68%;--actor-bottom:31.8%;}
  #game .play-top button{padding:4px 10px;min-height:30px;}
  .room-logo{width:min(24%,180px);}
  #game #categories,#game #answers{top:calc(var(--edge) + 8%);bottom:5%;}
  #game #categories .cat-row button,#game #answers button{min-height:44px;font-size:14px;padding:5px 8px;}
  #game .speech{padding:7px;min-height:32px;}
  #game #status{font-size:14px;}
  #game .speech::after,#game .speech.has-badge::after{left:-15px;width:20px;height:17px;bottom:3px;}
  html[lang="bn"] #game #status{font-size:17px;}
}

/* Keep all five buttons centered after Back becomes visible on question two. */
@media (min-aspect-ratio:4/5) {
  #game .stage-wrap:has(#back:not([hidden])) #answers {
    left:50%;right:auto;transform:translateX(-50%);
    width:min(85%,1050px);
  }
}
@media (min-aspect-ratio:4/5) and (max-height:450px) {
  #game .stage-wrap {--edge:58%;--actor-bottom:41.8%;}
  #game #answers {top:calc(var(--edge) + 9%);bottom:5%;}
}

/* Owner-approved refinement: the logo is a small desk nameplate, never a hat overlay.
   A speech bubble hugs its text, with the number adjacent to the question. */
#game .room-logo {
  top:calc(var(--edge) - 1.2%);bottom:auto;left:50%;height:7.8%;width:auto;
  max-width:38%;max-height:60px;padding:2px 7px;object-fit:contain;
  background:linear-gradient(#3e2413,#24120a);border:1px solid #cfa45d;border-radius:6px;
  box-shadow:0 3px 5px #16090090;filter:none;
}
#game .speech {
  left:var(--speech-left,58%);top:var(--speech-top,38%);
  width:max-content;max-width:var(--speech-max,40%);
  min-width:0;min-height:0;padding:8px 11px;gap:6px;
  justify-content:flex-start;align-items:center;text-align:left;
}
#game #status {flex:0 1 auto;min-width:0;width:auto;overflow-wrap:anywhere;text-align:left;}
#game .q-badge {
  flex:0 0 auto;align-self:flex-start;min-width:1.35em;
  padding:3px 5px;line-height:1.15;border-radius:6px;
  margin-top:1px;
}
#game .speech::after,#game .speech.has-badge::after {
  left:calc(-1 * var(--speech-tail,30px) + 2px);width:var(--speech-tail,30px);
  height:24px;bottom:-4px;top:auto;right:auto;margin:0;border:0;
  clip-path:polygon(100% 0,100% 66%,0 100%,70% 40%);
}
@media(max-aspect-ratio:4/5){
  #game .stage-wrap{--edge:56%;--actor-bottom:43.8%;}
  #game .room-logo{height:7.8%;max-height:52px;max-width:42%;}
  #game .speech{padding:7px 8px;gap:4px;border-radius:13px;}
  #game .speech::after,#game .speech.has-badge::after{height:18px;}
  #game #categories{top:calc(var(--edge) + 9%);}
  #game #answers{
    top:calc(var(--edge) + 9%);bottom:auto;width:min(96%,440px);
    display:flex;flex-direction:column;justify-content:flex-start;gap:8px;
  }
  #game #answers .answer-row{display:flex;width:auto;max-width:100%;flex-wrap:nowrap;justify-content:center;gap:8px;}
  #game #answers button{
    flex:0 1 auto;width:auto;min-width:44px;min-height:44px;height:auto;
    padding:7px clamp(10px,3vw,16px);border-radius:999px;white-space:normal;
  }
}
@media(max-aspect-ratio:4/5) and (max-height:620px){
  #game .stage-wrap{--edge:52%;--actor-bottom:47.8%;}
  #game #answers{gap:6px;}
  #game #answers .answer-row{gap:6px;}
  #game #answers button{padding:5px 10px;}
}
@media(min-aspect-ratio:4/5) and (max-height:450px){
  #game .room-logo{max-height:29px;padding:1px 4px;}
  #game .speech{padding:6px 8px;gap:4px;}
  #game .speech::after,#game .speech.has-badge::after{height:17px;}
}

/* Mobile answer tray: both rows share the same outer edges, not button widths.
   Three generous equal columns above; two wider equal columns below. */
@media (max-aspect-ratio:4/5) {
  #game #answers {
    width:min(calc(100% - 32px),380px);
    gap:9px;
  }
  #game #answers .answer-row {
    display:grid;width:100%;max-width:none;gap:8px;
    grid-template-columns:repeat(3,minmax(0,1fr));
  }
  #game #answers .answer-row + .answer-row {
    grid-template-columns:repeat(2,minmax(0,1fr));
  }
  #game #answers .answer-row button {
    width:100%;min-width:0;min-height:48px;padding:8px 5px;
    border:1px solid #eac274;border-radius:14px;
    background:linear-gradient(180deg,#fff5d5 0%,#f5d18b 100%);
    box-shadow:inset 0 1px 0 #fff8dd,0 3px 6px #190b0566;
    font-size:clamp(14px,4vw,17px);line-height:1.2;
  }
  html[lang="bn"] #game #answers .answer-row button {font-size:clamp(16px,4.5vw,19px);line-height:1.3;}
  #game #answers .answer-row button:hover {background:#ffe1a0;}
  #game #answers .answer-row button:active {background:#e9bc70;}
}
@media (max-aspect-ratio:4/5) and (max-height:620px) {
  #game #answers {gap:7px;}
  #game #answers .answer-row {gap:7px;}
  #game #answers .answer-row button {min-height:44px;padding:5px 4px;}
}


/* Final owner-approved framing: wall-mounted Riddlex plaque, real wooden
   tabletop texture taken from the approved artwork, no mobile fascia.
   All interactive text remains the existing bilingual HTML. */
#game .room-logo {
  top:12%;right:33%;left:auto;bottom:auto;transform:none;z-index:0;
  width:clamp(80px,9vw,150px);height:auto;max-width:none;max-height:none;
  padding:0;background:none;border:0;border-radius:3px;
  box-shadow:0 3px 7px #18090066;filter:none;object-fit:contain;
}
@media (max-aspect-ratio:4/5) {
  #game .stage-wrap {
    --table-zone:clamp(154px,30%,248px);
    --edge:calc(100% - var(--table-zone));
    --actor-bottom:calc(var(--table-zone) - 1px);
  }
  #game .room-library {
    height:var(--edge);background-size:auto 160%;background-position:49% top;
  }
  #game .room-logo {
    top:16%;right:5%;width:38%;max-width:195px;height:auto;max-height:none;
  }
  #game .room-detective {
    left:-22%;width:104%;max-height:64%;
  }
  #game .room-cat {left:57%;width:46%;max-height:24%;}
  #game .room-lamp {display:none;}
  #game .room-lens {left:1%;width:19%;bottom:calc(var(--table-zone) - 10px);}
  #game .room-front {display:none;}
  #game .room-desk {
    top:var(--edge);bottom:0;height:auto;clip-path:none;border:0;
    background:linear-gradient(180deg,#32140540,transparent 10%,transparent 92%,#32140522),url("images/layered/mobile-tabletop.webp") center/100% 100% no-repeat;
    box-shadow:inset 0 2px 4px #2d150a70;
  }
  #game .room-desk::before {display:none;}
  #game .room-desk::after {
    height:9px;bottom:0;background:url("images/layered/desk-rim.webp") center/100% 100% no-repeat;
    box-shadow:none;
  }
  #game #answers {
    top:calc(var(--edge) + 14px);bottom:40px;
    align-content:center;justify-content:center;gap:9px;
    background:none;
  }
  #game #categories {
    top:calc(var(--edge) + 8px);bottom:10px;
    align-content:center;justify-content:center;
  }
  #game #categories .cat-row {gap:5px;}
  #game #categories .cat-row button {min-height:40px;padding:4px 10px;}
  #game #answers .answer-row button {
    border:1px solid #eac274;border-radius:999px;
    background:linear-gradient(180deg,#fff4d2,#f5ce81);
    color:#392417;box-shadow:inset 0 1px 0 #fff9de,0 3px 6px #190b0566;
  }
  #game #answers .answer-row button:hover {background:#ffe1a0;}
  #game #answers .answer-row button:active {background:#e9bc70;}
  #game #back {bottom:5px;left:5px;width:32px;height:32px;min-width:32px;min-height:32px;}
}
@media (max-aspect-ratio:4/5) and (max-height:620px) {
  #game .room-logo {top:7%;right:5%;width:35%;}
  #game .room-detective {left:-22%;width:98%;max-height:63%;}
  #game #answers {top:calc(var(--edge) + 8px);bottom:39px;gap:7px;}
  #game #answers .answer-row {gap:7px;}
  #game #answers .answer-row button {min-height:44px;padding:5px 4px;}
}
@media (min-aspect-ratio:4/5) and (max-height:450px) {
  #game .room-logo {top:3%;right:33%;width:9%;max-width:80px;}
}

/* Portrait art is sourced directly from the owner's approved illustration,
   not recomposed from the prior library, detective, cat and desk images.
   The original desktop artwork and desktop controls remain unchanged. */
.approved-portrait-art{display:none;}
@media(max-aspect-ratio:4/5){
  #game .stage-wrap{
    --table-zone:clamp(136px,23%,196px);
    --actor-zone:min(65%,calc(100vw * .75));
    --edge:calc(100% - var(--table-zone));
  }
  #game .room-art{visibility:hidden;}
  #game .approved-portrait-art{display:block;position:absolute;inset:0;z-index:0;pointer-events:none;overflow:hidden;background:#32190d;}
  #game .approved-portrait-art img{position:absolute;display:block;left:0;width:100%;object-fit:fill;}
  #game .approved-wall{top:0;height:calc(100% - var(--table-zone) - var(--actor-zone));}
  #game .approved-actors{bottom:var(--table-zone);height:var(--actor-zone);}
  #game .approved-table{bottom:0;height:var(--table-zone);}
  #game .stage-wrap:not(.portrait-art-ready) .approved-portrait-art,
  #game .stage-wrap:not(.portrait-art-ready) #ask-panel,
  #game .stage-wrap:not(.portrait-art-ready) #categories,
  #game .stage-wrap:not(.portrait-art-ready) #stage{visibility:hidden;}
  #game #answers{top:auto;bottom:26px;gap:8px;width:min(92%,440px);}
  #game #answers .answer-row button{min-height:44px;padding:5px 4px;font-size:clamp(14px,4vw,18px);line-height:1.2;}
  html[lang="bn"] #game #answers .answer-row button{font-size:clamp(16px,4.5vw,19px);}
  #game #categories{top:calc(var(--edge) + 8px);bottom:12px;}
  #game #categories .cat-row{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px;}
  #game #categories .cat-row button{min-height:44px;padding:4px 3px;font-size:clamp(13px,3.8vw,17px);}
  #game .speech{gap:4px;padding:7px 9px;max-width:var(--speech-max,52%);}
  #game #status{font-size:clamp(14px,4.2vw,17px);line-height:1.25;}
  html[lang="bn"] #game #status{font-size:clamp(15px,4.1vw,18px);line-height:1.4;}
  #game .q-badge{min-width:19px;padding:2px 4px;}
  #game #back{width:30px;height:30px;min-width:30px;min-height:30px;bottom:3px;left:5px;}
}
@media(max-aspect-ratio:4/5) and (max-height:620px){
  #game .stage-wrap{--table-zone:133px;--actor-zone:min(60%,calc(100vw * .69));}
  #game #answers{bottom:32px;gap:6px;}
  #game #answers .answer-row button{min-height:42px;padding:4px 3px;}
}

@media(max-aspect-ratio:4/5){
  #game .stage-wrap{--plaque-zone:calc(100vw * .218);--actor-zone:min(65%,calc(100vw * .79));}
  #game .approved-wall{height:calc(100% - var(--table-zone) - var(--actor-zone) - var(--plaque-zone));}
  #game .approved-wall-plaque{bottom:calc(var(--table-zone) + var(--actor-zone));height:var(--plaque-zone);}
  #game .stage-wrap:not(.portrait-art-ready) #hud,#game .stage-wrap:not(.portrait-art-ready) #back{visibility:hidden;}
}
@media(max-aspect-ratio:4/5) and (max-height:620px){
  #game .stage-wrap{--actor-zone:min(60%,calc(100vw * .69));--plaque-zone:min(19%,calc(100vw * .218));}
}

/* Riddlex is a single-screen app, including its landing menu. Keep the
   dynamic mobile viewport bounded even while browser bars expand/collapse. */
html, body {
  width:100%; height:100%; min-height:0; margin:0;
  overflow:hidden; overscroll-behavior:none;
}
@supports (height:100dvh) {
  html, body {height:100dvh;max-height:100dvh;}
}
#menu {width:100%;height:100%;max-height:100%;min-height:0;overflow:hidden;}
#menu .menu-stage {min-width:0;min-height:0;}
@media (max-aspect-ratio:4/5) {
  #menu .menu-stage {
    display:grid;place-items:center;
    background:radial-gradient(ellipse at center,#392419 0%,#120c09 76%);
  }
  #menu .menu-frame {
    width:min(100cqw,56.25cqh);height:min(100cqh,177.777778cqw);
    max-width:100%;max-height:100%;aspect-ratio:9/16;
    container-type:inline-size;overflow:hidden;
  }
  #menu .menu-port {width:100%;height:100%;object-fit:contain;object-position:center;}
  #menu .menu-back {top:7px;left:8px;padding:6px 12px;}
  #menu #play {width:min(280px,78%);}
}

/* Keep the approved portrait detective's face clear of the dialogue,
   including the initial category prompt. The desktop is unchanged. */
@media(max-aspect-ratio:4/5){
  #game .speech {
    left:var(--speech-left,56%);max-width:var(--speech-max,42%);
    padding:6px 8px;gap:4px;
  }
  #game .speech::after,#game .speech.has-badge::after {
    left:calc(-1 * var(--speech-tail,12px) + 2px);
    width:var(--speech-tail,12px);height:16px;
  }
  #game .speech.pop{animation:portrait-dialogue-in .2s ease-out both;}
  @keyframes portrait-dialogue-in{from{opacity:0;}to{opacity:1;}}
}

/* Keep the number attached to the question, use one consistent Bengali
   typeface and remove the legacy status padding that separated the number. */
#game .speech .q-badge{align-self:center;margin:0;flex:0 0 auto;min-width:1.45em;padding:3px 4px;font-size:1em;line-height:1;display:grid;place-items:center;border-radius:6px;}
#game .speech .q-badge[hidden]{display:none!important;}
#game .speech #status{padding:0;margin:0;flex:0 1 auto;min-width:0;letter-spacing:0;word-spacing:normal;overflow-wrap:break-word;word-break:normal;}
html[lang="bn"] #game .speech #status,html[lang="bn"] #game .speech .q-badge{
  font-family:SolaimanLipi,"Times New Roman",Times,serif;font-weight:400;
}
@media(max-aspect-ratio:4/5){
  #game .speech{gap:5px;padding:7px 8px;align-items:center;min-height:0;}
  html[lang="bn"] #game .speech #status{font-size:clamp(15px,4.1vw,18px);line-height:1.22;padding:0;}
  #game .speech .q-badge{font-size:clamp(14px,3.8vw,16px);}
  #game #answers{bottom:clamp(35px,5vh,44px);gap:8px;}
  #game #categories{bottom:22px;}
}
@media(max-aspect-ratio:4/5) and (max-height:620px){
  #game #answers{bottom:35px;gap:6px;}
  #game #answers .answer-row button{min-height:42px;}
}

/* After confirmation the detective speaks the result; there is no duplicate
   result panel, name card, or photo. Only the replay button stays on the desk. */
#game[data-view="solved"] #hud{
  position:absolute;top:var(--edge);bottom:0;left:0;right:0;
  display:grid;place-items:center;margin:0;padding:0 12px;max-height:none;overflow:visible;
}
#game[data-view="solved"] #guess{display:grid;place-items:center;width:100%;margin:0;gap:0;}
#game[data-view="solved"] #again{width:min(78%,320px);min-height:46px;border-radius:999px;border:1px solid #efc676;background:linear-gradient(#fff1ca,#f4ce81);color:#392417;box-shadow:0 4px 7px #10070066;}
#game[data-view="solved"] #solved-line,#game[data-view="solved"] #credit{display:none!important;}
#game[data-view="thinking"] .speech::before,#game[data-view="reveal"] .speech::before{
  content:"";position:absolute;bottom:-5px;left:10px;width:23px;height:3px;
  border-radius:3px;background:#e6bd68;animation:guess-thinking-pulse .8s ease-in-out infinite alternate;
}
@keyframes guess-thinking-pulse{from{opacity:.25;transform:scaleX(.55)}to{opacity:1;transform:scaleX(1)}}
@media(prefers-reduced-motion:reduce){#game .speech::before{animation:none!important;}}

/* A victory is a single, atomic visible state: never fade its speech from zero. */
#game[data-view="solved"] .speech.pop{animation:none;opacity:1;transform:none;}

/* Anchor the existing carved sign to the center of the actual inner wall
   panel, rather than its left molding. The background is 110% wide and
   centered: its inner panel maps to approximately 60.4–66.4% of the stage.
   A separate shadow wrapper follows the complete carved silhouette; do
   not cut through the gold frame or introduce a second wooden rectangle. */
.room-logo-mount{display:contents;}
@media(min-aspect-ratio:4/5){
  #game .room-logo-mount{
    display:block;position:absolute;left:63.5%;top:min(8.4vw,15%);width:5.9%;
    transform:translateX(-50%);z-index:0;line-height:0;
    filter:drop-shadow(1px 2px 1.5px #190a05b0);
  }
  #game .room-logo{
    position:relative;display:block;inset:auto;width:100%;height:auto;max-width:none;max-height:none;
    margin:0;padding:0;background:none;border:0;box-shadow:none;border-radius:0;
    transform:skewY(-3deg);transform-origin:center;
    filter:brightness(.96) saturate(.94);
    clip-path:none;
  }
}
@media(min-aspect-ratio:4/5) and (max-height:450px){
  #game .room-logo-mount{top:min(5.8vw,13%);}
}
/* One warm ivory silhouette: the curved tail overlaps the bubble body,
   and one drop-shadow follows both rather than outlining a separate triangle. */
#game .speech{
  box-shadow:none;filter:drop-shadow(0 3px 5px #10070035);
  background:#fffcf7;overflow:visible;
}
#game .speech::after,#game .speech.has-badge::after{
  background:#fffcf7;border:0;margin:0;top:auto;right:auto;
  left:calc(-1 * var(--speech-tail,30px) + 7px);
  width:var(--speech-tail,30px);height:23px;bottom:4px;
  clip-path:polygon(100% 0,100% 82%,82% 78%,62% 80%,39% 86%,0 100%,22% 74%,47% 48%,68% 26%,80% 0);
}
@media(max-aspect-ratio:4/5){
  #game .speech::after,#game .speech.has-badge::after{height:14px;bottom:4px;left:calc(-1 * var(--speech-tail,12px) + 4px);}
}

/* Owner-approved desktop dialogue: shorter tail, close to the mouth,
   warm ivory body, unchanged adaptive question width and number. */
@media(min-aspect-ratio:4/5){
  #game .speech{
    background:#fff2d7;border-radius:24px;padding:8px 12px;
    filter:drop-shadow(0 2px 3px #10070035);
  }
  #game .speech::after,#game .speech.has-badge::after{
    background:#fff2d7;height:19px;bottom:3px;
    left:calc(-1 * var(--speech-tail,24px) + 7px);
  }
}

/* Entire approved desktop scene, including its own integrated wall sign,
   window, detective, cat and ornate table. Only rasterized mock controls
   were removed. All live controls remain independent HTML. */
.approved-desktop-art{display:none;}
@media(min-aspect-ratio:4/5){
  #game .stage-wrap{--edge:66.3%;--actor-bottom:33.7%;}
  #game .approved-desktop-art{display:block;position:absolute;inset:0;width:100%;height:100%;object-fit:fill;z-index:0;pointer-events:none;}
  #game .room-art{visibility:hidden;}
  #game .stage-wrap:not(.desktop-art-ready) :is(#ask-panel,#categories,#hud,#back,#stage){visibility:hidden;}
  #game #answers,#game #categories{top:79%;bottom:10%;width:min(79%,1050px);}
  #game .stage-wrap:has(#back:not([hidden])) #answers{width:min(85%,1050px);}
  #game .speech{border-radius:24px;background:#fff2d7;}
  #game .speech::after,#game .speech.has-badge::after{background:#fff2d7;}
  #game[data-view="solved"] #hud{top:76%;bottom:10%;}
}
@media(min-aspect-ratio:4/5) and (max-height:450px){
  #game #answers,#game #categories{top:77%;bottom:5%;}
}
