/* ---------------------------------------------------------------------------
 * PC-88 Emulator Lab page (QUASI88 WASM) — Technosphere
 * Based on quasi88nc web styles (c) 2012 Takashi Toyoshima (BSD-3-Clause).
 * Restyled for technosphere.co.jp.
 * --------------------------------------------------------------------------- */

:root {
    --bg:        #0b0b0e;
    --bg2:       #101118;
    --card:      #15161c;
    --border:    rgba(255, 255, 255, 0.09);
    --text:      #f1f5f9;
    --muted:     #94a3b8;
    --accent:    #00c2d8;
    --accent2:   #0066ff;
    --amber:     #ffd9a8;
    --radius:    12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    background:
        radial-gradient(1100px 500px at 50% -10%, rgba(0, 102, 255, 0.14), transparent 60%),
        var(--bg);
    color: var(--text);
    font-family: 'M PLUS 1', 'Hiragino Kaku Gothic ProN', Meiryo, system-ui, sans-serif;
    min-height: 100vh;
    line-height: 1.8;
}

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

/* ---- Header / Footer ------------------------------------------------------ */

.lab-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 14px clamp(16px, 4vw, 40px);
    border-bottom: 1px solid var(--border);
}
.lab-header__brand {
    font-family: 'Montserrat', sans-serif;
    font-weight: 800;
    letter-spacing: 0.14em;
    font-size: 15px;
    color: var(--text);
    text-decoration: none;
}
.lab-header__brand span { color: var(--accent); }
.lab-header__nav { display: flex; gap: 18px; }
.lab-header__nav a {
    color: var(--muted);
    text-decoration: none;
    font-size: 13px;
}
.lab-header__nav a:hover { color: var(--text); }

.lab-footer {
    border-top: 1px solid var(--border);
    padding: 22px 16px 30px;
    text-align: center;
    color: var(--muted);
    font-size: 12.5px;
}
.lab-footer a { color: var(--muted); }

/* ---- Hero ------------------------------------------------------------------ */

.lab-main { max-width: 960px; margin: 0 auto; padding: 0 16px 40px; }

.lab-hero { text-align: center; padding: 40px 0 26px; }
.lab-hero__kicker {
    font-family: 'Montserrat', sans-serif;
    font-size: 11px;
    letter-spacing: 0.32em;
    color: var(--accent);
    margin-bottom: 10px;
}
.lab-hero__title {
    font-size: clamp(26px, 5.4vw, 42px);
    font-weight: 800;
    line-height: 1.3;
}
.lab-hero__sub { font-size: 0.62em; font-weight: 700; color: var(--amber); }
.lab-hero__lead {
    margin: 18px auto 0;
    max-width: 720px;
    font-size: 14.5px;
    color: var(--muted);
}
.lab-hero__lead strong { color: var(--text); }

/* ---- Emulator stage --------------------------------------------------------- */

.lab-stage-wrap { position: relative; display: flex; flex-direction: column; align-items: center; }

#stage {
    position: relative;
    width: 640px;
    max-width: 100%;
    background: #000;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: 0 24px 60px -18px rgba(0, 0, 0, 0.7), 0 0 42px -18px rgba(0, 194, 216, 0.45);
}

#canvas {
    display: block;
    width: 100%;
    aspect-ratio: 640 / 420;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    background: #000;
}

#toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: #0e0e13;
    border-top: 1px solid var(--border);
    height: 36px;
}

.progress {
    flex: 1;
    height: 6px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 3px;
    overflow: hidden;
}
#progress-bar {
    display: block;
    width: 0;
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent2));
    transition: width 0.2s;
}

.tool-btn {
    font-family: 'Montserrat', sans-serif;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--text);
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 4px 12px;
    cursor: pointer;
}
.tool-btn:hover { border-color: var(--accent); color: var(--accent); }

