/* Hallmark · scope: app · genre: playful · theme: cabin system (locked) · redesign: polish · v2.0.0 */
/* Hallmark · Critique: the full room leads; warm highlights belong to ready actions. */
@font-face {
  font-family: CabinPixel;
  src: url('assets/fonts/cabin-pixel.woff2') format('woff2');
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --font-cabin: CabinPixel, 'Microsoft YaHei', sans-serif;
  --night: #131f1b;
  --night-edge: #0d1715;
  --fir-deep: #20342a;
  --fir: #2c4937;
  --fir-light: #3d5e45;
  --fir-pressed: #456748;
  --brass: #e9bf7e;
  --brass-light: #ffe0a8;
  --brass-pressed: #d9ac69;
  --brass-muted: #927249;
  --wood-edge: #432f22;
  --wood: #795736;
  --paper: #f5e6c7;
  --paper-light: #fff3d8;
  --paper-shade: #e4cca2;
  --paper-hover: #f1ddb4;
  --cream: #fff1cd;
  --cream-muted: #d4bf98;
  --ink: #3d291b;
  --ink-muted: #6c4c32;
  --rule: #b99462;
  --focus-light: #ffe3a6;
  --focus-dark: #244b37;
  --shade: #0a1511a8;
  --shade-clear: #09120f15;
  --soft-highlight: #ffe3a638;
  --soft-ink: #412a2429;
  --board: #bd9765;
  --bead-center: #40372f55;
  --edge: clamp(16px, 2.4vi, 32px);
  --key: 48px;
  --dialog-gap: 24px;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  font-family: var(--font-cabin);
  font-size: 16px;
  font-weight: 400;
  font-synthesis: none;
  color: var(--cream);
}

* { box-sizing: border-box; }
html, body { overflow-x: clip; }
body { margin: 0; background: var(--night); }
[hidden] { display: none !important; }
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: default; }
button:focus-visible, a:focus-visible {
  outline: 2px solid var(--focus-light);
  outline-offset: 4px;
}
button:active:not(:disabled) { transform: translateY(1px); }
h1, h2 { margin: 0; font-weight: 400; text-wrap: balance; overflow-wrap: break-word; min-width: 0; }
::selection { background: var(--brass); color: var(--ink); }
.icon { display: block; width: 24px; height: 24px; flex-shrink: 0; fill: currentColor; shape-rendering: crispEdges; }

