/* === RESET === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
img { display: block; max-width: 100%; }
button { font: inherit; cursor: pointer; border: none; background: none; }
a { color: inherit; text-decoration: none; }

/* === TOKENS === */
:root {
  --bg: #111;
  --surface: #1c1c1c;
  --border: #2e2e2e;
  --text: #e8e8e8;
  --muted: #777;
  --accent: #f07220;
  --accent-red: #e85252;
  --font: 'Inter', system-ui, -apple-system, sans-serif;
  --radius: 10px;
  --nav-h: 52px;
}
[data-theme="light"] {
  --bg: #f5f5f5;
  --surface: #fff;
  --border: #e0e0e0;
  --text: #111;
  --muted: #666;
}

/* === ICONS === */
.icon {
  display: inline-block;
  width: 1em;
  height: 1em;
  vertical-align: -0.125em;
  stroke: currentColor;
  fill: none;
  flex-shrink: 0;
}
.icon-solid { fill: currentColor; }

/* === BASE === */
html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.5;
}

/* === NAV === */
nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0 1.5rem;
  height: var(--nav-h);
}
.logo {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--accent);
  white-space: nowrap;
  flex-shrink: 0;
  letter-spacing: -0.01em;
}
.nav-links {
  display: flex;
  gap: 1.5rem;
  flex: 1;
}
.nav-links a {
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--muted);
  transition: color 0.12s;
  white-space: nowrap;
}
.nav-links a:hover,
.nav-links a.active { color: var(--text); }

.theme-btn {
  margin-left: auto;
  border: 1px solid var(--border);
  color: var(--muted);
  width: 34px;
  height: 34px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  flex-shrink: 0;
  transition: color 0.12s, border-color 0.12s;
}
.theme-btn:hover {
  color: var(--text);
  border-color: var(--text);
}

/* === CONTAINER === */
.container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* === PAGE HEADER === */
.page-header {
  padding: 2rem 0 1.5rem;
}
.page-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 0.3rem;
}
.subtitle {
  color: var(--muted);
  font-size: 0.9rem;
}

/* === SEARCH === */
.search-row { margin-top: 1rem; margin-bottom: 1rem; }
.search-wrap {
  position: relative;
  max-width: 580px;
}
.search-wrap .icon {
  position: absolute;
  left: 0.9rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 0.85rem;
  pointer-events: none;
}
.search-wrap input {
  width: 100%;
  padding: 0.65rem 1rem 0.65rem 2.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}
.search-wrap input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(240,114,32,0.12);
}
.search-wrap input::placeholder { color: var(--muted); }

/* === FILTER CHIPS === */
.filter-row {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.cat-btn {
  padding: 0.3rem 0.8rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 100px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 500;
  white-space: nowrap;
  transition: color 0.12s, border-color 0.12s, background 0.12s;
}
.cat-btn:hover {
  color: var(--text);
  border-color: var(--text);
}
.cat-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* === RESULTS COUNT === */
.results-row {
  margin-bottom: 0.75rem;
  color: var(--muted);
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* === GAMES GRID === */
.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.9rem;
  padding-bottom: 3rem;
}

/* === GAME CARD === */
@keyframes card-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.game-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
  animation: card-in 0.22s ease both;
}
.game-card:hover {
  border-color: var(--accent);
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);
}
.game-thumb {
  position: relative;
  aspect-ratio: 1;
  background: var(--border) url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23444' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'><rect x='2' y='8' width='20' height='8' rx='4'/><line x1='6' y1='12' x2='10' y2='12'/><line x1='8' y1='10' x2='8' y2='14'/><line x1='15' y1='13' x2='15.01' y2='13' stroke-width='3'/><line x1='18' y1='11' x2='18.01' y2='11' stroke-width='3'/></svg>") center / 36px no-repeat;
  overflow: hidden;
}
.game-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.badge-new {
  position: absolute;
  top: 0.4rem;
  left: 0.4rem;
  background: var(--accent);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  pointer-events: none;
}
.fav-btn {
  position: absolute;
  top: 0.4rem;
  right: 0.4rem;
  background: rgba(0,0,0,0.5);
  border: none;
  color: rgba(255,255,255,0.7);
  width: 26px;
  height: 26px;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  opacity: 0;
  transition: opacity 0.12s, color 0.12s;
  cursor: pointer;
}
.game-card:hover .fav-btn,
.fav-btn.active { opacity: 1; }
.fav-btn.active { color: var(--accent-red); }
.fav-btn:hover { color: var(--accent-red); }