.lab-stateline {
    margin-top: 12px;
    font-size: 13px;
    color: var(--amber);
    text-align: center;
    min-height: 1.6em;
}
.lab-stagenote {
    margin-top: 2px;
    font-size: 12px;
    color: var(--muted);
    text-align: center;
}

/* ---- ROM picker modal -------------------------------------------------------- */

.modal {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 8px;
    z-index: 10;
}
.modal-card {
    width: 640px;
    max-width: 100%;
    max-height: 100%;
    overflow: auto;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 24px 48px -16px rgba(0, 0, 0, 0.7);
}
.modal-header {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 15px; font-weight: 700; }
.modal-body { padding: 14px 18px; }
.modal-note {
    font-size: 12px;
    color: var(--muted);
    background: rgba(0, 102, 255, 0.08);
    border-left: 3px solid var(--accent2);
    border-radius: 6px;
    padding: 10px 12px;
    margin-bottom: 12px;
}
.modal-note strong { color: var(--text); }

.rom-table-scroll { overflow-x: auto; }
.rom-table { width: 100%; border-collapse: collapse; font-size: 12.5px; white-space: nowrap; }
.rom-table td { padding: 7px 8px; border-bottom: 1px solid rgba(255, 255, 255, 0.05); }
.rom-table td:nth-child(2), .rom-table td:nth-child(3) {
    font-family: 'Montserrat', monospace;
    font-size: 11.5px;
    color: var(--muted);
}
.rom-table .state { color: var(--muted); font-size: 11.5px; }
.rom-table .state.optional { color: #64748b; }

.select-btn {
    font-size: 11.5px;
    color: var(--text);
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 3px 14px;
    cursor: pointer;
}
.select-btn:hover { border-color: var(--accent); color: var(--accent); }

.modal-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 12px 18px 16px;
    border-top: 1px solid var(--border);
}
.primary-btn {
    font-size: 13px;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    border: none;
    border-radius: 999px;
    padding: 9px 28px;
    cursor: pointer;
}
.primary-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.ghost-btn {
    font-size: 12.5px;
    color: var(--muted);
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 8px 18px;
    cursor: pointer;
}
.ghost-btn:hover { color: var(--text); border-color: var(--accent); }

/* ---- Content sections --------------------------------------------------------- */

.lab-section {
    max-width: 760px;
    margin: 42px auto 0;
}
.lab-section h2 {
    font-size: 19px;
    font-weight: 800;
    margin-bottom: 12px;
    padding-left: 12px;
    border-left: 4px solid var(--accent);
}
.lab-section p, .lab-section li { font-size: 14px; color: #cbd5e1; }
.lab-section ul, .lab-section ol { padding-left: 22px; margin-top: 6px; }
.lab-section li { margin-bottom: 8px; }
.lab-section strong { color: var(--text); }

.lab-section--legal {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px 24px;
}
.lab-section--legal h2 { border-left-color: var(--amber); }

.lab-credits { list-style: none; padding-left: 0; }
.lab-credits li {
    font-size: 13px;
    color: var(--muted);
    padding: 6px 0;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.08);
}

/* ---- CTA ------------------------------------------------------------------------ */

.lab-cta {
    margin: 48px auto 10px;
    max-width: 760px;
    text-align: center;
    background: linear-gradient(135deg, rgba(0, 194, 216, 0.10), rgba(0, 102, 255, 0.10));
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 26px 20px;
}
.lab-cta p { font-size: 14px; color: #cbd5e1; margin-bottom: 16px; }
.lab-cta__links { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.lab-cta__btn {
    display: inline-block;
    font-size: 13.5px;
    font-weight: 700;
    color: #fff;
    text-decoration: none;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    border-radius: 999px;
    padding: 11px 30px;
}
.lab-cta__btn--ghost {
    background: transparent;
    border: 1px solid var(--accent);
    color: var(--accent);
}

@media (max-width: 480px) {
    .lab-hero { padding-top: 26px; }
    .modal { padding: 4px; }
    .modal-footer { justify-content: center; }
}