#app {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: clip;
  background: var(--night);
}
.playfield { position: absolute; inset: 0; }
.room {
  position: absolute;
  inset: 50% auto auto 50%;
  width: min(100%, 150vh);
  width: min(100%, 150dvh);
  aspect-ratio: 3 / 2;
  transform: translate(-50%, -50%);
  background: url('assets/cabin.webp') center / contain no-repeat;
}
#scene { display: block; width: 100%; height: 100%; image-rendering: pixelated; }
#scene:focus-visible { outline: 2px solid var(--focus-light); outline-offset: -2px; }
#door-guide {
  position: absolute;
  inset: auto auto max(4px, 2%) 50%;
  translate: -50% 0;
  display: flex;
  align-items: center;
  gap: 5px;
  width: max-content;
  padding: 4px 8px;
  border: 1px solid var(--brass-muted);
  background: var(--fir-deep);
  color: var(--cream);
  font-size: 14px;
  line-height: 1.25;
  pointer-events: none;
}
#door-guide .icon { width: 16px; height: 16px; color: var(--brass); }
#kitchen-signs {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* A single title at the foot of the room leaves the windows and fireplace visible. */
.entry {
  position: absolute;
  inset: 0;
  display: grid;
  justify-items: center;
  align-items: end;
  padding: 16px 16px max(24px, 6.5dvh, env(safe-area-inset-bottom));
  background: linear-gradient(180deg, var(--shade-clear) 34%, var(--shade) 100%);
}
.welcome {
  width: min(100%, 488px);
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 24px 24px 16px;
  border: 2px solid var(--brass-muted);
  background: var(--fir-deep);
  box-shadow: inset 0 0 0 4px var(--night-edge), 0 8px 24px var(--shade);
  text-align: center;
  animation: arrival 240ms var(--ease-out) both;
}
.welcome h1 { color: var(--cream); font-size: 40px; line-height: 1.24; }
.welcome p { margin: 0; line-height: 1.5; }
.welcome .signature { color: var(--cream-muted); }
.welcome .primary { margin-block: 4px; min-width: 184px; }
#load-status { color: var(--cream-muted); }
#load-status:empty { display: none; }
noscript { color: var(--cream-muted); }
@keyframes arrival { from { opacity: .45; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* The same pressed edge and focused outline travel from menu to game. */
.primary, .paper-button, .hud button, .dpad button, .interact, #sprint, .modal-actions button, .portrait-note button {
  border: 2px solid var(--control-edge, var(--wood-edge));
  border-radius: 0;
  background: var(--control-fill, var(--fir));
  color: var(--control-ink, var(--cream));
  box-shadow: inset 0 2px var(--soft-highlight), inset 0 -2px var(--soft-ink);
}
@media (hover: hover) and (pointer: fine) {
  :is(.primary, .paper-button, .hud button, .dpad button, .interact, #sprint, .modal-actions button, .portrait-note button):hover:not(:disabled) {
    background: var(--control-hover, var(--fir-light));
  }
}
:is(.primary, .paper-button, .hud button, .dpad button, .interact, #sprint, .modal-actions button, .portrait-note button):active:not(:disabled) {
  background: var(--control-pressed, var(--fir-pressed));
  box-shadow: inset 0 2px var(--soft-ink);
}
.primary, .paper-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 16px;
  line-height: 1.25;
  text-wrap: balance;
}
.primary, .interact:not(:disabled), #sprint[aria-pressed="true"], #hang-beads:not(:disabled), .gift-wrap .paper-button {
  --control-edge: var(--brass-muted);
  --control-fill: var(--brass);
  --control-hover: var(--brass-light);
  --control-pressed: var(--brass-pressed);
  --control-ink: var(--ink);
}
.primary:disabled { --control-fill: var(--paper-shade); opacity: .78; }
.paper-button.secondary, .album-nav .paper-button {
  --control-fill: var(--paper-light);
  --control-hover: var(--paper-hover);
  --control-pressed: var(--paper-shade);
  --control-edge: var(--rule);
  --control-ink: var(--ink);
}
.paper-button .icon { width: 20px; height: 20px; }