.game-info {
  padding: 0.55rem 0.65rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.game-name {
  font-size: 0.825rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.game-tag {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: capitalize;
}

/* === EMPTY / LOADING === */
.loading-msg,
.empty-msg,
.error-msg {
  grid-column: 1 / -1;
  text-align: center;
  padding: 3rem;
  color: var(--muted);
  font-size: 0.9rem;
}

/* === FOOTER === */
footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem 1.5rem;
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: auto;
}
.footer-inner {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.footer-copy { margin: 0; }
.footer-links {
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
}
.footer-links a { transition: color 0.12s; }
.footer-links a:hover { color: var(--text); }
footer a { color: inherit; text-decoration: none; }

/* =========================================
   PLAY PAGE
   ========================================= */
.play-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 1.25rem;
  padding: 1.25rem 0 3rem;
  align-items: start;
}
.game-frame-wrap {
  position: relative;
  background: #000;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

/* ── Game loading overlay ─────────────────────────────────── */
.game-loading {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0d0d0d;
  transition: opacity 0.45s ease;
}
.game-loading-hide { opacity: 0; pointer-events: none; }

.game-loading-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.2rem;
  padding: 0 2rem;
  animation: loading-fadein 0.4s ease both;
}
@keyframes loading-fadein {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Spinner ring */
.loading-ring-svg { width: 56px; height: 56px; }
.loading-ring-track {
  fill: none;
  stroke: rgba(255,255,255,0.08);
  stroke-width: 3;
}
.loading-ring-arc {
  fill: none;
  stroke: var(--accent);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: 56 95;
  transform-origin: 30px 30px;
  animation: loading-spin 0.9s linear infinite;
}
@keyframes loading-spin { to { transform: rotate(360deg); } }

/* Game name label */
.loading-game-name {
  font-size: 1rem;
  font-weight: 600;
  color: rgba(255,255,255,0.9);
  letter-spacing: -0.01em;
  max-width: 300px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Sliding progress bar */
.loading-bar-wrap {
  width: 160px;
  height: 2px;
  background: rgba(255,255,255,0.1);
  border-radius: 1px;
  overflow: hidden;
}
.loading-bar {
  height: 100%;
  width: 50%;
  background: var(--accent);
  border-radius: 1px;
  animation: loading-slide 1.6s ease-in-out infinite;
}
@keyframes loading-slide {
  0%   { transform: translateX(-200%); }
  100% { transform: translateX(400%); }
}

/* ── Buggy game banner ────────────────────────────────────── */
.buggy-banner {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.9rem;
  background: rgba(245,166,35,0.1);
  border: 1px solid rgba(245,166,35,0.3);
  border-radius: var(--radius);
  margin-bottom: 0.6rem;
  font-size: 0.8rem;
  color: #f5a623;
  line-height: 1.4;
}
.buggy-banner[hidden] { display: none; }
.buggy-icon { width: 15px; height: 15px; flex-shrink: 0; }
.buggy-dismiss {
  margin-left: auto;
  font-size: 1rem;
  line-height: 1;
  color: #f5a623;
  opacity: 0.7;
  flex-shrink: 0;
  padding: 0 0.2rem;
}
.buggy-dismiss:hover { opacity: 1; }

/* ── Buggy badge on game cards ────────────────────────────── */
.badge-buggy {
  position: absolute;
  bottom: 0.4rem;
  left: 0.4rem;
  background: rgba(0,0,0,0.6);
  color: #f5a623;
  font-size: 0.65rem;
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
  pointer-events: none;
  line-height: 1.4;
}
.game-iframe {
  width: 100%;
  /* Fill viewport height minus nav (52px) and controls bar (42px) */
  height: calc(100vh - var(--nav-h) - 42px);
  min-height: 400px;
  max-height: 900px;
  display: block;
  border: none;
  background: #000;
}
.frame-controls {
  display: flex;
  gap: 0.4rem;
  padding: 0.5rem 0.6rem;
  background: var(--surface);
  border-top: 1px solid var(--border);
  align-items: center;
}
.ctrl-btn {
  border: 1px solid var(--border);
  color: var(--muted);
  height: 30px;
  padding: 0 0.7rem;
  border-radius: 6px;
  font-size: 0.78rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  transition: color 0.12s, border-color 0.12s;
  background: none;
}
.ctrl-btn:hover {
  color: var(--text);
  border-color: var(--text);
}
.ctrl-btn.fav-active {
  color: var(--accent-red);
  border-color: var(--accent-red);
}
.ctrl-spacer { flex: 1; }
.session-time {
  font-size: 0.75rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* Game sidebar */
.game-sidebar {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.sidebar-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.15rem;
}
.sidebar-card .game-title {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.2rem;
}
.sidebar-card .game-author {
  color: var(--muted);
  font-size: 0.8rem;
  margin-bottom: 0.75rem;
}
.tags-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
}
.tag {
  padding: 0.2rem 0.55rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 100px;
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: capitalize;
}
.game-desc {
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.6;
}

/* Recommended */
.sidebar-section-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.65rem;
}
.rec-list {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.rec-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.35rem 0.4rem;
  border-radius: 6px;
  transition: background 0.12s;
}
.rec-item:hover { background: var(--bg); }
.rec-thumb {
  width: 42px;
  height: 42px;
  border-radius: 5px;
  object-fit: cover;
  background: var(--border) url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23444' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'><rect x='2' y='8' width='20' height='8' rx='4'/><line x1='6' y1='12' x2='10' y2='12'/><line x1='8' y1='10' x2='8' y2='14'/><line x1='15' y1='13' x2='15.01' y2='13' stroke-width='3'/><line x1='18' y1='11' x2='18.01' y2='11' stroke-width='3'/></svg>") center / 22px no-repeat;
  flex-shrink: 0;
}
.rec-info { overflow: hidden; }
.rec-name {
  font-size: 0.82rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rec-tag {
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: capitalize;
}

/* =========================================
   FAVORITES PAGE
   ========================================= */
.fav-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 4rem 2rem;
}
.fav-empty h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
}
.fav-empty p {
  color: var(--muted);
  font-size: 0.875rem;
  margin-bottom: 1.25rem;
}

/* =========================================
   ABOUT PAGE
   ========================================= */
.about-wrap {
  max-width: 700px;
  padding: 2.5rem 0 4rem;
}
.about-wrap h1 {
  font-size: 1.9rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 0.35rem;
}
.about-wrap .lead {
  color: var(--muted);
  font-size: 0.95rem;
  margin-bottom: 2rem;
  line-height: 1.6;
}
.about-wrap h2 {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 2.25rem 0 0.65rem;
}
.about-wrap p {
  color: var(--text);
  font-size: 0.9rem;
  line-height: 1.75;
  margin-bottom: 0.7rem;
}
.about-wrap code {
  font-family: ui-monospace, 'Cascadia Code', monospace;
  font-size: 0.82rem;
  background: var(--border);
  padding: 0.1em 0.4em;
  border-radius: 4px;
}
.about-wrap a { color: var(--accent); text-decoration: underline; }
.about-wrap a:hover { opacity: 0.82; }
.about-list {
  padding-left: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 0.7rem;
}
.about-list li {
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--text);
  padding-left: 1.25rem;
  position: relative;
}
.about-list li::before {
  content: '–';
  position: absolute;
  left: 0;
  color: var(--accent);
  font-weight: 600;
}
.about-kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  margin-bottom: 2rem;
}
.about-kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.about-kpi-val {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--accent);
  line-height: 1;
}
.about-kpi-label {
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 500;
}
@media (max-width: 540px) {
  .about-kpi-row { grid-template-columns: repeat(2, 1fr); }
  .about-wrap h1 { font-size: 1.55rem; }
}

