:root {
  --bg: #120a14;
  --bg-2: #1c1220;
  --panel: #241829;
  --line: #3a2c40;
  --text: #ece6ef;
  --muted: #9b8fa3;
  --accent: #d4f046;
  --hit: #2fb86e;
  --near: #d9962b;
  --miss: #4b4152;
  --warn: #f2a742;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: radial-gradient(ellipse at 20% 0%, #2a1530 0%, var(--bg) 55%) fixed, var(--bg);
  color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
}
button, input { font: inherit; color: inherit; }

.topbar {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--line);
}
h1 { margin: 0; font-size: 20px; font-style: italic; font-weight: 800; letter-spacing: .5px; }
.tag { font-size: 11px; font-style: normal; color: var(--bg); background: var(--accent); padding: 1px 6px; border-radius: 3px; vertical-align: middle; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.btn {
  border: 1px solid var(--line); background: var(--panel); padding: 6px 12px; border-radius: 4px; cursor: pointer; font-weight: 600;
}
.btn:hover { border-color: var(--muted); }
.btn:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #1a1a0a; }
.btn-warn { background: var(--warn); border-color: var(--warn); color: #2a1a05; }
.difficulty { display: flex; border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.difficulty button { border: 0; background: transparent; padding: 6px 12px; cursor: pointer; }
.difficulty button[aria-checked='true'] { background: var(--accent); color: #1a1a0a; font-weight: 700; }

.statusbar { display: flex; gap: 10px; align-items: center; padding: 8px 16px; color: var(--muted); border-bottom: 1px solid var(--line); }
.dots { display: inline-flex; gap: 4px; }
.dots i { width: 9px; height: 9px; border-radius: 50%; border: 1px solid var(--accent); }
.dots i.used { background: var(--accent); }
.sep { opacity: .4; }

.panel {
  position: absolute; right: 16px; top: 64px; z-index: 5; width: min(320px, calc(100vw - 32px));
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 12px 14px; box-shadow: 0 10px 30px #0008;
}
.panel-title { margin: 0 0 4px; font-weight: 700; }
.panel-note { margin: 0 0 8px; color: var(--muted); font-size: 12px; }
.panel label { display: flex; gap: 8px; align-items: center; padding: 4px 0; cursor: pointer; }
.panel label.disabled { color: var(--muted); cursor: not-allowed; }
.panel small { color: var(--muted); }

main { flex: 1; padding: 16px; }
.empty { text-align: center; color: var(--text); margin-top: 8vh; }
.target { font-size: 36px; color: var(--muted); }
.muted { color: var(--muted); }
.legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 18px; list-style: none; padding: 0; color: var(--muted); font-size: 13px; }
.sw { display: inline-block; width: 11px; height: 11px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 6px; background: #0e0810cc; }
table { border-collapse: separate; border-spacing: 4px; min-width: 100%; }
th { color: var(--accent); font-size: 13px; font-weight: 700; padding: 6px 8px; white-space: nowrap; cursor: help; }
th:first-child { cursor: default; }
td {
  text-align: center; padding: 8px 10px; border-radius: 3px; white-space: nowrap; font-weight: 600; min-width: 84px;
}
td.name { background: var(--bg-2); text-align: left; position: sticky; left: 0; z-index: 1; }
td.name small { display: block; color: var(--muted); font-weight: 400; font-size: 11px; }
.hit { background: var(--hit); }
.near { background: var(--near); }
.miss { background: var(--miss); }
.unknown { background: repeating-linear-gradient(135deg, var(--miss) 0 6px, #3d3443 6px 12px); color: var(--muted); }
td img { width: 32px; height: 18px; object-fit: cover; border-radius: 2px; vertical-align: middle; margin-right: 6px; }
.arrow { margin-left: 4px; }
tr.new td { animation: flip .45s ease both; }
@keyframes flip { from { transform: rotateX(90deg); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { tr.new td { animation: none; } }

.inputbar { position: sticky; bottom: 0; padding: 10px 16px 6px; background: linear-gradient(transparent, var(--bg) 30%); }
form { display: flex; gap: 8px; }
#guessInput { flex: 1; min-width: 0; padding: 10px 12px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 4px; }
.suggest { margin-bottom: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.suggest div { padding: 8px 12px; cursor: pointer; display: flex; gap: 10px; align-items: baseline; }
.suggest div[aria-selected='true'] { background: var(--accent); color: #1a1a0a; }
.suggest div[aria-selected='true'] small { color: #3a3a1a; }
.suggest small { color: var(--muted); }
.suggest .guessed { opacity: .45; }
.credit { margin: 6px 0 0; font-size: 11px; color: var(--muted); text-align: center; }
.credit a { color: inherit; }

dialog {
  width: min(420px, calc(100vw - 32px)); background: var(--panel); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; padding: 20px 22px;
}
dialog::backdrop { background: #000a; }
dialog h2 { margin: 0; text-align: center; font-style: italic; }
dialog .muted { text-align: center; margin: 4px 0 12px; }
.answer-name { text-align: center; font-size: 22px; font-weight: 800; margin: 0 0 10px; }
.answer-name a { color: var(--accent); text-decoration: none; }
dl { display: grid; grid-template-columns: auto 1fr; margin: 0; }
dt, dd { padding: 7px 0; border-bottom: 1px solid var(--line); margin: 0; }
dt { color: var(--muted); }
dd { text-align: right; font-weight: 700; }
dd img { width: 32px; height: 18px; object-fit: cover; border-radius: 2px; vertical-align: middle; margin-right: 6px; }
.dialog-actions { display: flex; gap: 10px; justify-content: center; margin-top: 16px; }

@media (max-width: 600px) {
  .topbar { padding: 10px 16px; }
  h1 { font-size: 17px; }
  td { min-width: 70px; padding: 7px 8px; font-size: 13px; }
}