.hud {
  position: absolute;
  inset: max(var(--edge), env(safe-area-inset-top))
         max(var(--edge), env(safe-area-inset-right)) auto max(var(--edge), env(safe-area-inset-left));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  pointer-events: none;
}
.room-name {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--brass-muted);
  background: var(--fir-deep);
  line-height: 1.25;
}
.room-name > span:first-child { color: var(--brass); }
.room-name .icon { width: 20px; height: 20px; }
.hud-actions { display: flex; align-items: center; gap: 8px; pointer-events: auto; }
.hud button {
  --control-edge: var(--brass-muted);
  --control-fill: var(--fir-deep);
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  min-width: 44px;
  min-height: 44px;
  padding: 8px;
}
.hud #music { padding-inline: 12px; }
.hud #music[aria-pressed="true"] .music-symbol { color: var(--brass); }
.dpad {
  position: absolute;
  left: max(var(--edge), env(safe-area-inset-left));
  bottom: max(var(--edge), env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: repeat(3, var(--key));
  grid-template-rows: repeat(3, var(--key));
  gap: 4px;
  touch-action: none;
  user-select: none;
}
.dpad button {
  --control-edge: var(--brass-muted);
  --control-fill: var(--fir-deep);
  padding: 0;
  display: grid;
  place-items: center;
  touch-action: none;
  color: var(--cream);
}
.dpad button.held {
  background: var(--brass);
  color: var(--ink);
  transform: translateY(1px);
  box-shadow: inset 0 2px var(--soft-ink);
}
.dpad button[data-dir="up"] { grid-area: 1 / 2; }
.dpad button[data-dir="left"] { grid-area: 2 / 1; }
.dpad button[data-dir="right"] { grid-area: 2 / 3; }
.dpad button[data-dir="down"] { grid-area: 3 / 2; }
.movement-actions {
  position: absolute;
  right: max(var(--edge), env(safe-area-inset-right));
  bottom: max(var(--edge), env(safe-area-inset-bottom));
  display: grid;
  justify-items: end;
  gap: 6px;
}
.interact {
  min-block-size: 56px;
  inline-size: 144px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px;
  line-height: 1.25;
  text-wrap: balance;
}
.interact:disabled {
  --control-fill: var(--fir-deep);
  --control-edge: var(--brass-muted);
  --control-ink: var(--cream-muted);
}
#sprint {
  display: none;
  min-height: 44px;
  min-width: 88px;
  padding: 4px 8px;
  align-items: center;
  justify-content: center;
  gap: 6px;
  touch-action: manipulation;
  --control-edge: var(--brass-muted);
}
#sprint .icon { width: 18px; height: 18px; }
@media (any-pointer: coarse) {
  #sprint { display: flex; }
}
.portrait-note, .toast {
  position: absolute;
  left: 50%;
  translate: -50% 0;
  max-inline-size: calc(100% - 32px);
  inline-size: max-content;
  border: 1px solid var(--brass-muted);
  background: var(--fir-deep);
  color: var(--cream);
  line-height: 1.45;
}
.portrait-note { top: max(76px, calc(env(safe-area-inset-top) + 56px)); display: flex; align-items: center; gap: 8px; padding: 4px 4px 4px 12px; }
.portrait-note > span:first-child { color: var(--brass); }
.portrait-note button {
  display: grid;
  place-items: center;
  min-inline-size: 44px;
  min-block-size: 44px;
  padding: 0;
  --control-edge: transparent;
}
.toast {
  bottom: max(var(--edge), env(safe-area-inset-bottom));
  max-inline-size: calc(100% - 368px);
  padding: 8px 16px;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  z-index: 5;
}
.toast.visible { opacity: 1; }

#app[data-scene="kitchen"] {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
}
#app[data-scene="kitchen"] .hud {
  grid-row: 1;
  position: relative;
  inset: auto;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 8px;
  padding: max(8px, env(safe-area-inset-top)) max(var(--edge), env(safe-area-inset-right)) 6px max(var(--edge), env(safe-area-inset-left));
}
#app[data-scene="kitchen"] .room-name { justify-self: start; white-space: nowrap; }
#app[data-scene="kitchen"] .hud-actions { justify-self: end; }
#app[data-scene="kitchen"] .playfield { grid-row: 3; position: relative; container-type: size; }
#app[data-scene="kitchen"] .room { top: 50%; width: min(100%, 150cqh); }
#app[data-scene="kitchen"] #controls { position: absolute; inset: 0; pointer-events: none; }
#app[data-scene="kitchen"] :is(.dpad, .movement-actions) { pointer-events: auto; }
#app[data-scene="kitchen"] .portrait-note {
  grid-row: 2;
  position: relative;
  inset: auto;
  translate: none;
  justify-self: center;
  margin-block-end: 4px;
}
#kitchen-orders { display: flex; align-items: center; justify-content: center; gap: 8px; }
#kitchen-summary {
  display: grid;
  gap: 2px;
  padding-inline: 8px;
  border-inline-start: 1px solid var(--brass-muted);
  color: var(--cream-muted);
  font-size: 14px;
  white-space: nowrap;
}
#kitchen-clock { color: var(--brass); font-variant-numeric: tabular-nums; }
#kitchen-tickets {
  display: flex;
  gap: 6px;
  padding: 0;
  margin: 0;
  list-style: none;
}
.kitchen-task {
  min-width: 106px;
  display: grid;
  gap: 2px;
  padding: 4px 8px;
  border: 1px solid var(--brass-muted);
  background: var(--fir-deep);
  line-height: 1.25;
}
.kitchen-task .task-name { color: var(--cream); }
.kitchen-task .task-step { font-size: 14px; color: var(--cream-muted); }
.kitchen-task.done .task-step { color: var(--brass-light); }
@media (max-width: 720px) and (orientation: landscape) {
  #app[data-scene="kitchen"] .room-name > span:first-child,
  #app[data-scene="kitchen"] .music-title { display: none; }
  #app[data-scene="kitchen"] .room-name { padding-inline: 7px; }
  #app[data-scene="kitchen"] .hud #music { padding-inline: 8px; }
  #kitchen-orders { flex-direction: column; gap: 4px; }
  #kitchen-summary { display: flex; gap: 8px; border: 0; }
  .kitchen-task { padding-inline: 6px; }
}
@media (orientation: portrait) {
  #app[data-scene="kitchen"] { padding-block-end: max(clamp(106px, 28dvh, 172px), calc(env(safe-area-inset-bottom) + 106px)); }
  #app[data-scene="kitchen"] .hud { grid-template-columns: 1fr auto; }
  #app[data-scene="kitchen"] .hud-actions { grid-column: 2; grid-row: 1; }
  #kitchen-orders { grid-column: 1 / -1; grid-row: 2; flex-wrap: wrap; gap: 4px; }
  #kitchen-summary { width: 100%; display: flex; justify-content: center; gap: 8px; border: 0; }
}