/* =========================================
   404 PAGE
   ========================================= */
.not-found {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - var(--nav-h));
  text-align: center;
  padding: 2rem;
}
.not-found .err-code {
  font-size: 7rem;
  font-weight: 800;
  color: var(--border);
  line-height: 1;
  letter-spacing: -0.05em;
  margin-bottom: 1rem;
}
.not-found h1 {
  font-size: 1.3rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
}
.not-found p {
  color: var(--muted);
  font-size: 0.875rem;
  margin-bottom: 1.5rem;
}
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.6rem 1.25rem;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.875rem;
  border: none;
  cursor: pointer;
  transition: opacity 0.12s;
}
.btn:hover { opacity: 0.88; }

/* =========================================
   PLAYTIME CHART
   ========================================= */
.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.15rem;
  margin-top: 1rem;
}
.chart-card .chart-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.85rem;
}
.chart-card canvas {
  width: 100% !important;
  max-height: 160px;
}
.chart-empty {
  font-size: 0.8rem;
  color: var(--muted);
  text-align: center;
  padding: 1.5rem 0;
}
.total-playtime {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.6rem;
}
.total-playtime strong {
  color: var(--text);
}

/* =========================================
   AD SLOTS
   ========================================= */
.ad-slot {
  display: block;
  overflow: hidden;
  text-align: center;
}
/* Zero height + no margin when empty — no layout shift */
.ad-slot:empty { margin: 0; padding: 0; }
.ad-leaderboard {
  width: 100%;
  margin: 0.5rem 0;
}
.ad-rect {
  width: 300px;
  max-width: 100%;
  margin: 0 auto;
}

