:root {
  color-scheme: light dark;
  --bg: #0f1115;
  --panel: #171a21;
  --text: #e8e8e8;
  --muted: #9aa0a6;
  --accent: #4f8cff;
  --error: #ff5c5c;
  --border: #2a2e37;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 260px;
  flex-shrink: 0;
  height: 100vh;
  position: sticky;
  top: 0;
  overflow-y: auto;
  padding: 20px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sidebar h1 {
  font-size: 18px;
  margin: 0 0 8px;
}

.sidebar button {
  padding: 8px;
  font-size: 14px;
}

.back-link {
  color: var(--muted);
  font-size: 13px;
  text-decoration: none;
}

.bug-link {
  margin-top: auto;
  padding-top: 12px;
}

.bug-link a {
  color: var(--muted);
  font-size: 12px;
  text-decoration: none;
}

.bug-link a:hover {
  color: var(--text);
  text-decoration: underline;
}

.link-sep {
  color: var(--muted);
  font-size: 12px;
  margin: 0 4px;
}

.landing-footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 12px 20px;
  text-align: center;
  background: rgba(15, 17, 21, 0.92);
  backdrop-filter: blur(4px);
  border-top: 1px solid var(--border);
}

.landing-footer a {
  color: var(--muted);
  font-size: 12px;
  text-decoration: none;
}

.landing-footer a:hover {
  color: var(--text);
  text-decoration: underline;
}

.back-link:hover {
  color: var(--text);
}

.landing {
  max-width: 480px;
  margin: 80px auto;
  padding: 0 20px 64px;
  text-align: center;
}

.landing h1 {
  font-size: 24px;
  margin-bottom: 8px;
}

.game-count {
  display: inline-block;
  margin: 12px 0 0;
  padding: 4px 10px;
  font-size: 12px;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
}

.recent-section {
  margin-top: 20px;
  text-align: left;
}

.recent-heading {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: 0 0 8px;
}

.recent-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.recent-list li {
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 6px 4px 14px;
}

.recent-list a {
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
}

.recent-list a:hover {
  color: var(--accent);
}

.recent-forget {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  padding: 3px 7px;
  border-radius: 999px;
}

.recent-forget:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
}

.game-search {
  width: 100%;
  margin-top: 20px;
  padding: 10px 12px;
  font-size: 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
}

.game-search:focus {
  outline: none;
  border-color: var(--accent);
}

.game-list {
  list-style: none;
  padding: 0;
  margin: 16px 0 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.game-list a {
  display: block;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  font-size: 15px;
}

.game-list a:hover {
  border-color: var(--accent);
}

.help {
  font-size: 12px;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
}

.help summary {
  cursor: pointer;
  color: var(--text);
  font-size: 13px;
}

.help p,
.help ol {
  margin: 8px 0;
}

.help ol {
  padding-left: 18px;
}

.help li {
  margin-bottom: 6px;
}

.help-label {
  color: var(--text);
  font-weight: 600;
  margin-top: 12px;
  margin-bottom: 4px;
}

.help-path {
  display: block;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 8px;
  font-family: ui-monospace, monospace;
  font-size: 11px;
  color: var(--text);
  word-break: break-all;
  margin-bottom: 8px;
}

.help code {
  font-family: ui-monospace, monospace;
  background: var(--panel);
  padding: 1px 4px;
  border-radius: 3px;
}

.help kbd {
  font-family: ui-monospace, monospace;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 5px;
  font-size: 11px;
}

.history-list {
  list-style: none;
  padding: 0;
  margin: 8px 0 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.history-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
}

.history-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.history-when {
  color: var(--text);
  font-size: 11px;
}

.history-filename {
  color: var(--muted);
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-download {
  flex-shrink: 0;
  font-size: 11px;
  padding: 4px 8px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.history-download:hover {
  filter: brightness(1.1);
}

.drop-zone {
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 16px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}

.drop-zone.dragover {
  border-color: var(--accent);
  color: var(--text);
}

.file-name {
  font-size: 12px;
  color: var(--muted);
  word-break: break-all;
}

#downloadBtn {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}

#downloadBtn:disabled {
  background: var(--border);
  color: var(--muted);
  cursor: not-allowed;
}

.disclaimer {
  font-size: 11px;
  color: var(--muted);
}

.main {
  flex: 1;
  padding: 20px;
  min-width: 0;
}

.error-banner {
  background: rgba(255, 92, 92, 0.15);
  border: 1px solid var(--error);
  color: var(--error);
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 16px;
}

.restore-banner {
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  background: rgba(79, 140, 255, 0.12);
  border: 1px solid var(--accent);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 16px;
  font-size: 14px;
}

.restore-banner:not([hidden]) {
  display: flex;
}

.restore-banner button {
  padding: 4px 10px;
  font-size: 13px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
}

.restore-banner button:hover {
  border-color: var(--accent);
}

#restoreBtn {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.tab-btn {
  background: none;
  border: none;
  color: var(--muted);
  padding: 8px 14px;
  cursor: pointer;
  font-size: 14px;
  border-bottom: 2px solid transparent;
}

.tab-btn.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.hint {
  color: var(--muted);
  font-size: 14px;
}

#friendlyForm {
  display: grid;
  gap: 12px;
  max-width: 420px;
}