/* A fir header anchors every window; the activity itself owns the paper below. */
dialog {
  color-scheme: light;
  width: min(680px, calc(100% - 2 * var(--dialog-gap)));
  max-height: calc(100dvh - 2 * var(--dialog-gap));
  padding: 0;
  border: 4px solid var(--wood);
  border-radius: 0;
  overflow: clip;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 12px 36px var(--shade);
}
dialog::backdrop { background: var(--shade); }
.dialog-frame {
  display: flex;
  flex-direction: column;
  max-height: calc(100dvh - 2 * var(--dialog-gap) - 8px);
  min-height: 0;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 0 0 auto;
  gap: 12px;
  min-height: 64px;
  padding: 8px 16px 8px 24px;
  background: var(--fir-deep);
  color: var(--cream);
  border-bottom: 2px solid var(--brass-muted);
}
.modal-heading { display: flex; align-items: center; gap: 12px; min-width: 0; }
.modal-header h2 { font-size: 24px; line-height: 1.3; }
#modal-symbol { color: var(--brass); }
.modal-actions { display: flex; flex: none; gap: 8px; }
.modal-actions button { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; --control-edge: var(--brass-muted); }
#reading-music[aria-pressed="true"] { color: var(--brass); }
#modal-content {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 24px;
  scrollbar-width: thin;
  scrollbar-color: var(--wood) var(--paper-shade);
}
#modal-content p { margin: 0 0 16px; line-height: 1.8; }
#modal-content :is(button, a):focus-visible { outline-color: var(--focus-dark); }
.actions { display: flex; flex-wrap: wrap; align-items: start; gap: 8px; margin-top: 16px; }
.actions.kitchen-decoration { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kitchen-decoration button:has(canvas) { flex-direction: column; padding-inline: 2px; }
.kitchen-decoration button:last-child { grid-column: 1 / -1; justify-self: start; }
.kitchen-cookie-sample { width: 60px; height: 42px; image-rendering: pixelated; }
.help-copy { max-width: 54ch; }
.help-copy kbd {
  display: inline-block;
  font: inherit;
  min-width: 24px;
  padding-inline: 4px;
  border: 1px solid var(--rule);
  background: var(--paper-light);
  text-align: center;
}

.album-page {
  max-width: 480px;
  margin-inline: auto;
  padding: 4px;
  background: var(--fir-deep);
  border: 1px solid var(--wood);
}
.album-photo {
  display: block;
  width: 100%;
  height: min(51dvh, 472px);
  object-fit: contain;
}
.album-nav { display: flex; justify-content: center; align-items: center; gap: 16px; margin-top: 16px; }
.album-nav > span { min-width: 64px; color: var(--ink-muted); font-variant-numeric: tabular-nums; text-align: center; }
.album-nav .paper-button { width: 44px; height: 44px; padding: 0; }
.album-nav .paper-button span { position: absolute; clip-path: inset(50%); width: 1px; height: 1px; overflow: clip; white-space: nowrap; }
.letter {
  max-width: 34em;
  margin-inline: auto;
  padding: clamp(16px, 4vi, 32px);
  border: 1px solid var(--rule);
  background: var(--paper-light);
  transform-origin: center top;
  animation: letter-unfold 240ms var(--ease-out) both;
}
@keyframes letter-unfold {
  from { opacity: 0; transform: translateY(12px) scale(.97); }
  to { opacity: 1; transform: none; }
}
#modal-content .letter p { margin-bottom: 16px; line-height: 1.9; }
#modal-content .letter p:first-child { font-size: 24px; }
#modal-content .letter .sign { text-align: right; color: var(--ink-muted); border-top: 1px solid var(--rule); padding-top: 12px; margin: 24px 0 0; }
.postcard-art {
  width: 100%;
  max-height: 48dvh;
  object-fit: contain;
  display: block;
  padding: 4px;
  background: var(--fir-deep);
  color: var(--cream);
  image-rendering: pixelated;
}
.postcard-note { margin-top: 16px; line-height: 1.8; }
#modal-content .postcard-name { margin: 8px 0 0; color: var(--ink-muted); text-align: right; }

dialog[data-kind="beads"] { width: min(772px, calc(100% - 2 * var(--dialog-gap))); }
.beads-workbench { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 212px); gap: 20px; align-items: start; }
.bead-grid {
  display: grid;
  grid-template-columns: repeat(16, minmax(0, 1fr));
  gap: 2px;
  padding: 8px;
  border: 2px solid var(--wood);
  background: var(--board);
  touch-action: none;
  aspect-ratio: 1;
}
.bead-grid button {
  padding: 0;
  border: 0;
  min-width: 0;
  min-height: 0;
  border-radius: 50%;
  position: relative;
  touch-action: none;
  box-shadow: inset 0 1px var(--soft-highlight), inset 0 -1px var(--soft-ink);
}
.bead-grid button:after { content: ''; position: absolute; inset: 34%; border-radius: 50%; background: var(--bead-center); }
.bead-grid button:focus-visible { outline-offset: 0; z-index: 1; }
.beads-tools { display: grid; align-content: start; gap: 12px; }
.bead-reference {
  width: 104px;
  max-width: 100%;
  border: 2px solid var(--rule);
  padding: 4px;
  background: var(--paper-light);
  image-rendering: pixelated;
}
.palette { display: grid; grid-template-columns: repeat(auto-fit, 44px); gap: 8px; }
.palette button { position: relative; width: 44px; height: 44px; border: 2px solid var(--wood); padding: 0; }
.palette button:first-child { background-image: linear-gradient(135deg, transparent 47%, var(--rule) 47% 53%, transparent 53%); }
.palette button[aria-pressed="true"] { outline: 2px solid var(--fir); outline-offset: 2px; }
.palette button[aria-pressed="true"]::after {
  content: '';
  position: absolute;
  inset: 12px;
  border: 2px solid var(--fir);
  background: var(--cream);
}
.palette button:focus-visible { outline: 3px solid var(--focus-dark); outline-offset: 3px; }
.beads-tools .actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 0; gap: 8px; }
#hang-beads { grid-column: 1 / -1; }
#hang-beads:disabled { opacity: .55; }
.beads-tools .paper-button { padding-inline: 8px; }
.beads-tools .paper-button .icon { display: none; }
#modal-content .beads-status { margin: 0; color: var(--ink-muted); line-height: 1.5; }
.export-preview { display: block; width: min(100%, 400px); margin: 24px auto 12px; image-rendering: pixelated; border: 4px solid var(--wood); }
.download-link { color: var(--focus-dark); display: grid; place-items: center; width: fit-content; margin: 12px auto 0; min-height: 44px; text-underline-offset: 4px; }

