<?php
session_start();
header('Content-Type: text/html; charset=UTF-8');

$checks = [
    'PHP' => PHP_VERSION,
    'ROM endpoint' => file_exists(__DIR__ . '/rom.php') ? 'OK' : 'ERRO',
    'EmulatorJS loader' => file_exists(__DIR__ . '/emulatorjs/loader.js') ? 'OK' : 'ERRO',
    'EmulatorJS emulator' => file_exists(__DIR__ . '/emulatorjs/emulator.js') ? 'OK' : 'ERRO',
    'Cores JSON' => file_exists(__DIR__ . '/emulatorjs/cores/cores.json') ? 'OK' : 'ERRO',
    'Uploads folder' => is_dir(__DIR__ . '/../dados/uploads') ? 'OK' : 'ERRO',
    'Jogos JSON' => file_exists(__DIR__ . '/../dados/jogos.json') ? 'OK' : 'ERRO',
];
?>
<!doctype html><html lang="pt-BR"><head><meta charset="utf-8"><title>Diagnóstico JG2 Retro</title>
<style>body{font-family:Arial,sans-serif;padding:25px;background:#f4f7fb}table{border-collapse:collapse;background:#fff}td{padding:12px 18px;border:1px solid #ddd}.ok{color:green;font-weight:bold}.bad{color:#d00;font-weight:bold}</style></head>
<body><h1>🎮 Diagnóstico JG2 Retro</h1><table>
<?php foreach($checks as $k=>$v): ?><tr><td><?=htmlspecialchars($k)?></td><td class="<?=($v==='OK' || str_starts_with($v,'8.') || str_starts_with($v,'7.'))?'ok':'bad'?>"><?=htmlspecialchars($v)?></td></tr><?php endforeach; ?>
</table><p>Depois do teste, você pode apagar este arquivo.</p></body></html>