.field-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field-row label {
  font-size: 13px;
  color: var(--muted);
}

.field-row input {
  padding: 8px;
  font-size: 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
}

.code-editor {
  position: relative;
  width: 100%;
  min-height: 420px;
}

.code-highlight,
.code-input {
  position: absolute;
  inset: 0;
  margin: 0;
  width: 100%;
  height: 100%;
  font-family: ui-monospace, monospace;
  font-size: 13px;
  line-height: 1.5;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  box-sizing: border-box;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow: auto;
}

.code-highlight {
  background: var(--panel);
  color: var(--text);
  pointer-events: none;
}

.code-input {
  background: transparent;
  color: transparent;
  caret-color: var(--text);
  resize: none;
}

.code-input::selection {
  background: rgba(79, 140, 255, 0.35);
}

.tok-key { color: #7dd3fc; }
.tok-string { color: #86efac; }
.tok-number { color: #fbbf24; }
.tok-boolean { color: #f472b6; }
.tok-null { color: #94a3b8; font-style: italic; }

.field-error {
  color: var(--error);
  font-size: 13px;
}

.report-page {
  max-width: 480px;
  margin: 80px auto;
  padding: 0 20px 64px;
  text-align: left;
}

.report-page h1 {
  font-size: 22px;
  margin-bottom: 12px;
}

.report-page ol {
  padding-left: 20px;
  margin: 16px 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 14px;
  color: var(--text);
}

.given-up-heading {
  font-size: 16px;
  margin: 24px 0 4px;
}

.given-up-list {
  list-style: none;
  padding: 0;
  margin: 16px 0 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.given-up-list li {
  padding: 10px 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.given-up-name {
  font-size: 14px;
  font-weight: 600;
}

.given-up-reason {
  font-size: 13px;
  color: var(--muted);
  margin-top: 4px;
}

.cta-btn {
  display: inline-block;
  margin-top: 20px;
  padding: 10px 18px;
  background: var(--accent);
  color: white;
  border-radius: 6px;
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
}

.cta-btn:hover {
  filter: brightness(1.1);
}

.cookie-banner {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  z-index: 100;
  max-width: 480px;
  margin: 0 auto;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.cookie-banner p {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--text);
}

.cookie-banner a {
  color: var(--accent);
}

.cookie-banner-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.cookie-banner-actions button {
  padding: 8px 14px;
  font-size: 13px;
  border-radius: 6px;
  border: 1px solid var(--border);
  cursor: pointer;
}

.cookie-accept {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.cookie-decline {
  background: transparent;
  color: var(--muted);
}
