:root {
  color-scheme: dark;
  font-family: "Helvetica Neue", Arial, sans-serif;
  background: #1B1512;
  color: #F1E6CF;
  -webkit-tap-highlight-color: transparent;
  /* Play Lab system controls in a motel room at night: dark wood, cream type, amber focus. */
  --pl-font: "Helvetica Neue", Arial, sans-serif;
  --pl-topbar-bg: #1B1512;
  --pl-topbar-text: #F1E6CF;
  --pl-control-text: #F1E6CF;
  --pl-control-bg: #251C17;
  --pl-control-border: #5C4231;
  --pl-focus: #F4B740;
  --pl-overlay: rgb(10 8 6 / .84);
  --pl-card-bg: #251C17;
  --pl-card-text: #F1E6CF;
  --pl-card-muted: #D9CCB4;
  --pl-card-border: #5C4231;
  --pl-primary: #F4B740;
  --pl-primary-text: #15100D;
  --pl-shadow: rgb(0 0 0 / .4);
  --pl-share-bg: #251C17;
  --pl-radius-control: 3px;
  --pl-radius-card: 4px;
  --pl-radius-picture: 3px;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
body { min-width: 320px; background: #1B1512; }
button, a { font: inherit; }

button {
  min-height: 44px;
  border: 1px solid #5C4231;
  border-radius: 3px;
  padding: 9px 14px;
  color: #F1E6CF;
  background: #251C17;
  cursor: pointer;
  touch-action: manipulation;
}
button:focus-visible, a:focus-visible, canvas:focus-visible { outline: 3px solid #F4B740; outline-offset: 3px; }
button:disabled { cursor: default; }

[data-pl="topbar"] { box-shadow: 0 1px 0 #5C4231; }
[data-pl="back"] { font-weight: 800; }
[data-pl="howto-card"] h2 { font-family: "Arial Narrow", "Roboto Condensed", Arial, sans-serif; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: #FFD3DF; text-shadow: 0 0 6px #FF5C8A; }
[data-pl="howto-pictures"] { gap: 6px; }
[data-pl="howto-pictures"] canvas { width: calc((100% - 12px) / 3); min-width: 80px; min-height: 80px; }
[data-pl="howto-lines"] { font-weight: 600; }

.shell {
  width: min(100%, 430px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: calc(60px + env(safe-area-inset-top)) 8px calc(4px + env(safe-area-inset-bottom));
}

/* Two fixed lines: the next step can be long, and the board must not move when it changes. */
.instruction {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 42px;
  margin: 0 4px 4px;
  overflow: hidden;
  font-size: 15px;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
}

/* A room's new rule: a neon "New" tag, and a tap on the line plays its loop again. */
.instruction.has-new { display: block; padding-top: 1px; cursor: pointer; }
.new-tag { display: inline-block; margin-right: 4px; padding: 0 6px; border: 1.5px solid #FF5C8A; border-radius: 3px; color: #FFD3DF; font: 700 12px/17px "Arial Narrow", "Roboto Condensed", Arial, sans-serif; letter-spacing: .06em; text-transform: uppercase; text-shadow: 0 0 5px #FF5C8A; vertical-align: 1px; }

.board-shell {
  position: relative;
  width: min(100%, calc((100svh - 210px) * 360 / 600));
  margin: 0 auto;
  overflow: hidden;
  border: 1px solid #5C4231;
  background: #1B1512;
}
#board, #stay-board { display: block; width: 100%; height: auto; aspect-ratio: 360 / 600; touch-action: none; user-select: none; -webkit-user-select: none; }

.status-row { min-height: 50px; padding: 6px 4px 0; }
.message { margin: 0; font-size: 15px; line-height: 1.35; text-align: center; }
/* The HUD on the board shows the counts; this copy is for screen readers. */
.move-count { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.controls { display: flex; justify-content: center; gap: 9px; padding: 2px 0 0; }
.controls[hidden] { display: none; }
.controls button { min-width: 120px; font-weight: 700; }
/* Chapter 2: the voice switch sits beside Reset level, so choosing a voice never moves the board. */
.voice { display: inline-flex; border: 1px solid #5C4231; border-radius: 6px; overflow: hidden; }
.voice[hidden] { display: none; }
.controls .voice button { min-width: 0; min-height: 44px; height: 44px; padding: 0 12px; white-space: nowrap; line-height: 1; border: 0; border-radius: 0; display: inline-flex; align-items: center; gap: 6px; background: #251C17; color: #F1E6CF; }
.controls .voice button + button { border-left: 1px solid #5C4231; }
.controls .voice button[aria-pressed="true"] { background: #F4B740; color: #15100D; }
.voice svg { width: 18px; height: 18px; fill: currentColor; stroke: currentColor; stroke-width: 1.6; stroke-linejoin: round; }
.voice button.pulse { animation: voice-pulse 1.1s ease-in-out infinite; }
@keyframes voice-pulse { 50% { box-shadow: inset 0 0 0 3px #FF5C8A; } }
.reduced-motion .voice button.pulse { animation: none; box-shadow: inset 0 0 0 3px #FF5C8A; }
@media (max-width: 340px) { .controls .voice button { padding: 0 8px; } .controls button { min-width: 96px; white-space: nowrap; padding-left: 10px; padding-right: 10px; } .controls { gap: 6px; } }

.primary-button { color: #15100D; background: #F4B740; border-color: #F4B740; font-weight: 800; }
.primary-button:active { transform: translateY(1px); }

.result-card {
  position: absolute;
  right: 8px;
  bottom: 8px;
  left: 8px;
  z-index: 4;
  padding: 12px 10px 10px;
  border: 1px solid #5C4231;
  border-top: 4px solid #C23B3B;
  border-radius: 4px;
  background: #251C17;
  text-align: center;
}
.result-title { margin: 2px 0 0; font-family: "Arial Narrow", "Roboto Condensed", Arial, sans-serif; font-size: 24px; font-weight: 700; letter-spacing: .02em; }
.result-marks { margin: 4px 0 10px; font-size: 15px; font-weight: 700; }
.result-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px; }
.result-actions button { padding: 8px 9px; font-size: 14px; font-weight: 700; white-space: nowrap; }

/* The level list is the motel key board: one plastic diamond key per room. */
.map-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 4px 4px; }
.map-heading h1 { margin: 0; font-family: "Arial Narrow", "Roboto Condensed", Arial, sans-serif; font-size: 30px; letter-spacing: .04em; text-transform: uppercase; color: #FFD3DF; text-shadow: 0 0 8px #FF5C8A; }
.map-deck { margin: 4px 4px 12px; color: #D9CCB4; font-size: 15px; line-height: 1.35; }
.level-map { margin-top: 8px; }
.level-tile { display: flex; align-items: center; gap: 14px; width: 100%; min-height: 56px; padding: 8px 6px; border: 0; border-bottom: 1px solid #5C4231; border-radius: 0; background: transparent; text-align: left; }
.tile-names { display: flex; flex: 1; flex-direction: column; gap: 2px; }
.level-tile strong { font-size: 18px; font-weight: 700; }
.tile-meta { color: #D9CCB4; font-size: 14px; }
.level-tile.future .tile-meta { color: #9A8C7C; }
.tile-stars { font-size: 15px; letter-spacing: 2px; color: #F4B740; }
.key-tag {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 34px;
  height: 46px;
  clip-path: polygon(50% 0, 100% 52%, 50% 100%, 0 52%);
  color: #F1E6CF;
  background: #C23B3B;
  font-size: 15px;
  font-weight: 700;
}
.key-tag::before { content: ""; position: absolute; left: 50%; top: 7px; width: 5px; height: 5px; margin-left: -2.5px; border-radius: 50%; background: #1B1512; }
.level-tile.future .key-tag { background: #5C4231; color: #B9AB96; }
.level-tile.future strong { color: #B9AB96; }
/* Today: a tiny calendar page on the tag instead of a number. */
.key-tag.calendar .cal { position: relative; display: block; width: 15px; height: 14px; border: 1.5px solid #F1E6CF; border-top-width: 4px; border-radius: 1px; }
.key-tag.calendar .cal::before, .key-tag.calendar .cal::after { content: ""; position: absolute; top: -7px; width: 1.5px; height: 5px; background: #F1E6CF; }
.key-tag.calendar .cal::before { left: 2px; }
.key-tag.calendar .cal::after { right: 2px; }
/* Locked rooms: a small keyhole after the grey name. */
.keyhole { position: relative; width: 12px; height: 18px; margin-right: 6px; }
.keyhole::before { content: ""; position: absolute; top: 0; left: 1px; width: 10px; height: 10px; border-radius: 50%; background: #B9AB96; }
.keyhole::after { content: ""; position: absolute; top: 7px; left: 3px; border: 3px solid transparent; border-bottom: 10px solid #B9AB96; border-top: 0; width: 0; }
.map-credit { margin: 16px 4px 0; color: #D9CCB4; font-size: 14px; line-height: 1.45; }
.level-tile[data-daily="true"] strong { font-style: italic; }

/* The shared level cabinet keeps its standard groups and grid. These colors make it a
   motel's backlit key board without replacing the component's structure or behavior. */
.plc-cabinet { gap: 14px; }
.plc-cabinet__group { border-color: #5C4231; border-radius: 5px; background: #251C17; box-shadow: 0 9px 22px rgb(0 0 0 / .3); }
.plc-cabinet__head { padding: 11px 12px; color: #F1E6CF; background: #3a271e; font-family: "Arial Narrow", "Roboto Condensed", Arial, sans-serif; font-size: 15px; letter-spacing: .055em; text-transform: uppercase; }
.plc-cabinet__head span:last-child { color: #F4B740; font-family: "Helvetica Neue", Arial, sans-serif; font-size: 11px; letter-spacing: .02em; text-transform: none; }
.plc-cabinet__grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; padding: 9px; }
.plc-cabinet .level-tile { display: grid; grid-template-rows: 28px minmax(26px, 1fr) 13px; align-items: center; justify-items: center; gap: 2px; min-width: 0; min-height: 88px; padding: 5px 3px 4px; border: 1px solid #5C4231; border-radius: 3px; color: #F1E6CF; background: #30221c; text-align: center; box-shadow: inset 0 0 0 1px rgb(255 255 255 / .025); }
.plc-cabinet .level-tile:hover, .plc-cabinet .level-tile:focus-visible { border-color: #F4B740; background: #38271e; }
.plc-cabinet .level-tile.complete { border-color: #927038; }
.plc-cabinet .key-tag { width: 24px; height: 28px; color: #F1E6CF; font-size: 12px; }
.plc-cabinet .key-tag::before { top: 5px; width: 4px; height: 4px; margin-left: -2px; }
.plc-cabinet .key-tag.calendar .cal { width: 13px; height: 12px; }
.cabinet-key-name { display: -webkit-box; overflow: hidden; max-width: 100%; color: #F1E6CF; font-size: 11px; font-weight: 700; line-height: 1.08; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.plc-cabinet .tile-stars { min-height: 12px; color: #F4B740; font-size: 10px; line-height: 1; letter-spacing: 0; }
.plc-cabinet .plc-cabinet__preview { min-height: 128px; padding: 8px; border-top: 1px solid #5C4231; color: #D9CCB4; background: #201813; }
.plc-cabinet .plc-cabinet__preview::after { content: "Later"; border-color: #B9AB96; border-radius: 3px; color: #D9CCB4; background: #251C17; }
html[lang="zh-Hant"] .plc-cabinet .plc-cabinet__preview::after { content: "之後"; }
.plc-cabinet__preview canvas { width: 100%; height: auto; border: 1px solid #5C4231; border-radius: 3px; }

.success-effect { position: absolute; inset: 0; z-index: 3; overflow: hidden; pointer-events: none; }
.success-effect i { position: absolute; top: 40%; left: 50%; width: 9px; height: 9px; border-radius: 2px; opacity: 0; background: #F4B740; }
.success-effect.on i { animation: confetti .72s ease-out both; }
.success-effect i:nth-child(2) { background: #FF5C8A; animation-delay: .05s; }
.success-effect i:nth-child(3) { background: #F4B740; animation-delay: .1s; }
.success-effect i:nth-child(4) { background: #FF5C8A; animation-delay: .02s; }
.success-effect i:nth-child(5) { background: #F4B740; animation-delay: .12s; }
@keyframes confetti { 0% { transform: translate(0, 0) rotate(0); opacity: 1; } 100% { transform: translate(var(--x, 0), var(--y, 0)) rotate(240deg); opacity: 0; } }
.success-effect i:nth-child(1) { --x: -112px; --y: -105px; }.success-effect i:nth-child(2) { --x: 106px; --y: -96px; }.success-effect i:nth-child(3) { --x: 130px; --y: 92px; }.success-effect i:nth-child(4) { --x: -126px; --y: 78px; }.success-effect i:nth-child(5) { --x: 8px; --y: -145px; }

.load-error { margin: 54px 8px; padding: 18px; border: 1px solid #5C4231; background: #251C17; color: #F1E6CF; line-height: 1.4; }
.reduced-motion *, .reduced-motion *::before, .reduced-motion *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; } }
/* How to play in words on phones; the question mark only below 360 px (the kit's cut is 430 px). */
@media (min-width: 360px) and (max-width: 430px) {
  .pl-howto-word { display: inline; }
  .pl-howto-question { display: none; }
  /* The three right-hand controls must fit the right half of the bar: tighter padding, and
     How to play may break onto two short lines. */
  .pl-topbar__actions button { padding: 4px; }
  .pl-topbar__actions [data-pl="howto"] { max-width: 66px; font-size: 12px; line-height: 1.1; white-space: normal; text-align: center; }
}
@media (max-width: 359px) {
  [data-pl="howto-card"] { padding: 14px; }
  .plc-cabinet__grid { gap: 6px; padding: 7px; }
  .plc-cabinet .level-tile { min-height: 82px; }
  .cabinet-key-name { font-size: 10px; }
}

/* Chapters still being built: a drawn glimpse under the rooms (house rule 16). */
.chapter-soon, .chapter-head { display: grid; gap: 4px; padding: 14px 6px 10px; border-bottom: 1px solid #5C4231; }
.chapter-soon canvas, .chapter-head canvas { width: 100%; height: auto; border: 1.5px solid #5C4231; border-radius: 4px; }
.chapter-soon strong, .chapter-head strong { font-size: 18px; font-weight: 700; color: #F1E6CF; }
.chapter-soon .tile-meta, .chapter-head .tile-meta { color: #B9AB96; }
.chapter-head { border-bottom: 0; border-top: 1px solid #5C4231; margin-top: 8px; }

/* House rule 22: the game's own mark and name top left; it opens the key cabinet. */
[data-pl="back"].pl-brand { display: inline-flex; align-items: center; gap: 8px; padding: 6px 8px 6px 2px; font-weight: 800; letter-spacing: .02em; color: #FFD3DF; text-decoration: none; }
.pl-brand__mark { width: 30px; height: 30px; flex: none; }
.pl-brand__title { text-shadow: 0 0 6px rgba(255, 92, 138, .55); white-space: nowrap; }
@media (max-width: 359px) { [data-pl="back"].pl-brand { gap: 6px; font-size: 13px; } .pl-brand__title { white-space: normal; max-width: 64px; line-height: 1.05; } }
.map-credit .lab-credit { display: inline-block; margin-top: 10px; padding: 12px 0; color: #F1E6CF; }

/* Phones: the board takes the full width so a cell stays over 40 css px; a short screen scrolls below the board
   (the counts and Reset), and the board itself never scrolls, pans or zooms. */
@media (max-width: 480px) { .board-shell { width: 100%; } }

/* The long stay: its menu entry and its screen reuse the board, instruction and controls above. */
.stay-entry { margin: 14px 0 0; border: 1px solid #5C4231; border-radius: 5px; background: #251C17; box-shadow: 0 9px 22px rgb(0 0 0 / .3); overflow: hidden; }
.stay-entry__head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 11px 12px; background: #3a271e; color: #F1E6CF; font-family: "Arial Narrow", "Roboto Condensed", Arial, sans-serif; font-size: 15px; letter-spacing: .04em; text-transform: uppercase; }
.stay-entry__head span:last-child { color: #F4B740; font-family: "Helvetica Neue", Arial, sans-serif; font-size: 11px; letter-spacing: .02em; text-transform: none; text-align: right; }
.stay-entry__body { padding: 10px 12px 12px; }
.stay-entry__body canvas { display: block; width: 100%; height: auto; border: 1px solid #5C4231; border-radius: 3px; background: #1B1512; }
.stay-entry__body p { margin: 8px 0 0; color: #D9CCB4; font-size: 14px; line-height: 1.35; }
.stay-entry__body .stay-entry__best { color: #F4B740; font-weight: 700; }
.stay-entry__buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.stay-entry__buttons button { min-height: 44px; padding: 8px 14px; font-weight: 700; }
/* The decision buttons sit on the board (the band under the card), so a short phone never has to scroll to reach them. */
.stay-controls { position: absolute; left: 3.3%; right: 3.3%; top: calc(446 / 600 * 100%); height: calc(52 / 600 * 100%); z-index: 2; display: flex; gap: 8px; }
.stay-controls[hidden] { display: none; }
.stay-controls button { flex: 1 1 0; min-width: 0; min-height: 44px; height: 100%; padding: 0 6px; font-size: 15px; font-weight: 800; white-space: nowrap; }
.stay-controls button.two-line { display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1; }
.stay-controls button.two-line small { display: block; font-size: 11px; font-weight: 600; opacity: .85; margin-top: 2px; }
.stay-controls button:disabled { background: #2B1F19; color: #8C7F6F; border-color: #4A3426; opacity: 1; }
.stay-status { min-height: 0; padding: 0; }
#stay-screen .result-card { z-index: 5; }

.hotel-facade { display: block; width: 100%; height: auto; aspect-ratio: 640 / 150; border-bottom: 1px solid #5C4231; background: #0F1320; }

/* One screen (P1FS09, taste/ONE_SCREEN.md): room name and counts, the goal, then the board in the room that is left,
   then one row of controls. Sizes from taste/ACCESSIBLE_PLAY.md (level text 22, zh 24; HUD numbers 24; labels 18). */
.room-head { display: flex; flex-direction: column; margin: 0 2px; }
.room-title { margin: 0; font-size: 22px; line-height: 1.45; font-weight: 400; color: #F1E6CF; }
:lang(zh-Hant) .room-title { font-size: 24px; line-height: 1.6; }
.hud-row { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 14px; margin: 0; font-size: 18px; line-height: 1.45; color: #D9CCB4; }
.hud-row[hidden] { display: none; }
.hud-item b { font-size: 24px; color: #F1E6CF; font-variant-numeric: tabular-nums; }
.hud-item.teach { padding: 0 6px; border-radius: 4px; box-shadow: inset 0 0 0 2px #F4B740; animation: hud-teach 1.4s ease-in-out infinite; }
@keyframes hud-teach { 50% { box-shadow: inset 0 0 0 2px rgba(244, 183, 64, .25); } }
#play-screen.fit .instruction { display: block; height: auto; min-height: 0; margin: 0 0 6px; padding: 0 2px; font-size: 22px; font-weight: 400; line-height: 1.45; text-align: left; overflow: visible; color: #F1E6CF; }
:lang(zh-Hant) #play-screen.fit .instruction { font-size: 24px; line-height: 1.6; }
#play-screen.fit .new-tag { font-size: 18px; line-height: 24px; vertical-align: 2px; }
#play-screen.fit { display: flex; flex-direction: column; min-height: calc(100svh - 64px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); }
#play-screen.fit .board-room { flex: 1 1 0; display: flex; justify-content: center; align-items: flex-start; }
#play-screen.fit .board-shell { flex: none; margin: 0; }
#play-screen.fit .status-row { min-height: 0; padding: 4px 4px 2px; }
#play-screen.fit .message:empty { display: none; }
#play-screen.fit .controls { padding: 4px 0 2px; }

/* More: the rare controls (Reset level) one tap away. */
.more { position: relative; }
.more-menu { position: absolute; right: 0; bottom: calc(100% + 6px); z-index: 6; display: grid; gap: 6px; min-width: 180px; padding: 8px; border: 1px solid #5C4231; border-radius: 6px; background: #251C17; box-shadow: 0 8px 20px rgb(0 0 0 / .45); }
.more-menu[hidden] { display: none; }
.more-menu button { width: 100%; white-space: nowrap; }

/* The result is a sheet pinned to the bottom of the screen, Next first and full width, wherever the page is scrolled
   (play-template kit 18 pattern). */
#play-screen .result-card { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; width: min(100%, 430px); max-height: 62dvh; margin: 0 auto; overflow-y: auto; overscroll-behavior: contain; padding: 14px 14px calc(14px + env(safe-area-inset-bottom)); border-radius: 12px 12px 0 0; border-top: 4px solid #F4B740; text-align: left; box-shadow: 0 -10px 30px rgb(0 0 0 / .5); }
#play-screen .result-title { font-size: 28px; line-height: 1.3; }
#play-screen .result-marks { margin: 4px 0 12px; font-size: 20px; line-height: 1.45; }
#play-screen .result-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
#play-screen .result-actions button { min-height: 48px; font-size: 20px; white-space: normal; }
#play-screen .result-actions button:not([hidden]):first-child, #play-screen .result-actions .primary-button:not([hidden]) { grid-column: 1 / -1; }
#play-screen .result-actions button[hidden] { display: none; }
#play-screen .result-actions button[hidden] + button { grid-column: 1 / -1; }
#play-screen.fit.is-result .status-row { display: none; }
/* the said line sits under the board; spare height goes above the controls, which stay in the thumb zone */
#play-screen.fit .controls { margin-top: auto; }
/* the goal slot keeps two lines, so the board stays put from room to room (test/v2_stable.mjs) */
#play-screen.fit .instruction { min-height: 2.9em; }
:lang(zh-Hant) #play-screen.fit .instruction { min-height: 3.2em; }