/* =========================================
   CAMO (TAB DISGUISE)
   ========================================= */
.camo-wrap {
  position: relative;
  flex-shrink: 0;
}
.camo-btn {
  border: 1px solid var(--border);
  color: var(--muted);
  width: 34px;
  height: 34px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  transition: color 0.12s, border-color 0.12s;
}
.camo-btn:hover {
  color: var(--text);
  border-color: var(--text);
}
.camo-btn.camo-on {
  color: var(--accent);
  border-color: var(--accent);
}
.camo-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.4rem;
  min-width: 190px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  z-index: 200;
}
.camo-dropdown.open { display: block; }
.camo-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.45rem 0.75rem;
  border-radius: 5px;
  font-size: 0.82rem;
  color: var(--muted);
  transition: background 0.1s, color 0.1s;
  white-space: nowrap;
}
.camo-item:hover { background: var(--bg); color: var(--text); }
.camo-item.active { color: var(--accent); }
.camo-item-off { color: var(--muted); }
.camo-sep {
  height: 1px;
  background: var(--border);
  margin: 0.35rem 0.4rem;
}

/* =========================================
   RECENTLY PLAYED ROW
   ========================================= */
.section-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.65rem;
}
.recent-row {
  margin-top: 1.5rem;
  margin-bottom: 1.5rem;
}
.recent-scroll {
  display: flex;
  gap: 0.7rem;
  overflow-x: auto;
  padding-bottom: 0.4rem;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.recent-scroll::-webkit-scrollbar { height: 4px; }
.recent-scroll::-webkit-scrollbar-track { background: transparent; }
.recent-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.recent-card {
  flex: 0 0 130px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.12s;
  text-decoration: none;
  color: var(--text);
}
.recent-card:hover {
  border-color: var(--accent);
}
.recent-thumb {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
  background: var(--border);
}
.recent-name {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.4rem 0.5rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* =========================================
   STATS PAGE — PREMIUM
   ========================================= */
.stats-wrap { padding: 2rem 0 4rem; }
.stats-hd { margin-bottom: 1.5rem; }
.stats-hd h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.25rem;
}

/* KPI row */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.2rem 1.25rem;
  transition: border-color 0.15s, transform 0.15s;
}
.kpi-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.kpi-card.kpi-featured {
  border-color: var(--accent);
  background: linear-gradient(135deg, rgba(240,114,32,0.1) 0%, var(--surface) 65%);
}
.kpi-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: rgba(240,114,32,0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  margin-bottom: 0.9rem;
  font-size: 1rem;
}
.kpi-val {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
  margin-bottom: 0.3rem;
  font-variant-numeric: tabular-nums;
}
.kpi-featured .kpi-val { color: var(--accent); }
.kpi-label { font-size: 0.75rem; color: var(--muted); font-weight: 500; }

/* Shared panel */
.stats-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.15rem 1.25rem;
}
.stats-panel-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.stats-panel-title { font-size: 0.85rem; font-weight: 600; }
.stats-panel-sub { font-size: 0.75rem; color: var(--muted); }

/* Charts row */
.stats-charts-row {
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 1rem;
  margin-bottom: 1rem;
}
.activity-canvas-wrap {
  position: relative;
  height: 180px;
}

/* Donut */
.donut-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.9rem;
}
.donut-legend { width: 100%; display: flex; flex-direction: column; gap: 0.4rem; }
.donut-leg-item { display: flex; align-items: center; gap: 0.55rem; font-size: 0.78rem; }
.donut-leg-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.donut-leg-name {
  flex: 1;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-transform: capitalize;
}
.donut-leg-pct { font-weight: 600; font-variant-numeric: tabular-nums; }

