:root {
  color-scheme: light;
  --paper: #f7f0e7;
  --paper-deep: #efe4d8;
  --white: #fffdf9;
  --ink: #392c38;
  --muted: #877985;
  --plum: #684e68;
  --plum-deep: #4f3a52;
  --coral: #d77d72;
  --coral-soft: #f3d8ce;
  --line: #e7d8cf;
  --sage: #dfe7d9;
  --shadow: 0 16px 38px rgb(69 48 61 / 9%);
  --display: var(--font-display, "SPELLLENS", "Onest", sans-serif);
  --body: var(--font-body, "Onest", system-ui, sans-serif);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--paper); }
body { margin: 0; min-width: 320px; min-height: 100vh; color: var(--ink); background: radial-gradient(ellipse at 80% 0%, #fffaf1 0, transparent 36rem), var(--paper); font-family: var(--body); }
button, summary { -webkit-tap-highlight-color: transparent; }
button { color: inherit; font: inherit; }
button:focus-visible, summary:focus-visible, a:focus-visible { outline: 3px solid #b9759c; outline-offset: 3px; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.app-shell { width: min(1440px, 100%); margin: 0 auto; padding: max(18px, env(safe-area-inset-top)) clamp(14px, 2.5vw, 34px) max(16px, env(safe-area-inset-bottom)); }
.skip-link { position: absolute; z-index: 50; top: 8px; left: 8px; padding: 10px 14px; transform: translateY(-150%); border-radius: 12px; color: var(--white); background: var(--plum-deep); }
.skip-link:focus { transform: none; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.brand-lockup { display: flex; align-items: center; gap: 13px; min-width: 0; }
.brand-mark { display: grid; width: 46px; height: 46px; flex: 0 0 46px; place-items: center; border: 1px solid #ddc9bd; border-radius: 15px; color: var(--plum); background: #fffaf3; }
.brand-mark svg { width: 27px; height: 27px; }
.brand-copy { min-width: 0; }
.eyebrow, .section-kicker, .surface-caption { margin: 0; color: #927a8a; font-size: 10px; font-weight: 700; letter-spacing: .12em; line-height: 1.4; }
h1, h2, h3, p { margin-top: 0; }
.brand-copy h1 { margin: 2px 0 0; color: var(--plum-deep); font: 700 clamp(23px, 2.2vw, 30px)/1.05 var(--display); letter-spacing: -.025em; }
.brand-subtitle { margin: 5px 0 0; color: var(--muted); font-size: 13px; line-height: 1.3; }
.top-actions { display: flex; align-items: center; gap: 7px; }
.icon-button, .secondary-button, .quiet-button, .text-button, .primary-button, .close-button { display: inline-flex; align-items: center; justify-content: center; gap: 9px; min-height: 46px; border: 1px solid transparent; border-radius: 14px; cursor: pointer; text-decoration: none; transition: background .18s ease, border-color .18s ease, transform .18s ease, box-shadow .18s ease; }
.icon-button { min-width: 50px; padding: 0 12px; color: var(--plum); border-color: #eadbd1; background: rgb(255 253 249 / 75%); font-size: 12px; font-weight: 600; }
.icon-button:hover, .secondary-button:hover { border-color: #d1b9c9; background: #fff; }
.icon-button[aria-pressed="true"] { border-color: #bea2bb; color: var(--plum-deep); background: #eee3ec; }
.icon-button svg { width: 18px; height: 18px; }
.icon-button b { color: var(--coral); font-size: 11px; }

.game-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 320px); align-items: start; gap: clamp(16px, 2vw, 26px); }
.room-panel { min-width: 0; }
.room-heading { display: flex; align-items: end; justify-content: space-between; gap: 14px; min-height: 55px; padding: 0 5px 12px; }
.section-kicker { color: var(--coral); }
.room-prompt { margin: 4px 0 0; color: var(--ink); font-size: 15px; font-weight: 600; line-height: 1.35; }
.room-hint { max-width: 250px; margin: 0 0 2px; color: var(--muted); font-size: 12px; line-height: 1.45; text-align: right; }
.scene-frame { overflow: hidden; padding: 10px; border: 1px solid #e4d4ca; border-radius: 22px; background: #fffaf4; box-shadow: var(--shadow); }
.scene-wrap { position: relative; overflow: hidden; width: 100%; aspect-ratio: 3 / 2; border-radius: 15px; background: #eaded3; }
#scene { display: block; width: 100%; height: 100%; object-fit: contain; }
.scene-corner { position: absolute; z-index: 1; width: 22px; height: 22px; border-color: rgb(255 250 244 / 78%); border-style: solid; pointer-events: none; }
.scene-corner--tl { top: 9px; left: 9px; border-width: 1px 0 0 1px; border-top-left-radius: 7px; }
.scene-corner--br { right: 9px; bottom: 9px; border-width: 0 1px 1px 0; border-bottom-right-radius: 7px; }
.scene-caption { display: flex; align-items: center; gap: 8px; min-height: 33px; padding: 7px 5px 0; color: #907f87; font-size: 11px; }
.caption-dot { width: 7px; height: 7px; flex: 0 0 7px; border-radius: 50%; background: #96a992; box-shadow: 0 0 0 3px #e7eee3; }
.save-status { margin-left: auto; color: #8c7d88; font-size: 10px; white-space: nowrap; }

.play-dock { display: flex; flex-direction: column; gap: 14px; min-width: 0; padding: 18px; border: 1px solid #e5d7ce; border-radius: 22px; background: rgb(255 251 246 / 88%); box-shadow: 0 10px 30px rgb(69 48 61 / 6%); }
.story-note { display: flex; align-items: center; gap: 11px; padding: 2px 1px 3px; }
.note-mark { display: grid; width: 39px; height: 39px; flex: 0 0 39px; place-items: center; border-radius: 13px; color: var(--coral); background: #f8e7df; }
.note-mark svg { width: 22px; height: 22px; }
.story-note .eyebrow { margin-bottom: 3px; }
.story-note p:last-child { margin: 0; color: #5d4d5a; font-size: 12px; line-height: 1.45; }
.box-card { padding: 14px; border: 1px solid #ead8cf; border-radius: 17px; background: linear-gradient(135deg, #fff9f1, #f8eee7); }
.box-card-top { display: flex; align-items: center; gap: 11px; margin-bottom: 12px; }
.box-number { display: grid; width: 38px; height: 38px; flex: 0 0 38px; place-items: center; border-radius: 12px; color: var(--plum); background: #eae0eb; font-size: 13px; font-weight: 700; }
.box-copy { margin: 3px 0 0; color: #746572; font-size: 12px; line-height: 1.35; }
.primary-button { width: 100%; min-height: 49px; padding: 0 16px; color: #fffaf6; border-color: var(--plum); background: var(--plum); font-size: 13px; font-weight: 600; box-shadow: 0 5px 12px rgb(83 59 83 / 17%); }
.primary-button:hover { transform: translateY(-1px); border-color: var(--plum-deep); background: var(--plum-deep); box-shadow: 0 8px 16px rgb(83 59 83 / 21%); }
.primary-button svg { margin-left: auto; }
.item-actions { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(96px, .85fr); gap: 8px; }
.secondary-button { padding: 0 12px; color: var(--plum); border-color: #dfcfdb; background: #f8f1f7; font-size: 12px; font-weight: 600; }
.secondary-button svg { flex: 0 0 19px; }
kbd { display: inline-grid; width: 22px; height: 22px; margin-left: auto; place-items: center; border: 1px solid #e1d2df; border-radius: 6px; color: #927f90; background: #fffafc; font: 600 10px var(--body); }
.quiet-button { padding: 0 12px; color: #806d7d; border-color: #eadfd7; background: transparent; font-size: 12px; font-weight: 600; }
.quiet-button:hover, .text-button:hover { border-color: #e5c3bc; color: #9b5d5c; background: #fcf0ea; }
.surface-picker { padding: 12px 0 0; border-top: 1px solid #eee2da; }
.surface-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 9px; }
.surface-heading h2 { margin: 0; color: var(--plum-deep); font: 700 16px/1.2 var(--display); }
.surface-caption { color: #a3939e; font-size: 9px; }
.zone-actions { display: flex; flex-wrap: wrap; gap: 7px; min-height: 42px; }
.zone-actions:empty::before { align-self: center; color: #9b8b95; content: "Сначала возьми вещь — подскажем подходящие места."; font-size: 11px; line-height: 1.4; }
.zone-actions button { min-height: 44px; padding: 0 12px; border: 1px solid #e7dad2; border-radius: 12px; color: #685666; background: #fffdf9; cursor: pointer; font-size: 11px; font-weight: 600; }
.zone-actions button[aria-pressed="true"], .zone-actions button.is-selected { border-color: #c69fbc; color: var(--plum-deep); background: #f0e4ef; }
.settings-menu { padding-top: 1px; border-top: 1px solid #eee2da; }
.settings-menu summary { display: flex; align-items: center; gap: 8px; min-height: 42px; color: #826f7d; cursor: pointer; font-size: 12px; font-weight: 600; list-style: none; }
.settings-menu summary::-webkit-details-marker { display: none; }
.settings-menu summary svg { width: 17px; height: 17px; }
.settings-menu[open] summary { color: var(--plum-deep); }
.text-button { min-height: 42px; padding: 0 12px; color: #806d7d; background: transparent; font-size: 12px; }
.page-footer { display: flex; justify-content: space-between; gap: 12px; padding: 14px 5px 0; color: #a08d96; font-size: 10px; }

.modal { width: min(760px, calc(100vw - 28px)); max-width: 760px; max-height: min(88dvh, 900px); overflow: auto; padding: 0; border: 1px solid #e5d5cc; border-radius: 24px; color: var(--ink); background: var(--paper); box-shadow: 0 24px 80px rgb(45 30 45 / 28%); overscroll-behavior: contain; }
.modal::backdrop { background: rgb(44 33 45 / 48%); backdrop-filter: blur(4px); }
.modal-shell { position: relative; min-height: 180px; padding: clamp(20px, 4vw, 34px); }
.modal-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.modal-header h2, .modal-shell--small h2, .modal-shell--ending h2 { margin: 5px 0 6px; color: var(--plum-deep); font: 700 clamp(25px, 4vw, 36px)/1.08 var(--display); }
.modal-intro, .dialog-copy { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
.close-button { width: 46px; min-width: 46px; height: 46px; padding: 0; color: #806c7d; border-color: #e8d9d0; background: #fffaf5; }
.close-button:hover { color: #a6575b; background: #fff; }
.close-button svg { width: 19px; height: 19px; }
.album-summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 21px 0 14px; padding: 13px 15px; border: 1px solid #e8d8cf; border-radius: 15px; background: #fffaf5; }
.album-count { display: flex; align-items: baseline; gap: 8px; color: var(--muted); font-size: 12px; }
.album-count b { color: var(--coral); font: 700 23px/1 var(--display); }
.album-whisper { color: #93818d; font-size: 11px; text-align: right; }
.gift-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 13px; }
.gift-card { position: relative; isolation: isolate; display: flex; min-width: 0; min-height: 188px; flex-direction: column; justify-content: flex-end; overflow: hidden; padding: 21px; border: 1px solid #e2cfc4; border-radius: 18px; background: linear-gradient(145deg, #fffaf1 0%, #f1e3da 100%); box-shadow: 0 8px 20px rgb(74 49 62 / 8%); }
.gift-card::before { position: absolute; z-index: -1; inset: 7px; border: 1px solid rgb(151 105 127 / 29%); border-radius: 13px; background: url("../assets/ui/gift-card-frame.png") center / 100% 100% no-repeat; content: ""; opacity: .75; pointer-events: none; }
.gift-card::after { position: absolute; z-index: -1; top: 17px; right: 17px; width: 30px; height: 30px; border: 1px solid rgb(215 125 114 / 25%); border-radius: 50%; background: rgb(255 253 249 / 62%); content: ""; }
.gift-card h3 { margin: 0 0 7px; color: var(--plum-deep); font: 700 19px/1.15 var(--display); }
.gift-card p { max-width: 31ch; margin: 0; color: #746470; font-size: 12px; line-height: 1.55; }
.gift-card .gift-card-status { margin-bottom: auto; color: var(--coral); font-size: 9px; font-weight: 700; letter-spacing: .11em; text-transform: uppercase; }
.gift-card button { position: relative; z-index: 1; min-height: 44px; margin-top: 12px; border: 1px solid #d8c2d4; border-radius: 12px; color: var(--plum); background: rgb(255 253 249 / 92%); cursor: pointer; font: 600 11px var(--body); }
.empty-note { grid-column: 1 / -1; margin: 0; padding: 28px 18px; border: 1px dashed #d9c8ce; border-radius: 16px; color: #8c7a87; background: #fffaf5; font-size: 13px; line-height: 1.5; text-align: center; }
.card-modal { width: min(610px, calc(100vw - 28px)); background: transparent; border-color: transparent; box-shadow: none; overflow: visible; }
.card-modal::backdrop { background: rgb(44 33 45 / 58%); }
.modal-shell--card { padding: clamp(14px, 4vw, 26px); }
.card-close-form, .ending-close-form { position: absolute; z-index: 3; top: 0; right: 0; }
.memory-card { min-height: min(68dvh, 560px); padding: clamp(38px, 8vw, 70px); border-radius: 21px; background-color: #fff8ed; }
.memory-card::before { inset: 11px; border-radius: 16px; opacity: .93; }
.memory-card h2 { margin: 10px 0; color: var(--plum-deep); font: 700 clamp(27px, 6vw, 42px)/1.06 var(--display); }
.memory-card .card-message { max-width: 38ch; color: #655361; font-size: 15px; line-height: 1.75; }
.memory-card .card-signoff { margin-top: 18px; color: var(--coral); font-size: 12px; font-weight: 600; }
.modal-shell--small { width: min(480px, 100%); margin: auto; padding: 36px; text-align: center; }
.confirm-modal { width: min(480px, calc(100vw - 28px)); }
.dialog-stamp { display: grid; width: 49px; height: 49px; margin: 0 auto 18px; place-items: center; border-radius: 17px; color: var(--coral); background: #f6e4dc; }
.dialog-stamp svg { width: 25px; height: 25px; }
.modal-shell--small .dialog-copy { max-width: 34ch; margin: 0 auto; }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 22px; }
.dialog-actions form { display: flex; }
.ending-modal { width: min(590px, calc(100vw - 28px)); }
.modal-shell--ending { overflow: hidden; min-height: 430px; padding: 52px clamp(25px, 7vw, 66px) 42px; text-align: center; }
.ending-art { position: absolute; z-index: -1; inset: 0; background: radial-gradient(ellipse at 50% 7%, #f6e1dc 0, transparent 50%), linear-gradient(180deg, #fff9f0, #f1e4dd); }
.modal-shell--ending > .eyebrow { margin-top: 40px; }
.modal-shell--ending h2 { margin: 10px 0; font-size: clamp(32px, 7vw, 48px); }
.ending-copy { max-width: 37ch; margin: 0 auto 22px; color: #786a76; font-size: 14px; line-height: 1.65; }
.modal-shell--ending .primary-button { max-width: 270px; margin: 0 auto; }
.loading-overlay { position: fixed; z-index: 20; inset: 0; display: grid; padding: 22px; place-items: center; background: rgb(247 240 231 / 88%); backdrop-filter: blur(8px); }
.loading-overlay[hidden] { display: none; }
.loading-card { width: min(310px, 100%); padding: 27px; border: 1px solid #e3d2c9; border-radius: 20px; background: #fffaf5; box-shadow: var(--shadow); text-align: center; }
.loading-card p:last-of-type { margin: 8px 0 15px; color: #766774; font-size: 13px; }
.loading-mark { display: block; width: 27px; height: 27px; margin: 0 auto 16px; border: 2px solid #e9d8d2; border-top-color: var(--coral); border-radius: 50%; animation: turn 1s linear infinite; }
.loading-line { height: 4px; overflow: hidden; border-radius: 5px; background: #efe5dd; }
.loading-line span { display: block; width: 42%; height: 100%; border-radius: inherit; background: var(--coral); animation: loading-sweep 1.4s ease-in-out infinite alternate; }
.toast { position: fixed; z-index: 30; right: max(16px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom)); max-width: min(360px, calc(100vw - 32px)); padding: 12px 16px; transform: translateY(14px); border: 1px solid #d8c5d4; border-radius: 14px; color: #fffaf7; background: var(--plum-deep); box-shadow: 0 12px 28px rgb(45 30 45 / 20%); font-size: 12px; line-height: 1.45; opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease; }
.toast.is-visible { transform: translateY(0); opacity: 1; }
@keyframes turn { to { transform: rotate(360deg); } }
@keyframes loading-sweep { from { transform: translateX(0); } to { transform: translateX(140%); } }

@media (max-width: 900px) {
  .game-layout { grid-template-columns: minmax(0, 1fr) 286px; gap: 14px; }
  .play-dock { padding: 15px; gap: 12px; }
  .room-heading { align-items: flex-start; flex-direction: column; gap: 5px; }
  .room-hint { max-width: none; text-align: left; }
}
@media (max-width: 720px) {
  .app-shell { padding-right: max(14px, env(safe-area-inset-right)); padding-left: max(14px, env(safe-area-inset-left)); }
  .topbar { align-items: stretch; flex-direction: column; gap: 12px; margin-bottom: 13px; }
  .brand-mark { width: 42px; height: 42px; flex-basis: 42px; border-radius: 14px; }
  .brand-copy h1 { font-size: 26px; }
  .top-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
  .icon-button { width: 100%; padding: 0 8px; }
  .game-layout { grid-template-columns: minmax(0, 1fr); gap: 13px; }
  .room-heading { min-height: auto; padding: 0 3px 9px; }
  .room-prompt { font-size: 14px; }
  .room-hint { font-size: 11px; }
  .scene-frame { padding: 7px; border-radius: 17px; }
  .scene-wrap { border-radius: 12px; }
  .scene-caption { min-height: 30px; gap: 7px; padding-top: 6px; font-size: 10px; }
  .save-status { font-size: 9px; }
  .play-dock { display: grid; grid-template-columns: minmax(0, 1fr); gap: 11px; padding: 14px; border-radius: 18px; }
  .story-note { display: none; }
  .box-card { padding: 11px; }
  .box-card-top { margin-bottom: 9px; }
  .item-actions { grid-template-columns: minmax(0, 1.15fr) minmax(95px, .85fr); }
  .surface-picker { padding-top: 10px; }
  .zone-actions { gap: 6px; }
  .zone-actions button { flex: 1 1 auto; }
  .settings-menu { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
  .settings-menu summary { flex: 0 0 auto; }
  .settings-menu[open] .text-button { margin-top: 1px; }
  .page-footer { padding-top: 11px; font-size: 9px; }
  .gift-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .gift-card { min-height: 164px; padding: 16px; }
  .modal { max-height: calc(100dvh - max(20px, env(safe-area-inset-top)) - max(20px, env(safe-area-inset-bottom))); border-radius: 19px; }
  .modal-shell { padding: 21px; }
  .album-summary { align-items: flex-start; flex-direction: column; gap: 5px; margin-top: 16px; padding: 11px 13px; }
  .album-whisper { text-align: left; }
  .modal-shell--small { padding: 29px 22px; }
  .modal-shell--ending { min-height: 390px; padding: 49px 23px 29px; }
}
@media (max-width: 420px) {
  .app-shell { padding-top: max(12px, env(safe-area-inset-top)); padding-right: max(12px, env(safe-area-inset-right)); padding-left: max(12px, env(safe-area-inset-left)); }
  .topbar { gap: 10px; }
  .brand-lockup { gap: 10px; }
  .brand-copy h1 { font-size: 24px; }
  .brand-subtitle { margin-top: 3px; font-size: 12px; }
  .icon-button { min-height: 46px; gap: 6px; font-size: 11px; }
  .icon-button svg { width: 17px; height: 17px; }
  .room-heading { gap: 4px; }
  .section-kicker { font-size: 9px; }
  .scene-frame { padding: 5px; }
  .scene-caption { gap: 6px; font-size: 9px; }
  .caption-dot { width: 6px; height: 6px; flex-basis: 6px; }
  .save-status { font-size: 8px; }
  .play-dock { padding: 11px; }
  .box-card { padding: 10px; }
  .box-card-top { gap: 8px; }
  .box-number { width: 34px; height: 34px; flex-basis: 34px; }
  .item-actions { gap: 6px; }
  .secondary-button, .quiet-button { gap: 6px; padding: 0 8px; font-size: 11px; }
  kbd { width: 20px; height: 20px; }
  .surface-heading h2 { font-size: 15px; }
  .page-footer span:first-child { max-width: 25ch; }
  .gift-grid { gap: 8px; }
  .gift-card { min-height: 156px; padding: 14px; }
  .gift-card h3 { font-size: 17px; }
  .gift-card p { font-size: 11px; }
  .memory-card { padding: 38px 27px; }
  .dialog-actions { flex-direction: column; }
  .dialog-actions form, .dialog-actions button { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* Controls and artwork added by game integration. */
button:disabled{cursor:default;opacity:.45;transform:none!important;box-shadow:none!important}
#scene{touch-action:none;image-rendering:pixelated;cursor:default}
.scene-zoom{position:absolute;right:10px;bottom:10px;min-height:44px;padding:0 12px;border:1px solid #ead5c2;border-radius:12px;background:#fff3dfeb;color:#554050;font:600 11px var(--body);cursor:pointer;z-index:2}
.cell-controls{width:100%;display:flex;gap:5px;flex-wrap:wrap;margin-top:6px}
.cell-controls button{font-size:18px;min-width:38px;flex:1;min-height:44px;padding:0 8px}
.cell-controls .place-button{font-size:12px;flex:2;min-width:90px;color:#fff;background:var(--plum)}
.cell-status{width:100%;font-size:10px;line-height:1.5;color:var(--muted);margin:2px 0 0}
.gift-icon{display:block;width:72px;height:72px;object-fit:contain;align-self:center;margin:8px auto 15px;image-rendering:pixelated}
.gift-card{justify-content:flex-start;min-height:240px;padding:26px 23px}
.gift-card-status{position:relative;z-index:1}
.gift-card button{margin-top:auto}
.gift-card::before{opacity:.4}
.memory-card{min-height:550px;padding:115px 60px 90px;justify-content:center}
.memory-card::before{opacity:.95;inset:0}
.memory-card .card-message,.memory-card h2,.memory-card .card-signoff,.card-actions,.move-item,.open-envelope{position:relative;z-index:1}
.card-actions{display:flex;gap:8px;flex-wrap:wrap;margin-top:20px}
.card-actions button{padding:0 12px;margin-top:0;flex:1}
.card-actions button[aria-pressed=true]{background:var(--plum);color:white}
.memory-card .move-item{margin-top:14px;background:#fff9edcc;color:var(--muted);font-size:11px}
.card-modal{overflow:auto}
.toast{max-width:min(420px,calc(100vw - 32px))}
@media(max-width:720px){.scene-zoom{right:6px;bottom:6px;min-height:40px;font-size:10px}.scene-caption>span:nth-child(2){display:none}.save-status{margin-left:0}.memory-card{min-height:500px;padding:98px 34px 90px}.memory-card h2{font-size:30px}.memory-card .card-message{font-size:14px;line-height:1.6}.gift-card:not(.memory-card){padding:22px 16px}.play-dock{position:relative}.room-hint{line-height:1.4}}

/* Keep decorative ribbon outside the readable copy surface. */
.memory-card{padding:110px 50px 95px}
.memory-card::after{inset:94px 32px 70px;width:auto;height:auto;border-radius:12px;background:#fff8e8;border:1px solid #edd7ba;box-shadow:0 3px 12px #a37b3620;z-index:-1}
.memory-card h2{font-size:32px;line-height:1.12}
@media(max-width:720px){.memory-card{padding:90px 30px 85px}.memory-card::after{inset:76px 18px 65px}.memory-card h2{font-size:27px}.memory-card .card-message{font-size:13px;line-height:1.65}}

/* Selecting a real object precedes reading its letter and placing it. */
.box-contents{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;margin:16px 0}
.box-contents[hidden]{display:none}
.box-item{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:8px;min-height:114px;padding:12px 7px;border:1px solid #e4d0c8;border-radius:13px;background:#fffbf4;color:var(--plum);font:600 11px/1.4 var(--body);cursor:pointer}
.box-item:hover{background:#f6ecef;border-color:#b98ea9}
.box-item img{width:58px;height:58px;object-fit:contain;image-rendering:pixelated}
.item-story-modal{width:min(570px,calc(100vw - 24px));max-height:calc(100dvh - 24px);overflow:auto;background:#fff9f0}
.item-story-paper{position:relative;padding:32px clamp(24px,6vw,48px);background:radial-gradient(ellipse at 50% 0,#f7e1dc,transparent 60%)}
.story-close{position:absolute;top:12px;right:12px;font:26px/1 var(--body)}
.item-story-paper>.eyebrow{padding-right:40px;line-height:1.5}
.story-image{display:block;width:96px;height:96px;object-fit:contain;image-rendering:pixelated;margin:20px auto 22px}
.item-story-paper h2{margin:0 0 18px;color:var(--plum-deep);font:700 clamp(28px,6vw,38px)/1.12 var(--display)}
.story-text{margin:0;color:#665460;font:400 16px/1.75 var(--body)}
.story-sign{margin:20px 0;color:var(--coral);font:600 14px var(--body)}
.story-actions{display:flex;flex-direction:column;align-items:stretch;gap:10px;margin-top:25px}
.story-actions .text-button{min-height:44px;text-align:center}
.gift-card .read-story{margin-top:12px;margin-bottom:8px;color:var(--muted);background:#fffaf4}
@media(max-width:720px){.item-story-paper{padding:28px 24px}.story-image{width:72px;height:72px;margin:16px auto}.story-text{font-size:15px;line-height:1.65}.story-actions{margin-top:18px}}

#story-back[hidden]{display:none}

/* Phone controls keep the room visible and use native surface selection. */
body.modal-is-open{overflow:hidden}
.held-item{display:flex;align-items:center;gap:12px;padding:10px 12px;border-radius:14px;background:#f5eaf1;color:var(--plum-deep)}
.held-item[hidden]{display:none}
.held-item img{width:48px;height:48px;object-fit:contain;image-rendering:pixelated}
.held-item strong{font-size:13px}.held-item p{margin:4px 0 0;color:var(--muted);font-size:11px;line-height:1.4}
.surface-select{display:none}
.scene-view-controls{position:absolute;right:8px;bottom:8px;z-index:2;display:flex;gap:5px}
.scene-view-controls button{min-width:44px;min-height:44px;padding:0 10px;border:1px solid #d9bfc9;border-radius:12px;background:#fff9edf2;color:var(--plum-deep);font:700 22px/1 var(--body);cursor:pointer}
.scene-view-controls #zoom-reset{font-size:11px;font-weight:600}.scene-view-controls #zoom-reset[hidden]{display:none}
.story-letter-header{display:flex;align-items:center;justify-content:space-between;gap:14px;position:sticky;top:0;z-index:3;background:#fff7ef}
.story-letter-header .eyebrow{margin:0;line-height:1.5}.story-letter-header .story-close{position:static;flex-shrink:0}
.item-story-modal{max-height:calc(100vh - 32px);max-height:calc(100dvh - max(16px,env(safe-area-inset-top)) - max(16px,env(safe-area-inset-bottom)))}
@media(max-width:720px){
 .app-shell{padding-top:max(8px,env(safe-area-inset-top));padding-bottom:max(12px,env(safe-area-inset-bottom))}
 .topbar{flex-direction:row;align-items:center;gap:8px;margin-bottom:8px}.brand-lockup{gap:7px}.brand-mark{width:32px;height:32px;flex-basis:32px;border-radius:11px}.brand-mark svg{width:23px;height:23px}
 .brand-copy>.eyebrow,.brand-subtitle{display:none}.brand-copy h1{font-size:22px;white-space:nowrap}
 .top-actions{display:flex;gap:4px;flex-shrink:0}.icon-button{width:auto;min-width:44px;min-height:44px;padding:0 8px;gap:4px}.top-actions .icon-button>span{font-size:0}.top-actions .icon-button b{font-size:11px}
 .game-layout{gap:10px}.room-panel{position:sticky;top:0;z-index:2;background:var(--paper);padding-top:5px;padding-bottom:7px}.room-heading{padding-bottom:7px;gap:2px}.room-hint{display:none}
 .room-prompt{font-size:13px}.scene-frame{box-shadow:0 7px 18px #45313d10}.scene-caption{min-height:23px;padding-top:5px}.save-status{font-size:10px}
 .play-dock{display:flex;padding:11px;gap:10px}.box-card{padding:10px}.box-card-top{margin-bottom:8px}.box-card-top .eyebrow{display:none}.box-number{width:30px;height:30px;flex-basis:30px}.box-copy{font-size:13px;font-weight:600}
 .box-contents{grid-template-columns:none;grid-auto-flow:column;grid-auto-columns:minmax(92px,1fr);overflow-x:auto;overscroll-behavior-x:contain;scroll-snap-type:x proximity;margin:10px -2px 3px;padding:2px 2px 8px;scrollbar-width:thin}
 .box-item{min-height:105px;padding:8px 5px;scroll-snap-align:start}.box-item img{width:52px;height:52px}
 body[data-box-choices=true] #box-button{display:none}
 body[data-holding=false] .surface-picker,body[data-holding=false] .item-actions{display:none}
 body[data-holding=true] .box-card,body[data-holding=true] .settings-menu{display:none}
 .held-item{padding:8px 10px}.held-item img{width:38px;height:38px}.held-item p{font-size:11px}.item-actions{gap:7px}.item-actions kbd{display:none}
 .surface-picker{padding-top:8px}.surface-heading{margin-bottom:7px}.surface-caption{display:none}.zone-actions>button[data-surface]{display:none}
 .surface-select{display:block;width:100%;min-height:46px;border:1px solid #c9adc1;border-radius:12px;padding:10px 12px;background:var(--white);color:var(--ink);font:500 16px var(--body)}
 .cell-controls{display:grid;grid-template-columns:repeat(4,minmax(44px,1fr));gap:6px;margin-top:4px}.cell-controls button{min-height:44px;min-width:44px}.cell-controls .place-button{grid-column:1/-1;min-height:46px;font-size:14px}
 .settings-menu summary,.text-button{min-height:44px}.page-footer{display:none}
 .modal-shell{padding:18px}.gift-grid{grid-template-columns:1fr 1fr}.gift-card .gift-icon{width:56px;height:56px}.gift-card h3{font-size:19px}
 .story-letter-header{margin-top:-8px}.story-image{margin:12px auto 16px}.item-story-paper{padding:20px 24px}.story-text{font-size:16px;line-height:1.65}
 .story-actions{position:sticky;bottom:0;z-index:2;margin-top:16px;padding-top:12px;background:linear-gradient(#fff9f000,#fff9f0 12px)}
 .toast{bottom:max(8px,env(safe-area-inset-bottom));font-size:11px;padding:9px 12px}
}
@media(max-width:380px){.brand-mark{display:none}.brand-copy h1{font-size:20px}.held-item p{font-size:10px}.gift-grid{grid-template-columns:1fr}.item-story-paper{padding:18px 20px}}
@media(max-width:1000px) and (max-height:500px) and (orientation:landscape){
 .app-shell{padding:6px max(10px,env(safe-area-inset-right)) 6px max(10px,env(safe-area-inset-left))}.topbar{flex-direction:row;margin-bottom:5px;gap:10px}.brand-copy>.eyebrow,.brand-subtitle,.brand-mark{display:none}.brand-copy h1{font-size:22px}.top-actions{display:flex}.icon-button{min-height:44px}
 .game-layout{grid-template-columns:minmax(0,1fr) 250px;gap:10px}.room-panel{position:relative;padding:0}.room-heading{min-height:0;padding-bottom:5px}.room-hint,.scene-caption{display:none}.room-prompt{font-size:12px}.scene-frame{padding:4px}.scene-wrap{width:min(100%,calc((100dvh - 118px)*1.5));margin-inline:auto}
 .play-dock{display:flex;max-height:calc(100dvh - 64px);overflow-y:auto;padding:10px;gap:8px}.story-note{display:none}.box-card{padding:9px}.box-card-top .eyebrow{display:none}.box-contents{grid-auto-flow:row;grid-template-columns:1fr 1fr;grid-auto-columns:auto;margin:10px 0}.box-item{min-height:82px;padding:6px}.box-item img{width:42px;height:42px}
 body[data-holding=false] .surface-picker,body[data-holding=false] .item-actions,body[data-holding=true] .box-card,body[data-holding=true] .settings-menu,body[data-box-choices=true] #box-button{display:none}.item-actions kbd{display:none}
 .surface-caption,.zone-actions>button[data-surface]{display:none}.surface-select{display:block;width:100%;min-height:46px;font-size:16px;border:1px solid #c9adc1;border-radius:12px;background:var(--white);color:var(--ink);padding:8px}
 .cell-controls{display:grid;grid-template-columns:repeat(4,minmax(44px,1fr));gap:4px}.cell-controls button{min-width:44px}.cell-controls .place-button{grid-column:1/-1}.page-footer{display:none}.modal-shell{padding:18px}.story-image{width:48px;height:48px;margin:8px auto}.item-story-paper{padding:16px 24px}.story-actions{position:sticky;bottom:0;padding-top:10px;background:#fff9f0}.story-letter-header{position:sticky;top:0}
}

@media(max-width:720px){.toast{top:max(58px,env(safe-area-inset-top));bottom:auto;left:50%;right:auto;transform:translate(-50%,-6px);width:max-content;max-width:calc(100vw - 24px)}.toast.is-visible{transform:translate(-50%,0)}}
@media(max-width:380px){.held-item p{display:none}}
@media(max-width:1000px) and (max-height:500px) and (orientation:landscape){.held-item{padding:6px 8px;gap:8px}.held-item img{width:32px;height:32px}.held-item p{display:none}.held-item strong{font-size:12px}}

@media(max-width:720px){.room-panel{top:env(safe-area-inset-top,0px)}}
@media(max-width:1000px) and (max-height:500px) and (orientation:landscape){.toast{top:58px;bottom:auto;left:50%;right:auto;transform:translate(-50%,-6px);width:max-content;max-width:calc(100vw - 24px)}.toast.is-visible{transform:translate(-50%,0)}}

body[data-holding=false] .surface-picker,body[data-holding=false] .item-actions,body[data-holding=true] .box-card{display:none}
