:root {
  --paper:#f4eedf;
  --paper-2:#ede4d1;
  --ink:#172826;
  --muted:#71807a;
  --green:#1d5c4b;
  --green-2:#287864;
  --orange:#f06f3a;
  --gold:#e7a92e;
  --red:#c84b46;
  --line:rgba(23,40,38,.12);
  --shadow:0 18px 50px rgba(32,44,38,.12);
  font-family: ui-rounded,"SF Pro Rounded","PingFang SC","Microsoft YaHei",system-ui,sans-serif;
}
*{box-sizing:border-box}
html,body{margin:0;min-height:100%;background:#dfe7dd;color:var(--ink)}
body{background:
  radial-gradient(circle at 10% 0%,rgba(255,255,255,.85),transparent 27%),
  linear-gradient(135deg,#dde8df,#cfded6);overflow-x:hidden}
button{font:inherit;color:inherit}
button:focus-visible{outline:3px solid rgba(240,111,58,.4);outline-offset:2px}
.app-shell{width:min(100%,540px);min-height:100vh;margin:0 auto;background:var(--paper);box-shadow:0 0 60px rgba(24,49,42,.18);position:relative;padding-bottom:170px;overflow:hidden}
.app-shell::before{content:"";position:absolute;inset:0;pointer-events:none;opacity:.35;background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80' viewBox='0 0 80 80'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.7' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.045'/%3E%3C/svg%3E")}
.topbar{height:74px;padding:14px 18px 8px;display:flex;align-items:center;justify-content:space-between;position:relative;z-index:2}
.brand{border:0;background:transparent;padding:0;display:flex;align-items:center;gap:10px;text-align:left;cursor:pointer}
.brand-mark{width:42px;height:42px;border-radius:13px;background:var(--green);display:grid;place-items:center;color:#fff9e9;font-size:22px;font-weight:900;box-shadow:0 6px 14px rgba(29,92,75,.24);transform:rotate(-3deg)}
.brand b{display:block;font-size:16px;letter-spacing:.02em}.brand small{color:var(--muted);display:block;margin-top:2px}
.top-actions{display:flex;gap:8px}.icon-button,.close-button{border:1px solid var(--line);background:rgba(255,255,255,.55);width:38px;height:38px;border-radius:12px;font-weight:900;cursor:pointer}.icon-button.muted{color:#aaa;text-decoration:line-through}
main{position:relative;z-index:1}
.status-card{margin:5px 16px 12px;background:var(--green);color:#fff;border-radius:22px;padding:16px 18px;display:grid;grid-template-columns:1fr 1.4fr;gap:16px;box-shadow:0 14px 28px rgba(29,92,75,.22);position:relative;overflow:hidden}
.status-card::after{content:"";position:absolute;width:140px;height:140px;border:30px solid rgba(255,255,255,.05);border-radius:50%;right:-70px;top:-75px}
.eyebrow{font-size:10px;text-transform:uppercase;letter-spacing:.16em;font-weight:800;opacity:.68}.cash-block strong{font-size:32px;display:block;margin:3px 0 2px}.currency{font-size:18px;opacity:.7;margin-right:2px}.delta{font-size:11px;color:#cbe5d6}.delta.positive{color:#ffe19b}.delta.negative{color:#ffc0b3}
.rent-block{border-left:1px solid rgba(255,255,255,.18);padding-left:16px}.rent-copy{display:flex;align-items:flex-end;justify-content:space-between}.rent-copy strong{font-size:22px;color:#ffe3a1}.calendar-dots{display:flex;gap:4px;margin:10px 0 6px}.calendar-dots i{height:5px;flex:1;border-radius:3px;background:rgba(255,255,255,.18)}.calendar-dots i.done{background:var(--gold)}.deadline{font-size:11px;color:#d3e6df}
.board-card{margin:0 12px;background:#fffaf0;border:1px solid rgba(82,70,46,.1);border-radius:26px;padding:15px;box-shadow:var(--shadow)}
.board-heading{display:flex;align-items:center;justify-content:space-between;margin:0 3px 12px}.board-heading h1{font-size:18px;margin:2px 0 0}.combo-pill{background:#fff1d6;border:1px solid #f2d195;border-radius:13px;padding:6px 10px;text-align:center;min-width:60px}.combo-pill span{font-size:8px;font-weight:900;display:block;color:#b77a12;letter-spacing:.12em}.combo-pill b{font-size:18px;color:#d05e29}
.board{display:grid;grid-template-columns:repeat(5,1fr);gap:7px;background:#d7c8a8;padding:8px;border:4px solid #6f4e36;border-radius:18px;box-shadow:inset 0 0 0 2px rgba(255,255,255,.32),inset 0 8px 24px rgba(65,46,29,.18);min-height:330px;position:relative}
.slot{min-width:0;aspect-ratio:.88;background:linear-gradient(145deg,#f4ead4,#e8dac0);border:1px solid rgba(84,62,35,.17);border-radius:13px;position:relative;display:flex;flex-direction:column;align-items:center;justify-content:center;box-shadow:inset 0 1px 0 white,0 2px 4px rgba(57,43,25,.08);overflow:hidden;cursor:pointer;transform:translateZ(0)}
.slot.empty{opacity:.45;background:repeating-linear-gradient(135deg,#eee4cf,#eee4cf 6px,#e8ddc7 6px,#e8ddc7 12px)}
.slot.reveal{animation:cardIn .34s cubic-bezier(.2,.9,.2,1) both;animation-delay:var(--delay)}
.slot.triggered{animation:pulse .45s ease}.slot.destroyed{animation:destroy .55s ease forwards}.slot.multiplied::after{content:"×" attr(data-mult);position:absolute;top:4px;left:4px;background:#ef7542;color:#fff;border-radius:7px;padding:2px 5px;font-size:10px;font-weight:900}
.sprite{display:block;width:54px;max-width:76%;aspect-ratio:1;background-image:url('assets/sprites/company-atlas.svg');background-size:1600% 1000%;background-position:calc(var(--sx) * 100% / 15) calc(var(--sy) * 100% / 9);filter:drop-shadow(0 3px 2px rgba(53,42,29,.12));flex:none}
.slot-name{font-size:10px;line-height:1.1;font-weight:900;text-align:center;width:100%;padding:0 3px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin-top:1px}.slot-value{position:absolute;right:3px;top:3px;background:#183f37;color:white;min-width:19px;height:19px;border-radius:7px;display:grid;place-items:center;font-size:10px;font-weight:900;border:1px solid rgba(255,255,255,.5)}
.rarity-Uncommon{box-shadow:inset 0 0 0 2px rgba(40,120,100,.24),0 2px 4px rgba(57,43,25,.08)}.rarity-Rare{box-shadow:inset 0 0 0 2px rgba(151,72,138,.3),0 2px 4px rgba(57,43,25,.08)}.rarity-Very-Rare{box-shadow:inset 0 0 0 2px rgba(231,169,46,.55),0 2px 4px rgba(57,43,25,.08)}
.ticker{height:34px;margin-top:10px;border-radius:11px;background:#f1eadc;display:flex;align-items:center;gap:8px;padding:0 10px;color:#65716c;font-size:11px;overflow:hidden}.ticker-dot{width:7px;height:7px;border-radius:50%;background:#56a888;box-shadow:0 0 0 4px rgba(86,168,136,.12)}
.action-dock{position:fixed;bottom:0;left:50%;transform:translateX(-50%);width:min(100%,540px);padding:10px 16px max(14px,env(safe-area-inset-bottom));background:linear-gradient(180deg,rgba(244,238,223,.1),#f4eedf 18%);z-index:10}
.token-row{display:grid;grid-template-columns:repeat(4,1fr);gap:7px;margin-bottom:9px}.token{border:1px solid var(--line);border-radius:13px;background:rgba(255,255,255,.78);height:49px;display:grid;grid-template-columns:20px 1fr;grid-template-rows:1fr 1fr;align-items:center;padding:5px 8px;cursor:pointer}.token span{grid-row:1/3;font-size:19px;color:var(--green)}.token b{font-size:14px;line-height:1}.token small{font-size:8px;color:var(--muted);white-space:nowrap}
.work-button{width:100%;height:62px;border:0;border-radius:19px;background:linear-gradient(135deg,#f57c45,#eb5d32);color:white;display:flex;align-items:center;justify-content:center;gap:12px;box-shadow:0 12px 24px rgba(222,84,39,.28),inset 0 1px 0 rgba(255,255,255,.38);cursor:pointer;transition:.18s transform}.work-button:active{transform:scale(.98)}.work-button:disabled{filter:grayscale(.7);opacity:.6}.work-button b{font-size:21px;display:block}.work-button small{font-size:10px;display:block;opacity:.8}.work-icon{background:rgba(255,255,255,.2);width:35px;height:35px;border-radius:50%;display:grid;place-items:center;padding-left:2px}.work-button.compact{height:48px;margin-top:16px}.work-button.compact b{font-size:15px}
dialog{border:0;color:var(--ink)}dialog::backdrop{background:rgba(13,28,24,.58);backdrop-filter:blur(5px)}.sheet{width:min(calc(100% - 24px),510px);max-height:87vh;margin:auto auto 10px;border-radius:26px;padding:20px;background:var(--paper);box-shadow:0 30px 80px rgba(0,0,0,.3);animation:sheetUp .3s ease}.sheet-head{display:flex;align-items:flex-start;justify-content:space-between;margin-bottom:16px}.sheet-head h2{margin:3px 0 0;font-size:22px}.choice-hint{font-size:10px;color:var(--muted);margin-top:6px}.choice-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:9px}.choice-card{border:1px solid var(--line);background:#fffaf0;border-radius:18px;padding:10px 8px 12px;min-width:0;text-align:center;cursor:pointer;position:relative;transition:.18s transform,.18s box-shadow}.choice-card:hover{transform:translateY(-3px);box-shadow:0 10px 20px rgba(30,50,43,.1)}.choice-card .sprite{margin:auto;width:70px}.choice-card h3{font-size:13px;margin:4px 0}.choice-card p{font-size:9px;color:var(--muted);line-height:1.45;height:42px;overflow:hidden;margin:4px 0}.card-tags{display:flex;justify-content:center;gap:3px;min-height:17px}.rarity-label,.mechanic-label{font-size:8px;padding:3px 6px;border-radius:9px;font-weight:900;white-space:nowrap}.rarity-label{background:#ece3d4;color:#7d7162}.mechanic-label{background:#dcece4;color:#276653}.choice-card .base{font-size:12px;font-weight:900;color:var(--green);margin-top:7px}.sheet-actions{display:grid;grid-template-columns:1fr 1fr;gap:8px;margin-top:14px}.secondary,.ghost{height:43px;border-radius:13px;border:1px solid var(--line);cursor:pointer;font-size:11px;font-weight:800}.secondary{background:var(--green);color:white}.ghost{background:transparent}.secondary:disabled{opacity:.4}
.library-sheet{height:min(90vh,760px);padding:0;overflow:hidden}.sheet-head.sticky{padding:18px 18px 10px;margin:0;background:var(--paper)}.filter-row{display:flex;gap:6px;padding:0 18px 10px;overflow:auto}.filter-button{white-space:nowrap;border:1px solid var(--line);background:#fff8ea;border-radius:10px;padding:6px 10px;font-size:9px;cursor:pointer}.filter-button.active{background:var(--green);color:#fff}.library-grid{height:calc(100% - 110px);overflow:auto;padding:0 14px 24px;display:grid;grid-template-columns:repeat(2,1fr);gap:8px;align-content:start}.library-row{border:1px solid var(--line);background:#fffaf0;border-radius:14px;padding:8px;display:grid;grid-template-columns:46px 1fr;gap:7px;cursor:pointer;min-width:0}.library-row .sprite{width:46px}.library-row h3{font-size:11px;margin:2px 0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.library-row p{font-size:8px;color:var(--muted);margin:0;line-height:1.35;height:23px;overflow:hidden}.library-row .count{color:var(--orange);font-size:9px;font-weight:900}.detail-dialog{width:min(calc(100% - 32px),390px);border-radius:24px;padding:24px;background:#fffaf0;box-shadow:0 30px 80px rgba(0,0,0,.3)}.detail-close{position:absolute;right:12px;top:12px}.detail-hero{text-align:center}.detail-hero .sprite{width:110px;margin:auto}.detail-hero h2{font-size:24px;margin:5px 0}.detail-meta{display:flex;justify-content:center;gap:6px;flex-wrap:wrap}.detail-meta span{font-size:9px;background:#eee4d3;padding:4px 8px;border-radius:10px}.rule-box,.flavor-box{border-radius:15px;padding:13px;margin-top:13px}.rule-box{background:#e4efe9;border:1px solid #c8ded3}.flavor-box{background:#f7ead5;border:1px solid #ebd6b4}.rule-box b,.flavor-box b{display:block;font-size:10px;letter-spacing:.12em;margin-bottom:5px}.rule-box p,.flavor-box p{font-size:11px;line-height:1.65;margin:0}
.result-art{width:82px;height:82px;border-radius:25px;background:#dbece3;color:var(--green);display:grid;place-items:center;font-size:44px;font-weight:900;margin:0 auto 12px}.result-art.fail{background:#f3d9d4;color:var(--red)}#resultDialog{text-align:center}#resultDialog h2{font-size:25px;margin:5px 0}#resultDialog p{font-size:12px;color:var(--muted);line-height:1.6}.help-grid{display:grid;grid-template-columns:1fr 1fr;gap:9px}.help-grid article{background:#fffaf0;border:1px solid var(--line);border-radius:16px;padding:12px}.help-grid b{display:grid;place-items:center;width:24px;height:24px;border-radius:8px;background:var(--green);color:white}.help-grid h3{font-size:13px;margin:9px 0 3px}.help-grid p{font-size:9px;line-height:1.45;color:var(--muted);margin:0}
.catalog-button{width:100%;margin-top:12px}
.toast-stack{position:fixed;z-index:50;top:82px;left:50%;transform:translateX(-50%);width:min(calc(100% - 28px),500px);display:flex;flex-direction:column;align-items:center;gap:6px;pointer-events:none}.toast{background:rgba(21,53,45,.95);color:white;border-radius:12px;padding:9px 13px;font-size:11px;box-shadow:0 7px 20px rgba(0,0,0,.18);animation:toast .35s ease,fadeOut .3s ease 2.35s forwards}.toast.combo{background:rgba(230,91,45,.96)}.float-layer{position:fixed;inset:0;pointer-events:none;z-index:40}.float-number{position:absolute;font-weight:1000;color:#ed6c35;font-size:22px;text-shadow:0 2px white;animation:floatUp .9s ease forwards}.float-number.negative{color:#c74444}
@keyframes cardIn{from{opacity:0;transform:translateY(-18px) rotate(-2deg) scale(.8)}to{opacity:1;transform:none}}@keyframes pulse{50%{transform:scale(1.08);filter:brightness(1.12)}}@keyframes destroy{45%{transform:scale(1.08) rotate(5deg);filter:brightness(1.3)}to{opacity:0;transform:scale(.2) rotate(16deg)}}@keyframes sheetUp{from{opacity:0;transform:translateY(40px)}to{opacity:1;transform:none}}@keyframes toast{from{opacity:0;transform:translateY(-12px)}to{opacity:1;transform:none}}@keyframes fadeOut{to{opacity:0;transform:translateY(-8px)}}@keyframes floatUp{from{opacity:0;transform:translateY(8px) scale(.7)}30%{opacity:1}to{opacity:0;transform:translateY(-45px) scale(1.1)}}
@media(max-width:390px){.board{gap:5px;padding:6px;min-height:295px}.slot{border-radius:10px}.slot-name{font-size:8px}.sprite{width:47px}.status-card{grid-template-columns:.9fr 1.5fr}.choice-card .sprite{width:60px}.choice-card p{height:38px}.app-shell{padding-bottom:164px}.help-grid{grid-template-columns:1fr}}
@media(min-width:541px){.action-dock{border-radius:24px 24px 0 0}.app-shell{min-height:100vh}.board{min-height:380px}.sprite{width:62px}}

/* Viewport-locked game layout: the primary loop always occupies exactly one
   visual viewport, including mobile browsers with dynamic address bars. */
html,body{width:100%;height:100%;height:100dvh;overflow:hidden;overscroll-behavior:none}
.app-shell{height:100vh;height:100dvh;min-height:0;max-height:100dvh;padding-bottom:0;display:grid;grid-template-rows:auto minmax(0,1fr);overflow:hidden}
.topbar{height:clamp(50px,8dvh,68px);padding:clamp(7px,1.5dvh,13px) 16px 5px}
.brand-mark{width:clamp(34px,5.5dvh,42px);height:clamp(34px,5.5dvh,42px);font-size:clamp(18px,2.8dvh,22px)}
main{height:100%;min-height:0;display:grid;grid-template-rows:auto minmax(0,1fr) auto;overflow:hidden}
.status-card{margin:2px 12px clamp(5px,1dvh,9px);padding:clamp(8px,1.7dvh,14px) 15px;border-radius:clamp(16px,2.8dvh,22px);gap:12px}
.cash-block strong{font-size:clamp(23px,4.2dvh,32px)}.rent-copy strong{font-size:clamp(18px,3dvh,22px)}
.calendar-dots{margin:clamp(4px,1dvh,8px) 0 5px}
.board-card{margin:0 10px;min-height:0;padding:clamp(7px,1.5dvh,13px);border-radius:clamp(17px,3dvh,26px);display:grid;grid-template-rows:auto minmax(0,1fr) auto;overflow:hidden}
.board-heading{margin:0 3px clamp(5px,1dvh,10px)}.board-heading h1{font-size:clamp(14px,2.4dvh,18px)}
.combo-pill{padding:4px 8px;min-width:55px}.combo-pill b{font-size:clamp(15px,2.4dvh,18px)}
.board{height:100%;min-height:0!important;grid-template-rows:repeat(4,minmax(0,1fr));gap:clamp(3px,.8dvh,7px);padding:clamp(4px,1dvh,8px);border-width:clamp(3px,.6dvh,4px)}
.slot{aspect-ratio:auto;min-height:0;border-radius:clamp(8px,1.6dvh,13px)}
.sprite{width:clamp(30px,7dvh,54px);max-width:72%;max-height:62%}.slot-name{font-size:clamp(7px,1.35dvh,10px)}
.ticker{height:clamp(24px,4.2dvh,34px);margin-top:clamp(4px,.8dvh,8px)}
.action-dock{position:relative;inset:auto;transform:none;width:100%;padding:clamp(4px,.8dvh,8px) 12px max(7px,env(safe-area-inset-bottom));background:linear-gradient(180deg,rgba(244,238,223,.55),#f4eedf 20%)}
.token-row{gap:5px;margin-bottom:clamp(4px,.7dvh,7px)}.token{height:clamp(37px,6.2dvh,48px);padding:4px 7px}.token span{font-size:clamp(15px,2.5dvh,19px)}.token b{font-size:clamp(11px,1.9dvh,14px)}
.work-button{height:clamp(44px,7.3dvh,58px);border-radius:clamp(14px,2.3dvh,19px)}.work-button b{font-size:clamp(17px,2.8dvh,21px)}.work-icon{width:clamp(29px,4.5dvh,35px);height:clamp(29px,4.5dvh,35px)}
dialog{max-height:100dvh;overflow:hidden}.sheet{max-height:calc(100dvh - 12px);margin:auto auto 6px;overflow:hidden}.library-sheet{height:calc(100dvh - 12px)}.detail-dialog{max-height:calc(100dvh - 20px);overflow:auto}

@media(max-height:700px){
  .topbar{height:46px;padding:5px 12px 3px}.brand-mark{width:32px;height:32px;font-size:17px}.brand small{display:none}.icon-button{width:32px;height:32px}
  .status-card{margin:1px 9px 4px;padding:6px 11px;border-radius:14px}.eyebrow{font-size:8px}.cash-block strong{font-size:21px;margin:1px 0}.rent-copy strong{font-size:17px}.calendar-dots{margin:3px 0}.delta,.deadline{font-size:9px}
  .board-card{margin:0 7px;padding:6px;border-radius:16px}.board-heading{margin-bottom:4px}.board-heading h1{font-size:13px}.combo-pill{padding:2px 6px;min-width:50px}.combo-pill b{font-size:14px}
  .board{gap:3px;padding:3px;border-width:3px;border-radius:13px}.sprite{width:34px;max-height:56%}.slot-name{font-size:7px}.slot-value{min-width:16px;height:16px;font-size:8px}.ticker{height:21px;margin-top:3px;font-size:9px}
  .action-dock{padding:3px 8px max(5px,env(safe-area-inset-bottom))}.token-row{margin-bottom:3px}.token{height:34px;padding:2px 5px}.token small{font-size:7px}.work-button{height:42px}.work-button b{font-size:16px}.work-button small{font-size:8px}.work-icon{width:27px;height:27px}
  .sheet{padding:14px;border-radius:20px}.sheet-head{margin-bottom:8px}.sheet-head h2{font-size:18px}.choice-grid{gap:6px}.choice-card{padding:6px 4px 8px;border-radius:14px}.choice-card .sprite{width:42px}.choice-card h3{font-size:11px;margin:2px 0}.choice-card p{height:28px;font-size:8px;line-height:1.3;margin:2px 0}.choice-card .base{font-size:10px;margin-top:3px}.rarity-label,.mechanic-label{font-size:7px;padding:2px 4px}.sheet-actions{margin-top:7px}.secondary,.ghost{height:36px;font-size:9px}
}

@media(max-height:560px){
  .topbar{height:40px}.brand b{font-size:13px}.brand-mark{width:28px;height:28px}.status-card{grid-template-columns:.8fr 1.4fr;padding:4px 10px}.delta{display:none}.calendar-dots{margin:2px 0}.board-heading .eyebrow,.ticker{display:none}.board-card{grid-template-rows:auto minmax(0,1fr)}
  .token small{display:none}.token{grid-template-rows:1fr}.work-button{height:37px}.choice-card .sprite{width:34px}.choice-card p{height:21px}.sheet{padding:10px}.sheet-head{margin-bottom:5px}
}
