:root {
    --bg-color: #0d1117;
    --text-color: #c9d1d9;
    --panel-bg: #161b22;
    --btn-bg: #21262d;
    --btn-border: #30363d;
    --btn-active-bg: #1f6feb; 
    --btn-active-border: #388bfd;
}

* { 
    box-sizing: border-box; 
    margin: 0; padding: 0; 
    user-select: none; 
    -webkit-user-select: none; 
    touch-action: none; 
    -webkit-tap-highlight-color: transparent; 
}

body { 
    position: fixed;
    width: 100%;
    background: var(--bg-color); 
    color: var(--text-color); 
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif; 
    display: flex; flex-direction: column; align-items: center; 
    justify-content: space-between; height: 100vh; height: 100dvh; 
    overflow: hidden; padding-bottom: env(safe-area-inset-bottom);
    overscroll-behavior: none;
}

#screen-container { flex-grow: 1; display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; overflow: hidden; position: relative; }
canvas { width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; background: #000; }

.config-panel {
    position: absolute;
    inset: 0;
    z-index: 20;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px;
    background: rgba(13, 17, 23, 0.96);
    color: var(--text-color);
    border-radius: 0;
    box-sizing: border-box;
    pointer-events: auto;
    overflow-y: auto;
    touch-action: pan-y;
    overscroll-behavior: contain;
}

.config-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.config-button {
    background: var(--btn-bg);
    border: 2px solid var(--btn-border);
    color: var(--text-color);
    padding: 8px 12px;
    border-radius: 10px;
    font-weight: bold;
    cursor: pointer;
}

.config-button:hover {
    border-color: var(--btn-active-border);
}

.config-button:focus,
.config-button:focus-visible,
#configTextarea:focus,
#configTextarea:focus-visible {
    outline: none;
    box-shadow: none;
}

#configTextarea {
    width: 100%;
    flex: 1;
    min-height: 0;
    background: #0d1117;
    color: var(--text-color);
    border: 1px solid #30363d;
    border-radius: 0px;
    padding: 12px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 12px;
    resize: none;
    overflow: auto;
    touch-action: pan-y;
    overscroll-behavior: contain;
}

.config-autolock {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    user-select: none;
}

.config-autolock input {
    width: 16px;
    height: 16px;
}

.config-options {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    font-size: 12px;
}

.form-select {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    font-size: 12px;
}
/* -------------------------------------------------------- */

#controls { 
    width: 100%; 
    height: 100%;     
    background: var(--panel-bg); 
    border-top: 1px solid var(--btn-border);
    position: relative;
}

.layout-container { display: none; width: 100%; height: 100%; padding: 5px; }
.layout-container.active { display: flex; }

button:active, .active-press { 
    background: var(--btn-active-bg) !important; 
    border-color: var(--btn-active-border) !important; 
    color: #fff !important; 
}

/* --- TOGGLE SWITCH & UTILS --- */
.switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
    margin: 0 auto;
}

.switch input { opacity: 0; width: 0; height: 0; }

.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: var(--btn-border);
    transition: .4s;
    border-radius: 22px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 14px; width: 14px;
    left: 4px; bottom: 4px;
    background-color: var(--text-color);
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider { background-color: var(--btn-active-bg); }
input:checked + .slider:before { transform: translateX(18px); background-color: #fff; }

.top-link-bar {
    width: 100%;
    padding: 10px 0;
    display: flex;
    justify-content: center;
    background: rgba(0, 0, 0, 0.08);
}

.top-link-bar a { color: #999; font-size: 13px; text-decoration: none; }
.top-link-bar a:hover { color: #bbb; }

@media (orientation: landscape) {
    body { flex-direction: row; align-items: stretch; justify-content: space-between; }
    #screen-container { width: 50%; height: 100%; padding: 16px; }
    #controls { width: 50%; height: 100%; min-height: auto; border-top: none; border-left: 1px solid var(--btn-border); }
    .layout-container { padding: 12px; }
}

#welcome-intro {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    background: #0d1117;
    color: var(--text-color);
    z-index: 99999;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    transition: opacity 0.6s ease, visibility 0.6s ease;
}

.intro-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 20px;
}

.intro-content h1 {
    font-size: 28px;
    color: #ffffff;
    font-weight: bold;
}

.intro-content p {
    font-size: 14px;
    color: #8b949e;
}

.reset-config {
    background: none;
    border: none;
    color: inherit;
    font: inherit;
    cursor: pointer;
    padding: 0;
}