/* Heatmap */
.stats-heatmap-panel { margin-bottom: 1rem; overflow-x: auto; }
.heatmap-grid {
  display: grid;
  grid-template-rows: repeat(7, 12px);
  grid-auto-flow: column;
  gap: 3px;
  margin-bottom: 0.6rem;
  width: max-content;
}
.hm-cell {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  background: var(--border);
  cursor: default;
}
.hm-cell[data-level="1"] { background: rgba(240,114,32,0.2); }
.hm-cell[data-level="2"] { background: rgba(240,114,32,0.4); }
.hm-cell[data-level="3"] { background: rgba(240,114,32,0.6); }
.hm-cell[data-level="4"] { background: rgba(240,114,32,0.82); }
.hm-cell[data-level="5"] { background: #f07220; }
.heatmap-legend {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  justify-content: flex-end;
}
.heatmap-leg-label { font-size: 0.72rem; color: var(--muted); }
.heatmap-leg-cells { display: flex; gap: 3px; }

/* Top games list */
.stats-section-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  margin: 1.25rem 0 0.65rem;
}
.stats-list { display: flex; flex-direction: column; gap: 0.4rem; }
.stats-row {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.65rem 0.85rem;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.12s;
}
.stats-row:hover { border-color: var(--accent); }
.stats-rank {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  min-width: 22px;
  text-align: center;
  flex-shrink: 0;
}
.stats-rank.gold   { color: #f5c842; }
.stats-rank.silver { color: #a8b8cc; }
.stats-rank.bronze { color: #c87941; }
.stats-thumb {
  width: 40px;
  height: 40px;
  border-radius: 5px;
  object-fit: cover;
  background: var(--border) url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23444' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'><rect x='2' y='8' width='20' height='8' rx='4'/><line x1='6' y1='12' x2='10' y2='12'/><line x1='8' y1='10' x2='8' y2='14'/><line x1='15' y1='13' x2='15.01' y2='13' stroke-width='3'/><line x1='18' y1='11' x2='18.01' y2='11' stroke-width='3'/></svg>") center / 20px no-repeat;
  flex-shrink: 0;
}
.stats-info { flex: 1; overflow: hidden; }
.stats-game-name {
  font-size: 0.875rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stats-bar-wrap {
  flex: 1;
  height: 5px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  max-width: 200px;
}
.stats-bar-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.9s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.stats-pct {
  font-size: 0.72rem;
  color: var(--muted);
  min-width: 36px;
  text-align: right;
  flex-shrink: 0;
}
.stats-time {
  font-size: 0.8rem;
  font-weight: 600;
  min-width: 52px;
  text-align: right;
  flex-shrink: 0;
}
.stats-empty { text-align: center; padding: 4rem 2rem; color: var(--muted); }
.stats-empty p { margin-bottom: 1rem; font-size: 0.9rem; }

@media (max-width: 860px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .stats-charts-row { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .kpi-val { font-size: 1.65rem; }
}

/* =========================================
   SAVES PAGE
   ========================================= */
.saves-wrap { padding: 2rem 0 4rem; }
.saves-hd { margin-bottom: 1.5rem; }
.saves-hd h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.25rem;
}
.saves-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 1rem;
  align-items: start;
}

/* Sidebar */
.saves-sidebar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.saves-sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.8rem;
  font-weight: 600;
}
.saves-count {
  background: var(--border);
  border-radius: 100px;
  padding: 0.1rem 0.5rem;
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 500;
}
.saves-list {
  overflow-y: auto;
  max-height: 460px;
  padding: 0.35rem;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.saves-list::-webkit-scrollbar { width: 4px; }
.saves-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.saves-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  width: 100%;
  text-align: left;
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  border: none;
  background: none;
  color: var(--text);
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
}
.saves-item:hover { background: var(--bg); }
.saves-item.active { background: rgba(240,114,32,0.1); color: var(--accent); }
.saves-item-name {
  font-size: 0.82rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  font-family: ui-monospace, 'Cascadia Code', monospace;
}
.saves-item-meta { font-size: 0.72rem; color: var(--muted); flex-shrink: 0; }
.saves-badge {
  display: inline-block;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 0.1em 0.4em;
  border-radius: 3px;
  margin-left: 0.35rem;
  background: rgba(240,114,32,0.15);
  color: var(--accent);
  vertical-align: middle;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-family: inherit;
}
.saves-badge-json { background: rgba(124,107,255,0.15); color: #7c6bff; }
.saves-sidebar-foot {
  border-top: 1px solid var(--border);
  padding: 0.5rem 0.65rem;
}
.saves-empty-hint {
  padding: 2.5rem 1rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.7;
}

/* Editor pane */
.saves-editor-pane { display: flex; flex-direction: column; gap: 1rem; }
.saves-placeholder {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 4rem 2rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.875rem;
}
.saves-editor {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.saves-editor-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1.15rem;
  border-bottom: 1px solid var(--border);
}
.saves-key-name {
  font-size: 0.9rem;
  font-weight: 700;
  font-family: ui-monospace, 'Cascadia Code', monospace;
  color: var(--accent);
  margin: 0;
}
.saves-key-meta { font-size: 0.72rem; color: var(--muted); margin: 0.15rem 0 0; }
.saves-editor-actions { display: flex; gap: 0.4rem; flex-shrink: 0; }

/* Action buttons */
.saves-action-btn {
  padding: 0.35rem 0.85rem;
  border-radius: var(--radius);
  font-size: 0.78rem;
  font-weight: 500;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.12s, color 0.12s, opacity 0.12s;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-family: inherit;
}
.saves-action-btn:hover { border-color: var(--accent); color: var(--accent); }
.saves-action-save { background: var(--accent); border-color: var(--accent); color: #fff; }
.saves-action-save:hover { opacity: 0.88; color: #fff; border-color: var(--accent); }
.saves-action-delete { color: var(--accent-red); border-color: var(--accent-red); background: transparent; }
.saves-action-delete:hover { background: rgba(232,82,82,0.08); }
.saves-action-import { cursor: pointer; }

/* Decode tabs */
.saves-decode-bar {
  display: flex;
  border-bottom: 1px solid var(--border);
  padding: 0 1.15rem;
}
.saves-tab {
  padding: 0.5rem 0.75rem;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color 0.12s;
  margin-bottom: -1px;
  font-family: inherit;
}
.saves-tab:hover { color: var(--text); }
.saves-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* Textarea */
.saves-textarea {
  width: 100%;
  min-height: 340px;
  background: var(--bg);
  border: none;
  color: var(--text);
  font-family: ui-monospace, 'Cascadia Code', monospace;
  font-size: 0.8rem;
  line-height: 1.65;
  padding: 1rem 1.15rem;
  resize: vertical;
  outline: none;
  display: block;
}
.saves-status {
  font-size: 0.75rem;
  color: var(--accent);
  padding: 0.4rem 1.15rem 0.6rem;
  min-height: 1.5rem;
}

/* Backup panel */
.saves-backup-desc {
  font-size: 0.875rem;
  color: var(--muted);
  margin-bottom: 1rem;
  line-height: 1.6;
}
.saves-backup-btns { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* Origin warning */
.saves-origin-warn {
  background: rgba(240,114,32,0.08);
  border: 1px solid rgba(240,114,32,0.25);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  font-size: 0.82rem;
  color: var(--accent);
  line-height: 1.5;
  margin-bottom: 1.5rem;
}
.saves-origin-warn a { color: inherit; font-weight: 600; text-decoration: underline; }

@media (max-width: 700px) {
  .saves-layout { grid-template-columns: 1fr; }
  .saves-list { max-height: 200px; }
}

/* =========================================
   RESPONSIVE
   ========================================= */
@media (max-width: 1060px) {
  .play-layout {
    grid-template-columns: 1fr;
  }
  .game-sidebar {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
}
@media (max-width: 700px) {
  .nav-links { gap: 1rem; }
  .nav-links a { font-size: 0.85rem; }
  .game-sidebar { grid-template-columns: 1fr; }
  .games-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .game-iframe { height: 60vw; min-height: 260px; max-height: 500px; }
}
@media (max-width: 500px) {
  nav { padding: 0 1rem; gap: 0.5rem; }
  .container { padding: 0 1rem; }
  .games-grid { grid-template-columns: repeat(2, 1fr); gap: 0.7rem; }
  .nav-links { gap: 0.75rem; overflow-x: auto; scrollbar-width: none; flex-shrink: 1; min-width: 0; }
  .nav-links::-webkit-scrollbar { display: none; }
}
