/* Home browsing uses the same supplied ledger backdrop. Actions retain their
   existing court clock; the page itself is only a scrollable state projection. */
html body[data-game='palace'].game-shell #game:is([data-page='economy'],[data-page='social'],[data-page='hosting'],[data-page='royal-child']) {
 display:block;position:relative;box-sizing:border-box;padding:clamp(8px,1.8cqh,22px) clamp(12px,2cqw,34px);color:#574535;
 background:linear-gradient(rgba(250,240,221,.1),rgba(250,240,221,.16)),
 var(--palace-quiet-folio-image) center / cover;
}
#game:is([data-page='economy'],[data-page='social'],[data-page='hosting'],[data-page='royal-child']) > :is(.game-hud,.game-background,[data-return-home]) {display:none;}
html body[data-game='palace'].game-shell #game > #tab-content.home-activities-page {
 position:relative;inset:auto;display:flex;flex-direction:column;gap:clamp(6px,1.4cqh,16px);box-sizing:border-box;
 width:100%;height:100%;min-width:0;min-height:0;max-height:none;margin:0;padding:0;overflow:hidden;
 grid-column:auto;grid-row:auto;background:none;border:0;box-shadow:none;backdrop-filter:none;color:#574535;
}
.home-activities-heading {display:flex;align-items:center;flex:none;gap:clamp(8px,1.5cqw,20px);min-width:0;}
.home-activities-heading h2 {font-size:var(--font-heading);line-height:1.35;margin:0;color:#60472f;}
.home-activities-heading button {min-height:38px;margin:0;padding:5px 10px;font-size:var(--font-body);}
.home-activities-heading [data-return-home] {margin-left:auto;}
.home-activities-folio {
 display:flex;flex-direction:column;position:relative;isolation:isolate;flex:1;min-width:0;min-height:0;box-sizing:border-box;
 width:calc(100% - clamp(28px,5cqw,78px));max-width:1320px;margin:0 auto clamp(6px,1.5cqh,16px);padding:clamp(9px,1.3cqw,20px);
 overflow:hidden;border:1px solid #b394616f;border-radius:12px;background:rgba(255,248,233,.81);box-shadow:0 4px 18px #4f391d17,inset 0 0 12px #ffffff47;
}
.home-activities-folio > .dossier-ornament {position:absolute;opacity:.24;pointer-events:none;z-index:0;}
.home-activities-folio > .dossier-corner-top {top:0;right:0;width:clamp(54px,9cqw,120px);}
.home-activities-folio > .dossier-corner-bottom {bottom:0;left:0;width:clamp(54px,9cqw,120px);}
.home-activities-scroll {position:relative;z-index:1;flex:1;min-width:0;min-height:0;overflow:auto;overscroll-behavior:contain;scrollbar-width:thin;padding:3px 5px;font-size:var(--font-body);line-height:1.55;}
.home-activities-scroll :is(h3,h4) {margin:10px 0 6px;font-size:var(--font-section);color:#6d5033;}
.home-activities-scroll p {margin:6px 0;overflow-wrap:anywhere;}
.economy-balance {display:flex;flex-wrap:wrap;gap:6px;}
.economy-section-tabs {display:flex;flex-wrap:wrap;gap:8px;margin:10px 0;}
.economy-section-tabs button {min-height:44px;margin:0;padding:7px 12px;}
.economy-section-tabs button[aria-current='true'] {background:#ebddc1;border-color:#ab874d;color:#5c4026;}
.economy-unlock-hints,.economy-reason {color:#80694d;font-size:var(--font-note);}
.economy-reason {display:block;flex-basis:100%;}
.economy-recipe,.economy-host-record {border-bottom:1px solid #ad936c55;padding:9px 0;margin:4px 0;}
.economy-row {display:flex;flex-wrap:wrap;align-items:center;gap:8px;padding:8px 0;border-bottom:1px solid #ad936c55;}
.economy-field {display:flex;flex-wrap:wrap;align-items:center;gap:8px;margin:8px 0;}
.economy-field select {max-width:100%;min-width:0;min-height:44px;padding:7px;background:#fff8eb;color:#60472f;}
.economy-host-form{display:flex;flex-direction:column;gap:clamp(5px,1cqh,9px);min-width:0;}
.economy-host-options{display:flex;flex-direction:column;gap:clamp(6px,1cqh,10px);min-width:0;}
.economy-host-form .hosting-choice-field{margin:0;}
.economy-host-form .economy-segmented-options{min-width:0;}
.economy-host-form .economy-host-guest-status{
 margin:clamp(6px,1cqh,10px) 0 0;
 font-size:var(--font-body);font-weight:600;color:#684d34;
}
.economy-host-form .economy-host-empty{margin:2px 0;font-size:var(--font-note);color:#80694d;}
.economy-host-form .economy-host-prizes{display:flex;flex-direction:column;gap:clamp(4px,.8cqh,8px);}
.economy-host-form .economy-host-prizes:empty{display:none;}
.economy-guests {display:flex;flex-direction:column;gap:6px;}
.economy-guests label {display:flex;align-items:center;gap:8px;min-height:44px;}
.home-activities-scroll button {min-height:44px;max-width:100%;white-space:normal;padding:8px 12px;margin:3px;font-size:var(--font-body);}
/* Human relations: the two supplied transparent illustrations are the entry art. */
#game[data-page='social'] .social-overview-page .home-activities-folio {
 width:100%;max-width:none;margin:0;padding:0;
 border:0;border-radius:0;background:transparent;box-shadow:none;
}
#game[data-page='social'] .social-overview-page .home-activities-folio > .dossier-ornament {display:none;}
#game[data-page='social'] .social-overview-page .home-activities-scroll {
 display:flex;flex-direction:column;min-height:0;overflow:hidden;padding:0;
}
.social-choices {
 display:grid;grid-template-columns:repeat(2,minmax(0,1fr));
 flex:1;min-height:0;min-width:0;gap:clamp(14px,3cqw,42px);
 padding:clamp(5px,1cqh,12px) clamp(10px,2.2cqw,30px);
 align-items:stretch;
}
#game[data-page='social'] .home-activities-scroll .social-choice {
 display:flex;flex-direction:column;justify-content:center;align-items:center;
 box-sizing:border-box;min-width:0;min-height:0;width:100%;height:100%;
 margin:0;padding:clamp(3px,.8cqh,9px);
 border:0;background:transparent;box-shadow:none;
 color:#60472f;cursor:pointer;
}
#game[data-page='social'] .home-activities-scroll .social-choice:hover .social-choice-art-frame {
 background:rgba(255,249,232,.40);border-color:rgba(153,113,62,.83);
}
#game[data-page='social'] .home-activities-scroll .social-choice:focus-visible {
 outline:2px solid #967142;outline-offset:-2px;
}
.social-choice-art-frame {
 display:flex;align-items:center;justify-content:center;flex:1;
 box-sizing:border-box;min-width:0;min-height:0;width:100%;
 max-height:clamp(116px,48cqh,290px);
 padding:clamp(6px,1cqh,12px) clamp(8px,1.2cqw,16px);
 border:1px solid rgba(166,129,80,.65);border-radius:10px;
 background:rgba(255,249,234,.26);
 box-shadow:inset 0 0 0 2px rgba(255,250,240,.36),0 2px 8px rgba(74,47,19,.09);
 transition:background-color .16s,border-color .16s;
 pointer-events:none;
}
.social-choice-image {
 display:block;flex:1;min-height:0;min-width:0;width:100%;height:100%;
 max-height:100%;object-fit:contain;pointer-events:none;
}
.social-choice-name {
 display:block;flex:none;min-height:0;margin:clamp(2px,.8cqh,9px) 0 0;
 font-size:var(--font-section);font-weight:600;letter-spacing:.13em;line-height:1.35;
}
.social-choice-missing-art .social-choice-image {display:none;}
@media (orientation:landscape) and (max-height:450px){
 .social-choices {gap:clamp(8px,2cqw,20px);padding:2px clamp(7px,1.5cqw,16px);}
 .social-choice-art-frame {max-height:46cqh;padding:4px 7px;}
 .social-choice-name {margin-top:2px;}
}
@media (orientation:landscape) and (max-height:450px) {
 .home-activities-heading button {min-height:34px;}
 .home-activities-folio {margin-bottom:4px;padding:7px 10px;}
 .home-activities-scroll {padding-top:0;}
}

#game[data-page='royal-child'] .dossier-child-card {align-items:start;}
#game[data-page='royal-child'] .home-activities-scroll {overflow-y:auto;overscroll-behavior:contain;}
#game[data-page='royal-child'] .dossier-child-grid {display:block;}
#game[data-page='royal-child'] .dossier-child-card {display:grid;grid-template-columns:minmax(110px,28%) minmax(0,1fr);align-items:start;gap:clamp(10px,1.5cqw,22px);min-width:0;}
#game[data-page='royal-child'] .dossier-child-info {min-width:0;overflow-wrap:anywhere;}
#game[data-page='royal-child'] .dossier-child-portrait {min-height:clamp(135px,28cqh,260px);}
#game[data-page='royal-child'] :is(.royal-child-care,.royal-child-growth) {margin-top:clamp(10px,1.4cqh,18px);padding-top:8px;border-top:1px solid rgba(151,116,71,.35);}
#game[data-page='royal-child'] :is(.royal-child-care,.royal-child-growth) h4 {font-size:var(--font-section);margin:0 0 7px;color:#654830;}
#game[data-page='royal-child'] .royal-child-care-actions {display:flex;flex-wrap:wrap;gap:6px;}
#game[data-page='royal-child'] .royal-child-care-actions button {flex:1 1 120px;margin:0;min-height:36px;}
#game[data-page='royal-child'] .royal-child-care-actions button:disabled {opacity:.46;cursor:not-allowed;}
#game[data-page='royal-child'] .royal-child-growth-entry {display:grid;grid-template-columns:minmax(0,1fr) auto;gap:4px 10px;padding:9px 0;border-bottom:1px solid rgba(151,116,71,.17);}
#game[data-page='royal-child'] .royal-child-growth-entry strong {font-size:var(--font-body);color:#604831;}
#game[data-page='royal-child'] .royal-child-growth-entry small {font-size:var(--font-note);color:#887154;}
#game[data-page='royal-child'] .royal-child-growth-entry p {grid-column:1/-1;margin:0;line-height:1.65;}
#game[data-page='royal-child'] .royal-child-father-entry {border-bottom:1px solid rgba(151,116,71,.18);padding:7px 0;}
#game[data-page='royal-child'] .royal-child-father-entry > summary {cursor:pointer;color:#604831;font-size:var(--font-body);font-weight:600;line-height:1.6;}
#game[data-page='royal-child'] .royal-child-father-entry > summary:focus-visible {outline:2px solid #967142;outline-offset:3px;}
#game[data-page='royal-child'] .royal-child-father-entry p {padding:4px 0;margin:0;line-height:1.75;white-space:pre-wrap;}

#game[data-page='social'] .social-royal-children {flex:none;margin:0 clamp(8px,1.8cqw,24px) clamp(4px,.9cqh,12px);padding:8px 12px;border:1px solid rgba(169,133,86,.5);border-radius:9px;background:rgba(255,247,229,.63);}
#game[data-page='social'] .social-royal-children h3 {font-size:var(--font-body);font-weight:600;color:#604831;margin:0 0 5px;}
#game[data-page='social'] .social-royal-children-links {display:flex;gap:5px;flex-wrap:wrap;max-height:16cqh;overflow:auto;}
#game[data-page='social'] .social-royal-children-links button {min-height:32px;margin:0;padding:3px 13px;}
#game[data-page='event'] .developer-pregnancy-toggle {font-size:var(--font-note);white-space:normal;max-width:100%;border:1px dashed #8c6f48;background:rgba(255,244,220,.87);color:#573c27;padding:7px 12px;border-radius:7px;}
#game[data-page='event'] .developer-pregnancy-toggle[aria-pressed='true'] {background:#5d7858;color:#fff9eb;}
@media (max-width:600px) {
 #game[data-page='royal-child'] .dossier-child-card {grid-template-columns:minmax(80px,26%) minmax(0,1fr);gap:8px;}
 #game[data-page='royal-child'] .royal-child-growth-entry {grid-template-columns:1fr;}
 #game[data-page='royal-child'] .royal-child-growth-entry p {grid-column:auto;}
}


.economy-transaction-receipt {border-left:3px solid #70844f;padding:7px 10px;background:#eef0dd;color:#344923;}

.industry-form {display:flex;flex-wrap:wrap;gap:8px;align-items:center;border:1px solid #bca983;padding:9px;margin:9px 0;}
.industry-form label {display:flex;flex-wrap:wrap;gap:5px;align-items:center;min-width:0;max-width:100%;}
.industry-form :is(input,select) {max-width:100%;min-width:0;min-height:40px;box-sizing:border-box;}
.industry-form input[type=number] {width:90px;}
.industry-table {width:100%;border-collapse:collapse;font-size:var(--font-body);}
.industry-table :is(th,td) {text-align:left;padding:6px;border-bottom:1px solid #ad936c55;overflow-wrap:anywhere;}

/* The warehouse is a stock ledger; buying and selling now live at the
   workshop, farm and merchant destinations rather than in this screen. */
.economy-warehouse-home{display:flex;flex-direction:column;gap:clamp(8px,1.4cqh,16px);min-width:0;}
.economy-warehouse-header-actions{display:flex;flex-wrap:wrap;align-items:center;gap:clamp(6px,.9cqw,12px);margin-left:auto;}
.economy-warehouse-silver{font-size:var(--font-note);white-space:nowrap;color:#725638;}
.home-activities-heading .economy-warehouse-header-actions button{
 min-height:clamp(30px,4.5cqh,39px);margin:0;padding:4px 12px;
 border:1px solid #b59461;border-radius:9px;
 color:#5a422d;font-size:var(--font-note);
}
.economy-warehouse-summary{
 display:flex;flex-direction:column;gap:clamp(6px,1cqh,12px);
 border:1px solid rgba(175,140,90,.45);border-radius:12px;
 background:rgba(255,248,232,.40);padding:clamp(9px,1.5cqh,17px) clamp(11px,1.5cqw,22px);
}
.economy-warehouse-summary-head{display:flex;flex-wrap:wrap;align-items:baseline;justify-content:space-between;gap:8px;}
.economy-warehouse-summary-head strong{font-size:var(--font-section);color:#5e422c;}
.economy-warehouse-summary-head span,.economy-warehouse-summary-detail{font-size:var(--font-note);color:#746044;}
.economy-warehouse-meter{height:7px;border-radius:20px;background:rgba(164,139,95,.22);overflow:hidden;}
.economy-warehouse-meter span{display:block;height:100%;border-radius:20px;background:#a08352;}
.economy-warehouse-summary-detail{margin:0;}
.economy-warehouse-empty{color:#7a6349;padding:12px 3px;}
.economy-warehouse-groups{display:flex;flex-direction:column;gap:12px;min-width:0;}
.economy-warehouse-group h4{font-size:var(--font-body);color:#6a5032;margin:2px 0 6px;}
.economy-warehouse-rows{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:clamp(5px,.8cqw,12px);}
.economy-warehouse-item{
 display:flex;align-items:center;justify-content:space-between;gap:10px;min-width:0;
 padding:clamp(7px,1cqh,12px) clamp(9px,1.2cqw,15px);
 border:1px solid rgba(174,140,91,.35);border-radius:9px;
 background:rgba(255,251,243,.34);
}
.economy-warehouse-item-name,.economy-warehouse-item-quantity{display:flex;flex-direction:column;gap:3px;min-width:0;}
.economy-warehouse-item-name strong{color:#59402d;font-size:var(--font-body);}
.economy-warehouse-item-name small,.economy-warehouse-item-quantity small{color:#856f52;font-size:var(--font-note);}
.economy-warehouse-item-quantity{text-align:right;flex:none;}
.economy-warehouse-item-quantity strong{font-size:var(--font-body);white-space:nowrap;color:#644a2d;font-variant-numeric:tabular-nums;}
@media (orientation:landscape) and (max-width:720px){.economy-warehouse-rows{grid-template-columns:minmax(0,1fr);}}

/* Share the full handcraft folio equally between the paper and embroidery routes. */
.handcraft-lines{
 display:grid;grid-template-columns:minmax(0,1fr);
 grid-template-rows:repeat(2,minmax(max-content,1fr));
 width:100%;height:100%;min-height:100%;min-width:0;gap:0;
}
.handcraft-line{
 display:flex;align-items:center;justify-content:center;
 box-sizing:border-box;min-width:0;min-height:0;
 padding:clamp(4px,.7cqh,9px) 0;
 border:0;background:transparent;
}
.handcraft-line + .handcraft-line{
 border-top:1px solid rgba(169,137,91,.32);
}
.handcraft-stages{
 display:grid;grid-template-columns:repeat(4,minmax(0,1fr));
 gap:clamp(3px,.8cqw,11px);width:100%;min-width:0;
}
.handcraft-stage{
 position:relative;display:flex;flex-direction:column;
 align-items:stretch;min-width:0;box-sizing:border-box;
 padding:0 clamp(1px,.45cqw,6px);
 border:0;background:transparent;
}
.handcraft-stage:not(:last-child)::after{
 content:'';position:absolute;z-index:0;pointer-events:none;
 top:clamp(17px,3cqh,23px);right:calc(-1 * clamp(3px,.8cqw,11px));
 width:clamp(3px,.8cqw,11px);height:1px;
 background:rgba(155,120,70,.55);
}
.handcraft-stage-choices{
 display:flex;flex-direction:column;align-items:center;justify-content:flex-start;
 gap:clamp(2px,.4cqh,5px);min-width:0;flex:1;
}
/* Compact reproductions of the ordinary palace choice plaques. The same
   ornamental images, gold rim and inset line are shared without full-width buttons. */
.home-activities-scroll .handcraft-recipe-choice{
 display:flex;align-items:center;justify-content:center;align-self:center;
 box-sizing:border-box;width:max-content;max-width:100%;min-width:0;
 min-height:clamp(37px,5.7cqh,47px);
 margin:0;padding:5px clamp(18px,2cqw,29px);
 color:var(--palace-ink,#513724);
 font:550 clamp(16px,1.8cqw,21px)/1.3 var(--palace-story-font,var(--game-text-font));
 text-align:center;white-space:normal;overflow-wrap:anywhere;cursor:pointer;
 border:1px solid var(--palace-gold,rgba(174,131,67,.70));border-radius:12px;
 background-image:image-set(
  url('/public/assets/ui/character-frames/ornaments/ornament-center-gold-02.webp?v=038bfafc99c2') type('image/webp'),
  image-set(url('/public/assets/ui/character-frames/ornaments/ornament-center-gold-02.webp?v=038bfafc99c2') type('image/webp'), url('/public/assets/ui/character-frames/ornaments/ornament-center-gold-02.png') type('image/png')) type('image/png')
 ),image-set(
  url('/public/assets/ui/character-frames/ornaments/branch-floral-right-01.webp?v=22870a9a9fc1') type('image/webp'),
  image-set(url('/public/assets/ui/character-frames/ornaments/branch-floral-right-01.webp?v=22870a9a9fc1') type('image/webp'), url('/public/assets/ui/character-frames/ornaments/branch-floral-right-01.png') type('image/png')) type('image/png')
 ),linear-gradient(100deg,rgba(255,252,241,.92),rgba(248,234,210,.84));
 background-position:left 6px center,right 4px center,center;
 background-size:10px auto,auto 68%,100% 100%;background-repeat:no-repeat;
 box-shadow:inset 0 0 0 2px rgba(255,249,232,.90),
            inset 0 0 0 3px var(--palace-inset,rgba(205,164,99,.44)),
            0 2px 6px rgba(44,28,11,.12);
}
.home-activities-scroll .handcraft-recipe-choice:is(:hover,:focus-visible){
 border-color:#956829;filter:brightness(1.025);
}
.home-activities-scroll .handcraft-recipe-choice:focus-visible{
 outline:2px solid #917039;outline-offset:2px;
}
.home-activities-scroll .handcraft-recipe-choice[data-locked='true']{
 color:#8d806f;opacity:.65;filter:saturate(.7);
}
.home-activities-scroll .handcraft-recipe-choice[data-locked='true']:is(:hover,:focus-visible){
 opacity:.82;
}
.handcraft-dialog{
 box-sizing:border-box;width:min(530px,calc(100vw - 28px));
 max-width:calc(100vw - 20px);max-height:calc(100dvh - 24px);
 margin:auto;padding:0;overflow:hidden;
 border:1px solid rgba(153,121,76,.85);border-radius:12px;
 background:#fcf5e7;color:#624b34;box-shadow:0 18px 48px rgba(46,32,17,.35);
 font-size:var(--font-body);
}
.handcraft-dialog[open]{display:flex;flex-direction:column;}
.handcraft-dialog::backdrop{background:rgba(35,29,20,.46);}
.handcraft-dialog-header{
 display:flex;align-items:center;gap:12px;
 padding:clamp(12px,1.7cqh,20px) clamp(14px,1.8cqw,24px);
 border-bottom:1px solid rgba(160,129,89,.29);
}
.handcraft-dialog-header h3{margin:0;font-size:var(--font-section);color:#61452c;}
.handcraft-dialog-tier{color:#967959;font-size:var(--font-note);}
.handcraft-dialog-close{margin-left:auto;}
.handcraft-dialog-body{
 display:flex;flex-direction:column;gap:8px;
 padding:clamp(14px,2cqh,23px) clamp(14px,1.8cqw,24px);
 overflow:auto;min-height:0;
}
.handcraft-dialog-material{
 display:grid;grid-template-columns:auto minmax(0,1fr) auto;
 align-items:center;gap:clamp(7px,1.1cqw,14px);
 padding-bottom:9px;border-bottom:1px solid rgba(173,147,108,.23);
}
.handcraft-dialog-material > strong,.handcraft-dialog-profit > strong{
 color:#6a4c31;font-weight:600;white-space:nowrap;
}
.handcraft-dialog-material > span{
 min-width:0;text-align:right;white-space:nowrap;
 font-variant-numeric:tabular-nums;
}
.handcraft-dialog-purchase{
 display:flex;flex-direction:column;align-items:flex-end;
 gap:3px;min-width:0;
}
.handcraft-dialog-purchase .economy-reason{
 margin:0;font-size:var(--font-note);text-align:right;
}
.handcraft-dialog-profit{
 display:flex;align-items:center;justify-content:space-between;gap:18px;
 margin:0;padding-bottom:9px;line-height:1.55;
 border-bottom:1px solid rgba(173,147,108,.23);
}
.handcraft-dialog-profit > span{
 color:#6a593a;font-variant-numeric:tabular-nums;
}
.handcraft-dialog-body > .handcraft-dialog-status{
 display:block;margin:3px 0 0;padding:0;border:0;
 color:#876f52;font-size:var(--font-note);
}
.handcraft-locked-message{
 margin:0;padding:clamp(18px,3cqh,30px);
 text-align:center;color:#755939;line-height:1.6;
}
@media (max-width:460px){
 .handcraft-dialog-material{
  grid-template-columns:minmax(0,1fr) auto;
 }
 .handcraft-dialog-material > span{justify-self:end;}
 .handcraft-dialog-purchase{grid-column:1/-1;align-items:flex-end;}
}
.handcraft-dialog-actions{
 display:flex;justify-content:flex-end;padding:11px clamp(14px,1.8cqw,24px);
 border-top:1px solid rgba(160,129,89,.29);
}
.handcraft-dialog button{
 min-height:36px;max-width:100%;padding:5px 14px;margin:0;
 font-size:var(--font-body);color:#63472f;
 border:1px solid #b09265;border-radius:6px;

}
.handcraft-dialog button:disabled{opacity:.56;cursor:not-allowed;}
@media (orientation:landscape) and (max-height:450px){
 .handcraft-line{padding:3px 0;}
 .home-activities-scroll .handcraft-recipe-choice{min-height:32px;padding:3px 5px;}
 .handcraft-dialog-body{padding-top:9px;padding-bottom:9px;}
}

/* The full-bleed economy settlement is itself the overview screen. */
html body[data-game='palace'].game-shell #game[data-page='economy'] > #tab-content.home-activities-page.economy-overview-page{
 position:absolute;inset:0;display:block;box-sizing:border-box;
 width:auto;height:auto;margin:0;padding:0;gap:0;overflow:hidden;
 border:0;border-radius:0;background:transparent;box-shadow:none;
}
#game[data-page='economy'] .economy-estate-map{
 position:absolute;inset:0;display:block;width:100%;height:100%;min-height:0;overflow:hidden;
 background:#e7ddc5;
}
.economy-estate-viewport{
 position:absolute;inset:0;width:100%;height:100%;min-height:0;
 overflow-x:auto;overflow-y:hidden;overscroll-behavior-x:contain;
 scrollbar-width:thin;scrollbar-color:#9c815b9c transparent;
 touch-action:pan-y;cursor:grab;
}
.economy-estate-viewport:is(:active,.is-dragging){cursor:grabbing;user-select:none;-webkit-user-select:none;}
.economy-estate-viewport:focus-visible{outline:2px solid #b48c54;outline-offset:-4px;}
.economy-estate-scene{
 position:relative;box-sizing:border-box;height:100%;
 width:100%;min-width:100%;overflow:hidden;isolation:isolate;background:#f0e5d3;
}
.economy-estate-ground{
 position:absolute;inset:0;width:100%;height:100%;object-fit:fill;
 pointer-events:none;user-select:none;
}
.economy-estate-missing-ground .economy-estate-ground{display:none;}
#game .economy-estate-node{
 position:absolute;z-index:2;display:flex;align-items:center;justify-content:center;
 box-sizing:border-box;min-width:clamp(60px,5.3cqw,80px);min-height:clamp(30px,5.1cqh,39px);
 max-width:180px;margin:0;padding:5px clamp(10px,1.2cqw,16px);
 border:1px solid #ab895ec9;border-radius:14px;
 background:#fff8e8e8;box-shadow:0 2px 6px #5c412c55,inset 0 0 0 1px #fffcf0ac;
 color:#5e412a;font-size:clamp(14px,1.3cqw,18px);font-weight:650;line-height:1.15;
 white-space:nowrap;transform:translate(-50%,-50%);cursor:pointer;touch-action:pan-y;
}
/* An unlocked site gets a true double border; locked sites retain the single line. */
#game .economy-estate-node[data-unlocked='true']{
 border-width:3px;border-style:double;
}
#game .economy-estate-node::after{
 content:'';position:absolute;top:100%;left:50%;width:1px;height:7px;
 background:#a37a4cb0;pointer-events:none;
}
#game .economy-estate-node:is(:hover,:focus-visible){
 z-index:3;border-color:#8a6135;background:#fffaf0;
 box-shadow:0 3px 9px #4c372a60,inset 0 0 0 1px #fffaf0;
}
#game .economy-estate-node:focus-visible{outline:2px solid #8a6135;outline-offset:2px;}

#game .economy-estate-new-dot{
 position:absolute;top:-5px;right:-5px;width:10px;height:10px;box-sizing:border-box;
 border:2px solid #fff8e8;border-radius:50%;background:#b84034;
 box-shadow:0 1px 4px #53271e88;pointer-events:none;
}
#game .economy-estate-dialog{
 box-sizing:border-box;position:fixed;inset:0;margin:auto;
 width:min(390px,calc(100vw - 36px));max-height:min(78vh,400px);
 padding:0;border:1px solid #b79b71;border-radius:15px;
 background:#fff9ed;color:#62472d;box-shadow:0 12px 40px #2c231f66,inset 0 0 0 3px #f5e9d2;
 overflow:auto;
}
#game .economy-estate-dialog::backdrop{background:rgba(25,30,25,.40);}
#game .economy-estate-dialog-close{
 position:absolute;top:10px;right:12px;z-index:2;
 flex:none;width:28px;height:28px;min-width:28px;min-height:28px;padding:0;
 border:0;border-radius:50%;background:transparent;color:#785c3c;font-size:24px;line-height:1;
}
#game .economy-estate-dialog-content{
 display:flex;flex-direction:column;align-items:center;gap:10px;
 padding:clamp(20px,4cqh,26px) 20px 20px;text-align:center;
}
#game .economy-estate-dialog-message{margin:0;font-weight:650;font-size:var(--font-section);line-height:1.45;}
#game .economy-estate-dialog-price-label{margin:0;color:#83674b;}
#game .economy-estate-dialog-price{font-size:24px;line-height:1.5;}
#game .economy-estate-dialog-subtext{
 margin:0;max-width:320px;color:#8b7353;font-size:var(--font-body);line-height:1.6;
}
/* Use the shared .palace-choice option artwork, border and sizing. */
#game .economy-estate-dialog-primary{
 min-width:150px;max-width:100%;margin:7px 0 0;cursor:pointer;
 font-size:var(--font-body);font-weight:600;
}
#game .economy-estate-dialog-primary:disabled{opacity:.55;cursor:not-allowed;}
#game .economy-estate-dialog-detail-text{
 width:100%;box-sizing:border-box;margin:2px 0 0;padding-top:10px;
 border-top:1px solid #b79b7155;
 font-size:var(--font-note);color:#816344;line-height:1.65;text-align:left;
}
@media (orientation:landscape) and (max-height:450px){
 #game .economy-estate-dialog{width:min(365px,calc(100vw - 32px));max-height:85vh;}
 #game .economy-estate-dialog-content{padding:22px 16px 17px;gap:8px;}
 #game .economy-estate-dialog-close{top:7px;right:10px;}
}

.economy-estate-navigation{
 position:absolute;z-index:10;inset:0 0 auto 0;
 display:flex;align-items:flex-start;justify-content:space-between;
 padding:clamp(11px,2.1cqh,24px) clamp(12px,2.3cqw,29px);pointer-events:none;
}
#game .economy-estate-navigation button{
 pointer-events:auto;min-height:clamp(36px,6cqh,48px);min-width:0;margin:0;
 padding:5px clamp(13px,1.5cqw,20px);
 border:1px solid #b79b71c9;border-radius:12px;
 background:#fff5e4ec;color:#66482b;
 box-shadow:0 3px 12px #4e3d2633,inset 0 0 0 2px #fff9ec99;
 font-size:var(--font-body);font-weight:600;white-space:nowrap;
}
#game .economy-estate-navigation button:is(:hover,:focus-visible){background:#fff8ed;}
@media (orientation:landscape) and (max-height:450px){
 #game .economy-estate-node{min-height:30px;padding:4px 9px;font-size:clamp(13px,1.5cqw,17px);}
 .economy-estate-navigation{padding:9px 14px;}
 #game .economy-estate-navigation button{min-height:34px;padding:3px 12px;}
}

/* The farm overview and its in-page management share the building layout. */
.farm-page .home-activities-scroll.farm-home{display:flex;flex-direction:column;overflow:hidden;gap:12px;}
.farm-entrances{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:clamp(6px,1.4cqw,18px);flex:1;min-height:0;padding:2px;}
.home-activities-scroll :is(.farm-entrances,.workshop-entrances,.shop-entrances) button{
 display:flex;flex-direction:column;align-items:center;justify-content:center;
 gap:clamp(5px,.9cqh,9px);box-sizing:border-box;
 width:100%;min-width:0;min-height:80px;margin:0;padding:clamp(9px,1.5cqh,17px) 7px;
 border:1px solid var(--palace-gold,rgba(174,131,67,.70));
 border-radius:16px;background:transparent;color:var(--palace-ink,#513724);
 box-shadow:inset 0 0 0 3px rgba(255,249,232,.58),inset 0 0 0 4px var(--palace-inset,rgba(205,164,99,.44));
}
.home-activities-scroll :is(.farm-entrances,.workshop-entrances,.shop-entrances) button:is(:hover,:focus-visible){
 background:rgba(255,251,239,.14);border-color:#956829;
}
.home-activities-scroll :is(.farm-entrances,.workshop-entrances,.shop-entrances) button:focus-visible{
 outline:2px solid #917039;outline-offset:2px;
}
.farm-type-art{display:block;width:100%;height:0;flex:1;min-height:0;object-fit:contain;pointer-events:none;}
.farm-entrances strong{font-size:clamp(20px,3cqw,32px);letter-spacing:.12em;}
.farm-entrances :is(span,small){font-size:var(--font-note);}

.farm-plot{min-width:0;}

.farm-date,.farm-form-fee,.farm-form-note{font-size:var(--font-note);color:#7d684e;}
.farm-plot-form{display:flex;flex-direction:column;gap:clamp(5px,.8cqh,10px);}
.farm-section-heading{font-size:var(--font-body);font-weight:600;}
/* Farm settings: one native grid for the crop selector and both option rows. */
.farm-plot-form > :is(.farm-field,.farm-choice-field){
 display:grid;grid-template-columns:minmax(6em,1fr) minmax(0,3fr);
 align-items:center;gap:clamp(6px,1cqw,12px);min-width:0;margin:2px 0;
}
.farm-field > span{min-width:0;}
.farm-field select{width:100%;min-width:0;min-height:clamp(33px,5.5cqh,42px);padding:4px 10px;font:inherit;color:inherit;background:#fff9ed;border-radius:10px;}
/* Shared exposed choices for farm plans, workshop patterns and merchant decisions. */
.economy-segmented-field{
 display:grid;grid-template-columns:clamp(68px,8.2cqw,105px) minmax(0,1fr);
 align-items:center;gap:clamp(6px,1cqw,12px);min-width:0;margin:2px 0;
}
.economy-segmented-field[hidden]{display:none;}
.economy-segmented-label{font-size:var(--font-body);color:#684d34;white-space:nowrap;}
.economy-segmented-options{
 display:grid;grid-template-columns:repeat(var(--economy-option-count),minmax(0,1fr));
 gap:clamp(4px,.65cqw,8px);min-width:0;
}
.home-activities-scroll .economy-segmented-options button,
.merchant-modal-body .economy-segmented-options button{
 width:100%;min-width:0;min-height:clamp(32px,5.5cqh,40px);
 box-sizing:border-box;margin:0;padding:5px clamp(4px,.65cqw,9px);
 border:1px solid rgba(171,133,81,.64);border-radius:9px;
 color:#65462d;
 box-shadow:inset 0 0 0 2px rgba(255,249,232,.45);
 font-size:var(--font-note);font-weight:500;line-height:1.25;
 white-space:normal;overflow-wrap:anywhere;text-align:center;
}
.home-activities-scroll .economy-segmented-options button[aria-pressed='true'],
.merchant-modal-body .economy-segmented-options button[aria-pressed='true']{
 background:rgba(222,196,150,.76);border-color:#96703d;color:#513b26;font-weight:700;
}
.home-activities-scroll .economy-segmented-options button:is(:hover,:focus-visible),
.merchant-modal-body .economy-segmented-options button:is(:hover,:focus-visible){
 border-color:#94703c;outline-offset:1px;
}
.merchant-choice-field{grid-template-columns:clamp(72px,8.5cqw,100px) minmax(0,1fr);}
@media (orientation:landscape) and (max-height:450px){
 .economy-segmented-field{gap:6px;margin:1px 0;}
 .economy-segmented-options{gap:4px;}
 .home-activities-scroll .economy-segmented-options button,
 .merchant-modal-body .economy-segmented-options button{min-height:30px;padding:3px 4px;}
}
.farm-form-actions{display:flex;flex-wrap:wrap;gap:8px;align-items:center;}
.farm-form-actions[hidden]{display:none;}
.farm-form-error{color:#a34435;}
.farm-upgrade-preview{display:flex;flex-direction:column;gap:clamp(6px,1cqh,12px);padding:clamp(7px,1.5cqh,14px) 0;border-bottom:1px solid rgba(171,141,95,.36);}
.farm-upgrade-preview h4{margin:0;}
.farm-upgrade-preview p{margin:0;}
.farm-upgrade-price{font-weight:600;color:#674b2e;}
@media (orientation:landscape) and (max-height:450px){
 .farm-page .home-activities-scroll.farm-home{gap:5px;}
 .home-activities-scroll .farm-entrances button{gap:4px;}
 .farm-field select{min-height:33px;}
}

/* Workshop entrance layout owns its three columns; modal geometry, scroll and
   controls intentionally share the existing farm-dialog component rules. */
.workshop-page .home-activities-scroll.workshop-home {display:flex;flex-direction:column;overflow:hidden;}
.workshop-entrances {display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:clamp(6px,1.4cqw,18px);flex:1;min-height:0;padding:2px;}

.workshop-type-art {display:block;width:100%;height:0;flex:1;min-height:0;object-fit:contain;pointer-events:none;}
.workshop-entrances strong {font-size:clamp(20px,3cqw,32px);letter-spacing:.12em;}
.workshop-entrances :is(span,small) {font-size:var(--font-note);}
.workshop-production{display:flex;flex-direction:column;gap:clamp(7px,1.3cqh,12px);margin:0;min-width:0;}
.workshop-field{display:flex;align-items:center;gap:clamp(5px,.7cqw,9px);min-width:0;}
.workshop-field[hidden]{display:none;}
.workshop-field :is(select,input){max-width:100%;min-width:0;min-height:clamp(32px,5.4cqh,39px);padding:4px 8px;box-sizing:border-box;font:inherit;color:inherit;background:rgba(255,250,237,.84);border:1px solid rgba(185,148,96,.38);border-radius:9px;}
.workshop-primary-row{display:grid;grid-template-columns:minmax(105px,1fr) auto;align-items:center;gap:clamp(7px,1.1cqw,16px);min-width:0;}
.workshop-recipe-field{min-width:0;}
.workshop-quantity-field{white-space:nowrap;justify-content:flex-end;}
.workshop-stepper{display:inline-flex;align-items:center;justify-content:flex-end;gap:clamp(3px,.5cqw,7px);min-width:0;max-width:100%;}
.workshop-field .workshop-stepper input{width:clamp(30px,3.1cqw,42px);min-height:34px;flex:none;padding:3px 1px;text-align:center;font-weight:600;appearance:textfield;border:0;border-bottom:1px solid rgba(154,119,73,.45);border-radius:0;background:transparent;box-shadow:none;color:#5a412b;}
.workshop-field .workshop-stepper input:focus-visible{outline:none;border-bottom:2px solid #a8804e;background:rgba(255,253,246,.4);}
.workshop-stepper input::-webkit-inner-spin-button,.workshop-stepper input::-webkit-outer-spin-button{-webkit-appearance:none;margin:0;}
.home-activities-scroll .workshop-stepper button{display:inline-flex;flex:none;align-items:center;justify-content:center;min-height:clamp(30px,5cqh,38px);margin:0;padding:3px 7px;white-space:nowrap;font-size:var(--font-note);color:#67492c;border:1px solid rgba(181,141,83,.58);background:rgba(242,218,174,.66);box-shadow:inset 0 0 0 2px rgba(255,249,227,.5);}
.home-activities-scroll .workshop-stepper .workshop-step-one{width:clamp(30px,3.3cqw,37px);height:clamp(30px,5cqh,37px);min-width:30px;padding:0;border-radius:50%;font-size:clamp(18px,2cqw,24px);line-height:1;}
.home-activities-scroll .workshop-stepper .workshop-step-max{min-width:clamp(42px,4.7cqw,58px);border-radius:20px;padding-inline:7px;}
.home-activities-scroll .workshop-stepper button:is(:hover,:focus-visible):not(:disabled){background:#e7c88f;border-color:#ab834d;}
.home-activities-scroll .workshop-stepper button:active:not(:disabled){background:#d9b875;}
.home-activities-scroll .workshop-stepper button:disabled{opacity:.46;cursor:default;}
.workshop-order{padding:6px 0;border-bottom:1px solid #b8a27e66;}
.workshop-preview{font-size:var(--font-note);min-width:0;container-type:inline-size;}
.workshop-preview-lines{display:flex;flex-direction:column;min-width:0;padding:clamp(5px,1cqh,10px) clamp(8px,1cqw,13px);}
.workshop-preview-line{display:grid;grid-template-columns:clamp(40px,5cqw,62px) minmax(0,1fr);align-items:center;gap:8px;min-width:0;padding:clamp(4px,.65cqh,7px) 0;}
.workshop-preview-line+.workshop-preview-line{border-top:1px solid rgba(157,123,76,.23);}
.workshop-preview-label{font-size:var(--font-note);color:#876d4d;line-height:1.4;}
.workshop-preview-value{font-size:var(--font-body);font-weight:600;line-height:1.4;color:#61462d;overflow-wrap:anywhere;}
.workshop-supply-actions{display:flex;align-items:center;flex-wrap:wrap;gap:clamp(5px,.6cqw,9px);padding:6px 0 2px;border-top:1px solid rgba(157,123,76,.23);}
.home-activities-scroll .workshop-supply-actions button{
 min-height:clamp(30px,4.6cqh,38px);margin:0;padding:3px 12px;
 border:1px solid #b38c58;border-radius:8px;
 color:#674a29;font-size:var(--font-note);
}
.home-activities-scroll .workshop-supply-actions button:disabled{opacity:.56;cursor:not-allowed;}
.workshop-supply-note{font-size:var(--font-note);color:#956849;}
.workshop-preview-material-list{display:flex;flex-wrap:wrap;align-items:baseline;gap:0 6px;min-width:0;font-size:var(--font-body);font-weight:600;color:#61462d;}
.workshop-preview-material{display:inline-flex;align-items:baseline;white-space:nowrap;}
.workshop-preview-material:not(:last-child)::after{content:'、';color:#876d4d;}
.workshop-preview-amount{color:#61462d;}
.workshop-preview-shortage{color:#a33f36;}
.workshop-preview-output-detail{display:flex;align-items:baseline;justify-content:space-between;gap:3px 12px;flex-wrap:wrap;min-width:0;}
.workshop-preview-meta{font-size:var(--font-note);color:#66704f;white-space:nowrap;}
@container (max-width:340px){.workshop-preview-output-detail{gap:2px 8px;}.workshop-preview-meta{white-space:normal;}}
@media (orientation:landscape) and (max-height:450px){.workshop-field :is(select,input){min-height:32px;}.workshop-preview-lines{padding-block:3px;}}
.workshop-art-placeholder {display:none;}
.workshop-missing-art .workshop-type-art {display:none;}
.workshop-missing-art .workshop-art-placeholder {display:flex;flex:1;min-height:0;align-items:center;justify-content:center;font-size:clamp(36px,10cqh,80px);color:#8e7652;}

/* Shop hub now mirrors farm and workshop entry cards, with its own dialog. */
.shops-page .home-activities-scroll.shop-home{display:flex;flex-direction:column;overflow:hidden;}
.shop-entrances{
 display:grid;grid-template-columns:repeat(3,minmax(0,1fr));
 gap:clamp(6px,1.4cqw,18px);flex:1;min-height:0;min-width:0;padding:2px;
}
.shop-type-art{display:block;width:100%;height:0;flex:1;min-height:0;object-fit:contain;pointer-events:none;}
.shop-entrances strong{font-size:clamp(20px,3cqw,32px);letter-spacing:.12em;}
.shop-entrances span{font-size:var(--font-note);text-align:center;}
.shop-dialog .industry-form{min-width:0;max-width:100%;box-sizing:border-box;}
.shop-dialog .industry-form label{min-width:0;}
.shop-dialog .industry-form :is(input,select){max-width:100%;}
.shop-dialog .economy-reason{margin-top:5px;}
/* Processing is drawn larger than the other workshop illustrations. */
.workshop-entrances [data-workshop-type='processing'] .workshop-type-art{
 transform:scale(.82);transform-origin:center;
}

@media (orientation:landscape) and (max-height:450px){.industry-shop-art{width:clamp(96px,16cqw,160px);height:clamp(80px,20cqh,113px);}}

/* All three industry pages share a transparent illustration stage. */
html body[data-game='palace'].game-shell #game[data-page='economy'] > #tab-content.home-activities-page.economy-detail-page:is(.farm-page,.workshop-page,.shops-page,.routes-page) .home-activities-folio{
 width:100%;max-width:none;margin:0;padding:0;
 border:0;border-radius:0;background:transparent;box-shadow:none;
}
#game[data-page='economy'] .economy-detail-page:is(.farm-page,.workshop-page,.shops-page,.routes-page) .home-activities-folio > .dossier-ornament{display:none;}
#game[data-page='economy'] .economy-detail-page:is(.farm-page,.workshop-page,.shops-page,.routes-page) .home-activities-scroll{padding:clamp(2px,.5cqw,7px);}
/* The existing title slot becomes an actual purchase / clearing toolbar. */
.economy-management-heading{
 display:flex;align-items:center;gap:clamp(8px,1.2cqw,18px);
 min-width:0;flex-wrap:wrap;
}
.home-activities-heading .economy-management-heading button{
 margin:0;min-height:clamp(34px,5.2cqh,44px);
 padding:5px clamp(12px,1.5cqw,20px);font-size:var(--font-body);
 border:1px solid var(--palace-gold,rgba(174,131,67,.70));
 border-radius:11px;color:var(--palace-ink,#513724);

 box-shadow:inset 0 0 0 3px rgba(255,249,232,.48),inset 0 0 0 4px var(--palace-inset,rgba(205,164,99,.44));
}
.home-activities-heading .economy-management-heading button:disabled{opacity:.55;cursor:not-allowed;}
.economy-managed-count{color:#6c5134;font-size:var(--font-body);white-space:nowrap;}
.industry-purchase-dialog .industry-purchase-options{
 display:grid;grid-template-columns:repeat(3,minmax(0,1fr));
 gap:clamp(6px,1cqw,12px);min-width:0;
}
.industry-purchase-dialog .industry-purchase-options button{
 width:100%;min-width:0;min-height:clamp(50px,9cqh,72px);margin:0;padding:8px 6px;
 border:1px solid var(--palace-gold,rgba(174,131,67,.70));border-radius:11px;

 box-shadow:inset 0 0 0 3px rgba(255,249,232,.48),inset 0 0 0 4px var(--palace-inset,rgba(205,164,99,.44));
}
@media (max-width:540px){
 .industry-purchase-dialog .industry-purchase-options{grid-template-columns:minmax(0,1fr);}
}


/* A full-stage directory shares the merchant preparation paper, not the modal. */
.merchant-directory-page .merchant-directory-stage{
 display:flex;flex-direction:column;flex:1;min-width:0;min-height:0;
 width:100%;height:100%;box-sizing:border-box;overflow:hidden;
 background:url('/public/assets/backgrounds/ui/quiet-paper.webp') center/cover;
 color:#63472f;container-type:size;
}
.merchant-directory-stage-header{
 display:flex;align-items:center;gap:clamp(10px,1.8cqw,24px);flex:none;
 min-height:clamp(43px,8cqh,66px);
 padding:clamp(5px,1cqh,11px) clamp(17px,2.2cqw,33px);
 box-sizing:border-box;border-bottom:1px solid rgba(164,123,73,.28);
}
.merchant-directory-stage-title{margin:0;font-size:var(--font-heading);color:#65472d;line-height:1.15;}
html body[data-game='palace'] #game .merchant-directory-stage-back{
 flex:none;box-sizing:border-box;width:clamp(125px,13cqw,165px);
 min-width:0;min-height:clamp(33px,5.5cqh,44px);
 margin:0;padding:3px clamp(9px,1.3cqw,18px);
 font-size:var(--font-body);white-space:nowrap;
}
.merchant-directory-stage-body{
 flex:1;min-width:0;min-height:0;overflow-y:auto;
 scrollbar-width:thin;overscroll-behavior:contain;
 padding:clamp(10px,2.1cqh,24px) clamp(20px,4cqw,76px);
 box-sizing:border-box;
}
.merchant-directory-stage-content{
 width:100%;max-width:1180px;margin:0 auto;
 font-size:var(--font-body);line-height:1.5;
}
.merchant-directory-stage-content .merchant-directory-year{margin:0 0 7px;color:#67472e;}
.merchant-directory-stage-content > small{display:block;color:#80694d;margin-bottom:clamp(10px,1.5cqh,18px);}
.merchant-directory-stage-content .merchant-directory-list{display:flex;flex-direction:column;gap:clamp(6px,1.1cqh,12px);}
.merchant-directory-stage-content .merchant-house-row{
 display:grid;grid-template-columns:clamp(26px,3cqw,40px) minmax(0,1fr) auto;
 align-items:center;gap:clamp(8px,1.3cqw,18px);
 width:100%;min-width:0;box-sizing:border-box;
 margin:0;padding:clamp(8px,1.35cqh,15px) clamp(12px,1.7cqw,22px);
 min-height:clamp(55px,9cqh,90px);text-align:left;
 border:1px solid var(--palace-gold,rgba(174,131,67,.70));border-radius:15px;
 color:var(--palace-ink,#513724);background:rgba(255,253,248,.82);
 box-shadow:inset 0 0 0 3px rgba(255,250,235,.9),inset 0 0 0 4px var(--palace-inset,rgba(205,164,99,.44)),0 3px 9px rgba(44,28,11,.12);
 font:inherit;cursor:pointer;
}
.merchant-directory-stage-content .merchant-house-row:is(:hover,:focus-visible){border-color:#956829;background:rgba(255,255,251,.94);}
.merchant-directory-stage-content .merchant-house-row:focus-visible{outline:2px solid #917039;outline-offset:2px;}
.merchant-directory-stage-content .merchant-house-row :is(strong,small){overflow-wrap:anywhere;}
.merchant-directory-stage-content .merchant-house-rank{font-size:var(--font-section);}
.merchant-directory-stage-content .merchant-house-main{min-width:0;}
.merchant-directory-stage-content .merchant-house-value{flex:none;text-align:right;}
.merchant-directory-stage-content .merchant-directory-mine{margin-top:clamp(9px,1.5cqh,17px);}
@media (orientation:landscape) and (max-height:450px){
 .merchant-directory-stage-header{min-height:40px;padding:3px 16px;}
 .merchant-directory-stage-body{padding:7px 18px 9px;}
 .merchant-directory-stage-content .merchant-house-row{min-height:48px;padding:6px 12px;}
}

/* Merchant routes occupy the entire game stage, like the Shuanglu board.
   No economy parchment behind the map; city hotspots retain map coordinates. */
html body[data-game='palace'].game-shell #game[data-page='economy']:has(> #tab-content.merchant-stage){
 padding:0;background:#e7ce9d;
}
html body[data-game='palace'].game-shell #game > #tab-content.home-activities-page.merchant-stage{
 gap:0;padding:0;margin:0;width:100%;height:100%;background:transparent;
}
.routes-page .home-activities-scroll.merchant-home{
 position:relative;display:flex;flex-direction:column;flex:1;
 width:100%;height:100%;min-height:0;gap:0;overflow:hidden;padding:0;
}
.merchant-map-area{
 position:relative;display:flex;align-items:center;justify-content:center;flex:1;
 min-width:0;min-height:0;width:100%;overflow:hidden;container-type:size;
}
.merchant-map{
 position:absolute;left:50%;top:50%;flex:none;
 width:max(100cqw,calc(100cqh * 1672 / 941));aspect-ratio:1672 / 941;
 transform:translate(-50%,-50%);transform-origin:center;
}
.economy-routes-map{display:block;width:100%;height:100%;object-fit:contain;border-radius:0;}
.merchant-map-overlay{position:absolute;inset:0;width:100%;height:100%;pointer-events:none;}
.merchant-map-overlay polyline{fill:none;stroke:#9c362b;stroke-width:5;stroke-dasharray:10 9;opacity:.86;}
.merchant-fleet-marker{fill:none;stroke:#f3e7af;stroke-width:9;paint-order:stroke;filter:drop-shadow(0 0 3px #5b381d);}
.home-activities-scroll .merchant-city{
 position:absolute;transform:translate(-50%,-50%);width:5%;height:9%;
 min-width:30px;min-height:30px;padding:0;margin:0;border:0;border-radius:50%;
 background:transparent;box-shadow:none;font-size:clamp(16px,2.5vw,27px);
 line-height:1;text-shadow:0 0 3px #fff;
}
.home-activities-scroll .merchant-city[data-merchant-connection="closed"]{color:#6b5c50;}
.home-activities-scroll .merchant-city[data-merchant-connection="opening"]{color:#9b650c;}
.home-activities-scroll .merchant-city[data-merchant-connection="open"]{color:#982421;}
.home-activities-scroll .merchant-city:focus-visible{outline:3px solid #a32522;outline-offset:1px;}
.home-activities-scroll .merchant-city:is(:hover,[aria-pressed="true"]){background:#a3252224;outline:2px solid rgba(141,68,42,.56);outline-offset:1px;}
.merchant-toolbar{
 position:absolute;z-index:14;top:clamp(10px,2cqh,22px);right:clamp(10px,1.4cqw,22px);
 display:flex;flex-direction:column;align-items:stretch;gap:clamp(8px,1.4cqh,14px);
 width:clamp(82px,9.5cqw,122px);padding:0;margin:0;
 background:transparent;border:0;box-shadow:none;
}
.home-activities-scroll .merchant-toolbar button,
.home-activities-scroll .merchant-exit{
 margin:0;box-sizing:border-box;min-height:clamp(34px,5.3cqh,44px);
 border:1px solid #ad8958;border-radius:10px;
 color:#644527;
 box-shadow:inset 0 0 0 2px rgba(255,247,226,.66),0 3px 10px rgba(75,45,22,.20);
 font-size:var(--font-body);font-weight:600;letter-spacing:.04em;
 white-space:nowrap;text-align:center;
}
.home-activities-scroll .merchant-toolbar button{width:100%;max-width:none;padding:5px 10px;}
.home-activities-scroll .merchant-toolbar button[aria-current="true"]{
 background:#e5c994;border-color:#967043;
}
.home-activities-scroll .merchant-exit{
 position:absolute;z-index:14;right:clamp(10px,1.4cqw,22px);
 bottom:clamp(10px,2cqh,22px);width:clamp(82px,9.5cqw,122px);
 padding:5px 12px;
}
.home-activities-scroll .merchant-toolbar button:hover,
.home-activities-scroll .merchant-exit:hover{background:#ffeed0;}
/* The city card sits on the map; operations open one temporary parchment dialog. */
.merchant-city-card{
 position:absolute;z-index:17;top:35%;left:clamp(12px,2.5cqw,34px);
 width:clamp(220px,23cqw,305px);max-width:calc(100% - 24px);
 box-sizing:border-box;padding:clamp(9px,1.4cqh,15px) clamp(11px,1.4cqw,18px);
 border:1px solid #a68151;border-radius:12px;
 background:linear-gradient(145deg,rgba(251,235,203,.97),rgba(238,212,166,.97));
 box-shadow:0 8px 25px #43321d65,inset 0 0 0 3px #fff8e687;
 color:#5c402a;
}
.merchant-city-card[data-side="right"]{left:auto;right:clamp(12px,2.5cqw,34px);}
.merchant-city-card[data-vertical="bottom"]{top:auto;bottom:15%;}
.merchant-city-card-heading{display:flex;align-items:center;justify-content:space-between;gap:10px;border-bottom:1px solid #b6936266;padding-bottom:5px;}
.home-activities-scroll .merchant-city-card-heading h3{margin:0;font-size:var(--font-section);line-height:1.2;color:#654628;}
.home-activities-scroll .merchant-city-card-heading button{
 min-width:28px;min-height:28px;margin:0;padding:0 6px;
 font-size:var(--font-body);border-radius:6px;
}
.home-activities-scroll .merchant-city-card p{
 margin:6px 0;font-size:var(--font-note);line-height:1.45;
}
.merchant-city-meta{color:#87603a;font-weight:600;}
.merchant-city-actions{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:5px;}
.merchant-city-waiting{display:block;grid-column:1/-1;padding:8px 9px;border:1px solid #b9956d80;border-radius:7px;text-align:center;background:#ede0c6b8;color:#765c3e;font-size:var(--font-note);}
.home-activities-scroll .merchant-city-actions button{
 min-width:0;min-height:32px;max-width:none;margin:0;padding:5px 7px;
 border-radius:7px;font-size:var(--font-note);
}
.home-activities-scroll .merchant-city-actions button:first-child:last-child{grid-column:1/-1;}
/* City actions use a single full 16:9 stage. The underlying route map is
   unmounted while trading, planning or browsing local merchant information. */
.merchant-action-page .merchant-action-stage{
 display:flex;flex-direction:column;flex:1;min-width:0;min-height:0;
 width:100%;height:100%;box-sizing:border-box;overflow:hidden;
 background:url('/public/assets/backgrounds/ui/quiet-paper.webp') center/cover;
 color:#63472f;container-type:size;
}
.merchant-action-stage-header{
 display:flex;align-items:center;gap:clamp(10px,1.8cqw,24px);flex:none;
 min-height:clamp(43px,8cqh,66px);
 padding:clamp(5px,1cqh,11px) clamp(17px,2.2cqw,33px);
 box-sizing:border-box;border-bottom:1px solid rgba(164,123,73,.28);
}
.merchant-action-stage-title{margin:0;font-size:var(--font-heading);color:#65472d;line-height:1.15;}
html body[data-game='palace'] #game .merchant-action-stage-back{
 flex:none;box-sizing:border-box;min-width:clamp(125px,13cqw,165px);
 min-height:clamp(33px,5.5cqh,44px);margin:0;
 padding:3px clamp(9px,1.3cqw,18px);font-size:var(--font-body);white-space:nowrap;
}
.merchant-action-stage-body{
 flex:1;min-width:0;min-height:0;overflow-y:auto;scrollbar-width:thin;
 overscroll-behavior:contain;box-sizing:border-box;
 padding:clamp(10px,2.1cqh,24px) clamp(20px,4cqw,76px);
}
.merchant-action-stage .merchant-action-stage-content{
 display:flex;flex:none;flex-direction:column;gap:clamp(6px,1cqh,12px);
 width:100%;max-width:1180px;max-height:none;min-width:0;min-height:0;
 margin:0 auto;padding:0;box-sizing:border-box;overflow:visible;
 font-size:var(--font-body);line-height:1.5;
}
.merchant-action-stage-content :is(h4,p){margin:0;}
.merchant-action-stage-content h4{font-size:var(--font-section);}
.merchant-action-stage-content .merchant-form{width:100%;max-width:960px;gap:clamp(6px,1cqh,12px);}
.merchant-action-stage-content .merchant-reason{line-height:1.5;}
.merchant-action-stage-content .merchant-form button{font-size:var(--font-body);min-height:clamp(34px,5.5cqh,44px);}
.merchant-action-stage-content .merchant-field :is(select,input){min-height:clamp(34px,5.5cqh,44px);}
@media (orientation:landscape) and (max-height:450px){
 .merchant-action-stage-header{min-height:40px;padding:3px 16px;}
 .merchant-action-stage-body{padding:7px 18px 9px;}
}
/* Returning home transfers leftover goods without an automatic sale. */
.merchant-action-stage-content .merchant-return-stock-list,
.merchant-trip-report .merchant-return-stock-list{
 display:flex;flex-direction:column;gap:clamp(6px,.9cqh,11px);
 width:100%;max-width:900px;box-sizing:border-box;
 padding:clamp(11px,1.7cqh,19px) clamp(14px,1.7cqw,24px);
 border:1px solid rgba(161,124,72,.34);border-radius:13px;
 background:rgba(255,250,235,.61);
}
.merchant-action-stage-content .merchant-return-stock-row,
.merchant-trip-report .merchant-return-stock-row{
 display:flex;flex-wrap:wrap;justify-content:space-between;align-items:center;
 gap:clamp(10px,1.5cqw,18px);font-size:var(--font-body);
}
.merchant-action-stage-content .merchant-return-stock-row strong,
.merchant-trip-report .merchant-return-stock-row strong{font-weight:650;}
.merchant-cash-details{
 display:grid;grid-template-columns:repeat(2,minmax(0,1fr));
 gap:clamp(9px,1.4cqw,17px);width:100%;max-width:900px;
}
.merchant-cash-detail{
 display:flex;align-items:baseline;justify-content:space-between;
 gap:clamp(8px,1cqw,14px);padding:clamp(8px,1.3cqh,13px);
 border-bottom:1px solid rgba(148,108,65,.25);
 font-size:var(--font-body);color:#775a3d;
}
.merchant-cash-detail strong{font-weight:650;color:#62452e;}
.merchant-action-stage-content .merchant-return-actions{
 display:flex;flex-wrap:wrap;align-items:center;gap:clamp(9px,1.5cqw,19px);
 width:100%;max-width:900px;margin-top:clamp(6px,1cqh,12px);
}
.merchant-action-stage-content .merchant-return-actions button{
 min-width:clamp(155px,19cqw,270px);margin:0;
}
.merchant-trip-report{
 display:flex;flex-direction:column;gap:clamp(8px,1.3cqh,16px);
 margin:clamp(10px,1.7cqh,20px) 0;padding:clamp(15px,2cqh,24px);
 background:rgba(255,249,230,.64);border:1px solid rgba(165,127,74,.32);
 border-radius:13px;
}
.merchant-trip-report h4,.merchant-trip-report p{margin:0;}
.merchant-trip-report-label{font-weight:650;}
@media (max-width:650px){
 .merchant-cash-details{grid-template-columns:minmax(0,1fr);}
}

/* Merchant city pages: overview first, operations in their own pages. */
.merchant-action-stage-content .merchant-city-summary{
 display:flex;flex-direction:column;gap:clamp(9px,1.7cqh,18px);
 width:100%;max-width:970px;box-sizing:border-box;padding:clamp(8px,1.2cqh,12px) 0 clamp(11px,1.7cqh,18px);
}
.merchant-action-stage-content .merchant-city-summary-head{
 display:flex;align-items:center;justify-content:flex-end;min-height:clamp(24px,3.4cqh,36px);
}
.merchant-action-stage-content .merchant-city-connection{
 display:inline-block;font-size:var(--font-note);font-weight:650;line-height:1.35;
 padding:clamp(3px,.5cqh,6px) clamp(9px,1.2cqw,16px);
 border:1px solid rgba(103,125,82,.33);border-radius:20px;
 background:rgba(232,238,218,.55);color:#596343;
}
.merchant-action-stage-content .merchant-city-advantages{
 display:grid;grid-template-columns:repeat(2,minmax(0,1fr));
 gap:clamp(16px,3cqw,42px);width:100%;font-size:var(--font-body);line-height:1.55;
}
.merchant-action-stage-content .merchant-city-advantage{min-width:0;}
.merchant-action-stage-content .merchant-city-advantage>span{font-size:var(--font-note);color:#907456;}
.merchant-action-stage-content .merchant-city-advantage>p{margin:clamp(3px,.5cqh,7px) 0 0;color:#63472f;font-weight:600;}
.merchant-action-stage-content .merchant-market-note{
 font-size:var(--font-note);color:#795637;line-height:1.5;
 padding:clamp(7px,1.2cqh,12px) clamp(10px,1.2cqw,16px);
 background:rgba(252,240,213,.55);border-left:3px solid #a98554;
}
.merchant-action-stage-content .merchant-city-entry-actions{
 display:flex;flex-wrap:wrap;gap:clamp(8px,1.2cqw,15px);
 padding:clamp(8px,1.5cqh,16px) 0;
}
.merchant-action-stage-content .merchant-city-entry-actions button{min-width:clamp(150px,16cqw,220px);margin:0;}
.merchant-action-stage-content .merchant-city-news,
.merchant-action-stage-content .merchant-city-houses{
 display:flex;flex-direction:column;gap:clamp(6px,.9cqh,12px);
 padding:clamp(9px,1.5cqh,16px) 0;border-top:1px solid rgba(157,123,76,.28);
}
.merchant-action-stage-content .merchant-city-news>button{align-self:flex-start;}
.merchant-action-stage-content .merchant-city-houses{
 flex-direction:column;align-items:flex-start;
 gap:clamp(8px,1.2cqh,14px);width:100%;max-width:970px;
 padding:clamp(12px,1.9cqh,20px) 0;
}
.merchant-action-stage-content .merchant-city-houses>strong{
 font-size:var(--font-body);font-weight:650;white-space:nowrap;
}
.merchant-action-stage-content .merchant-city-house-links{
 display:flex;align-items:center;flex-wrap:wrap;
 gap:clamp(8px,1.2cqw,15px);width:100%;
}
.merchant-action-stage-content .merchant-city-house-links button{
 margin:0;min-width:clamp(150px,16cqw,220px);
}
.merchant-action-stage-content .merchant-city-entry-actions{
 margin:0;max-width:970px;border-top:1px solid rgba(157,123,76,.28);
}

.merchant-action-stage-content .merchant-trade-card{
 display:flex;flex-direction:column;align-items:flex-start;gap:clamp(8px,1.2cqh,14px);
 padding:clamp(10px,1.7cqh,18px) clamp(13px,1.9cqw,24px);
 border:1px solid rgba(173,133,74,.35);border-radius:14px;
 background:rgba(255,250,237,.62);max-width:960px;
}
.merchant-action-stage-content .merchant-trade-card>strong{font-size:var(--font-body);}
.merchant-action-stage-content .merchant-trade-item-head{
 display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;
 width:100%;gap:clamp(6px,1cqw,13px);
}
.merchant-action-stage-content .merchant-trade-item-head>strong{font-size:var(--font-body);}
.merchant-action-stage-content .merchant-trade-item-head>span{font-size:var(--font-note);color:#755a40;}
.merchant-action-stage-content .merchant-trade-summary{
 display:flex;flex-wrap:wrap;align-items:baseline;gap:clamp(9px,1.4cqw,18px);
 width:100%;font-size:var(--font-body);font-weight:400;color:#715334;
}
.merchant-action-stage-content .merchant-trade-summary>strong{
 font-size:clamp(19px,2.5cqw,30px);font-weight:700;color:#63472f;
}
.merchant-action-stage-content .merchant-trade-summary>small{
 flex-basis:100%;font-size:var(--font-note);font-weight:400;color:#886e4e;
}

.merchant-action-stage-content .merchant-trade-card>button[type=submit],
.merchant-action-stage-content .merchant-depart-form>button[type=submit]{
 min-width:clamp(150px,18cqw,240px);align-self:flex-start;
}

.merchant-action-stage-content .merchant-depart-form{
 display:flex;flex-direction:column;gap:clamp(9px,1.3cqh,15px);max-width:960px;
}
.merchant-quantity-field{
 display:flex;align-items:center;flex-wrap:wrap;gap:clamp(7px,1cqw,15px);min-width:0;
}
.merchant-quantity-field>span{min-width:clamp(80px,11cqw,140px);}
.merchant-quantity-stepper{display:flex;align-items:center;flex-wrap:wrap;gap:clamp(3px,.55cqw,8px);}
.merchant-action-stage-content .merchant-quantity-stepper input{
 flex:none;box-sizing:border-box;min-height:clamp(34px,5.3cqh,42px);
 width:clamp(42px,5.8cqw,75px);padding:3px 5px;text-align:center;
 border:0;border-bottom:1px solid rgba(154,119,73,.55);border-radius:0;
 background:rgba(255,253,246,.46);box-shadow:none;appearance:textfield;
 font-size:var(--font-body);font-weight:600;color:#62452d;
}
.merchant-quantity-stepper input::-webkit-inner-spin-button,
.merchant-quantity-stepper input::-webkit-outer-spin-button{-webkit-appearance:none;margin:0;}
#game .merchant-action-stage-content .merchant-quantity-stepper button{
 position:static;z-index:auto;display:inline-flex;justify-content:center;align-items:center;
 flex:none;width:auto;min-width:clamp(30px,3.4cqw,44px);
 min-height:clamp(32px,5.5cqh,42px);margin:0;padding:3px 7px;
 border:1px solid rgba(181,141,83,.60);border-radius:19px;
 background:rgba(245,226,187,.78);background-image:none;box-shadow:inset 0 0 0 2px rgba(255,249,227,.5);
 color:#67492c;font-size:var(--font-note);font-weight:600;white-space:nowrap;
}
#game .merchant-action-stage-content .merchant-quantity-stepper button.workshop-step-max{min-width:clamp(43px,5cqw,60px);}
#game .merchant-action-stage-content .merchant-quantity-stepper button:is(:hover,:focus-visible):not(:disabled){background:#e7c88f;border-color:#ad8754;}
#game .merchant-action-stage-content .merchant-quantity-stepper button:disabled{opacity:.42;cursor:default;}
/* Merchant office pages are separate: financial overview, caravan management,
   letters, records, and the independent two-part trade intelligence folio. */
.merchant-office .merchant-market-heading{display:flex;align-items:center;justify-content:space-between;gap:10px;}
.merchant-office .merchant-market-heading h4{margin:0;}
.merchant-office .merchant-market-grid{
 display:grid;grid-template-columns:repeat(2,minmax(0,1fr));
 gap:clamp(8px,1.5cqw,18px);margin-top:clamp(8px,1.5cqh,16px);
}
.merchant-office .merchant-market-report{
 display:flex;flex-direction:column;gap:clamp(6px,.9cqh,11px);min-width:0;
 padding:clamp(10px,1.5cqh,17px) clamp(11px,1.4cqw,20px);
 border:1px solid rgba(165,123,66,.35);border-radius:12px;
 background:rgba(255,250,235,.66);
}
.merchant-office .merchant-market-report :is(h4,p,small){margin:0;line-height:1.5;}
.merchant-office .merchant-market-report small{display:block;font-size:var(--font-note);color:#80674b;}
.merchant-office .merchant-market-report button{align-self:flex-start;margin-top:auto;}
.merchant-office .merchant-opportunity{
 padding:clamp(10px,1.7cqh,20px);margin:clamp(8px,1.5cqh,16px) 0;
 border:1px solid rgba(166,126,70,.32);border-radius:12px;
 background:rgba(255,250,235,.58);
}
@media (max-width:650px){
 .merchant-office .merchant-market-grid{grid-template-columns:minmax(0,1fr);}
}
@media (max-width:650px){
 .merchant-action-stage-content .merchant-city-advantages{grid-template-columns:minmax(0,1fr);gap:10px;}
}

@media (orientation:landscape) and (max-height:450px){
 .merchant-action-stage-content .merchant-trade-card{gap:5px;padding:8px 12px;}
 .merchant-action-stage-content .merchant-quantity-stepper{gap:3px;}
 #game .merchant-action-stage-content .merchant-quantity-stepper button{min-height:32px;padding:2px 6px;}
}

/* Original merchant-modal rules are retained for other dialogs until the
   merchant page reorganization is handled separately. */

/* Native modal has its own top layer and backdrop; its body scrolls instead of
   growing beyond the landscape stage. */
.merchant-modal{
 position:fixed;top:50%;left:50%;right:auto;bottom:auto;
 transform:translate(-50%,-50%);margin:0;box-sizing:border-box;
 width:min(84vw,640px);max-width:calc(100vw - 30px);
 max-height:min(88vh,630px);height:max-content;min-height:0;padding:0;
 border:1px solid #a78150;border-radius:14px;
 color:#59412a;background:linear-gradient(145deg,#f8e5c3,#ebcea2);
 box-shadow:0 16px 45px #1b140f80,inset 0 0 0 4px #fff6e675;
 overflow:hidden;
}
.merchant-modal[open]{display:flex;flex-direction:column;justify-content:flex-start;align-items:stretch;}
.merchant-modal::backdrop{background:rgba(26,23,19,.44);}
.merchant-modal[data-size="compact"]{width:min(78vw,460px);}
.merchant-modal[data-size="wide"]{width:min(89vw,830px);}
.merchant-modal-heading{
 flex:0 0 auto;display:flex;align-items:center;justify-content:space-between;gap:12px;
 height:auto;min-height:0;margin:0;
 padding:clamp(6px,1.2cqh,10px) clamp(13px,1.8cqw,24px);
 border-bottom:1px solid #b9986880;
}
.merchant-modal-heading h3{flex:1;min-width:0;margin:0;font-size:var(--font-section);line-height:1.2;color:#68492d;}
.merchant-modal-heading button{
 flex:none;margin:0;min-height:30px;padding:3px 12px;box-sizing:border-box;
}
.merchant-modal-body{
 flex:0 1 auto;min-height:0;max-height:100%;overflow-y:auto;
 overscroll-behavior:contain;scrollbar-width:thin;
 box-sizing:border-box;padding:clamp(10px,1.8cqh,20px) clamp(13px,1.8cqw,25px) clamp(12px,2cqh,22px);
 font-size:var(--font-note);line-height:1.55;
}
.merchant-modal-body :is(h4,p){margin:6px 0;}
.merchant-modal-body h4{font-size:var(--font-body);color:#674b30;}
.merchant-modal-body button{max-width:100%;box-sizing:border-box;margin:3px 3px 3px 0;min-height:33px;padding:5px 11px;font-size:var(--font-note);white-space:normal;border-radius:8px;}
.merchant-panel-tabs{
 display:flex;gap:6px;min-width:0;margin:0 0 12px;padding:0 0 8px;
 border-bottom:1px solid #b48e5e80;
}
.merchant-panel-tabs button{flex:1;min-width:0;white-space:nowrap;margin:0;}
.merchant-panel-tabs button[aria-current="true"]{background:#d9b982;border-color:#99703d;font-weight:700;}
.merchant-fleet-summary{font-weight:700;color:#655039;}
.merchant-panel-receipt{border-left:3px solid #85946d;padding:4px 8px;background:#82926917;}
.merchant-form{display:flex;flex-direction:column;gap:6px;padding:6px 0;}
.merchant-field{display:flex;flex-wrap:wrap;align-items:center;gap:5px;min-width:0;}
.merchant-field>span{flex:none;}
.merchant-field :is(select,input){
 min-height:33px;max-width:100%;min-width:0;box-sizing:border-box;padding:4px 8px;
 font:inherit;color:inherit;background:#fff5dfb8;border:1px solid #bba482;border-radius:7px;
}
.merchant-field input{width:7em;}
.merchant-reason{font-size:var(--font-note);color:#80694d;}
.merchant-preparation-stage .merchant-charter-form{
 display:grid;grid-template-columns:minmax(0,1fr) max-content;align-items:end;
 gap:clamp(4px,.8cqh,8px) clamp(9px,1.5cqw,20px);min-width:0;width:100%;
}
.merchant-preparation-stage .merchant-charter-form label{grid-column:1;display:flex;flex-direction:column;gap:4px;min-width:0;}
.merchant-preparation-stage .merchant-charter-form input{
 box-sizing:border-box;width:100%;min-width:0;min-height:clamp(34px,5.5cqh,44px);
 padding:4px 10px;border:1px solid #b89d70;border-radius:9px;
 background:rgba(255,251,240,.88);font:inherit;color:#65472d;
}
.merchant-preparation-stage .merchant-charter-form .merchant-reason{grid-column:1;grid-row:2;margin:0;}
.merchant-preparation-stage .merchant-charter-form button{grid-column:2;grid-row:1/3;align-self:center;min-width:clamp(130px,18cqw,210px);}
@media (max-width:640px){
 .merchant-preparation-stage .merchant-charter-form{grid-template-columns:minmax(0,1fr);}
 .merchant-preparation-stage .merchant-charter-form button{grid-column:1;grid-row:auto;justify-self:end;}
}
.merchant-trip-heading{font-size:var(--font-body);font-weight:700;color:#674b30;}
.merchant-depart-summary{line-height:1.6;color:#76543a;}
.merchant-letter{border-bottom:1px solid #bba48288;padding-bottom:10px;}
.merchant-letter-story p,.merchant-letter-outcome p{white-space:pre-wrap;line-height:1.65;overflow-wrap:anywhere;}
.merchant-letter-context{font-size:var(--font-note);color:#7d684e;}
.merchant-letter-outcome{margin:10px 0;padding-left:10px;border-left:2px solid #a78453;}
.merchant-event-settlement{padding:8px 10px;margin:10px 0;background:#a7845314;border:1px solid #bba48266;font-size:var(--font-note);}
.merchant-event-settlement h5{margin:0 0 5px;}
.merchant-letter-option{display:flex;flex-direction:column;align-items:flex-start;gap:3px;margin:7px 0;}
.merchant-letter-option button{max-width:100%;white-space:normal;overflow-wrap:anywhere;text-align:left;}
.merchant-letter-option small{padding:0 4px;color:#7d684e;overflow-wrap:anywhere;}
.merchant-modal .industry-table{width:100%;table-layout:fixed;overflow-wrap:anywhere;font-size:var(--font-note);}
@media (orientation:landscape) and (max-height:450px){
 .merchant-toolbar{top:8px;right:8px;gap:6px;width:clamp(77px,9.4cqw,112px);}
 .home-activities-scroll .merchant-toolbar button,
 .home-activities-scroll .merchant-exit{min-height:32px;padding:4px 6px;font-size:var(--font-note);}
 .home-activities-scroll .merchant-exit{right:8px;bottom:8px;width:clamp(77px,9.4cqw,112px);}
 .merchant-city-card{top:28%;max-height:70%;overflow-y:auto;}
 .merchant-city-card[data-vertical="bottom"]{top:auto;bottom:12%;}
 .merchant-modal{max-height:89vh;}
 .merchant-modal-heading{padding:6px 12px;}
 .merchant-modal-body{padding:8px 12px 12px;}
}



/* Completion lives in the top layer, never above or inside the craft tree. */
.handcraft-result-dialog > h3{margin:0;padding:clamp(16px,3cqh,26px);font-size:var(--font-section);text-align:center;}
.handcraft-result-dialog .handcraft-dialog-actions{justify-content:center;gap:12px;}
.handcraft-result-error{margin:0;padding:0 16px 12px;color:#a34435;font-size:var(--font-note);}


/* Building management replaces the entrance grid: transparent art on the left,
   in-page operations on the right. Only the controls column scrolls. */
.home-activities-scroll.industry-building-home {display:flex;flex-direction:column;min-height:0;overflow:hidden;}
.industry-building-layout{
 display:grid;grid-template-columns:minmax(0,1.7fr) minmax(0,3.3fr);
 flex:1;min-height:0;min-width:0;gap:clamp(10px,2cqw,28px);
 padding:clamp(3px,.8cqw,12px);
}
.industry-building-aside{display:flex;flex-direction:column;min-width:0;min-height:0;gap:clamp(6px,1cqh,12px);}
.industry-building-art-frame{display:flex;flex-direction:column;align-items:center;flex:1;min-width:0;min-height:0;padding:clamp(2px,.5cqh,7px);box-sizing:border-box;border:0;border-radius:0;background:transparent;box-shadow:none;}
.home-activities-scroll .industry-building-art-title{flex:none;margin:0;font-size:clamp(24px,2.9cqw,35px);font-weight:700;line-height:1.18;letter-spacing:.12em;color:#60472f;text-align:center;}
.industry-building-art-window{display:flex;justify-content:center;align-items:center;flex:1;min-height:0;width:100%;overflow:visible;}
.industry-building-art{display:block;max-width:100%;max-height:100%;width:100%;height:100%;object-fit:contain;pointer-events:none;transform:scale(1.08);}
.home-activities-scroll .industry-building-art-status{flex:none;max-width:100%;margin:0 0 clamp(2px,.6cqh,6px);color:#596343;font-size:var(--font-note);font-weight:600;text-align:center;line-height:1.35;}
.industry-building-aside-footer{display:flex;align-items:center;justify-content:center;gap:clamp(7px,1cqw,14px);flex:none;flex-wrap:wrap;min-height:clamp(37px,6cqh,51px);}
.industry-building-level,.industry-building-upgrade-note{color:#745a3d;font-size:var(--font-note);}
.home-activities-scroll .industry-building-aside-footer button,
.home-activities-scroll .industry-building-decision button,
.home-activities-scroll .industry-shop-strategies button{
 margin:0;min-height:clamp(33px,5.5cqh,45px);padding:5px clamp(12px,1.6cqw,22px);
 border:1px solid var(--palace-gold,rgba(174,131,67,.70));border-radius:10px;
 color:#583e28;
 box-shadow:inset 0 0 0 3px rgba(255,249,232,.45),inset 0 0 0 4px var(--palace-inset,rgba(205,164,99,.44));
}
.home-activities-scroll:is(.workshop-home,.farm-home,.shop-home) .industry-building-aside-footer button{
 min-height:clamp(30px,4.5cqh,38px);padding:3px clamp(9px,1.2cqw,15px);
 font-size:var(--font-note);border-radius:9px;
}
.industry-building-controls{
 min-width:0;min-height:0;overflow:auto;overscroll-behavior:contain;
 display:flex;flex-direction:column;gap:clamp(7px,1cqh,12px);
 padding:3px clamp(4px,.8cqw,12px) 10px 2px;box-sizing:border-box;
}
.industry-building-controls h4:not(.farm-section-heading){margin:4px 0 1px;font-size:var(--font-section);color:#60452b;}
.industry-building-controls p{margin:3px 0;line-height:1.45;overflow-wrap:anywhere;}
.industry-building-question{font-size:var(--font-body);padding:10px 0;}
.industry-building-decision{display:flex;gap:12px;flex-wrap:wrap;}
.industry-building-controls .workshop-field{justify-content:space-between;margin:2px 0;}
.industry-building-controls .workshop-field>span{flex:none;min-width:5em;}
.industry-building-controls .workshop-field select{flex:1;max-width:75%;}
.industry-building-controls .workshop-primary-row .workshop-field>span{min-width:0;}
.industry-building-controls .workshop-primary-row .workshop-recipe-field select{width:100%;max-width:none;}
.industry-building-controls .workshop-primary-row .workshop-quantity-field{flex-wrap:nowrap;}
.industry-building-controls .farm-form-actions{margin-top:5px;}
.industry-building-controls .workshop-production{margin:0;gap:clamp(7px,1.3cqh,12px);}
.industry-building-controls .workshop-preview{border:1px solid rgba(174,131,67,.24);border-radius:11px;background:rgba(255,249,232,.24);padding:0;box-sizing:border-box;}
.workshop-notice-dialog{width:min(360px,80vw);max-width:calc(100vw - 24px);box-sizing:border-box;padding:clamp(17px,3cqh,25px);
 border:1px solid #ab874d;border-radius:12px;background:#fff1d9;color:#60472f;
 text-align:center;box-shadow:0 14px 35px #241b1544;}
.workshop-notice-dialog::backdrop{background:rgba(17,32,26,.45);}
.workshop-notice-dialog h4{margin:0 0 9px;font-size:var(--font-section);}
.workshop-notice-dialog p{margin:8px 0 16px;line-height:1.6;}
.workshop-notice-dialog button{min-height:36px;padding:5px 26px;}
.industry-building-controls .workshop-preview-output .workshop-preview-value{font-weight:600;}
.industry-building-controls .industry-building-status{margin:0;font-size:var(--font-body);color:#596343;font-weight:600;}
.industry-building-controls .workshop-deliveries summary{font-size:var(--font-note);color:#806b51;cursor:pointer;}
.industry-building-controls .workshop-production button[data-workshop-confirm]{align-self:flex-end;width:clamp(116px,50%,248px);min-height:clamp(36px,5.8cqh,44px);margin:0;padding:4px 14px;}
.industry-building-controls .workshop-order{padding:8px 0;border-top:1px solid #b8a27e66;border-bottom:0;}
.industry-building-controls .workshop-order strong{font-size:var(--font-body);}
.industry-building-controls .workshop-order p{font-size:var(--font-note);}
.industry-building-controls .workshop-orders{display:flex;flex-direction:column;gap:2px;}
/* Three shops use the same frameless building stage and compact controls. */
.shop-home .industry-building-controls{gap:clamp(9px,1.6cqh,17px);padding-top:clamp(8px,1.5cqh,17px);}
/* Tea research is a compact top-right action, parallel to the shop title. */
.shop-home.tea-shop-management .industry-building-controls{
  gap:clamp(7px,1.2cqh,12px);padding-top:clamp(4px,.8cqh,10px);
}
.industry-shop-header-actions{
  display:flex;justify-content:flex-end;align-items:center;flex:none;min-width:0;
}
.home-activities-scroll .industry-shop-header-actions .industry-shop-tea-research{
  display:inline-flex;align-items:center;justify-content:center;gap:clamp(5px,.6cqw,9px);
  box-sizing:border-box;width:auto;min-width:clamp(125px,16cqw,185px);
  min-height:clamp(33px,5.2cqh,42px);margin:0;
  padding:3px clamp(12px,1.6cqw,20px);white-space:nowrap;
  border:1px solid var(--palace-gold,rgba(174,131,67,.70));border-radius:11px;
  background:rgba(226,196,142,.45);color:#67492c;
  box-shadow:inset 0 0 0 3px rgba(255,249,232,.53),inset 0 0 0 4px var(--palace-inset,rgba(205,164,99,.44));
}
.industry-shop-tea-research::before{
  content:'❧';font-size:1.05em;line-height:1;color:#ae8347;
}
@media (orientation:landscape) and (max-height:450px){
  .shop-home.tea-shop-management .industry-building-controls{gap:5px;padding-top:2px;}
  .home-activities-scroll .industry-shop-header-actions .industry-shop-tea-research{min-height:32px;padding:2px 10px;}
}
.industry-shop-stockline,.industry-shop-policy-row,.industry-shop-recent{
 display:grid;grid-template-columns:clamp(75px,8.5cqw,108px) minmax(0,1fr);gap:clamp(8px,1.1cqw,14px);
 align-items:center;min-width:0;
}
.industry-shop-label{font-size:var(--font-body);font-weight:600;color:#65472d;white-space:nowrap;}
.industry-shop-stock-items{display:flex;flex-wrap:wrap;align-items:center;gap:3px clamp(7px,1.2cqw,15px);min-width:0;}
.industry-shop-stock-item{font-size:var(--font-body);color:#624931;white-space:normal;overflow-wrap:anywhere;}
.industry-shop-empty{font-size:var(--font-body);color:#89745a;}
.industry-building-controls .industry-shop-strategies{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:clamp(4px,.6cqw,9px);min-width:0;}
.home-activities-scroll .industry-shop-strategies button{
 min-width:0;width:100%;margin:0;min-height:clamp(32px,5.4cqh,42px);
 padding:5px 3px;font-size:var(--font-note);white-space:nowrap;
}
.home-activities-scroll .industry-shop-strategies button[aria-pressed='true']{
 background:rgba(220,197,150,.65);border-color:#97703b;color:#65462a;font-weight:700;
}
/* Shops share the warehouse and select products without moving inventory. */
.industry-shop-products{display:flex;flex-direction:column;gap:clamp(5px,.85cqh,10px);min-width:0;
 padding-top:clamp(6px,1cqh,10px);border-top:1px solid rgba(169,133,86,.28);}
.industry-building-controls .industry-shop-products>h4{margin:0;font-size:var(--font-section);}
.industry-shop-products .farm-form-note{margin:0;font-size:var(--font-note);color:#806649;}
.industry-shop-products-list{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));
 gap:clamp(5px,.75cqh,9px) clamp(7px,1.2cqw,14px);}
.industry-shop-product{display:flex;align-items:center;gap:clamp(8px,1cqw,13px);min-width:0;
 border:1px solid rgba(168,129,74,.34);border-radius:10px;background:rgba(255,250,239,.38);
 padding:clamp(5px,.8cqh,8px) clamp(8px,1.2cqw,14px);cursor:pointer;}
.industry-shop-product:has(input:checked){background:rgba(223,191,138,.40);border-color:rgba(151,112,56,.80);
 box-shadow:inset 0 0 0 2px rgba(255,251,237,.48);}
.industry-shop-product input{flex:none;width:18px;height:18px;accent-color:#967047;margin:0;}
.industry-shop-product-info{display:flex;flex-direction:column;gap:2px;min-width:0;}
.industry-shop-product-info strong{font-size:var(--font-note);color:#62452d;}
.industry-shop-product-info small{font-size:var(--font-note);color:#816b4c;line-height:1.3;}
.workshop-destination-field{margin:clamp(5px,.8cqh,8px) 0 0;}
.workshop-destination-price{margin:0;padding:clamp(4px,.6cqh,7px) clamp(8px,1.3cqw,14px);
 color:#6e5637;font-size:var(--font-note);line-height:1.36;}
@media (orientation:landscape) and (max-height:450px){
 .industry-shop-products-list{gap:4px 8px;}
 .industry-shop-product{padding:3px 7px;}
 .workshop-destination-field{margin-top:3px;}
}
.industry-shop-recent{
 padding-top:clamp(7px,1.1cqh,11px);border-top:1px solid rgba(169,133,86,.23);
 font-size:var(--font-note);color:#786045;
}
.industry-shop-recent .industry-shop-label{font-size:var(--font-note);font-weight:600;}
@media (orientation:landscape) and (max-height:450px){
 .shop-home .industry-building-controls{gap:clamp(6px,1.1cqh,10px);padding-top:3px;}
 .industry-shop-recent{padding-top:5px;}
}
.industry-building-controls .industry-form{border:0;border-top:1px solid #b8a27e66;padding:10px 0;margin:0;}
.industry-building-controls .industry-form label{flex:1;}
.industry-building-controls .industry-form :is(input,select){min-height:34px;}
@media (orientation:landscape) and (max-height:450px){
 .industry-building-layout{gap:clamp(9px,1.5cqw,22px);padding:2px 4px;}
 .industry-building-art-frame{padding:0;}
 .home-activities-scroll .industry-building-art-title{margin-top:0;font-size:clamp(23px,3cqw,31px);}
 .home-activities-scroll .industry-building-art-status{margin-bottom:clamp(3px,1cqh,8px);}
 .home-activities-scroll .workshop-stepper .workshop-step-one{min-width:30px;width:30px;height:32px;min-height:32px;}
 .home-activities-scroll .workshop-stepper button{min-height:32px;padding:2px 5px;}
 .home-activities-scroll .workshop-stepper .workshop-step-max{min-width:46px;}
 .workshop-field .workshop-stepper input{min-height:32px;}
 .industry-building-controls{gap:5px;padding-bottom:5px;}
 .industry-building-aside-footer{gap:6px;}
}

/* Charter and public directory share the existing merchant dialog. */
.merchant-charter-form{display:flex;flex-wrap:wrap;gap:8px;align-items:center;}
.merchant-charter-form label{display:flex;flex-direction:column;gap:5px;width:100%;}
.merchant-charter-form input{width:100%;min-width:0;box-sizing:border-box;}
.merchant-charter-form .merchant-reason{width:100%;margin:0;}
.merchant-directory-list{display:flex;flex-direction:column;gap:5px;margin-top:10px;}
.home-activities-scroll .merchant-house-row{display:grid;grid-template-columns:24px minmax(0,1fr) auto;gap:7px;align-items:center;width:100%;box-sizing:border-box;text-align:left;margin:0;padding:8px;white-space:normal;}
.merchant-house-main,.merchant-house-value{display:flex;flex-direction:column;gap:3px;min-width:0;overflow-wrap:anywhere;}
.merchant-house-main small,.merchant-house-value small{font-size:var(--font-note);font-weight:normal;}
.merchant-house-value{text-align:right;}
.merchant-directory-mine{border-top:1px solid #bba48288;margin-top:12px;padding-top:6px;}
.merchant-house-detail-row{overflow-wrap:anywhere;line-height:1.7;}
.merchant-valuation-note p{font-size:var(--font-note);line-height:1.7;}

.merchant-form[data-merchant-sell-product] {
 border-bottom:1px solid rgba(113,76,40,.22);
 padding-block:8px;
}

/* Merchant company pages use the shared palace dossier, not the route map. */
.merchant-office-page .home-activities-folio{max-width:1180px;}
.merchant-office{padding:clamp(4px,1cqw,12px) clamp(6px,1.4cqw,18px);}
.merchant-office .merchant-panel-tabs{position:sticky;top:0;z-index:2;background:rgba(250,239,219,.95);}
.merchant-office .merchant-panel-tabs button{margin:0;min-height:36px;padding:5px 12px;font-size:var(--font-body);}
.merchant-office :is(h4,p){margin:7px 0;}
.merchant-office h4{color:#664a2d;font-size:var(--font-section);margin-top:15px;}
.merchant-office .merchant-fleet-summary{padding:8px 12px;background:#e2d1ad50;border:1px solid #af936873;border-radius:8px;}
.merchant-office .merchant-reason{color:#7a6347;font-size:var(--font-note);}
.merchant-office .merchant-form{max-width:650px;}
.merchant-office .merchant-form button{min-height:36px;}

/* The owned merchant overview is a compact two-column ledger within the palace folio. */
.merchant-office .merchant-overview-head{
 display:flex;align-items:baseline;justify-content:space-between;flex-wrap:wrap;gap:5px 16px;
 margin:8px 0 11px;
}
.merchant-office .merchant-overview-head h4{margin:0;}
.merchant-overview-city{color:#80694d;font-size:var(--font-note);}
.merchant-overview-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:clamp(8px,1.2cqw,16px);min-width:0;}
.merchant-overview-card{
 display:flex;flex-direction:column;min-width:0;
 border:1px solid #c4a57991;border-radius:9px;
 padding:clamp(9px,1.2cqw,15px);background:#f8ecd58a;color:#64472c;
}
.merchant-overview-label{font-size:var(--font-note);color:#816849;line-height:1.4;}
.merchant-overview-figure{display:block;margin:3px 0 6px;font-size:clamp(20px,2.5cqw,29px);font-weight:700;line-height:1.3;}
.merchant-overview-change{margin:-3px 0 7px;color:#877154;font-size:var(--font-note);}
.merchant-overview-rows{display:grid;gap:5px;margin-top:auto;padding-top:8px;border-top:1px solid #ba9a6b70;}
.merchant-overview-stat{display:flex;justify-content:space-between;gap:6px 12px;align-items:baseline;font-size:var(--font-note);}
.merchant-overview-stat>span{min-width:0;color:#785d40;}
.merchant-overview-stat>strong{flex:none;text-align:right;font-weight:600;}
.merchant-overview-connected{display:flex;flex-wrap:wrap;gap:4px 10px;margin:10px 0 4px;font-size:var(--font-note);}
.merchant-overview-connected strong{color:#715237;}
.merchant-overview-connected span{color:#6d5438;}
.merchant-office .merchant-valuation-note{margin:5px 0 12px;color:#7a6347;font-size:var(--font-note);}
.merchant-office .merchant-valuation-note summary{cursor:pointer;}
@media (max-width:620px){
 .merchant-overview-grid{grid-template-columns:1fr;}
}


/* Tea research shares the building layout and its single scrolling controls column. */
.tea-research-home .industry-building-layout,
.shop-preparation-home .industry-building-layout{background:url('/public/assets/backgrounds/ui/quiet-paper.webp') center/cover;}
.tea-research-controls .tea-story-paragraph{flex:none;line-height:1.8;margin:0 0 .7em;}
/* The completed tea sale story now has its own short pages before purchase. */
.tea-qualified-pages{display:flex;flex-direction:column;min-width:0;gap:clamp(5px,.9cqh,9px);}
.tea-qualified-pages>h3{margin:0 0 clamp(4px,.8cqh,8px);font-size:var(--font-section);}
.tea-research-controls .tea-qualified-pages>.tea-story-paragraph{line-height:1.55;margin:0;}
.tea-qualified-pages>.tea-materials{margin:0;line-height:1.5;}

/* A single compact opening vignette for tea, grain and cloth shops.
   Centre in the fitted 16:9 stage (not in the browser viewport). */
#game .tea-shop-opening-dialog{
 position:fixed;inset:auto;
 left:calc(var(--palace-view-x) + env(safe-area-inset-left,0px) + (var(--palace-view-w) - env(safe-area-inset-left,0px) - env(safe-area-inset-right,0px)) / 2);
 top:calc(var(--palace-view-y) + env(safe-area-inset-top,0px) + (var(--palace-view-h) - env(safe-area-inset-top,0px) - env(safe-area-inset-bottom,0px)) / 2);
 transform:translate(-50%,-50%);margin:0;box-sizing:border-box;
 width:min(80cqw,650px);max-width:calc(100cqw - 24px);
 max-height:min(84cqh,510px);padding:0;
 border:1px solid #b89a6b;border-radius:14px;
 background:#fff6e7;color:#5e4933;
 box-shadow:0 14px 36px #30221e52,inset 0 0 0 3px #f6e5c9;
 overflow:hidden;
}
#game .tea-shop-opening-dialog[open]{
 display:flex;flex-direction:column;align-items:stretch;
}
#game .tea-shop-opening-dialog::backdrop{background:rgba(27,28,23,.48);}
#game .tea-shop-opening-close{
 position:absolute;z-index:2;top:8px;right:10px;
 box-sizing:border-box;width:32px;height:32px;min-width:32px;min-height:32px;
 margin:0;padding:0;border:0;background:transparent;color:#765c41;
 font-size:24px;line-height:1;cursor:pointer;
}
#game .tea-shop-opening-story{
 flex:1;min-height:0;overflow-y:auto;overscroll-behavior:contain;
 padding:clamp(17px,3cqh,26px) clamp(20px,3.2cqw,35px) clamp(7px,1.3cqh,12px);
 scrollbar-width:thin;
}
#game .tea-shop-opening-story :is(h3,.shop-opening-title){
 margin:0 38px clamp(9px,1.8cqh,15px) 0;
 font-size:var(--font-section);line-height:1.35;font-weight:700;color:#60472f;
}
#game .tea-shop-opening-story :is(.tea-story-paragraph,.shop-story-paragraph){
 margin:0 0 clamp(8px,1.5cqh,13px);
 font-size:var(--font-body);line-height:1.58;
}
#game .tea-shop-opening-story .shop-preparation-result{
 margin:clamp(3px,.8cqh,7px) 0 0;
 font-size:var(--font-body);line-height:1.5;
}
#game .tea-shop-opening-proceed{
 flex:none;align-self:center;box-sizing:border-box;
 width:min(215px,calc(100% - 40px));min-height:clamp(34px,5.3cqh,42px);
 margin:clamp(4px,.9cqh,8px) 0 clamp(9px,1.6cqh,14px);
}
@media (orientation:landscape) and (max-height:450px){
 #game .tea-shop-opening-story{padding:clamp(12px,2.2cqh,18px) 20px 5px;}
 #game .tea-shop-opening-story :is(.tea-story-paragraph,.shop-story-paragraph){
  line-height:1.5;margin-bottom:clamp(6px,1.2cqh,9px);
 }
 #game .tea-shop-opening-proceed{margin:4px 0 8px;}
}

/* Tea research reads as a continuous folio, without isolated avatar cards. */
#game .tea-research-controls .tea-dialogue-line{
 padding-left:clamp(8px,1.2cqw,15px);
 color:#674b35;
}
#game .tea-research-controls .tea-story-pages{
 display:flex;flex-direction:column;gap:clamp(6px,1cqh,10px);
 min-width:0;flex:none;
}
#game .tea-research-controls .tea-story-pages>h3{
 margin:0 0 clamp(2px,.5cqh,6px);line-height:1.32;
}
#game .tea-research-controls .tea-story-pages>.tea-story-paragraph{
 margin:0;line-height:1.5;
}
#game .tea-research-controls[data-tea-chapter='fifth'] h3{
 margin-top:0;
}


.tea-research-controls>button,.tea-choice-form>button{align-self:flex-start;white-space:normal;}
/* Use one width for every research decision, regardless of label length. */
#game .tea-research-controls .tea-research-action,
#game .tea-research-controls .tea-trial-choice{
 box-sizing:border-box;width:min(100%,430px);max-width:100%;
 min-width:0;align-self:flex-start;white-space:normal;
}
#game .tea-research-controls .tea-direction-options{
 width:100%;max-width:100%;gap:clamp(8px,1.5cqh,14px);
}
#game .tea-research-controls .tea-sale-selected{
 margin:0;font-size:var(--font-story);line-height:1.7;
}
.tea-choice-form{display:flex;flex-direction:column;gap:12px;flex:none;}
.tea-choice-form select,.tea-name-dialog input{max-width:100%;box-sizing:border-box;min-height:36px;padding:6px 10px;font:inherit;color:inherit;border:1px solid #b8a27e;background:#fff8e8;border-radius:7px;}
.tea-notebook{flex:none;border-top:1px solid #b8a27e66;padding:12px 0;margin-top:8px;}
.tea-notebook summary{cursor:pointer;color:#695139;font-weight:600;}
.tea-materials,.tea-flavor{color:#596343;font-weight:600;}
.tea-research-entry{flex:none;padding:8px 0;border-bottom:1px solid #b8a27e66;}
.tea-name-dialog{max-width:min(420px,85vw);color:#60472f;}
.tea-name-dialog form{display:flex;flex-direction:column;gap:18px;}
/* Compact estate inquiry dialogs share the palace-choice artwork. */
#game .economy-estate-dialog-content .economy-estate-dialog-subtext{
 max-width:100%;line-height:1.75;
}
#game .economy-estate-dialog-content .economy-estate-dialog-primary{
 display:flex;flex-direction:column;align-items:center;justify-content:center;gap:3px;
 width:min(100%,420px);min-width:0;box-sizing:border-box;
 padding:8px clamp(16px,3cqw,28px);
 white-space:normal;overflow-wrap:anywhere;
}
/* Research progress belongs in the notebook under the artwork, rather than
   repeating 'preparing' / 'not purchased' in the frame and footer. */
.tea-research-home .industry-building-aside-footer{
 display:block;min-height:0;text-align:center;
}
.tea-research-home .industry-building-aside-footer .tea-notebook{
 box-sizing:border-box;width:100%;max-height:35vh;overflow-y:auto;
 margin:0;padding:6px 10px;text-align:left;border-top:1px solid #b8a27e66;
}
.tea-research-home .industry-building-aside-footer .tea-notebook summary{text-align:center;}
.tea-choice-form .tea-trial-choice{
 display:flex;flex-direction:column;align-items:center;gap:4px;min-width:0;
 padding:8px 18px;text-align:center;white-space:normal;
}
.tea-choice-form .tea-trial-choice small{font-size:var(--font-note);font-weight:400;}
@media (orientation:landscape) and (max-height:450px){
 .tea-research-home .industry-building-aside-footer .tea-notebook{max-height:29vh;}
}



/* Shop preparation uses the existing building layout and stream avatars. */
:is(.shop-preparation-controls,.merchant-preparation-controls) .shop-story-paragraph{flex:none;line-height:1.8;margin:0 0 .7em;}
:is(.shop-preparation-controls,.merchant-preparation-controls) .stream-message{flex:none;width:100%;box-sizing:border-box;opacity:1;padding:10px;border:1px solid #b394617a;border-radius:9px;background:#fff9ec8f;}
:is(.shop-preparation-controls,.merchant-preparation-controls) .stream-message-content{flex:1;max-width:none;min-width:0;}
:is(.shop-preparation-controls,.merchant-preparation-controls) .stream-message p{font-size:var(--font-body);line-height:1.72;overflow-wrap:anywhere;}
:is(.shop-preparation-controls,.merchant-preparation-controls)>.palace-choice,.shop-preparation-choices>.palace-choice{flex:none;white-space:normal;}
/* Tea research and shop inspection labels share the dialogue choice's normal
   font weight, including labels wrapped in strong markup. */
html body[data-game='palace'] #game[data-page='economy']
:is(.tea-research-controls,.shop-preparation-controls)
:is(.tea-research-action,.tea-trial-choice,.shop-preparation-select-option,.palace-choice),
html body[data-game='palace'] #game[data-page='economy']
:is(.tea-research-controls,.shop-preparation-controls)
:is(.tea-trial-choice,.shop-preparation-select-option)>strong{
 font-weight:400;
}
/* Shop inspections use one active, explained choice and one final confirmation.
   Keep the merchant-route inspection cards separate: their action flow is unchanged. */
:is(.shop-preparation-controls[data-shop-stage='inspection'],.merchant-preparation-controls[data-merchant-preparation-stage='inspection']){
 gap:clamp(3px,.65cqh,7px);
}
:is(.shop-preparation-controls[data-shop-stage='inspection'],.merchant-preparation-controls[data-merchant-preparation-stage='inspection'])>h3{
 margin:0 0 2px;line-height:1.2;
}
:is(.shop-preparation-controls[data-shop-stage='inspection'],.merchant-preparation-controls[data-merchant-preparation-stage='inspection'])>.shop-story-paragraph{
 line-height:1.33;margin:0;
}
.shop-preparation-choices{
 display:grid;grid-template-columns:minmax(0,1fr);gap:clamp(3px,.6cqh,6px);
 width:100%;min-width:0;flex:none;
}
.shop-preparation-choices>.palace-choice>strong{font-size:var(--font-body);line-height:1.25;white-space:nowrap;}
html body[data-game='palace'] #game :is(.shop-preparation-controls[data-shop-stage='inspection'],.merchant-preparation-controls[data-merchant-preparation-stage='inspection'],.tea-research-controls[data-tea-stage='pricing']) .shop-preparation-choices>.shop-preparation-select-option{
 display:flex;justify-content:center;align-items:center;box-sizing:border-box;
 width:100%;min-width:0;min-height:clamp(34px,5cqh,44px);margin:0;
 padding:clamp(3px,.55cqh,6px) clamp(28px,3.2cqw,42px);
 font-size:var(--font-body);line-height:1.3;text-align:center;
 white-space:normal;cursor:pointer;
}
html body[data-game='palace'] #game :is(.shop-preparation-controls[data-shop-stage='inspection'],.merchant-preparation-controls[data-merchant-preparation-stage='inspection'],.tea-research-controls[data-tea-stage='pricing']) .shop-preparation-choices>.shop-preparation-select-option[aria-pressed='true']{
 color:#fff8e9;border-color:#d5b97c;
 background-image:linear-gradient(105deg,#775637,#96714a);
 background-color:#896744;
 box-shadow:inset 0 0 0 2px rgba(250,227,180,.4),inset 0 0 0 4px rgba(99,67,33,.25),0 3px 9px rgba(60,38,16,.15);
}
#game .shop-preparation-choice-detail{
 min-width:0;margin:0 0 clamp(3px,.65cqh,7px);
 padding:clamp(3px,.55cqh,6px) clamp(10px,1.4cqw,18px);
 color:#6f543b;font-size:var(--font-note);line-height:1.42;text-align:left;
}
.shop-preparation-inspection-actions{
 display:flex;justify-content:center;flex:none;margin-top:clamp(3px,.6cqh,6px);
}
html body[data-game='palace'] #game .shop-preparation-inspection-actions>.palace-choice{
 width:clamp(126px,19cqw,224px);max-width:100%;
 min-height:clamp(34px,5cqh,44px);margin:0;
 padding:4px clamp(12px,1.7cqw,22px);
 font-size:var(--font-body);
}
#game .shop-preparation-inspection-actions>.palace-choice:disabled{
 opacity:.5;cursor:default;
}
/* Qualified shop stories use short, page-by-page reading inside the 16:9 controls column. */
.shop-preparation-page{display:flex;flex-direction:column;min-width:0;gap:clamp(5px,.9cqh,9px);}
.shop-preparation-page>h3{flex:none;margin:0 0 clamp(3px,.6cqh,6px);font-size:var(--font-section);}
.shop-preparation-page>.shop-story-paragraph{margin:0;line-height:1.55;}
.shop-preparation-page>.stream-message{margin:0;}
.shop-preparation-page-actions{display:flex;justify-content:flex-end;align-items:center;gap:clamp(8px,1cqw,14px);flex-wrap:wrap;margin-top:clamp(6px,1cqh,12px);}
html body[data-game='palace'] #game .shop-preparation-page-actions>.palace-choice{
 flex:none;min-width:clamp(106px,13cqw,160px);min-height:clamp(34px,5.5cqh,44px);
 margin:0;padding:5px clamp(12px,1.6cqw,22px);font-size:var(--font-body);
}
.shop-preparation-result{color:#596343;font-weight:600;}

/* Merchant preparation leaves the route map completely. The entire
   16:9 stage uses the canonical quiet-paper background, without a modal. */
.merchant-preparation-page .merchant-preparation-stage{
 display:flex;flex-direction:column;flex:1;min-width:0;min-height:0;
 width:100%;height:100%;box-sizing:border-box;overflow:hidden;
 background:url('/public/assets/backgrounds/ui/quiet-paper.webp') center/cover;
 color:#63472f;container-type:size;
}
.merchant-preparation-stage-header{
 display:flex;align-items:center;gap:clamp(8px,1.4cqw,18px);flex:none;
 min-height:clamp(43px,8cqh,66px);
 padding:clamp(5px,1cqh,11px) clamp(17px,2.2cqw,33px);
 box-sizing:border-box;border-bottom:1px solid rgba(164,123,73,.28);
}
.merchant-preparation-stage-context{margin-left:auto;color:#9a7b57;font-size:var(--font-note);}
#game .merchant-preparation-stage-back{
 flex:none;box-sizing:border-box;
 width:clamp(125px,13cqw,165px);min-width:0;
 min-height:clamp(33px,5.5cqh,44px);
 margin:0;padding:3px clamp(14px,1.6cqw,22px);
 font-size:var(--font-body);white-space:nowrap;
}
.merchant-preparation-stage-body{
 display:flex;flex:1;min-width:0;min-height:0;overflow-y:auto;
 scrollbar-width:thin;overscroll-behavior:contain;
 padding:clamp(11px,2.5cqh,28px) clamp(20px,4cqw,76px);
 box-sizing:border-box;
}
.merchant-preparation-stage-content{
 display:flex;flex-direction:column;flex:1;min-width:0;min-height:100%;
 width:100%;max-width:1180px;margin:0 auto;
 font-size:var(--font-body);line-height:1.48;
}
.merchant-preparation-stage .merchant-preparation-controls{
 display:flex;flex-direction:column;flex:1;min-width:0;gap:clamp(5px,1cqh,11px);
}
.merchant-preparation-stage .merchant-preparation-controls>h3,
.merchant-preparation-stage .merchant-preparation-pages>h3{
 margin:0 0 clamp(4px,.9cqh,9px);line-height:1.25;
 font-size:var(--font-section);color:#65462d;
}
.merchant-preparation-stage .shop-story-paragraph,
.merchant-preparation-stage .merchant-reason{margin:0;line-height:1.48;}
.merchant-preparation-stage .stream-message{margin:0;padding:clamp(5px,.9cqh,10px) clamp(8px,1.4cqw,16px);}
.merchant-preparation-stage .stream-message p{margin:0;line-height:1.48;}
.merchant-preparation-stage .merchant-preparation-pages{
 display:flex;flex-direction:column;flex:1;min-height:0;gap:clamp(6px,1.2cqh,13px);
}
.merchant-preparation-stage .merchant-preparation-pages>.shop-story-paragraph{margin:0;line-height:1.48;}
.merchant-preparation-stage .shop-preparation-choices{gap:clamp(4px,.7cqh,7px);}
#game .merchant-preparation-stage .palace-choice{
 min-height:clamp(34px,5cqh,45px);font-size:var(--font-body);
 margin:0;
}
.merchant-preparation-stage .merchant-preparation-pages>.palace-choice{
 width:min(440px,100%);align-self:center;
}
.merchant-preparation-stage .shop-preparation-inspection-actions{margin-top:clamp(4px,1cqh,10px);}
.merchant-preparation-stage .shop-preparation-inspection-actions>.palace-choice{min-width:clamp(128px,18cqw,220px);}
.merchant-preparation-stage .story-reading-hint{margin-top:auto;}
@media (orientation:landscape) and (max-height:450px){
 .merchant-preparation-stage-header{min-height:40px;padding:3px 16px;}
 .merchant-preparation-stage-body{padding:7px 18px 9px;}
 .merchant-preparation-stage .merchant-preparation-controls{gap:4px;}
 .merchant-preparation-stage .merchant-preparation-pages{gap:5px;}
 .merchant-preparation-stage .stream-message{padding:4px 8px;}
}
.merchant-preparation-controls{display:flex;flex-direction:column;gap:clamp(6px,1cqh,12px);min-width:0;}
/* Merchant chapters use short story beats, with charter controls on the final page. */
.merchant-preparation-pages{display:flex;flex-direction:column;gap:clamp(5px,1cqh,10px);min-width:0;}
.merchant-preparation-pages>h3{margin:0 0 clamp(3px,.6cqh,7px);font-size:var(--font-section);}
.merchant-preparation-pages>.shop-story-paragraph{margin:0;line-height:1.55;}
.merchant-preparation-pages>.stream-message{margin:0;}
.merchant-preparation-pages>.merchant-charter-form{margin-top:clamp(5px,1cqh,10px);}
/* The right-hand story surface advances on blank-space click.
   Choices and purchase actions remain independently interactive. */
#game .story-reading-surface{
 flex:1;min-height:0;position:relative;
}
#game .story-reading-surface:has(.story-reading-hint){cursor:pointer;}
#game .story-reading-surface:focus-visible{
 outline:1px dashed rgba(158,121,69,.55);outline-offset:3px;
}
#game .story-reading-surface .story-reading-hint{
 align-self:flex-end;flex:none;margin:auto 0 0;
 padding:clamp(12px,2cqh,18px) 4px 0;
 text-align:right;font-size:var(--font-note);line-height:1.35;
 color:#9a7950;user-select:none;pointer-events:none;
}


/* Economy choices use the same three-layer artwork as palace dialogue:
   two ornaments plus one full-width translucent white ground. Never assign a
   one-layer gradient with the dialogue's multi-layer background-size: doing so
   paints only the thin stripe where the left ornament should be.
   Pressed/current choices keep their existing dark selected appearance. */
/* Keep both neutral and selected buttons above decorative page layers. */
html body[data-game='palace'] #game[data-page='economy']
:is(.home-activities-scroll button,.home-activities-heading button,.merchant-action-stage-content button,.economy-estate-dialog button,.merchant-modal button,.handcraft-dialog button,.tea-shop-opening-dialog button,.industry-purchase-dialog button,.workshop-notice-dialog button)
:not(:is(.economy-estate-dialog-close,.tea-shop-opening-close,.merchant-modal-heading button,.merchant-city-card-heading button,.merchant-city,.workshop-stepper button,.industry-shop-quantity-step)){
 position:relative;
 z-index:1;
}
html body[data-game='palace'] #game[data-page='economy']
:is(
 .home-activities-scroll button,
 .home-activities-heading button,
 .merchant-action-stage-content button,
 .economy-estate-dialog button,
 .merchant-modal button,
 .handcraft-dialog button,
 .tea-shop-opening-dialog button,
 .industry-purchase-dialog button,
 .workshop-notice-dialog button
):not(:is(
 .merchant-city,
 .merchant-city-card-heading button,
 .merchant-modal-heading button,
 .economy-estate-dialog-close,
 .tea-shop-opening-close,
 .workshop-stepper button,
 .industry-shop-quantity-step,
 .farm-entrances button,
 .workshop-entrances button,
 .shop-entrances button,
 [aria-pressed='true'],
 [aria-current='true']
)){
 border:1px solid var(--palace-gold,rgba(174,131,67,.70));
 border-radius:18px;
 /* A nearly solid pale base keeps the parchment beneath from tinting choices. */
 background-color:rgba(255,253,248,.94);
 background-image:var(--palace-choice-background-image);
 background-position:left 12px center,right 8px center,center;
 background-size:14px auto,auto 86%,100% 100%;
 background-repeat:no-repeat;
 color:var(--palace-ink,#513724);
 box-shadow:inset 0 0 0 3px rgba(255,249,232,.90),
            inset 0 0 0 4px var(--palace-inset,rgba(205,164,99,.44)),
            0 3px 9px rgba(44,28,11,.16);
 font-family:var(--palace-story-font,var(--game-text-font));
}
html body[data-game='palace'] #game[data-page='economy']
:is(.home-activities-scroll button,.home-activities-heading button,.merchant-action-stage-content button,.economy-estate-dialog button,.merchant-modal button,.handcraft-dialog button,.tea-shop-opening-dialog button,.industry-purchase-dialog button,.workshop-notice-dialog button)
:not(:is(.merchant-city,.merchant-city-card-heading button,.merchant-modal-heading button,.economy-estate-dialog-close,.tea-shop-opening-close,.workshop-stepper button,.industry-shop-quantity-step,.farm-entrances button,.workshop-entrances button,.shop-entrances button,[aria-pressed='true'],[aria-current='true']))
:is(:hover,:focus-visible):not(:disabled){
 border-color:#956829;filter:brightness(1.025);
}
