:root {
  --bg: #0f1420;
  --bg2: #161c2b;
  --card: #1b2336;
  --card2: #222b42;
  --text: #eef1f7;
  --muted: #9aa4bd;
  --accent: #4f8cff;
  --green: #3ddc84;
  --border: #2a3450;
  --danger: #ff5d5d;
  --radius: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  min-height: 100vh;
}
#app { max-width: 720px; margin: 0 auto; min-height: 100vh; position: relative; }
.view { padding-bottom: calc(32px + var(--safe-bottom)); }

/* Loading */
.loading { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 70vh; gap: 14px; }
.spinner { width: 44px; height: 44px; border: 4px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { font-size: 18px; font-weight: 600; }
.loading-sub { color: var(--muted); font-size: 14px; }

/* Header */
.header {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: calc(10px + var(--safe-top)) 14px 10px;
  background: rgba(15, 20, 32, 0.96);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.header h1 { font-size: 19px; margin: 0; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.back-btn {
  background: var(--card); border: 1px solid var(--border); color: var(--text);
  font-size: 17px; border-radius: 10px; min-width: 44px; min-height: 44px; cursor: pointer;
}
.icon-btn {
  background: var(--card); border: 1px solid var(--border); color: var(--text);
  font-size: 18px; border-radius: 10px; min-width: 44px; min-height: 44px; cursor: pointer;
}

/* Search */
.search-wrap { padding: 12px 14px 4px; position: sticky; top: calc(64px + var(--safe-top)); z-index: 15; background: var(--bg); }
.search-wrap input {
  width: 100%; padding: 13px 14px; font-size: 16px;
  background: var(--card); border: 1px solid var(--border); border-radius: 12px; color: var(--text);
}
.search-wrap input::placeholder { color: var(--muted); }
.search-wrap input:focus { outline: none; border-color: var(--accent); }

/* Sections */
.section-title { padding: 16px 14px 8px; font-size: 14px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }

/* Game cards */
.game-list { display: flex; flex-direction: column; gap: 10px; padding: 4px 14px 0; }
.game-card {
  display: block; width: 100%; text-align: left; cursor: pointer;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; color: var(--text);
}
.game-card:active { background: var(--card2); }
.game-card .gc-title { font-size: 18px; font-weight: 700; margin-bottom: 6px; }
.game-card .gc-meta { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 14px; margin-bottom: 8px; }
.progress { height: 8px; background: #0b0f1a; border-radius: 99px; overflow: hidden; }
.progress > div { height: 100%; background: linear-gradient(90deg, var(--accent), var(--green)); border-radius: 99px; transition: width 0.25s; }

/* Recents */
.recents { display: flex; gap: 10px; padding: 4px 14px 0; overflow-x: auto; }
.recent-chip {
  flex: 0 0 auto; background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 10px 14px; color: var(--text); cursor: pointer; font-size: 15px; font-weight: 600;
}
.recent-chip small { display: block; color: var(--muted); font-weight: 400; font-size: 12px; }

/* Checklist rows */
.checklist-list { display: flex; flex-direction: column; gap: 10px; padding: 12px 14px 0; }
.checklist-row {
  display: block; width: 100%; text-align: left; cursor: pointer;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; color: var(--text);
}
.checklist-row:active { background: var(--card2); }
.checklist-row .cr-title { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.checklist-row .cr-meta { color: var(--muted); font-size: 13px; margin-bottom: 8px; }

/* Game view actions */
.game-actions { display: flex; gap: 10px; padding: 14px 14px 0; }
.btn-secondary, .btn-danger, .btn-primary {
  border-radius: 12px; padding: 13px 16px; font-size: 15px; font-weight: 600; cursor: pointer; border: 1px solid var(--border);
}
.btn-secondary { background: var(--card); color: var(--text); flex: 1; }
.btn-danger { background: rgba(255,93,93,0.12); color: var(--danger); border-color: rgba(255,93,93,0.4); flex: 1; }
.btn-primary { background: var(--accent); color: #fff; border: none; width: 100%; margin-top: 6px; }
.btn-primary:disabled { opacity: 0.6; }

/* Filter tabs */
.filter-tabs { display: flex; gap: 8px; padding: 12px 14px 0; position: sticky; top: calc(64px + var(--safe-top)); z-index: 15; background: var(--bg); }
.search-wrap.has-tabs { top: calc(64px + var(--safe-top)); padding-bottom: 0; }
.filter-tabs { top: calc(64px + var(--safe-top) + 62px); padding-top: 8px; padding-bottom: 8px; }
.filter-tab {
  flex: 1; padding: 11px 0; border-radius: 99px; border: 1px solid var(--border);
  background: var(--card); color: var(--muted); font-size: 14px; font-weight: 600; cursor: pointer;
}
.filter-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Item rows */
.item-list { display: flex; flex-direction: column; gap: 8px; padding: 12px 14px 0; }
.item-row {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 13px 12px; cursor: pointer;
}
.item-row.done { opacity: 0.62; }
.item-row.done .item-name { text-decoration: line-through; }
.checkbox {
  flex: 0 0 auto; width: 28px; height: 28px; border-radius: 8px; margin-top: 1px;
  border: 2px solid var(--muted); background: transparent; cursor: pointer;
  display: flex; align-items: center; justify-content: center; font-size: 17px; color: #fff;
}
.item-row.done .checkbox { background: var(--green); border-color: var(--green); }
.item-body { flex: 1; min-width: 0; }
.item-name { font-size: 15.5px; font-weight: 600; }
.item-section {
  display: inline-block; font-size: 11.5px; font-weight: 700; color: var(--accent);
  background: rgba(79,140,255,0.14); border-radius: 6px; padding: 2px 8px; margin: 5px 0;
}
.item-loc { font-size: 13.5px; color: var(--muted); margin-top: 2px; }
.item-desc { font-size: 13.5px; color: #c6cddd; margin-top: 4px; }
.flag-btn {
  flex: 0 0 auto; background: transparent; border: none; font-size: 19px; cursor: pointer;
  min-width: 44px; min-height: 44px; opacity: 0.75;
}
.flag-btn:active { opacity: 1; transform: scale(1.15); }

/* Highlight flash for search jumps */
@keyframes flash { 0% { background: rgba(255, 214, 64, 0.55); } 100% { background: var(--card); } }
.item-row.flash { animation: flash 2.2s ease-out; border-color: #ffd640; }

/* Search results */
.result-row {
  display: block; width: 100%; text-align: left; cursor: pointer;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 13px 14px; color: var(--text); margin-bottom: 8px;
}
.result-row .rr-name { font-weight: 600; font-size: 15px; }
.result-row .rr-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.empty { text-align: center; color: var(--muted); padding: 34px 20px; font-size: 15px; }

/* Ads */
.ad-slot { padding: 12px 14px 0; text-align: center; min-height: 0; }
.ad-slot .ad-label { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 4px; }

/* Modal */
.modal {
  position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,0.65);
  display: flex; align-items: flex-end; justify-content: center;
}
@media (min-width: 560px) { .modal { align-items: center; } }
.modal-card {
  background: var(--bg2); border: 1px solid var(--border); border-radius: 18px 18px 0 0;
  width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto;
  padding: 16px 16px calc(20px + var(--safe-bottom));
}
@media (min-width: 560px) { .modal-card { border-radius: 18px; } }
.modal-card.small { max-width: 400px; border-radius: 18px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.modal-tabs { display: flex; gap: 6px; }
.modal-tab {
  background: transparent; border: none; color: var(--muted); font-size: 16px; font-weight: 700;
  padding: 10px 12px; cursor: pointer; border-bottom: 2px solid transparent;
}
.modal-tab.active { color: var(--text); border-bottom-color: var(--accent); }
.modal-title { font-size: 18px; font-weight: 700; margin: 0 0 8px; }
.modal-text { color: var(--muted); font-size: 15px; margin: 0 0 16px; }
.modal-actions { display: flex; gap: 10px; }
.modal-actions .btn-secondary, .modal-actions .btn-danger { flex: 1; }
.modal-body label { display: block; font-size: 14px; font-weight: 600; color: var(--muted); margin-bottom: 12px; }
.modal-body select, .modal-body input, .modal-body textarea {
  display: block; width: 100%; margin-top: 6px; padding: 12px; font-size: 16px;
  background: var(--card); border: 1px solid var(--border); border-radius: 10px; color: var(--text);
  font-family: inherit;
}
.modal-body select:focus, .modal-body input:focus, .modal-body textarea:focus { outline: none; border-color: var(--accent); }
.thanks { background: rgba(61,220,132,0.14); border: 1px solid rgba(61,220,132,0.5); color: var(--green); border-radius: 10px; padding: 12px; font-weight: 600; margin-bottom: 12px; }
.form-error { color: var(--danger); font-size: 14px; margin-top: 10px; }

/* My reports */
.my-report { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; margin-bottom: 10px; }
.my-report .mr-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.my-report .mr-type { font-weight: 700; font-size: 14px; }
.sent-badge { font-size: 12px; font-weight: 700; color: var(--green); background: rgba(61,220,132,0.14); padding: 3px 10px; border-radius: 99px; }
.my-report .mr-sub { color: var(--muted); font-size: 13px; }
.my-report .mr-details { font-size: 14px; margin-top: 6px; color: #c6cddd; }
.my-report .mr-date { color: var(--muted); font-size: 12px; margin-top: 6px; }