dialog[data-kind="badminton"] {
  --match-gap: max(var(--dialog-gap), env(safe-area-inset-left), env(safe-area-inset-right), env(safe-area-inset-top), env(safe-area-inset-bottom));
  --match-court-width: min(100%, calc((100dvh - 2 * var(--match-gap) - 208px) * 480 / 208));
  width: min(960px, calc(100% - 2 * var(--match-gap)));
  max-height: calc(100dvh - 2 * var(--match-gap));
}
dialog[data-kind="badminton"] .dialog-frame { max-height: calc(100dvh - 2 * var(--match-gap) - 8px); }
dialog[data-kind="badminton"] #modal-content { padding: 8px 16px 10px; }
.match-board, .match-stage, .match-controls { width: var(--match-court-width); margin-inline: auto; }
.match-board {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  color: var(--cream);
  background: var(--fir-deep);
  border: 2px solid var(--wood);
  border-bottom: 0;
}
.match-side {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: clamp(8px, 3vw, 30px);
  padding: 0 10px;
  background: #315044;
}
.match-side:last-child { justify-content: flex-start; background: #6d3b34; }
.match-side strong { min-width: 22px; text-align: center; font: inherit; font-size: 24px; color: #ffe6b2; }
.match-goal { padding: 0 10px; color: var(--cream-muted); font-size: 14px; }
.match-stage { position: relative; border: 2px solid var(--wood); background: #754d3d; }
.match-stage canvas { display: block; width: 100%; height: auto; image-rendering: pixelated; }
.match-stage .match-serve { position: absolute; left: 50%; bottom: 7%; translate: -50% 0; }
.match-overlay {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 8px;
  position: absolute;
  inset: 0;
  background: #202c24dc;
  color: var(--cream);
  text-align: center;
}
.match-overlay-actions { display: flex; gap: 6px; }
#modal-content .match-result { margin: 0; font-size: clamp(16px, 4vw, 24px); line-height: 1.2; }
.match-stage .paper-button:not(.secondary), .match-shots .shot-ready {
  --control-fill: var(--brass);
  --control-hover: var(--brass-light);
  --control-pressed: var(--brass-pressed);
  --control-ink: var(--ink);
}
#modal-content .match-stage button:focus-visible { outline-color: var(--focus-light); }
.match-controls { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-block-start: 6px; width: max(var(--match-court-width), min(100%, 568px)); }
.match-pause-guide, .match-jump-guide { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; white-space: nowrap; }
.match-pause-guide { color: var(--cream-muted); }
.match-jump-guide { color: var(--ink-muted); }
.modal-actions .match-touch-pause { display: none; }
.match-movement, .match-shots { display: flex; gap: 4px; }
.match-controls button { min-width: 44px; min-height: 44px; padding: 0 8px; white-space: nowrap; touch-action: none; user-select: none; }
.match-controls button:disabled { opacity: .72; }
.match-movement button.held { background: var(--brass); color: var(--ink); box-shadow: inset 0 2px var(--soft-ink); }
.match-key { min-width: 20px; padding: 2px 4px; border: 1px solid currentColor; font: inherit; font-size: 14px; line-height: 1; white-space: nowrap; }
#modal-content .match-hint { min-height: 20px; margin: 4px 0 0; color: var(--ink-muted); text-align: center; font-size: 14px; line-height: 1.4; }
.match-hint + [role="status"] { position: absolute; width: 1px; height: 1px; overflow: clip; clip-path: inset(50%); white-space: nowrap; }
@media (max-height: 570px) and (orientation: landscape) {
  dialog[data-kind="badminton"] { --match-court-width: min(100%, calc((100dvh - 2 * var(--match-gap) - 202px) * 480 / 208)); }
  dialog[data-kind="badminton"] #modal-content { padding: 5px 8px 6px; }
}
@media (pointer: coarse) {
  dialog[data-kind="badminton"] {
    --match-touch-move: clamp(46px, 12vw, 52px);
    --match-touch-shot: clamp(52px, 14vw, 58px);
  }
  .match-key, .match-jump-guide, .match-pause-guide { display: none; }
  .modal-actions .match-touch-pause { display: grid; }
  .match-controls button, .match-stage .match-serve {
    inline-size: var(--match-touch-shot);
    block-size: var(--match-touch-shot);
    padding: 0;
    border-radius: 50%;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
  }
  .match-movement button { inline-size: var(--match-touch-move); block-size: var(--match-touch-move); }
  .match-controls { align-items: center; width: max(var(--match-court-width), min(100%, 306px)); }
}
@media (pointer: coarse) and (min-width: 720px) and (max-height: 570px) and (orientation: landscape) {
  dialog[data-kind="badminton"] { --match-court-width: min(100%, calc((100dvh - 2 * var(--match-gap) - 133px) * 480 / 208)); }
  dialog[data-kind="badminton"] #modal-content { display: grid; grid-template-columns: 104px minmax(0, 1fr) 104px; align-items: end; }
  .match-board { grid-area: 1 / 2; }
  .match-stage { grid-area: 2 / 2; }
  .match-controls { display: contents; }
  .match-movement { grid-area: 2 / 1; justify-self: start; --match-touch-move: 48px; }
  .match-shots { grid-area: 2 / 3; justify-self: end; flex-direction: column; --match-touch-shot: clamp(48px, 14dvh, 58px); }
  .match-shots button { font-size: clamp(14px, 4.1dvh, 16px); }
  #modal-content .match-hint { grid-area: 3 / 1 / 4 / -1; }
}
@media (orientation: portrait) {
  dialog[data-kind="badminton"] { --match-court-width: min(100%, 650px); }
  dialog[data-kind="badminton"] #modal-content { padding: 8px 6px; }
}
@media (pointer: fine) and (max-width: 650px) {
  .match-movement .icon { display: none; }
  .match-controls button { padding-inline: 4px; }
}
@media (pointer: fine) and (max-width: 500px) { .match-controls { flex-wrap: wrap; justify-content: center; } }
dialog:is([data-kind="gift"], [data-kind="letter"]) { width: min(600px, calc(100% - 2 * var(--dialog-gap))); }
dialog:is([data-kind="gift"], [data-kind="letter"]) .dialog-frame { height: min(556px, calc(100dvh - 2 * var(--dialog-gap) - 8px)); }
dialog:is([data-kind="gift"], [data-kind="letter"]) #modal-content { flex: 1; }
.gift-wrap { min-height: 100%; display: grid; align-content: center; justify-items: center; gap: 12px; }
.gift-wrap .paper-button { min-inline-size: 152px; }
.gift-box { display: block; width: auto; height: min(42dvh, 216px); max-width: 100%; }
.gift-ribbon, .gift-lid, .gift-envelope { transition: transform var(--gift-motion) steps(6, end); }
.gift-ribbon { transition-property: transform, opacity; }
.gift-envelope {
  opacity: 0;
  transform: translateY(10px);
  transform-origin: 67px 62px;
  transition: transform var(--gift-motion) steps(6, end), opacity 120ms 80ms;
}
.gift-lid { transform-origin: 67px 60px; }
.gift-bow-left, .gift-bow-right { transform-origin: 67px 48px; }
.gift-wrap:not([data-stage="tied"]) .gift-ribbon { opacity: 0; }
.gift-wrap:not([data-stage="tied"]) .gift-bow-left { transform: translate(-19px, 9px) rotate(-16deg); }
.gift-wrap:not([data-stage="tied"]) .gift-bow-right { transform: translate(21px, 10px) rotate(16deg); }
.gift-wrap:not([data-stage="tied"]) .gift-band { transform: translateY(12px); }
.gift-wrap:is([data-stage="open"], [data-stage="taken"]) .gift-lid { transform: translate(-12px, -26px) rotate(-16deg); }
.gift-wrap:is([data-stage="open"], [data-stage="taken"]) .gift-envelope { opacity: 1; transform: none; }
.gift-wrap[data-stage="taken"] .gift-envelope { transform: translateY(-28px) rotate(-6deg); }

@media (max-height: 570px) and (orientation: landscape), (max-width: 640px) and (orientation: portrait) {
  .beads-tools .actions { grid-template-columns: repeat(3, auto); gap: 4px; }
  #hang-beads { grid-column: auto; }
  .beads-tools .paper-button { padding-inline: 2px; }
}

@media (max-height: 570px) and (orientation: landscape) {
  :root { --edge: 12px; --key: 44px; --dialog-gap: 12px; }
  .welcome { width: min(100%, 432px); padding: 16px 24px 12px; gap: 8px; }
  .welcome h1 { font-size: 32px; }
  .entry { padding-block-end: max(12px, env(safe-area-inset-bottom)); }
  .modal-header { min-height: 56px; padding: 4px 12px 4px 16px; }
  #modal-content { padding: 12px 16px 16px; }
  .album-photo { height: min(48dvh, 304px); }
  .album-nav { margin-top: 8px; }
  .postcard-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; align-items: center; }
  .postcard-note { margin-top: 0; }
  .beads-workbench { grid-template-columns: minmax(0, min(55dvh, 320px)) minmax(0, 264px); justify-content: center; gap: 16px; }
  .beads-tools { grid-template-columns: minmax(0, 56px) minmax(0, 200px); gap: 8px; }
  .beads-tools .actions, .beads-status { grid-column: 1 / -1; }
  .bead-reference { align-self: start; }
}

@media (orientation: portrait) {
  :root { --edge: 16px; --key: 44px; --dialog-gap: 12px; }
  .room { width: 100%; top: 43%; }
  .entry { padding-block-end: max(clamp(28px, 10dvh, 96px), env(safe-area-inset-bottom)); }
  .welcome h1 { font-size: 32px; }
  .hud #music { padding-inline: 8px; }
  .music-title { display: none; }
  .movement-actions, .dpad { bottom: max(24px, env(safe-area-inset-bottom)); }
  .toast { bottom: max(176px, calc(env(safe-area-inset-bottom) + 152px)); max-inline-size: calc(100% - 32px); }
  #modal-content { padding: 16px; }
  .modal-header { padding: 8px 12px; }
}
@media (max-width: 640px) and (orientation: portrait) {
  #app { --entry-split: max(50dvh, calc(66.667vi + 12px)); }
  #app:has(.entry:not([hidden])) .room {
    top: var(--entry-split);
    transform: translate(-50%, calc(-100% - 8px));
  }
  .entry { align-items: start; padding-block: calc(var(--entry-split) + 8px) 12px; }
  .beads-workbench { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .beads-tools { grid-template-columns: minmax(0, 64px) minmax(0, 1fr); }
  .beads-tools .actions, .beads-status { grid-column: 1 / -1; }
}
@media (max-width: 360px) and (orientation: portrait) {
  .room-name > span:first-child { display: none; }
  .room-name { padding-inline: 8px; }
  .interact { inline-size: 124px; }
  .modal-header h2 { font-size: 20px; }
  dialog[data-kind="letter"] #modal-symbol { display: none; }
  .beads-tools { grid-template-columns: minmax(0, 44px) minmax(0, 1fr); gap: 8px; }
  .palette { column-gap: 4px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; scroll-behavior: auto !important; }
  .gift-ribbon, .gift-lid, .gift-envelope { transition: none; }
  button:active:not(:disabled), .dpad button.held { transform: none; }
}

