:root {
  color-scheme: light;
  background: #f6efe4;
  color: #302746;
  font: 550 16px/1.4 "DM Sans", system-ui, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; }
#game { width: min(100%, 490px); margin: auto; padding: 19px 14px; }
h1 {
  margin: 0;
  font: 500 clamp(38px, 10vw, 55px)/1 "DM Serif Text", Georgia, serif;
  letter-spacing: -.055em;
}
header p { margin: 5px 0 9px; color: #5e526e; }
button, select { font: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:focus-visible, select:focus-visible { outline: 3px solid #7043a0; outline-offset: 3px; }
button:disabled { cursor: default; }
.room-progress {
  display: flex; justify-content: space-between; align-items: baseline;
  flex-wrap: wrap; gap: 2px 8px; color: #654b6c; font-size: .83rem;
}
.room-progress strong { color: #302746; }
#room-hint { margin: 3px 0 8px; color: #5e526e; font-size: .82rem; }
.room { aspect-ratio: 1.12; position: relative; isolation: isolate; overflow: hidden; border-radius: 21px; border: 1px solid #b89d92; background: #e7ae88; }
.wall {
  position: absolute; inset: 0 0 39%; overflow: hidden;
  border-bottom: 7px solid #b9846d;
  background: repeating-linear-gradient(90deg, #f5d9c0 0 25px, #f1d1ba 25px 28px);
}
.room::before {
  content: ""; position: absolute; inset: 62% 0 0; z-index: -1;
  background: repeating-linear-gradient(#dc9e7b 0 2px, transparent 2px 27px);
}
.door-frame { position: absolute; left: 8%; width: 30%; top: 15%; bottom: -9px; border: 6px solid #a16a5f; border-radius: 48% 48% 0 0 / 30% 30% 0 0; background: #c68d78; }
.door-frame::before { content: ""; position: absolute; inset: 11% 14%; border: 2px solid #aa7064; border-radius: 45% 45% 3px 3px / 22% 22% 3px 3px; }
.door-frame i { position: absolute; top: 59%; right: 10%; width: 9px; height: 9px; border-radius: 50%; background: #ffe4a1; }
.window-frame { position: absolute; left: 62%; top: 11%; width: 27%; height: 61%; overflow: hidden; border: 5px solid #bb826c; border-radius: 42% 42% 5px 5px / 28% 28% 5px 5px; background: #a5ccc6; box-shadow: 0 4px #cf9a7e; }
.window-frame::before { content: ""; position: absolute; inset: 45% -14% -15%; background: #76a58f; border-radius: 65% 87% 0 0; transform: rotate(-12deg); }
.window-frame::after { content: ""; position: absolute; top: 0; bottom: 0; left: 48%; width: 5px; background: #bb826c; }
.window-frame i { position: absolute; right: 17%; top: 19%; width: 20%; aspect-ratio: 1; border-radius: 50%; background: #ffe391; }
.light { position: absolute; left: 53%; top: 60%; width: 49%; height: 45%; background: #ffe9ad48; clip-path: polygon(25% 0,63% 0,100% 100%,0 100%); }
.rug { position: absolute; left: 11%; right: 11%; bottom: 8%; height: 29%; border-radius: 50%; background: #ce94a8; border: 4px double #ffd5c8; }
.spot {
  --spot-x: 24%;
  --spot-y: 77%;
  position: absolute; left: var(--spot-x); top: var(--spot-y); transform: translate(-50%, -50%);
  width: 38%; height: 23%; min-height: 48px; z-index: 1; padding: 0; touch-action: manipulation;
  border-radius: 13px; border: 2px dashed #5b4369; background: #ffebda9c;
}
.room[data-spot-count="3"] .spot { width: 27%; }
.spot:disabled { border: 1px solid #7656809c; background: #fff2da40; }
.spot[data-box] { border-color: transparent; background: transparent; }
.spot-label {
  position: absolute; left: 50%; bottom: -8px; transform: translateX(-50%);
  width: max-content; max-width: calc(100% + 12px); padding: 2px 7px;
  font-size: 12px; line-height: 1.12; color: #492e53; background: #fff2da; border-radius: 8px;
  overflow-wrap: anywhere;
}
.spot-label span { display: block; margin-top: 2px; font-size: .85em; }
.carton { display: none; position: absolute; left: 50%; bottom: 7px; transform: translateX(-50%); height: 52%; background: linear-gradient(90deg, #e0a677 0 44%, #edc499 44% 56%, #d19167 56%); border: 2px solid #805143; border-top: 5px solid #f6ce9f; border-radius: 5px; }
.spot[data-box] .carton { display: block; width: 77%; }
.spot[data-box="medium"] .carton { width: 65%; height: 48%; }
.spot[data-box="small"] .carton { width: 51%; height: 41%; }
.cat {
  --size: 52px; --fur: #c95746; --shade: #9d3d3c; --belly: #ffe2ba;
  position: absolute; z-index: 2; left: var(--x); top: var(--y); width: var(--size); height: var(--size);
  transform: translate(-50%, -50%); pointer-events: none;
  transition: left .28s ease-out, top .28s ease-out;
}
.cat.mochi { --size: 65px; --fur: #6475a0; --shade: #4c587f; --belly: #dfebef; }
.cat.bean { --size: 58px; --fur: #668b73; --shade: #426553; --belly: #f3efd2; }
.cat .body { position: absolute; inset: 48% 11% 1%; background: var(--fur); border: 2px solid var(--shade); border-radius: 50% 50% 38% 38%; }
.cat .tail { position: absolute; right: -7%; bottom: 5%; width: 32%; height: 31%; border: 7px solid var(--shade); border-left: 0; border-top: 0; border-radius: 0 0 70% 0; transform: rotate(-22deg); }
.cat .face { position: absolute; inset: 20% 13% 28%; background: var(--fur); border: 2px solid var(--shade); border-radius: 43%; }
.cat .face::before, .cat .face::after { content: ""; position: absolute; top: -32%; width: 42%; height: 58%; background: var(--shade); clip-path: polygon(9% 0,100% 100%,0 100%); }
.cat .face::before { left: -5%; }
.cat .face::after { right: -5%; transform: scaleX(-1); }
.cat .face b { position: absolute; left: 24%; top: 38%; height: 4px; width: 4px; background: #302746; border-radius: 50%; box-shadow: calc(var(--size) * .27) 0 #302746; }
.cat .face em { position: absolute; bottom: 11%; left: 34%; width: 34%; height: 27%; border-radius: 50%; background: var(--belly); }
.cat .face em::after { content: ""; position: absolute; width: 4px; height: 3px; border-radius: 50%; left: 50%; transform: translateX(-50%); background: #b46476; }
.cat span { position: absolute; top: 103%; left: 50%; transform: translateX(-50%); padding: 1px 5px; background: #fff4dc; color: #49334f; border-radius: 7px; font-size: 11px; white-space: nowrap; }
.cat[data-seated] span { display: none; }
.cat:not([data-seated]) { z-index: 3; }
.cat[data-waiting] span { background: #584376; color: white; }
.tray, .actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tray { margin-top: 11px; }
.tray[data-box-count="3"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.actions { grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); grid-template-columns: none; }
.tray button, .actions button, .wait-control select {
  min-height: 46px; border: 1px solid #b79aa7; border-radius: 12px;
  background: #fffcf5; padding: 4px 5px; overflow-wrap: anywhere;
}
.tray button { font-size: .92rem; }
.tray button { touch-action: none; user-select: none; }
.tray button[aria-pressed="true"] { background: #f6cfdd; border-color: #a45678; box-shadow: inset 0 0 0 1px #a45678; }
.tray button:disabled, .actions button:disabled { opacity: .49; }
.icon { display: inline-block; width: 20px; height: 14px; margin-right: 7px; border-radius: 2px; border: 1px solid #9b5c49; background: #cf926b; vertical-align: -.06em; }
#medium .icon { width: 17px; height: 12px; }
#small .icon { width: 15px; height: 11px; }
.wait-control {
  display: grid; grid-template-columns: 1fr minmax(0, 48%); align-items: center;
  gap: 3px 7px; margin: 8px 0 4px; font-size: .88rem;
}
.wait-control select { min-width: 0; padding-inline: 8px; }
.wait-control select:disabled { opacity: .64; }
#wait-status { grid-column: 1 / -1; font-size: .79rem; color: #62536b; }
#feedback { display: grid; gap: 2px; margin: 7px 2px 8px; min-height: 45px; }
#detail { font-size: 14px; color: #62536b; }
#game[data-phase="loss"] #notice { color: #923642; }
#game[data-phase="win"] #notice { color: #276246; }
#next, [data-phase="loss"] #restart { background: #584376; color: white; border-color: #584376; }
@media (max-width: 370px) {
  .tray button { font-size: .78rem; }
  .icon { margin-right: 3px; }
}
@media (max-height: 800px) {
  .room { max-height: 38dvh; }
  #game { padding-top: 9px; }
}
@media (max-height: 615px) {
  #game { padding-top: 7px; }
  .room { max-height: 32dvh; }
  h1 { font-size: clamp(29px, 9.6vw, 42px); }
  header p { margin-bottom: 6px; font-size: .89rem; }
  #room-hint { margin-bottom: 6px; }
  .tray { margin-top: 8px; }
  .wait-control { margin-top: 6px; }
  #feedback { min-height: 42px; margin-block: 5px 7px; }
  #detail { font-size: .81rem; }
  .cat { --size: 43px; }
  .cat.mochi { --size: 55px; }
  .cat.bean { --size: 48px; }
}
@media (prefers-reduced-motion: reduce) { .cat { transition: none; } }
