/* Appearance is scoped to the host document. Uploaded app artwork stays intact,
   and runtime iframe documents continue to own their colors and theme choice. */
:root{color-scheme:light;--surface:var(--white);--border:var(--line)}
.runtime-frame{color-scheme:normal}
.theme-control{position:relative;flex:0 0 44px;line-height:1}
.theme-control>summary{display:flex;align-items:center;justify-content:center;width:44px;height:44px;padding:10px;border:1px solid var(--line);border-radius:10px;color:var(--ink);background:transparent;cursor:pointer;list-style:none;touch-action:manipulation}
.theme-control>summary::-webkit-details-marker{display:none}
.theme-control>summary:hover,.theme-control[open]>summary{background:var(--soft-blue);border-color:var(--cobalt)}
.theme-menu{position:absolute;z-index:30;top:calc(100% + 12px);right:0;width:258px;max-width:calc(100vw - 32px);margin:0;padding:12px;border:1px solid var(--line);border-radius:14px;background:var(--white);color:var(--ink);box-shadow:0 14px 42px #20231e24;line-height:1.4}
.theme-menu-title{display:block;padding:4px 7px 10px;color:var(--muted);font-size:12px;font-weight:600}
.theme-option{display:flex;align-items:center;gap:12px;padding:11px 9px;border:1px solid transparent;border-radius:9px;cursor:pointer;min-height:60px}
.theme-option:hover{background:var(--paper)}
.theme-option:has(input:checked){background:var(--soft-blue);border-color:var(--line)}
.theme-option input{width:18px;height:18px;margin:0;accent-color:var(--cobalt);flex-shrink:0}
.theme-option strong,.theme-option small{display:block}
.theme-option strong{font-size:14px;line-height:1.5}
.theme-option small{font-size:12px;color:var(--muted);line-height:1.5}
.theme-option:focus-within{outline:2px solid var(--cobalt);outline-offset:1px}
@media(max-width:620px){.theme-menu{position:fixed;top:calc(80px + env(safe-area-inset-top));right:max(16px,env(safe-area-inset-right));max-height:calc(100dvh - 100px - env(safe-area-inset-top) - env(safe-area-inset-bottom));overflow:auto}}

:root[data-theme=gaming]{color-scheme:dark;--paper:#0b1020;--white:#141c31;--ink:#eef2ff;--muted:#b0bbd2;--line:#34415d;--cobalt:#95b2ff;--cobalt-dark:#bdcaff;--acid:#222d52;--soft-blue:#242f52;--shadow:0 14px 42px #05091766;--surface:#10192c;--border:var(--line);--theme-hover:#202c46;--theme-violet:#baabff;--theme-success:#a1e5cc;--theme-danger:#ffb2b9;--theme-danger-surface:#392338;--theme-focus:#acc9ff;background:var(--paper)}
:root[data-theme=gaming] body{background:radial-gradient(ellipse 70% 480px at 90% 0,#34215c30,transparent),radial-gradient(ellipse 60% 550px at 5% 20%,#183c7133,transparent),var(--paper)}
:root[data-theme=gaming] #header{background:#10172a;border-bottom-color:#34415d}
:root[data-theme=gaming] :focus-visible{outline-color:var(--theme-focus)}
:root[data-theme=gaming] ::selection{background:#5966c5;color:#fff}
:root[data-theme=gaming] .skip-link{background:#c4cfff;color:#10172a}
:root[data-theme=gaming] .button{background:#4055de;border-color:#7186f7;color:#fff;box-shadow:0 3px 16px #4055de1f}
:root[data-theme=gaming] .button:hover{background:#3346bf;border-color:#95a6ff;box-shadow:0 4px 22px #6472ff30}
:root[data-theme=gaming] .button.secondary,:root[data-theme=gaming] .button.ghost{background:transparent;color:var(--ink);box-shadow:none}
:root[data-theme=gaming] .button.secondary{border-color:#586887}
:root[data-theme=gaming] :is(.button.secondary,.button.ghost,.icon-button):hover{background:var(--theme-hover);border-color:#7283a8}
:root[data-theme=gaming] .button.ink{background:#2d3d63;border-color:#7185ad;color:var(--ink)}
:root[data-theme=gaming] .button.ink:hover{background:#3b4c78}
:root[data-theme=gaming] .button.danger{background:#8b294b;border-color:#d16a8e;color:#fff}
:root[data-theme=gaming] .button.danger:hover{background:#752240}
:root[data-theme=gaming] .button.danger.subtle{background:transparent;color:var(--theme-danger);border-color:#935372}
:root[data-theme=gaming] .button.danger.subtle:hover{background:var(--theme-danger-surface)}
:root[data-theme=gaming] .text-button.danger{color:var(--theme-danger)}
:root[data-theme=gaming] button:disabled{opacity:1;background:#202a40;border-color:#3e4b67;color:#a6b1c8;box-shadow:none;cursor:not-allowed}
:root[data-theme=gaming] .primary-nav a{color:var(--muted)}
:root[data-theme=gaming] .primary-nav a:hover,:root[data-theme=gaming] .primary-nav a.active{color:var(--ink)}
:root[data-theme=gaming] .primary-nav a.active:after{background:var(--cobalt)}
:root[data-theme=gaming] :is(.hero-note,.filter-right,.card-meta,.footer-bottom,.file-item small,.editor-footer){color:var(--muted)}
:root[data-theme=gaming] .badge{background:#27324d;color:#d3dcf3}
:root[data-theme=gaming] .badge.premium{background:#352957;color:#d5c5ff}
:root[data-theme=gaming] .badge.green{background:#173d3b;color:var(--theme-success)}
:root[data-theme=gaming] .card-badge{background:#292349ed!important;color:#e0d5ff!important;border:1px solid #716098}
:root[data-theme=gaming] .avatar{background:#2d365b;color:#e0d9ff}
:root[data-theme=gaming] .avatar.large{background:#2a355c;color:#e0d9ff}
:root[data-theme=gaming] .account-link{border-color:#6874a2}
:root[data-theme=gaming] .account-link:hover{background:#394771}
:root[data-theme=gaming] .spotlight,:root[data-theme=gaming] .empty-spotlight{background:linear-gradient(135deg,#202e52,#302347);border:1px solid #566193;box-shadow:0 16px 50px #080c1b66}
:root[data-theme=gaming] .spotlight-top .badge{background:#141d36b3;border-color:#7a89b5;color:#d1dcff}
:root[data-theme=gaming] .circle-arrow{border-color:#8d9ac5;color:#e0d9ff}
:root[data-theme=gaming] .stacked-dots i{background:#876cb2}
:root[data-theme=gaming] .stacked-dots i:first-child{background:#587aab}
:root[data-theme=gaming] .stacked-dots i:nth-child(2){background:#6472b5}
:root[data-theme=gaming] .filter-pill:hover{background:var(--theme-hover);border-color:#7686a6}
:root[data-theme=gaming] .filter-pill.selected{background:#2d3d68;border-color:#8294d9;color:#f1f4ff}
:root[data-theme=gaming] .rating{color:#cfbaff}
:root[data-theme=gaming] .rating .icon{fill:#bf9eff;stroke:#bf9eff}
:root[data-theme=gaming] .rating-summary>.icon{color:#bf9eff}
:root[data-theme=gaming] .card-art-link{background:var(--surface);border:1px solid var(--line)}
:root[data-theme=gaming] .artwork{background:#1b2742}
:root[data-theme=gaming] .art-grid{opacity:.4;background-image:linear-gradient(#899edd30 1px,transparent 1px),linear-gradient(90deg,#899edd30 1px,transparent 1px)}
:root[data-theme=gaming] .art-orbit{background:linear-gradient(135deg,#202c4e,#30204c)}
:root[data-theme=gaming] .art-orbit .shape-one{border-color:#8a91d6}
:root[data-theme=gaming] .art-orbit .shape-two{background:#5866bb;box-shadow:0 0 45px #7b65dd40}
:root[data-theme=gaming] .art-orbit .shape-three{border-color:#a797eb}
:root[data-theme=gaming] .art-orbit .art-symbol{color:#eef0ff}
:root[data-theme=gaming] :is(.art-wave,.variation-3.art-wave){background:linear-gradient(135deg,#162f4c,#242649)}
:root[data-theme=gaming] .art-wave .shape-one{border-color:#415e8f}
:root[data-theme=gaming] .art-wave .shape-two{border-color:#6380b2}
:root[data-theme=gaming] .art-wave .shape-three{background:#726cbd}
:root[data-theme=gaming] .art-canvas{background:linear-gradient(135deg,#2c2344,#202d45)}
:root[data-theme=gaming] .art-canvas .shape-one{background:#303451;border-color:#7a81ac;box-shadow:3px 8px 25px #080d2233}
:root[data-theme=gaming] .art-canvas .shape-two{background:#9e6eb0}
:root[data-theme=gaming] .art-canvas .shape-three{background:#5f9ba9}
:root[data-theme=gaming] :is(.art-game,.variation-1.art-game){background:linear-gradient(135deg,#172f4b,#292349)}
:root[data-theme=gaming] .art-game .shape-one{background:repeating-conic-gradient(#435283 0% 25%,#7184b8 0% 50%) 0 0/48px 48px;border-color:#b6bfea;box-shadow:7px 10px 0 #101b4366}
:root[data-theme=gaming] .art-game .shape-two{background:#bea6ee;box-shadow:0 5px 0 #8062aa}
:root[data-theme=gaming] .art-game .shape-three{background:#55a4c1;box-shadow:0 5px 0 #276485}
:root[data-theme=gaming] .art-game .art-symbol{color:#382758}
:root[data-theme=gaming] :is(.art-story,.variation-2.art-story){background:linear-gradient(135deg,#292744,#193444)}
:root[data-theme=gaming] .art-story .shape-one{background:#527493;box-shadow:14px 9px 0 #333a69}
:root[data-theme=gaming] .art-story .shape-two{background:#829bc0}
:root[data-theme=gaming] .art-story .shape-three{background:#d2c3f6}
:root[data-theme=gaming] .art-story .art-symbol{color:#42305f}
:root[data-theme=gaming] .weekly-banner{background:linear-gradient(110deg,#182940,#252242);border-color:#47577c}
:root[data-theme=gaming] :is(.weekly-medallion,.award-icon){background:#2a3159;border-color:#909bce;color:#d0c0ff}
:root[data-theme=gaming] .code-art{background:#1b2543}
:root[data-theme=gaming] .code-window{background:#10182c;border-color:#3c4869;color:#eef2ff;box-shadow:0 12px 35px #05091766}
:root[data-theme=gaming] .window-dots i{background:#8998c2}
:root[data-theme=gaming] .code-line{color:#b1abff}
:root[data-theme=gaming] .code-line.indent{color:#b9d5ff}
:root[data-theme=gaming] .code-published{color:var(--theme-success)}
:root[data-theme=gaming] .footer-bottom{border-color:var(--line)}
:root[data-theme=gaming] .notice{background:#1d2a45;border-color:#475d84;color:#c7d5ef}
:root[data-theme=gaming] :is(.field input,.field select,.field textarea,input[type=search]){background:#10192c;border-color:#5d6e90;color:var(--ink)}
:root[data-theme=gaming] :is(input,textarea)::placeholder{color:#9aaac7;opacity:1}
:root[data-theme=gaming] :is(.field input,.field select,.field textarea,input[type=search]):focus{outline:2px solid #acc9ff55;border-color:var(--theme-focus)}
:root[data-theme=gaming] :is(.field input,.field select,.field textarea):disabled{background:#202a40;color:#a6b1c8;opacity:1;cursor:not-allowed}
:root[data-theme=gaming] .field input[type=file]::file-selector-button{background:#303f62;color:var(--ink)}
:root[data-theme=gaming] :is(.dialog,.runtime-dialog){box-shadow:0 25px 100px #040817aa}
:root[data-theme=gaming] :is(.dialog,.runtime-dialog)::backdrop{background:#060b1ccc}
:root[data-theme=gaming] .empty-state{background:#131d31;border-color:#53658a}
:root[data-theme=gaming] .empty-icon{background:#2b345a;color:#ccb9ff}
:root[data-theme=gaming] .spinner{border-color:#465473;border-top-color:var(--cobalt)}
:root[data-theme=gaming] .toast{background:#28385b;color:var(--ink);border:1px solid #6478a4;box-shadow:var(--shadow)}
:root[data-theme=gaming] .toast.error{background:var(--theme-danger-surface);border-color:#a9617c}
:root[data-theme=gaming] .toast.error .icon{color:var(--theme-danger)}
:root[data-theme=gaming] .rank-badge{border-color:#68799e}
:root[data-theme=gaming] :is(.story-cover,.article-art){background:linear-gradient(130deg,#23364e,#332b54)}
:root[data-theme=gaming] .story-cover-1{background:linear-gradient(130deg,#1b3451,#2c305b)}
:root[data-theme=gaming] .story-cover-2{background:linear-gradient(130deg,#3b2a4d,#21354b)}
:root[data-theme=gaming] .price-card.featured{background:linear-gradient(145deg,#252849,#192e43);border-color:#7a79b2}
:root[data-theme=gaming] :is(.feature-list .icon,.help-strip>.icon){color:var(--theme-success)}
:root[data-theme=gaming] .auth-art{background:linear-gradient(135deg,#1e304e,#32204d)}
:root[data-theme=gaming] .auth-orbit{background:#5663a2}
:root[data-theme=gaming] .auth-orbit:after{border-color:#b1a6f2}
:root[data-theme=gaming] .auth-art>.icon{color:#ddd0ff}
:root[data-theme=gaming] .danger-zone{border-color:#985a77}
:root[data-theme=gaming] .app-stage{background:#142039}
:root[data-theme=gaming] .launch-overlay{background:#0c15354d}
:root[data-theme=gaming] .launch-overlay p{background:#18233de8;color:#d0daef}
:root[data-theme=gaming] .runtime-open{background:var(--white)}
:root[data-theme=gaming] .runtime-viewport{background:#10182c}
:root[data-theme=gaming] :is(th,.table-empty,.endpoint-row,.panel-toolbar,.editor-footer){background:#1b2740}
:root[data-theme=gaming] .token-value{background:#10192c;color:var(--ink)}
:root[data-theme=gaming] .file-item{color:var(--muted)}
:root[data-theme=gaming] :is(.file-item.selected,.admin-nav button.active){background:#293655;color:#d8e2ff}
:root[data-theme=gaming] :is(.file-item,.admin-nav button):hover{background:#22304a;color:var(--ink)}
:root[data-theme=gaming] .code-editor{background:#0f1729;color:#dce7ff;caret-color:#b9caff}
:root[data-theme=gaming] .code-editor:disabled{background:#172037;color:#a6b1c8}
:root[data-theme=gaming] .code-editor:focus{box-shadow:inset 0 0 0 2px #93adf0}
:root[data-theme=gaming] .studio-preview-stage{background:#10192c}
:root[data-theme=gaming] .form-error{background:var(--theme-danger-surface);border-color:#b7708b;color:#ffc5cf}
:root[data-theme=gaming] .notification-count{background:#ff9ba9}
:root[data-theme=gaming] .theme-menu{box-shadow:0 16px 48px #03071899;border-color:#5a6b91}
:root[data-theme=gaming] .theme-option input{accent-color:#a9baff}

@media(prefers-contrast:more){:root[data-theme=gaming]{--muted:#d0daef;--line:#7283a5}:root[data-theme=gaming] :is(.panel,.dialog,.stat,.table-wrap,.studio-workspace){border-color:#7283a5}:root[data-theme=gaming] .theme-menu{border-width:2px}}
@media(forced-colors:active){.theme-control>summary,.theme-menu,.theme-option:has(input:checked){border:1px solid ButtonText}.theme-menu{background:Canvas;color:CanvasText}.theme-option small,.theme-menu-title{color:CanvasText}.theme-option:focus-within{outline-color:Highlight}}
@media(prefers-reduced-motion:reduce){.theme-control *{transition:none;animation:none}}
