:root {
    --bar-h: 44px;
    --menu-w: 300px;

    --bg-page: #05070b;
    --bg-elevated: #141a22;
    --card-bg: #171d28;
    --card-bd: #273246;
    --accent: #4ea4ff;
    --accent-soft: rgba(78, 164, 255, 0.25);
    --text-main: #f5f7ff;
    --text-muted: #9ba7c5;
    --radius-lg: 12px;
    --gap: 18px;
}

html, body {
    margin: 0;
    height: 100%;
    background: var(--bg-page);
    color: var(--text-main);
}

body {
    font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto,
    Helvetica, Arial, "Noto Sans KR", "Malgun Gothic", sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

a {
    color: var(--accent);
    text-decoration: none;
}
a:hover {
    text-decoration: underline;
}
a:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    height: var(--bar-h);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 12px;
    background: var(--bg-elevated);
    border-bottom: 1px solid #223042;
}

.brand a {
    color: var(--text-main);
    text-decoration: none;
}

.spacer { flex: 1; }

.btn {
    background: #23272f;
    border: 1px solid #3b4252;
    border-radius: 999px;
    padding: 6px 12px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-main);
    transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}
.btn:hover {
    background: #2e3440;
    border-color: var(--accent);
}
.btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}


.userchip {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
    padding: 4px 8px;
    border-radius: 999px;
    transition: background 0.12s ease, box-shadow 0.12s ease;
}
.userchip:hover {
    background: rgba(255, 255, 255, 0.04);
}
.userchip:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}
.userchip img { width:24px; height:24px; border-radius:50%; object-fit: cover; background:#2b2b2b; }
.userchip .label { font-size:13px; opacity:.95; }

.stage {
    height: calc(100svh - var(--bar-h));
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    display: grid; place-items: center;
    background:#0f0f0f;
}

.stage iframe {
    width: min(100vw, calc((100svh - var(--bar-h)) * 0.5625));
    aspect-ratio: 576/1024;
    border: 0; background:#111; border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,.35);
}

.loader {
    position: absolute; inset: var(--bar-h) 0 0 0; /* 상단바 아래 전체 */
    display: grid; place-items: center; pointer-events: none;
}
.loader .box {
    display:flex; flex-direction:column; align-items:center; gap:10px;
    background:#1a1a1a; border:1px solid #2a2a2a; border-radius:12px;
    padding:14px 16px; box-shadow: 0 10px 26px rgba(0,0,0,.35);
}
.spinner { width:20px; height:20px; border:2px solid #555; border-top-color:#8cf; border-radius:50%; animation: spin 1s linear infinite; }
.muted { font-size:13px; color:#cfcfcf; opacity:.9; }
@keyframes spin { from { transform: rotate(0); } to { transform: rotate(360deg); } }

.menu {
    position: absolute;
    z-index: 20;
    width: min(90vw, var(--menu-w));
    background: var(--bg-elevated);
    border: 1px solid #223042;
    border-radius: 12px;
    box-shadow: 0 10px 26px rgba(0, 0, 0, 0.4);
    padding: 10px 12px;
    display: none;
}
.menu[data-open="true"] {
    display: block;
}
.menu::before {
    content: "";
    position: absolute;
    top: -8px;
    right: 24px;
    border-width: 8px;
    border-style: solid;
    border-color: transparent transparent var(--bg-elevated) transparent;
    filter: drop-shadow(0 -1px 0 #223042);
}
.menu .row {
    display: flex;
    align-items: center;
    gap: 10px;
}
.menu .name {
    font-weight: 600;
}
.menu .small {
    font-size: 12px;
    opacity: 0.85;
    color: var(--text-muted);
}
.menu .sep {
    height: 1px;
    background: #223042;
    margin: 10px 0;
}

.signed-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #1a2635;
    border: 1px solid #2d415c;
    border-radius: 999px;
    padding: 6px 10px;
    font-size: 13px;
}

.hidden {
    display: none !important;
}

#open-ad-layer {
    display: inline-block;
    padding: 8px 16px;
    background: #007bff;
    color: #fff;
    cursor: pointer;
    border-radius: 4px;
    user-select: none;
}

.ad-layer {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.ad-layer.visible {
    display: flex;
}

.ad-layer-content {
    position: relative;
    background: #fff;
    padding: 16px;
    border-radius: 8px;
    max-width: 360px;
    width: 100%;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

#close-ad-layer {
    position: absolute;
    top: 4px;
    right: 8px;
    border: none;
    background: transparent;
    font-size: 20px;
    cursor: pointer;
}

#open-payment-layer {
    display: inline-block;
    padding: 8px 16px;
    background: #007bff;
    color: #fff;
    cursor: pointer;
    border-radius: 4px;
    user-select: none;
}

.payment-layer {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.payment-layer.visible {
    display: flex;
}

.payment-layer-content {
    position: relative;
    background: #fff;
    padding: 16px;
    border-radius: 8px;
    max-width: 360px;
    width: 100%;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.payment-layer-content p {
    font-size: 13px;
    line-height: 1.35;
    margin: 0 0 12px 0;
    color: #202124;
}

#close-payment-layer {
    position: absolute;
    top: 4px;
    right: 8px;
    border: none;
    background: transparent;
    font-size: 20px;
    cursor: pointer;
}