:root{
  --bg: #12151b;
  --surface: #191d26;
  --card: #1e2330;
  --card-hover: #262c3c;
  --border: #2a3040;
  --text: #eef0f4;
  --muted: #8d94a6;
  --accent: #e0a458;
  --accent-dark: #b9803c;
  --teal: #5ec8c2;
  --danger: #e2685f;
  --radius: 10px;
  --shadow: 0 10px 30px rgba(0,0,0,.45);
  --font-display: 'Bricolage Grotesque', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'Space Mono', monospace;
}

*{ box-sizing: border-box; }
html,body{ margin:0; padding:0; }
body{
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  min-height: 100vh;
}
.hidden{ display:none !important; }
button{ font-family: inherit; cursor:pointer; }
input, select, textarea{ font-family: inherit; }

/* ============ LOGIN ============ */
.login-screen{
  min-height: 100vh;
  display:flex; align-items:center; justify-content:center;
  background:
    radial-gradient(circle at 20% 20%, rgba(224,164,88,.08), transparent 40%),
    radial-gradient(circle at 80% 80%, rgba(94,200,194,.08), transparent 40%),
    var(--bg);
  padding: 20px;
}
.login-card{
  width: 100%; max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 32px;
  text-align:center;
  box-shadow: var(--shadow);
}
.login-mark{ font-size: 40px; margin-bottom: 8px; }
.login-card h1{
  font-family: var(--font-display);
  font-size: 30px; font-weight: 700; margin: 0 0 6px;
}
.login-sub{ color: var(--muted); font-size: 14px; margin: 0 0 28px; }
#loginForm{ display:flex; flex-direction:column; gap:12px; }
#loginForm input{
  background: var(--card); border: 1px solid var(--border); color: var(--text);
  padding: 12px 14px; border-radius: 8px; font-size: 15px; outline:none;
}
#loginForm input:focus{ border-color: var(--accent); }
#loginForm button{
  background: var(--accent); color: #17140d; border:none; font-weight:700;
  padding: 12px; border-radius: 8px; font-size: 15px; margin-top: 6px;
  transition: background .15s;
}
#loginForm button:hover{ background: var(--accent-dark); }
.login-error{ color: var(--danger); font-size: 13px; min-height: 18px; margin: 14px 0 0; }

/* ============ TOPBAR ============ */
.topbar{
  display:flex; align-items:center; gap:24px;
  padding: 14px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top:0; z-index: 20;
}
.brand{ display:flex; align-items:center; gap:8px; flex-shrink:0; }
.brand-mark{ font-size: 22px; }
.brand-name{ font-family: var(--font-display); font-weight:700; font-size: 20px; letter-spacing: -.3px; }

.search-wrap{ flex:1; max-width: 480px; }
.search-wrap input{
  width:100%; background: var(--card); border:1px solid var(--border); color:var(--text);
  padding: 10px 14px; border-radius: 20px; font-size: 14px; outline:none;
}
.search-wrap input:focus{ border-color: var(--accent); }

.top-actions{ display:flex; align-items:center; gap:10px; margin-left:auto; }
.profile{ display:flex; align-items:center; gap:8px; padding: 0 4px; }
.profile-avatar{
  width:28px; height:28px; border-radius:50%; background: var(--teal); color:#0d1f1e;
  display:flex; align-items:center; justify-content:center; font-weight:700; font-size:12px;
  font-family: var(--font-mono);
}
.profile-name{ font-size: 13px; color: var(--muted); }

