ai-code-battle/web/replay.html
jedarden 41c7223f8a refactor(web): promote app.html to index.html as homepage
The main leaderboard SPA is now served at / (index.html) and the
standalone replay viewer lives at /replay.html. This removes the
_redirects workaround in index-builder that patched over the inverted
entry points.

- Rename web/app.html → web/index.html (main SPA)
- Rename web/index.html → web/replay.html (standalone viewer)
- Update vite.config.ts: main→index.html, replay→replay.html
- Remove _redirects injection from deploy.go verifyMergedOutput
- Update pages.json routes and README dev URL

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-25 08:51:52 -04:00

500 lines
11 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>AI Code Battle - Replay Viewer</title>
<style>
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
background-color: #0f172a;
color: #e2e8f0;
min-height: 100vh;
padding: 20px;
}
.container {
max-width: 1200px;
margin: 0 auto;
}
h1 {
font-size: 1.5rem;
margin-bottom: 20px;
color: #f8fafc;
}
.main-layout {
display: flex;
gap: 20px;
flex-wrap: wrap;
}
.viewer-container {
flex: 1;
min-width: 300px;
}
.canvas-wrapper {
background-color: #1e293b;
border-radius: 8px;
padding: 10px;
}
#replay-canvas {
display: block;
}
.sidebar {
width: 300px;
display: flex;
flex-direction: column;
gap: 15px;
}
.panel {
background-color: #1e293b;
border-radius: 8px;
padding: 15px;
}
.panel h2 {
font-size: 1rem;
margin-bottom: 10px;
color: #94a3b8;
text-transform: uppercase;
letter-spacing: 0.05em;
}
.controls {
display: flex;
gap: 8px;
flex-wrap: wrap;
}
button {
background-color: #3b82f6;
color: white;
border: none;
padding: 8px 16px;
border-radius: 6px;
cursor: pointer;
font-size: 14px;
transition: background-color 0.2s;
}
button:hover {
background-color: #2563eb;
}
button:disabled {
background-color: #475569;
cursor: not-allowed;
}
.slider-group {
display: flex;
flex-direction: column;
gap: 5px;
}
.slider-group label {
font-size: 12px;
color: #94a3b8;
}
input[type="range"] {
width: 100%;
}
.file-input-wrapper {
position: relative;
}
input[type="file"] {
display: none;
}
.file-label {
display: inline-block;
background-color: #475569;
color: white;
padding: 8px 16px;
border-radius: 6px;
cursor: pointer;
font-size: 14px;
transition: background-color 0.2s;
}
.file-label:hover {
background-color: #64748b;
}
.url-input-group {
display: flex;
gap: 5px;
}
input[type="text"] {
flex: 1;
background-color: #0f172a;
border: 1px solid #334155;
color: #e2e8f0;
padding: 8px;
border-radius: 6px;
font-size: 14px;
}
select {
background-color: #0f172a;
border: 1px solid #334155;
color: #e2e8f0;
padding: 8px;
border-radius: 6px;
font-size: 14px;
}
.match-info {
font-size: 13px;
}
.match-info dt {
color: #94a3b8;
font-size: 11px;
text-transform: uppercase;
margin-top: 8px;
}
.match-info dd {
color: #f1f5f9;
}
.event-log {
max-height: 200px;
overflow-y: auto;
font-size: 12px;
font-family: monospace;
}
.event-log .event {
padding: 4px 0;
border-bottom: 1px solid #334155;
}
.event-log .event:last-child {
border-bottom: none;
}
.event-type {
color: #fbbf24;
}
.no-replay {
color: #64748b;
text-align: center;
padding: 20px;
}
.keyboard-shortcuts {
font-size: 12px;
color: #64748b;
margin-top: 10px;
}
.keyboard-shortcuts kbd {
background-color: #334155;
padding: 2px 6px;
border-radius: 4px;
font-family: monospace;
}
/* Minimap (§7.3) */
.minimap-container {
position: absolute;
bottom: 16px;
right: 16px;
border: 2px solid #475569;
border-radius: 6px;
overflow: hidden;
box-shadow: 0 4px 12px rgba(0,0,0,0.5);
opacity: 0.85;
transition: opacity 0.2s;
z-index: 10;
}
.minimap-container:hover {
opacity: 1;
}
#minimap-canvas {
display: block;
cursor: crosshair;
}
/* Transcript panel styles (§15.3) */
.transcript-panel {
position: fixed;
top: 0;
right: -400px;
width: 400px;
height: 100vh;
background-color: #1e293b;
border-left: 1px solid #334155;
box-shadow: -4px 0 12px rgba(0, 0, 0, 0.3);
transition: right 0.3s ease-in-out;
display: flex;
flex-direction: column;
z-index: 100;
}
.transcript-panel.open {
right: 0;
}
.transcript-header {
padding: 15px;
border-bottom: 1px solid #334155;
display: flex;
justify-content: space-between;
align-items: center;
}
.transcript-header h2 {
font-size: 1rem;
margin: 0;
color: #f8fafc;
}
.transcript-close {
background: none;
border: none;
color: #94a3b8;
font-size: 1.5rem;
cursor: pointer;
padding: 0;
width: 32px;
height: 32px;
display: flex;
align-items: center;
justify-content: center;
border-radius: 4px;
}
.transcript-close:hover {
background-color: #334155;
color: #f8fafc;
}
.transcript-content {
flex: 1;
overflow-y: auto;
padding: 15px;
font-size: 13px;
line-height: 1.5;
}
.transcript-content select {
width: 100%;
margin-bottom: 15px;
background-color: #0f172a;
border: 1px solid #334155;
color: #e2e8f0;
padding: 8px;
border-radius: 6px;
font-size: 13px;
}
.transcript-entry {
padding: 10px;
margin-bottom: 10px;
background-color: #0f172a;
border-radius: 6px;
border-left: 3px solid #334155;
cursor: pointer;
user-select: text;
}
.transcript-entry:hover {
background-color: #1a2436;
}
.transcript-entry.current {
border-left-color: #3b82f6;
background-color: #1e3a5f;
}
.transcript-entry .turn-number {
font-weight: bold;
color: #94a3b8;
font-size: 11px;
text-transform: uppercase;
margin-bottom: 4px;
}
.transcript-entry .text {
color: #e2e8f0;
}
.transcript-toggle-btn {
position: fixed;
top: 50%;
right: 0;
transform: translateY(-50%);
background-color: #3b82f6;
color: white;
border: none;
padding: 10px 6px;
border-radius: 6px 0 0 6px;
cursor: pointer;
font-size: 12px;
writing-mode: vertical-rl;
text-orientation: mixed;
box-shadow: -2px 0 8px rgba(0, 0, 0, 0.2);
z-index: 99;
transition: background-color 0.2s;
}
.transcript-toggle-btn:hover {
background-color: #2563eb;
}
.transcript-panel.open .transcript-toggle-btn {
display: none;
}
/* Responsive: on smaller screens, make panel wider */
@media (max-width: 768px) {
.transcript-panel {
width: 100%;
right: -100%;
}
}
</style>
</head>
<body>
<div class="container">
<h1>AI Code Battle - Replay Viewer</h1>
<div class="main-layout">
<div class="viewer-container">
<div class="canvas-wrapper" style="position:relative">
<canvas id="replay-canvas"></canvas>
<div id="no-replay" class="no-replay">Load a replay file to view</div>
<div class="minimap-container" id="minimap-container">
<canvas id="minimap-canvas" width="150" height="150"></canvas>
</div>
</div>
</div>
<div class="sidebar">
<div class="panel">
<h2>Load Replay</h2>
<div class="controls" style="margin-bottom: 10px;">
<div class="file-input-wrapper">
<label class="file-label" for="file-input">Choose File</label>
<input type="file" id="file-input" accept=".json">
</div>
</div>
<div class="url-input-group">
<input type="text" id="url-input" placeholder="Or enter URL...">
<button id="load-url-btn">Load</button>
</div>
</div>
<div class="panel">
<h2>Playback</h2>
<div class="controls">
<button id="play-btn" disabled>Play</button>
<button id="prev-btn" disabled>Prev</button>
<button id="next-btn" disabled>Next</button>
<button id="reset-btn" disabled>Reset</button>
</div>
<div class="slider-group" style="margin-top: 10px;">
<label>Turn: <span id="turn-display">0</span> / <span id="total-turns">0</span></label>
<input type="range" id="turn-slider" min="0" max="0" value="0" disabled>
</div>
<div class="slider-group" style="margin-top: 10px;">
<label>Speed: <span id="speed-display">100</span>ms/turn</label>
<input type="range" id="speed-slider" min="20" max="1000" value="100">
</div>
</div>
<div class="panel">
<h2>View Options</h2>
<div class="slider-group">
<label for="fog-select">Fog of War:</label>
<select id="fog-select">
<option value="">Disabled (full view)</option>
</select>
</div>
<div class="slider-group" style="margin-top: 10px;">
<label for="cell-size-select">Cell Size:</label>
<select id="cell-size-select">
<option value="8">Small (8px)</option>
<option value="12">Medium (12px)</option>
<option value="16" selected>Large (16px)</option>
<option value="20">X-Large (20px)</option>
</select>
</div>
</div>
<div class="panel">
<h2>Match Info</h2>
<dl class="match-info" id="match-info">
<dt>Match ID</dt>
<dd id="info-match-id">-</dd>
<dt>Winner</dt>
<dd id="info-winner">-</dd>
<dt>Turns</dt>
<dd id="info-turns">-</dd>
<dt>Reason</dt>
<dd id="info-reason">-</dd>
</dl>
</div>
<div class="panel">
<h2>Events This Turn</h2>
<div class="event-log" id="event-log">
<div class="no-replay">No events</div>
</div>
</div>
<div class="keyboard-shortcuts">
<kbd>Space</kbd> Play/Pause
<kbd></kbd><kbd></kbd> Step
<kbd>Home</kbd><kbd>End</kbd> First/Last
</div>
</div>
</div>
</div>
<!-- Transcript panel (§15.3) -->
<button id="transcript-toggle" class="transcript-toggle-btn" title="Toggle Transcript (T)">
Transcript
</button>
<div id="transcript-panel" class="transcript-panel">
<div class="transcript-header">
<h2>Turn-by-Turn Transcript</h2>
<button id="transcript-close" class="transcript-close" title="Close transcript">&times;</button>
</div>
<div class="transcript-content">
<select id="transcript-view-mode">
<option value="all">All Turns</option>
<option value="window">±10 Turns from Current</option>
<option value="recent">Recent 20 Turns</option>
</select>
<div id="transcript-entries">
<p style="color: #64748b; text-align: center; padding: 20px;">
Load a replay to view the transcript.
</p>
</div>
</div>
</div>
<script type="module" src="/src/main.ts"></script>
</body>
</html>