*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #1a1a2e;
  --surface: #16213e;
  --surface2: #0f3460;
  --accent: #e94560;
  --accent2: #533483;
  --text: #eee;
  --text2: #aaa;
  --border: #2a2a4a;
  --success: #2ecc71;
  --danger: #e74c3c;
  --radius: 10px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Helvetica Neue', Arial, sans-serif;
  font-size: 15px;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Header ── */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 24px;
  position: sticky;
  top: 0;
  z-index: 100;
}
header h1 { font-size: 1.1rem; color: var(--text); }
header h1 a { color: var(--text); }
nav { display: flex; gap: 16px; }
nav a { color: var(--text2); font-size: 0.9rem; padding: 4px 10px; border-radius: 6px; }
nav a.active, nav a:hover { color: var(--text); background: var(--surface2); text-decoration: none; }

/* ── Main ── */
main {
  max-width: 900px;
  margin: 0 auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ── Card ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.card h2 { font-size: 1rem; margin-bottom: 14px; color: var(--text); }

/* ── Form ── */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.form-group label { font-size: 0.85rem; color: var(--text2); }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 120px; }
.flex-grow { flex-grow: 1; }
input[type=text], input[type=number], textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 8px 12px;
  font-size: 0.95rem;
  width: 100%;
}
textarea { resize: vertical; font-family: monospace; font-size: 0.85rem; }
input:focus, textarea:focus { outline: none; border-color: var(--accent2); }

/* ── Buttons ── */
.btn {
  display: inline-block;
  padding: 9px 20px;
  border-radius: 7px;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  transition: opacity 0.15s;
}
.btn:hover { opacity: 0.85; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-secondary { background: var(--surface2); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 5px 12px; font-size: 0.82rem; }
.btn-xs { padding: 3px 8px; font-size: 0.78rem; }
.btn-clear { background: transparent; border: 1px solid var(--border); color: var(--text2); }

/* ── Messages ── */
.msg { margin-top: 10px; font-size: 0.88rem; min-height: 1.2em; }
.msg.success { color: var(--success); }
.msg.error { color: var(--danger); }

/* ── Badge ── */
.badge {
  background: var(--surface2);
  color: var(--text2);
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: normal;
}
.badge-bad {
  background: rgba(233,69,96,0.2);
  color: var(--accent);
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.8rem;
}

/* ── Game list ── */
.game-list { display: flex; flex-direction: column; gap: 10px; }
.game-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.game-item:hover { border-color: var(--accent2); }
.game-title { font-weight: 600; margin-bottom: 6px; }
.game-meta { display: flex; align-items: center; gap: 12px; }
.date { color: var(--text2); font-size: 0.82rem; }

/* ── Game header ── */
.game-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.game-header h2 { margin-bottom: 0; }

/* ── KIF text ── */
.kif-text {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
  font-size: 0.8rem;
  overflow-x: auto;
  white-space: pre;
  margin-top: 10px;
  max-height: 400px;
  overflow-y: auto;
}
details summary { cursor: pointer; color: var(--text2); font-size: 0.88rem; }
.game-header-btns { display: flex; gap: 8px; align-items: center; }
.btn-copy { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }

/* ── Image upload ── */
.image-upload-row { display: flex; gap: 16px; margin: 14px 0; flex-wrap: wrap; }
.image-box { flex: 1; min-width: 240px; display: flex; flex-direction: column; gap: 8px; }
.image-label { font-size: 0.82rem; color: var(--text2); font-weight: 600; }
.paste-area {
  background: var(--bg);
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 24px 12px;
  text-align: center;
  color: var(--text2);
  font-size: 0.85rem;
  cursor: pointer;
  user-select: none;
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.paste-area:focus { border-color: var(--accent2); outline: none; }
.paste-area.hidden { display: none; }
img.preview { width: 100%; border-radius: 6px; border: 1px solid var(--border); }
img.hidden { display: none; }
img.thumb {
  width: 100%;
  max-width: 340px;
  border-radius: 6px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: opacity 0.15s;
}
img.thumb:hover { opacity: 0.85; }

/* ── Bad move list ── */
.bad-move-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 12px;
}
.bad-move-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.move-num { font-weight: 700; color: var(--accent); }
.move-note { color: var(--text2); font-size: 0.88rem; flex-grow: 1; }
.image-triple { display: flex; gap: 12px; flex-wrap: wrap; }
.image-triple > div { flex: 1; min-width: 140px; display: flex; flex-direction: column; gap: 6px; }

/* ── Modal ── */
.modal { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; }
.modal-bg { position: absolute; inset: 0; background: rgba(0,0,0,0.85); cursor: pointer; }
.modal-img { position: relative; max-width: 95vw; max-height: 92vh; border-radius: 8px; }

/* ── Answer pair ── */
.answer-pair { display: flex; gap: 16px; flex-wrap: wrap; }
.answer-col { flex: 1; min-width: 200px; display: flex; flex-direction: column; gap: 8px; }
.answer-bad { color: var(--accent); }
.answer-correct { color: var(--success); }

/* ── Review ── */
.review-progress { margin-bottom: 12px; }
#progress-text { font-size: 0.85rem; color: var(--text2); display: block; margin-bottom: 6px; }
.progress-bar { background: var(--border); border-radius: 4px; height: 6px; }
.progress-fill { background: var(--accent); border-radius: 4px; height: 100%; transition: width 0.3s; }

.review-card { display: flex; flex-direction: column; gap: 16px; }
.review-meta { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.game-link { font-size: 0.85rem; }
.review-question, .review-answer { display: flex; flex-direction: column; gap: 8px; }
.review-img { width: 100%; max-width: 600px; border-radius: 8px; border: 1px solid var(--border); }
.review-controls { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
#btn-nav { display: flex; gap: 10px; }

/* ── Misc ── */
.loading, .empty { color: var(--text2); text-align: center; padding: 20px; }
.hidden { display: none !important; }

@media (max-width: 600px) {
  header { flex-direction: column; align-items: flex-start; gap: 8px; padding: 10px 14px; }
  .image-upload-row { flex-direction: column; }
  .image-triple { flex-direction: column; }
  .answer-pair { flex-direction: column; }
  .review-controls { flex-direction: column; align-items: flex-start; }
}
