/* "$ play" — the ASCII treasure hunt */
.play {
  container-type: inline-size;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 920px;
  color: var(--text);
  font: 13px/1.5 var(--mono);
  border: 1px solid var(--border);
  padding: 10px 12px;
  background: var(--surface);
}
.play:focus-visible { outline: 2px solid var(--shell); outline-offset: 2px; }
.play:not(:focus-within) .play-head::after {
  content: "click to play";
  color: var(--muted);
  margin-left: auto;
}
.play-head { display: flex; gap: 12px; justify-content: space-between; flex-wrap: wrap; }
.play-count { color: var(--muted); }
.play-main { display: grid; gap: 10px; justify-items: center; }
.play-mapbox { position: relative; min-width: 0; width: 100%; }
.play-map {
  display: block;
  width: 100%;
  height: auto;
  max-height: var(--play-map-max, none);
  object-fit: contain;
  object-position: center top;
  aspect-ratio: var(--play-aspect, 672 / 420);
  background: color-mix(in srgb, var(--surface) 60%, var(--page));
}

/* inventory: a row of game slots under the map, in the site's own colours */
.play-hotbar {
  list-style: none; margin: 0; padding: 5px;
  display: flex; gap: 5px;
  background: var(--abyss);
  border: 1px solid var(--border);
  border-radius: 4px;
}
.play-hotbar li {
  position: relative;
  width: 46px; height: 46px;
  display: grid; place-items: center;
  background: var(--night);
  border: 1px solid var(--ink-accent);
  border-radius: 3px;
  box-shadow: inset 0 2px 0 rgb(0 0 0 / .25);
}
.play-hotbar li.has { border-color: color-mix(in srgb, var(--gold) 55%, var(--ink-accent)); }
.play-hotbar .n { position: absolute; left: 4px; top: 1px; font-size: 10px; line-height: 1; color: var(--muted); }
.play-hotbar img { width: 32px; height: 32px; }
.play-hotbar li.new { animation: slot-pop .5s ease-out; }
@keyframes slot-pop { 0% { transform: scale(1); } 35% { transform: scale(1.18); border-color: var(--gold); box-shadow: 0 0 12px rgb(226 169 63 / .45); } 100% { transform: scale(1); } }
.play-hotbar .tip {
  position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  background: var(--night); border: 1px solid var(--border); color: var(--text);
  font-size: 11px; padding: 2px 8px; white-space: nowrap; pointer-events: none;
  opacity: 0; transition: opacity .1s; z-index: 2;
}
.play-hotbar li:hover .tip { opacity: 1; }

/* messages: a treasure is gold */
.play-log { min-height: 1.6em; font-size: 14px; text-align: center; }
.play-log .old { color: var(--muted); }
.play-log .t { color: var(--gold); }
.play-foot { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: center; color: var(--muted); }
.play-legend .t { color: var(--treasure); }
.play-legend .d { color: var(--door); }
.play-legend .you img { width: 14px; height: 14px; vertical-align: -2px; }
.play-keys b { color: var(--text); font-weight: 400; }
.play-map.cam { object-position: center; }

/* touch keys: the keyboard keys the game uses, as on-screen keycaps (touchscreens only) */
.play-pad { display: none; align-items: flex-end; gap: 14px; padding: 4px 2px 2px; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; }
.play-pad .arrows { display: grid; grid-template: 52px 52px / repeat(3, 56px); gap: 4px; flex: none; }
.play-pad .key {
  display: grid; place-items: center; padding: 0;
  background: var(--raised); color: var(--text);
  border: 1px solid var(--border); border-radius: 2px;
  font: 17px/1 var(--mono); cursor: pointer;
}
.play-pad .key.pressed { background: var(--shell); border-color: var(--shell); color: #fff; }
.play-pad .space { flex: 1; height: 52px; font-size: 14px; }
.play-pad .up { grid-area: 1 / 2; }
.play-pad .lt { grid-area: 2 / 1; }
.play-pad .dn { grid-area: 2 / 2; }
.play-pad .rt { grid-area: 2 / 3; }
@media (pointer: coarse) {
  .play-pad { display: flex; }
  .play-foot { display: none; }                    /* the keys are on screen; the window's × quits */
  .play:not(:focus-within) .play-head::after { content: none; }
}

/* dialog, like a game script */
.play-dialog {
  position: absolute; left: 10px; right: 10px; bottom: 10px;
  display: flex; gap: 16px; align-items: center;
  background: var(--surface);
  border: 2px solid var(--shell);
  padding: 12px 14px 20px;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--surface) 70%, transparent);
  cursor: pointer;
}
.play-dialog[hidden] { display: none; }
.pd-portrait { flex: none; width: 72px; display: grid; place-items: center; }
.pd-portrait[hidden] { display: none; }
.pd-portrait img { width: 72px; height: auto; }
.play-dialog[data-who="item"] .pd-portrait img, .play-dialog[data-who="empty"] .pd-portrait img { width: 60px; }
.play-dialog[data-who="mommy"] .pd-portrait img { width: 72px; filter: saturate(.85) brightness(.9); }
.pd-body { flex: 1; min-width: 0; }
.pd-who { color: var(--accent-text); font-weight: 700; min-height: 1lh; font-size: 15px; }
.play-dialog[data-who="narrator"] .pd-who::before { content: ""; }
.play-dialog[data-who="note"] .pd-text { font-style: italic; }
.pd-text { margin: 2px 0 4px; min-height: 2lh; white-space: pre-wrap; font-size: 17px; line-height: 1.45; }
/* "You found …!" */
.play-dialog[data-who="item"] .pd-text { color: var(--gold); }
.play-dialog[data-who="item"] .pd-text, .play-dialog[data-who="empty"] .pd-text { min-height: 0; margin: 4px 0; }
.pd-who:empty { display: none; }
.pd-next { position: absolute; right: 12px; bottom: 6px; font-size: 12px; animation: pd-blink 1s steps(1) infinite; }
@keyframes pd-blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .pd-next { animation: none; } }

@container (max-width: 520px) {
  .play-hotbar li { width: 38px; height: 38px; }
  .play-hotbar img { width: 28px; height: 28px; }
  .pd-text { font-size: 15px; }
}
