@font-face {
    font-family: Aptos;
    src: local("Aptos"), local("Aptos Display");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: Aptos;
    src: local("Aptos"), local("Aptos Display");
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: Aptos;
    src: local("Aptos"), local("Aptos Display");
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

:root {
    --ui: Aptos, "Segoe UI", "Source Sans 3", sans-serif;
    --bg: #181818;
    --editor: #1f1f1f;
    --line: #2b2b2b;
    --hover: #2a2d2e;
    --active: #37373d;
    --text: #cccccc;
    --bright: #ffffff;
    --muted: #858585;
    --blue: #007fd4;
    --kw: #c586c0;
    --fn: #dcdcaa;
    --cls: #4ec9b0;
    --str: #ce9178;
    --num: #b5cea8;
    --cm: #6a9955;
    --vr: #9cdcfe;
    --bi: #569cd6;
    --activity: 48px;
    --side: clamp(220px, 24vw, 300px);
}

html, body { background: var(--bg); }
body { font-family: var(--ui); }
.ide {
    height: 100dvh;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    padding-top: env(safe-area-inset-top);
    padding-right: env(safe-area-inset-right);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    overflow: hidden;
    background: var(--bg);
    color: var(--text);
    font-family: var(--ui);
}
.ide :focus-visible { outline: 1px solid var(--blue); outline-offset: -1px; }
.titlebar, .tabs, .activity, .sidebar, .status, .crumbs, .tab { user-select: none; }
.titlebar {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    height: 38px;
    padding: 0 12px;
    background: var(--bg);
    border-bottom: 1px solid var(--line);
    flex: 0 0 auto;
}
.lights { display: flex; gap: 8px; position: relative; z-index: 1; }
.lights i { width: 12px; height: 12px; border-radius: 50%; display: block; }
.lights i:nth-child(1) { background: #ff5f57; }
.lights i:nth-child(2) { background: #febc2e; }
.lights i:nth-child(3) { background: #28c840; }
.window-title {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
}
.command-center {
    position: absolute;
    left: 50%;
    z-index: 1;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 8px;
    height: 24px;
    width: min(480px, calc(100% - 200px));
    padding: 0 10px;
    border: 1px solid #3c3c3c;
    border-radius: 6px;
    background: #2c2c2c;
    color: #9a9a9a;
    font-family: inherit;
    font-size: 12px;
}
.command-center:hover { background: #353535; color: var(--text); }
.command-center svg { flex: 0 0 auto; }
.command-center span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.command-center kbd, .empty kbd, .palette-hint kbd {
    display: inline-block;
    margin-left: 2px;
    padding: 0 4px;
    border: 1px solid #555;
    border-bottom-width: 2px;
    border-radius: 3px;
    color: #ddd;
    font-family: inherit;
    font-size: 11px;
    line-height: 16px;
}
.avatar {
    position: relative;
    z-index: 1;
    margin-left: auto;
    width: 22px;
    height: 22px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: #0e639c;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
}
.workbench { position: relative; flex: 1; display: flex; min-height: 0; min-width: 0; overflow: hidden; }
.activity {
    width: var(--activity);
    flex: 0 0 var(--activity);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding-top: 4px;
    background: var(--bg);
    border-right: 1px solid var(--line);
}
.activity button {
    position: relative;
    width: var(--activity);
    height: 46px;
    display: grid;
    place-items: center;
    border: 0;
    background: transparent;
    color: #858585;
}
.activity button:hover { color: #fff; }
.activity button[aria-pressed="true"], .activity button.is-on { color: #fff; }
.activity button[aria-pressed="true"]::before {
    content: "";
    position: absolute;
    left: 0;
    top: 8px;
    bottom: 8px;
    width: 2px;
    background: #fff;
}
.sidebar {
    width: var(--side);
    flex: 0 0 var(--side);
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: var(--bg);
    border-right: 1px solid var(--line);
    transition: width .16s ease, flex-basis .16s ease;
}
html[data-sidebar="closed"] .sidebar { width: 0; flex-basis: 0; border-right-color: transparent; overflow: hidden; }
.side-title {
    height: 35px;
    display: flex;
    align-items: center;
    padding: 0 14px;
    color: #bbb;
    font-size: 11px;
    letter-spacing: .08em;
}
.ext-search {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 26px;
    margin: 0 12px 6px;
    padding: 0 8px;
    border: 1px solid #3c3c3c;
    border-radius: 2px;
    background: #2c2c2c;
    color: #858585;
    font-size: 13px;
    pointer-events: none;
}
.ext-search span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ext-section {
    padding: 10px 20px 4px;
    color: #bbb;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .06em;
}
.ext-list { overflow: auto; padding-bottom: 16px; }
.ext {
    display: grid;
    grid-template-columns: 42px 1fr;
    column-gap: 10px;
    row-gap: 1px;
    padding: 8px 16px 10px;
    pointer-events: none;
}
.ext-icon {
    grid-row: 1 / span 3;
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 6px;
    color: #1e1e1e;
    font-size: 18px;
    font-weight: 700;
}
.ext-name { display: flex; align-items: baseline; gap: 8px; color: #fff; font-size: 13px; line-height: 18px; }
.ext-badge { color: #858585; font-size: 11px; font-weight: 400; }
.ext-desc, .ext-pub, .ext-empty { margin: 0; color: #9d9d9d; font-size: 12px; line-height: 16px; }
.ext-pub { color: #858585; }
.ext-empty { padding: 8px 20px; }
.sidebar-backdrop { display: none; }
.editor-group { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--editor); overflow: hidden; }
.tabs {
    display: flex;
    flex: 0 0 auto;
    max-width: 100%;
    overflow-x: auto;
    background: var(--bg);
    border-bottom: 1px solid var(--line);
    scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab { display: flex; align-items: stretch; flex: 0 0 auto; height: 35px; background: var(--bg); border-right: 1px solid var(--line); color: #969696; }
.tab.is-active { background: var(--editor); color: #fff; box-shadow: inset 0 1px 0 #e7e7e7; }
.tab-main {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 4px 0 12px;
    border: 0;
    background: transparent;
    color: inherit;
    font-family: inherit;
    font-size: 13px;
    white-space: nowrap;
}
.tab-close {
    width: 22px;
    margin-right: 6px;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: inherit;
    opacity: 0;
    font-size: 15px;
    line-height: 1;
}
.tab:hover .tab-close, .tab.is-active .tab-close, .tab-close:focus-visible { opacity: 1; }
.tab-close:hover { background: #3c3c3c; }
.mark { width: 16px; height: 16px; border-radius: 3px; flex: 0 0 auto; }
.mark.json { background: #d7ba7d; }
.mark.md { background: #519aba; }
.mark.lnk { background: #c586c0; }
.mark.game { background: transparent; border: 1.5px solid #3fb950; border-radius: 50%; }
.live-dot { width: 6px; height: 6px; border-radius: 50%; background: #3fb950; flex: 0 0 auto; }
.crumbs {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 8px;
    min-height: 32px;
    padding: 4px 8px 4px 14px;
    border-bottom: 1px solid var(--line);
    color: #a9a9a9;
    font-size: 12px;
}
#breadcrumb { display: flex; align-items: center; min-width: 0; overflow: hidden; }
.crumb { white-space: nowrap; }
.crumb.current { color: #e8e8e8; }
.sep { margin: 0 6px; opacity: .55; }
.crumb-hint { margin-left: 16px; color: var(--cm); white-space: nowrap; }
.game-tools { display: none; align-items: center; flex-wrap: wrap; gap: 4px; margin-left: auto; min-width: 0; max-width: 100%; }
.ide[data-active="block-runner"] .game-tools { display: flex; }
.game-tools::-webkit-scrollbar { display: none; }
.mode-label { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.game-tools select {
    height: 24px;
    min-height: 0;
    padding: 0 6px;
    border: 1px solid #3c3c3c;
    border-radius: 4px;
    background: #2d2d2d;
    color: var(--text);
    font-family: inherit;
    font-size: 12px;
}
.tool-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 24px;
    padding: 0 8px;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: var(--text);
    font-family: inherit;
    font-size: 12px;
    white-space: nowrap;
}
.tool-btn:hover { background: var(--hover); }
#muteIcon { width: 16px; height: 16px; fill: currentColor; display: block; }
.editor-body { position: relative; flex: 1; min-height: 0; }
.editor-pane { position: absolute; inset: 0; overflow: hidden; }
.code-scroll {
    height: 100%;
    overflow: auto;
    padding: 8px 0 48px;
    font-family: var(--ui);
    font-size: clamp(13px, 0.4vw + 12px, 15px);
    line-height: 1.45;
    color: #d4d4d4;
    scrollbar-color: #424242 transparent;
    scrollbar-width: thin;
}
.code-scroll:focus, .code-scroll:focus-visible { outline: none; }
.code-scroll ::selection { background: #264f78; }
.line { display: flex; min-height: 1.45em; }
.line:hover { background: rgba(255, 255, 255, .035); }
.line.current { background: #2a2d2e; }
.gutter { flex: 0 0 48px; padding-right: 12px; text-align: right; color: #6e7681; user-select: none; }
.line.current .gutter { color: #c6c6c6; }
.source {
    flex: 1;
    min-width: 0;
    padding-right: 24px;
    padding-left: calc(var(--indent, 0) * 16px);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    background-origin: border-box;
    background-repeat: no-repeat;
}
.guide { background-image: linear-gradient(90deg, transparent 15px, rgba(255,255,255,.14) 15px, rgba(255,255,255,.14) 16px, transparent 16px); }
.source.i2 { background-image: linear-gradient(90deg, transparent 15px, rgba(255,255,255,.14) 15px, rgba(255,255,255,.14) 16px, transparent 16px); }
.source.i3 { background-image: linear-gradient(90deg, transparent 15px, rgba(255,255,255,.14) 15px, rgba(255,255,255,.14) 16px, transparent 16px), linear-gradient(90deg, transparent 31px, rgba(255,255,255,.14) 31px, rgba(255,255,255,.14) 32px, transparent 32px); }
.source.i4, .source.i5, .source.i6 { background-image: linear-gradient(90deg, transparent 15px, rgba(255,255,255,.14) 15px, rgba(255,255,255,.14) 16px, transparent 16px), linear-gradient(90deg, transparent 31px, rgba(255,255,255,.14) 31px, rgba(255,255,255,.14) 32px, transparent 32px), linear-gradient(90deg, transparent 47px, rgba(255,255,255,.14) 47px, rgba(255,255,255,.14) 48px, transparent 48px); }
.tok.kw { color: var(--kw); }
.tok.fn { color: var(--fn); }
.tok.cls { color: var(--cls); }
.tok.str, a.tok.str { color: var(--str); text-decoration: none; }
a.tok.str:hover { text-decoration: underline; }
.tok.num { color: var(--num); }
.tok.cm { color: var(--cm); }
.tok.vr, .tok.key { color: var(--vr); }
.tok.bi, .tok.hd { color: var(--bi); }
.tok.pn, .tok.tx { color: #d4d4d4; }
.caret {
    display: inline-block;
    width: 2px;
    height: .95em;
    margin-left: 1px;
    background: #aeafad;
    vertical-align: text-bottom;
    animation: ide-blink 1.06s steps(1) infinite;
}
@keyframes ide-blink { 50% { opacity: 0; } }
.empty {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: var(--muted);
    text-align: center;
    padding: 24px;
}
.empty strong { color: #ddd; font-size: 18px; font-weight: 600; }
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}
.status {
    flex: 0 0 auto;
    height: 24px;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0 8px;
    background: var(--bg);
    border-top: 1px solid var(--line);
    color: #9d9d9d;
    font-size: 12px;
}
.status-side { display: flex; align-items: center; gap: 12px; min-width: 0; }
.status-side.right { margin-left: auto; }
.status-item { white-space: nowrap; }
#statusFile::before {
    content: "";
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-right: 6px;
    border-radius: 50%;
    background: #3fb950;
}
#statusLang { color: #4fc1ff; }
.palette {
    position: fixed;
    z-index: 60;
    top: 14vh;
    left: 50%;
    transform: translateX(-50%);
    width: min(560px, calc(100% - 32px));
    background: #252526;
    border: 1px solid #454545;
    border-radius: 6px;
    box-shadow: 0 18px 60px #000c;
    overflow: hidden;
}
.palette input {
    width: 100%;
    height: 42px;
    border: 0;
    border-bottom: 1px solid #3c3c3c;
    background: transparent;
    color: #eee;
    padding: 0 14px;
    font-family: inherit;
    font-size: 14px;
    outline: none;
}
.palette-list { max-height: 280px; overflow: auto; padding: 4px 0; }
.palette-row {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    height: 32px;
    padding: 0 14px;
    border: 0;
    background: transparent;
    color: #ccc;
    font-family: inherit;
    font-size: 13px;
    text-align: left;
}
.palette-row small { margin-left: auto; color: #8d8d8d; }
.palette-row.is-selected, .palette-row:hover { background: #04395e; color: #fff; }
.palette-row.is-selected small, .palette-row:hover small { color: #d0e6f7; }
.palette-empty { margin: 0; padding: 12px 14px; color: var(--muted); font-size: 13px; }
.palette-hint {
    display: flex;
    gap: 14px;
    padding: 6px 12px 8px;
    border-top: 1px solid #3c3c3c;
    color: #8d8d8d;
    font-size: 11px;
}
.code-fallback { margin: 0; padding: 16px 20px; color: var(--cm); }

#arcade.arcade-viewport { height: 100%; min-height: 0; }
#panel-game { background: #09151c; }
#panel-game:not([hidden]) { display: block; }
#gameCanvas:focus, #gameCanvas:focus-visible { outline: none; }
#arcade .runner-hud { top: 12px; left: 14px; }
#arcade .overlay { padding: 20px 16px; }
#arcade .wordmark, #arcade .portal-trigger { display: none; }

@media (max-width: 1099px), (max-height: 639px) {
    .sidebar {
        position: absolute;
        z-index: 25;
        top: 0;
        bottom: 0;
        left: var(--activity);
        width: min(300px, calc(100% - var(--activity) - 8px));
        flex-basis: auto;
        box-shadow: 12px 0 40px #0008;
    }
    html[data-sidebar="closed"] .sidebar { display: none; }
    html[data-sidebar="open"] .sidebar-backdrop {
        display: block;
        position: absolute;
        z-index: 24;
        inset: 0 0 0 var(--activity);
        border: 0;
        background: #0008;
    }
}
@media (max-width: 900px) { .crumb-hint { display: none; } }
@media (max-width: 760px) {
    .command-center { position: static; transform: none; width: 32px; min-width: 0; padding: 0; justify-content: center; }
    .command-center span, .command-center kbd { display: none; }
    .mode-label span { display: none; }
    #breadcrumb .crumb:first-child, #breadcrumb .sep:first-of-type { display: none; }
    .status-quiet { display: none; }
    .tab-main { padding-left: 8px; gap: 4px; font-size: 12px; }
    .gutter { flex-basis: 32px; padding-right: 8px; }
}
@media (max-width: 720px) and (min-height: 560px) {
    .ide[data-active="block-runner"] #breadcrumb { display: none; }
    .ide[data-active="block-runner"] .game-tools { width: 100%; margin-left: 0; }
}
@media (max-width: 420px) {
    :root { --activity: 42px; }
    .lights { display: none; }
    .titlebar { padding-left: 8px; }
    #statusDetail { display: none; }
}
@media (max-height: 560px) {
    .titlebar { height: 30px; }
    .tab { height: 28px; }
    .crumbs { min-height: 0; padding-top: 2px; padding-bottom: 2px; }
    .status { display: none; }
    .ide[data-active="block-runner"] #breadcrumb { display: none; }
    .palette { top: 8px; }
    .palette-list { max-height: min(240px, 42dvh); }
    .palette-hint { display: none; }
    #arcade .control-btn { width: 44px; height: 44px; }
    #arcade .jump-btn { width: 50px; height: 50px; }
    #arcade .mobile-controls { bottom: 8px; }
    #arcade .overlay { padding: 12px; }
    #arcade .overlay-title { font-size: clamp(1.5rem, 7vw, 2.2rem); }
}
@media (pointer: coarse) and (min-height: 560px) {
    .tool-btn, .game-tools select { height: 36px; min-height: 36px; }
    .tab { height: 40px; }
    .tab-close { width: 32px; }
}
@media (hover: none) { .tab-close { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
    .sidebar { transition: none; }
    .caret { animation: none; }
}