.btn{
  border:none; border-radius: 8px; padding: 9px 16px; font-size: 13.5px; font-weight:600;
  transition: all .15s;
}
.btn-accent{ background: var(--accent); color:#17140d; }
.btn-accent:hover{ background: var(--accent-dark); }
.btn-ghost{ background: transparent; color: var(--muted); border:1px solid var(--border); }
.btn-ghost:hover{ color: var(--text); border-color: var(--muted); }
.btn-danger{ background: var(--danger); color:#fff; }
.btn-danger:hover{ background:#c8534a; }
.btn-lg{ padding: 12px 20px; font-size: 14.5px; }

/* ============ TOOLBAR ============ */
.toolbar{
  display:flex; align-items:center; justify-content:space-between;
  padding: 16px 28px; gap: 16px; flex-wrap: wrap;
}
.tabs{ display:flex; gap:4px; background: var(--surface); padding:4px; border-radius:10px; border:1px solid var(--border); }
.tab{
  background:transparent; border:none; color:var(--muted); padding:8px 16px; border-radius:7px;
  font-size:13.5px; font-weight:600;
}
.tab.active{ background: var(--card-hover); color: var(--text); }

.filters{ display:flex; align-items:center; gap:8px; flex-wrap: wrap; }
.filters select{
  background: var(--surface); color: var(--text); border:1px solid var(--border);
  padding: 8px 10px; border-radius: 7px; font-size: 13px; outline:none;
}
.view-toggle{ display:flex; border:1px solid var(--border); border-radius:7px; overflow:hidden; }
.view-btn{ background: var(--surface); color: var(--muted); border:none; padding: 7px 10px; font-size:14px; }
.view-btn.active{ background: var(--card-hover); color: var(--accent); }

/* ============ SHELF (grid) ============ */
.shelf{
  padding: 8px 28px 60px;
  display:grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 22px 18px;
}
.shelf.list-mode{
  display:flex; flex-direction:column; gap:10px;
}

.game-card{
  position:relative;
  background: var(--card);
  border-radius: 8px;
  overflow:hidden;
  cursor:pointer;
  border: 1px solid var(--border);
  display:flex;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}
.game-card:hover{
  transform: translateY(-6px) rotate(-.6deg);
  box-shadow: var(--shadow);
  background: var(--card-hover);
  z-index: 5;
}
.game-spine{
  width: 14px; flex-shrink:0;
  writing-mode: vertical-rl;
  display:flex; align-items:center; justify-content:center;
  font-family: var(--font-mono); font-size: 9px; letter-spacing: 1px;
  color: rgba(0,0,0,.55); font-weight:700;
}
.game-cover-wrap{ position:relative; flex:1; aspect-ratio: 3/4; background: var(--surface); }
.game-cover-wrap img{ width:100%; height:100%; object-fit:cover; display:block; }
.game-cover-fallback{
  width:100%; height:100%; display:flex; align-items:center; justify-content:center;
  font-family: var(--font-display); font-size: 15px; text-align:center; padding: 10px;
  color: var(--muted); background:
    repeating-linear-gradient(135deg, var(--surface), var(--surface) 10px, var(--card) 10px, var(--card) 20px);
}
.game-fav-btn{
  position:absolute; top:6px; right:6px; width:26px; height:26px; border-radius:50%;
  background: rgba(15,17,22,.65); border:none; color:#fff; font-size:13px;
  display:flex; align-items:center; justify-content:center;
  backdrop-filter: blur(2px);
}
.game-fav-btn.active{ color: var(--danger); }
.game-badge-new{
  position:absolute; top:6px; left:6px;
  background: var(--teal); color:#0d1f1e; font-family: var(--font-mono); font-size:9px; font-weight:700;
  padding: 3px 6px; border-radius: 4px; letter-spacing:.5px;
}
.game-info{ padding: 8px 10px 10px; position:absolute; bottom:0; left:0; right:0;
  background: linear-gradient(0deg, rgba(10,11,15,.92), rgba(10,11,15,0));
  padding-top: 26px;
}
.game-title{ font-size: 13px; font-weight:600; line-height:1.25; margin:0 0 3px; }
.game-meta{ font-size: 11px; color: var(--muted); font-family: var(--font-mono); }

/* list mode overrides */
.shelf.list-mode .game-card{ flex-direction:row; align-items:center; }
.shelf.list-mode .game-cover-wrap{ width:52px; aspect-ratio:3/4; flex-shrink:0; }
.shelf.list-mode .game-info{ position:static; background:none; flex:1; padding: 10px 14px; display:flex; align-items:center; gap:16px; }
.shelf.list-mode .game-title{ font-size:14px; min-width:180px; }
.shelf.list-mode .game-fav-btn{ position:static; background:none; color: var(--muted); }
.shelf.list-mode .game-fav-btn.active{ color: var(--danger); }
.shelf.list-mode .game-badge-new{ position:static; margin-left:auto; }

/* ============ EMPTY STATE ============ */
.empty-state{ text-align:center; padding: 80px 20px; color: var(--muted); }
.empty-icon{ font-size: 44px; margin-bottom: 12px; }
.empty-state h3{ font-family: var(--font-display); color: var(--text); font-size:20px; margin:0 0 6px; }
.empty-state p{ margin:0; font-size:14px; }

/* ============ MODALS ============ */
.modal-overlay{
  position:fixed; inset:0; background: rgba(8,9,12,.7);
  display:flex; align-items:center; justify-content:center; z-index: 100; padding: 20px;
  backdrop-filter: blur(3px);
}
.modal{
  background: var(--surface); border:1px solid var(--border); border-radius: 14px;
  max-width: 480px; width:100%; padding: 30px; position:relative; box-shadow: var(--shadow);
  max-height: 88vh; overflow-y:auto;
}
.modal-sm{ max-width: 380px; }
.modal-close{
  position:absolute; top:14px; right:14px; background:none; border:none; color: var(--muted); font-size:16px;
}
.modal-close:hover{ color: var(--text); }
.modal h2{ font-family: var(--font-display); margin:0 0 20px; font-size: 22px; }
.modal form{ display:flex; flex-direction:column; gap:14px; }
.modal label{ display:flex; flex-direction:column; gap:6px; font-size: 12.5px; color: var(--muted); font-weight:600; }
.modal input[type=text], .modal input[type=number], .modal textarea{
  background: var(--card); border:1px solid var(--border); color: var(--text);
  padding: 10px 12px; border-radius:7px; font-size: 14px; outline:none; resize:vertical;
}
.modal input:focus, .modal textarea:focus{ border-color: var(--accent); }
.form-row{ display:flex; gap:12px; }
.form-row label{ flex:1; }

.dropzone{
  border: 1.5px dashed var(--border); border-radius: 8px; padding: 18px; text-align:center;
  font-size: 13px; color: var(--muted); transition: all .15s;
}
.dropzone.dragover{ border-color: var(--accent); color: var(--accent); background: rgba(224,164,88,.06); }
.dropzone.has-file{ border-color: var(--teal); color: var(--teal); }

.progress-wrap{ height:6px; background: var(--card); border-radius: 4px; overflow:hidden; }
.progress-bar{ height:100%; width:0%; background: var(--accent); transition: width .15s; }

.confirm-text{ color: var(--muted); font-size:14px; line-height:1.5; }

/* ---- detail modal ---- */
.detail-modal{ max-width: 640px; display:flex; gap:24px; padding:24px; }
.detail-cover-wrap{ width: 200px; flex-shrink:0; position:relative; }
.detail-cover{ width:100%; aspect-ratio:3/4; object-fit:cover; border-radius:8px; background: var(--card); }
.detail-spine{ position:absolute; left:-8px; top:0; bottom:0; width:8px; border-radius: 4px; }
.detail-body{ flex:1; min-width:0; }
.badge-new{
  display:inline-block; background: var(--teal); color:#0d1f1e; font-family: var(--font-mono);
  font-size:10px; font-weight:700; padding:3px 7px; border-radius:4px; margin-bottom:8px;
}
.detail-body h2{ font-family: var(--font-display); margin: 0 0 10px; font-size: 24px; line-height:1.15; }
.detail-meta{ display:flex; gap:6px; flex-wrap:wrap; margin-bottom:12px; }
.pill{
  background: var(--card); border:1px solid var(--border); color: var(--muted);
  font-family: var(--font-mono); font-size: 11px; padding: 4px 9px; border-radius: 20px;
}
.detail-desc{ font-size:13.5px; color: var(--muted); line-height:1.6; margin: 0 0 14px; }
.detail-stats{ display:flex; gap:16px; font-size:12.5px; color: var(--muted); margin-bottom:18px; }
.detail-actions{ display:flex; gap:10px; flex-wrap:wrap; }

/* ============ TOASTS ============ */
.toast-container{ position:fixed; bottom:20px; right:20px; display:flex; flex-direction:column; gap:8px; z-index: 200; }
.toast{
  background: var(--surface); border:1px solid var(--border); color: var(--text);
  padding: 12px 18px; border-radius: 8px; font-size: 13.5px; box-shadow: var(--shadow);
  animation: toast-in .2s ease;
  border-left: 3px solid var(--teal);
}
.toast.error{ border-left-color: var(--danger); }
@keyframes toast-in{ from{ opacity:0; transform: translateY(8px); } to{ opacity:1; transform:none; } }

/* ============ RESPONSIVE ============ */
@media (max-width: 720px){
  .topbar{ flex-wrap:wrap; padding: 12px 16px; }
  .search-wrap{ order:3; max-width:none; width:100%; }
  .profile-name{ display:none; }
  .toolbar{ padding: 12px 16px; }
  .shelf{ padding: 8px 16px 50px; grid-template-columns: repeat(auto-fill, minmax(130px,1fr)); gap:14px 10px; }
  .detail-modal{ flex-direction:column; }
  .detail-cover-wrap{ width: 140px; margin: 0 auto; }
}
