* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #f0f0f0;
  --surface:   #ffffff;
  --border:    #eeeeee;
  --text:      #111111;
  --text-muted:#555555;
  --accent:    #cc0000;
  --input-border: #cccccc;
  --row-hover: #f5f5f5;
  --progress-bg: #e0e0e0;
  --shadow:    rgba(0,0,0,0.15);
  --result-hover: #f5f5f5;
}

[data-theme="dark"] {
  --bg:        #121212;
  --surface:   #1e1e1e;
  --border:    #2e2e2e;
  --text:      #e0e0e0;
  --text-muted:#999999;
  --accent:    #ff4444;
  --input-border: #444444;
  --row-hover: #2a2a2a;
  --progress-bg: #333333;
  --shadow:    rgba(0,0,0,0.5);
  --result-hover: #2a2a2a;
}

body {
  font-family: sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2rem;
  gap: 1.5rem;
  transition: background 0.3s, color 0.3s;
}
h1 { color: var(--accent); }
h2 { color: var(--accent); }

/* Botón modo oscuro */
#theme-toggle {
  position: fixed;
  top: 1rem;
  right: 1rem;
  background: var(--surface);
  color: var(--text);
  border: 2px solid var(--input-border);
  border-radius: 8px;
  padding: 0.4rem 0.8rem;
  cursor: pointer;
  font-size: 1.1rem;
  z-index: 100;
  transition: background 0.2s, color 0.2s;
}
#theme-toggle:hover { border-color: var(--accent); }

/* Nav tabs */
.tabs { display: flex; gap: 0.5rem; }
.tab-btn {
  padding: 0.5rem 1.2rem;
  border: 2px solid var(--accent);
  background: var(--surface);
  color: var(--accent);
  border-radius: 6px;
  cursor: pointer;
  font-weight: bold;
  transition: background 0.2s, color 0.2s;
}
.tab-btn.active, .tab-btn:hover { background: var(--accent); color: white; }

/* Vistas */
.view { display: none; width: 100%; max-width: 860px; flex-direction: column; align-items: center; gap: 1rem; }
.view.active { display: flex; }

/* Grid de juegos */
.game-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  width: 100%;
}

.game-btn {
  padding: 0;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  color: white;
  transition: transform 0.15s, box-shadow 0.2s;
  overflow: hidden;
  position: relative;
  background-color: #222;
  text-shadow: 0 1px 6px rgba(0,0,0,0.9);
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  display: flex;
  flex-direction: column;
}
.game-btn img.cover {
  width: 100%;
  height: 160px;
  object-fit: cover;
  object-position: center 20%;
  display: block;
}
.game-btn span {
  display: block;
  padding: 0.45rem 0.6rem;
  font-size: 0.82rem;
  font-weight: bold;
  text-align: center;
  background: inherit;
  color: white;
}
.game-btn:hover { transform: scale(1.04); box-shadow: 0 6px 16px rgba(0,0,0,0.35); }

.btn-nacional {
  grid-column: 1 / -1;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  height: 56px;
  letter-spacing: 1px;
}
.btn-nacional span {
  font-size: 1.1rem;
  padding: 0;
  background: transparent;
}

/* Banner en cabecera de tabla */
#table-header {
  padding: 0;
  overflow: hidden;
  position: relative;
}

/* Pokedex */
#back-btn {
  align-self: flex-start;
  padding: 0.5rem 1.2rem;
  background: #555;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}
#back-btn:hover { background: #333; }

table {
  border-collapse: collapse;
  background: var(--surface);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 8px var(--shadow);
  width: 100%;
}
th { color: white; padding: 0.75rem 1.5rem; }
td { padding: 0.5rem 1.5rem; text-align: center; border-bottom: 1px solid var(--border); }
tr:last-child td { border-bottom: none; }
img { width: 64px; height: 64px; image-rendering: pixelated; }
input[type="checkbox"] { width: 18px; height: 18px; cursor: pointer; }
a { color: var(--accent); text-decoration: none; font-weight: bold; }
a:hover { text-decoration: underline; }
.progress-text { font-size: 0.9rem; color: var(--text-muted); align-self: flex-end; }

/* Buscador */
#search-box {
  position: relative;
  width: 100%;
  max-width: 400px;
}
#search-input {
  width: 100%;
  padding: 0.6rem 1rem;
  border: 2px solid var(--input-border);
  border-radius: 8px;
  font-size: 1rem;
  outline: none;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.2s;
}
#search-input:focus { border-color: var(--accent); }
#search-results {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: var(--surface);
  border-radius: 8px;
  box-shadow: 0 4px 12px var(--shadow);
  list-style: none;
  max-height: 260px;
  overflow-y: auto;
  z-index: 10;
}
#search-results.open { display: block; }
#search-results li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.75rem;
  cursor: pointer;
  font-size: 0.95rem;
  color: var(--text);
  flex-wrap: wrap;
}
#search-results li:hover { background: var(--result-hover); }
#search-results li img { width: 36px; height: 36px; image-rendering: pixelated; flex-shrink: 0; }
.result-info { display: flex; flex-direction: column; gap: 0.2rem; flex: 1; min-width: 0; }
.result-name { font-size: 0.9rem; font-weight: bold; }
.result-games { display: flex; flex-wrap: wrap; gap: 0.25rem; }
.result-game-tag {
  font-size: 0.65rem;
  color: white;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  white-space: nowrap;
}
.result-submenu {
  list-style: none;
  width: 100%;
  padding: 0.25rem 0 0 2.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}
.result-submenu li { padding: 0.2rem 0; cursor: pointer; }
.progress-panel { display: flex; flex-direction: column; gap: 0.75rem; width: 100%; }
.progress-item { background: var(--surface); border-radius: 8px; padding: 0.75rem 1rem; box-shadow: 0 1px 4px var(--shadow); }
.progress-item-header { display: flex; justify-content: space-between; margin-bottom: 0.4rem; font-size: 0.9rem; font-weight: bold; color: var(--text); cursor: pointer; }
.progress-item-header:hover { color: var(--accent); }
.progress-bar-bg { background: var(--progress-bg); border-radius: 99px; height: 12px; overflow: hidden; cursor: pointer; }
.progress-bar-bg:hover { opacity: 0.85; }
.progress-bar-fill { height: 100%; border-radius: 99px; transition: width 0.4s ease; }
.progress-detail { margin-top: 0.75rem; border-top: 1px solid var(--border); padding-top: 0.75rem; }
.detail-group { margin-bottom: 0.5rem; }
.detail-label { font-size: 0.8rem; font-weight: bold; display: block; margin-bottom: 0.3rem; }
.detail-sprites { display: flex; flex-wrap: wrap; gap: 2px; }
.detail-sprites img { width: 40px; height: 40px; image-rendering: pixelated; }

#bulk-bar { margin: 0.5rem 0; }
.bulk-btn {
  padding: 0.4rem 1.2rem;
  border: none;
  border-radius: 6px;
  background: #444;
  color: #fff;
  cursor: pointer;
  font-size: 0.9rem;
}
.bulk-btn:hover { background: #222; }
#pokemon-table tbody tr:hover { background: var(--row-hover); }
