@import url('https://fonts.googleapis.com/css?family=Press Start 2P');

:root {
    --bg: #1a1d21;
    --surface: #252a30;
    --border: #3d454f;
    --text: #e4e8ec;
    --text-muted: #8a939e;
    --accent: #7ca3c4;
}

* {
    box-sizing: border-box;
}

html,
body {
    background-color: var(--bg);
    font-family: 'Lucida Console', Monaco, monospace;
    font-size: 14px;
    color: var(--text);
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden;
}

input[type="file"] {
    display: none;
}

a:link,
a:visited,
a:active,
a:hover {
    color: var(--text);
}

a:hover {
    color: var(--accent);
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

header h1 {
    font-family: 'Press Start 2P', monospace;
    font-size: 24px;
    color: var(--accent);
    margin: 0;
}

header a {
    font-size: 13px;
    text-decoration: none;
}

.main-content {
    flex: 1;
    display: flex;
    min-height: 0;
    overflow: hidden;
}

.sidebar {
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border-right: 1px solid var(--border);
    width: 280px;
    flex-shrink: 0;
    overflow-y: auto;
}

.canvas-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: auto;
    padding: 24px;
}

canvas {
    border: 2px solid var(--border);
    display: block;
    image-rendering: pixelated;
    flex-shrink: 0;
}

.section {
    border-bottom: 1px solid var(--border);
}

.section:last-child {
    border-bottom: none;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.15s;
}

.section-header:hover {
    background-color: var(--bg);
}

.section-title {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}

.section-toggle {
    font-size: 10px;
    color: var(--text-muted);
    transition: transform 0.15s;
}

.section-toggle.collapsed {
    transform: rotate(-90deg);
}

.section-content {
    padding: 0 16px 16px 16px;
}

.section-content.collapsed {
    display: none;
}

.panel-section {
    margin-bottom: 12px;
}

.panel-section:last-child {
    margin-bottom: 0;
}

.section-content>.panel-section:has(.stepper-row) {
    margin-bottom: 0;
}

.subsection-header {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}

.panel-section:first-child .subsection-header {
    margin-top: 4px;
}

.btn {
    height: 36px;
    padding: 0 14px;
    font-family: inherit;
    font-size: 13px;
    color: var(--text);
    background-color: transparent;
    border: 1px solid var(--border);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.15s, color 0.15s;
    user-select: none;
}

.btn:hover {
    border-color: var(--text-muted);
    color: var(--accent);
}

.btn-full {
    width: 100%;
}

.info-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
}

.info-label {
    color: var(--text-muted);
}

.info-value {
    text-align: right;
}

.control-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
}

.control-action {
    color: var(--text-muted);
}

.control-key {
    background: var(--bg);
    padding: 4px 10px;
    font-size: 12px;
    border: 1px solid var(--border);
}

.panel-top {
    padding: 16px;
    border-bottom: 1px solid var(--border);
}

.panel-top .stepper-row {
    margin-top: 12px;
}

.button-row {
    display: flex;
    gap: 8px;
}

.button-row .btn {
    flex: 1;
}

.stepper-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stepper-label {
    color: var(--text-muted);
}

.stepper {
    display: flex;
    align-items: center;
    gap: 8px;
}

.stepper-btn {
    width: 24px;
    height: 24px;
    font-family: inherit;
    font-size: 10px;
    color: var(--text-muted);
    background-color: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s;
}

.stepper-btn:hover {
    color: var(--accent);
}

.stepper-value {
    min-width: 80px;
    text-align: center;
    font-size: 13px;
}

.stepper-value.clickable {
    cursor: pointer;
    transition: color 0.15s;
}

.stepper-value.clickable:hover {
    color: var(--accent);
}

.debug-registers {
    font-family: 'Lucida Console', Monaco, monospace;
    font-size: 12px;
}

.register-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 3px 0;
}

.register-name {
    color: var(--text-muted);
    width: 24px;
}

.register-value {
    font-family: monospace;
    background: var(--bg);
    padding: 2px 6px;
    border: 1px solid var(--border);
    min-width: 32px;
    text-align: center;
}

.register-value.wide {
    min-width: 52px;
}

.flags-row,
.gpu-flags {
    display: flex;
    gap: 8px;
    padding: 6px 0;
    justify-content: flex-start;
    align-items: center;
}

.flags-label {
    color: var(--text-muted);
    font-size: 11px;
    min-width: 36px;
}

.flag {
    padding: 3px 8px;
    font-size: 11px;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text-muted);
}

.flag.set {
    background: var(--accent);
    color: var(--bg);
    border-color: var(--accent);
}

.status-row {
    display: flex;
    justify-content: flex-start;
    gap: 16px;
    padding: 6px 0;
}

.status-label {
    color: var(--text-muted);
    font-size: 11px;
}

.status-value {
    margin-left: 4px;
    font-family: monospace;
}

.debug-gpu .info-row {
    padding: 4px 0;
}

.tile-viewer {
    padding: 8px 0;
}

.tile-canvas {
    border: 1px solid var(--border);
    image-rendering: pixelated;
    width: 100%;
    height: auto;
    aspect-ratio: 128 / 192;
}

@media (max-width: 700px) {
    header {
        padding: 12px 16px;
    }

    header h1 {
        font-size: 16px;
    }

    .sidebar {
        width: 240px;
    }

    .canvas-wrapper {
        padding: 16px;
    }
}
